Browse Source

Use git submodule for WpfDesigner.

pull/730/merge
Daniel Grunwald 9 years ago
parent
commit
0b4e0b1580
  1. 3
      .gitmodules
  2. 30
      SharpDevelop.Tests.sln
  3. 18
      SharpDevelop.sln
  4. 13
      samples/XamlDesigner/App.xaml
  5. 106
      samples/XamlDesigner/App.xaml.cs
  6. 32
      samples/XamlDesigner/BitmapButton.xaml
  7. 45
      samples/XamlDesigner/BitmapButton.xaml.cs
  8. 33
      samples/XamlDesigner/Configuration/AssemblyInfo.cs
  9. 119
      samples/XamlDesigner/Configuration/Settings.Designer.cs
  10. 55
      samples/XamlDesigner/Configuration/Settings.settings
  11. 51
      samples/XamlDesigner/Configuration/app.config
  12. 29
      samples/XamlDesigner/Configuration/app.manifest
  13. 66
      samples/XamlDesigner/Converters.cs
  14. 253
      samples/XamlDesigner/Document.cs
  15. 22
      samples/XamlDesigner/DocumentView.xaml
  16. 68
      samples/XamlDesigner/DocumentView.xaml.cs
  17. 7
      samples/XamlDesigner/EnumBar.xaml
  18. 72
      samples/XamlDesigner/EnumBar.xaml.cs
  19. 26
      samples/XamlDesigner/EnumButton.cs
  20. 23
      samples/XamlDesigner/ErrorListView.xaml
  21. 33
      samples/XamlDesigner/ErrorListView.xaml.cs
  22. 102
      samples/XamlDesigner/ExtensionMethods.cs
  23. BIN
      samples/XamlDesigner/Images/Error.png
  24. BIN
      samples/XamlDesigner/Images/Reference.png
  25. BIN
      samples/XamlDesigner/Images/Tag.png
  26. 133
      samples/XamlDesigner/MainWindow.xaml
  27. 191
      samples/XamlDesigner/MainWindow.xaml.cs
  28. 177
      samples/XamlDesigner/MainWindow_Commands.cs
  29. 49
      samples/XamlDesigner/MyTypeFinder.cs
  30. 4
      samples/XamlDesigner/NewFileTemplate.xaml
  31. 260
      samples/XamlDesigner/Shell.cs
  32. 27
      samples/XamlDesigner/SimpleCommand.cs
  33. 31
      samples/XamlDesigner/TestFiles/1.xaml
  34. 53
      samples/XamlDesigner/TestFiles/2.xaml
  35. 16
      samples/XamlDesigner/TestFiles/3.xaml
  36. 16
      samples/XamlDesigner/TestFiles/4.xaml
  37. 6
      samples/XamlDesigner/Themes/Generic.xaml
  38. 109
      samples/XamlDesigner/Toolbox.cs
  39. 31
      samples/XamlDesigner/ToolboxView.xaml
  40. 94
      samples/XamlDesigner/ToolboxView.xaml.cs
  41. 214
      samples/XamlDesigner/XamlDesigner.csproj
  42. 47
      samples/XamlDesigner/XamlDesigner.sln
  43. 203
      samples/XamlDesigner/XamlFormatter.cs
  44. 6
      samples/XamlDesigner/app.config
  45. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj
  46. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ArrangeDirection.cs
  47. 327
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs
  48. 127
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs
  49. 42
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Commands.cs
  50. 68
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/AssemblyInfo.cs
  51. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/CodeAnalysisDictionary.xml
  52. 336
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs
  53. 233
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/CanvasPositionHandle.cs
  54. 100
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ClearableTextBox.cs
  55. 198
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/CollapsiblePanel.cs
  56. 110
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ColorHelper.cs
  57. 232
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ColorPicker.xaml
  58. 191
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ColorPicker.xaml.cs
  59. 70
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ContainerDragHandle.cs
  60. 699
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml
  61. 157
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs
  62. 44
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DropDownButton.cs
  63. 49
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnterTextBox.cs
  64. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml
  65. 146
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs
  66. 44
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumButton.cs
  67. 34
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ErrorBalloon.cs
  68. 134
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GrayOutDesignerExceptActiveArea.cs
  69. 673
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs
  70. 60
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridUnitSelector.xaml
  71. 122
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridUnitSelector.xaml.cs
  72. 207
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/InPlaceEditor.cs
  73. 116
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/InfoTextEnterArea.cs
  74. 359
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/MarginHandle.cs
  75. 68
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NullableComboBox.cs
  76. 249
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NullableComboBox.xaml
  77. 323
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.cs
  78. 140
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.xaml
  79. 185
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PageClone.cs
  80. 76
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs
  81. 151
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Picker.cs
  82. 140
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs
  83. 118
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/RelayCommand.cs
  84. 43
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/RenderTransformOriginThumb.cs
  85. 43
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SelectionFrame.cs
  86. 50
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs
  87. 90
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/DesignerThumb.cs
  88. 52
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/MultiPointThumb.cs
  89. 115
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs
  90. 52
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/ResizeThumb.cs
  91. 37
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/RotateThumb.cs
  92. 30
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/UserControlPointsObjectThumb.cs
  93. 252
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs
  94. 66
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomButtons.cs
  95. 157
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs
  96. 184
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomScrollViewer.cs
  97. 94
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomScrollViewer.xaml
  98. 382
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs
  99. 575
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  100. 388
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
  101. Some files were not shown because too many files have changed in this diff Show More

3
.gitmodules vendored

@ -7,3 +7,6 @@ @@ -7,3 +7,6 @@
[submodule "src/Libraries/cecil"]
path = src/Libraries/cecil
url = https://github.com/jbevain/cecil.git
[submodule "src/Libraries/WpfDesigner"]
path = src/Libraries/WpfDesigner
url = https://github.com/icsharpcode/WpfDesigner.git

30
SharpDevelop.Tests.sln

@ -182,15 +182,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer" @@ -182,15 +182,15 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Tests", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Tests\WpfDesign.Tests.csproj", "{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\Libraries\WpfDesigner\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\Libraries\WpfDesigner\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\Libraries\WpfDesigner\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Tests", "src\Libraries\WpfDesigner\WpfDesign.Designer\Tests\WpfDesign.Tests.csproj", "{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SettingsEditor", "src\AddIns\DisplayBindings\SettingsEditor\Project\SettingsEditor.csproj", "{85226AFB-CE71-4851-9A75-7EEC663A8E8A}"
EndProject
@ -546,18 +546,14 @@ Global @@ -546,18 +546,14 @@ Global
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5}.Release|Any CPU.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.Build.0 = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -566,6 +562,10 @@ Global @@ -566,6 +562,10 @@ Global
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.Build.0 = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.Build.0 = Release|Any CPU
{85226AFB-CE71-4851-9A75-7EEC663A8E8A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{85226AFB-CE71-4851-9A75-7EEC663A8E8A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{85226AFB-CE71-4851-9A75-7EEC663A8E8A}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -741,11 +741,11 @@ Global @@ -741,11 +741,11 @@ Global
{EEF5E054-4192-4A57-8FBF-E860D808A51D} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {0F5192F2-0744-4BA9-A074-6BE82D111B8D}
{83BAB756-1010-4A2F-9B9D-7F9EBCB288F5} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{78CC29AC-CC79-4355-B1F2-97936DF198AC} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1} = {83BAB756-1010-4A2F-9B9D-7F9EBCB288F5}
{85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{CBC6C247-747B-4908-B09A-4D2E0F640B6B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}

18
SharpDevelop.sln

@ -151,13 +151,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer" @@ -151,13 +151,13 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Data.SQLServer"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{D54BEB89-8CBE-475C-8BB9-836D2FD71260}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "src\Libraries\WpfDesigner\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\Libraries\WpfDesigner\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\Libraries\WpfDesigner\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "src\AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FormsDesigner", "src\AddIns\DisplayBindings\FormsDesigner\Project\FormsDesigner.csproj", "{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}"
EndProject
@ -441,10 +441,6 @@ Global @@ -441,10 +441,6 @@ Global
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.Build.0 = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -453,6 +449,10 @@ Global @@ -453,6 +449,10 @@ Global
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.Build.0 = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.Build.0 = Release|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -588,9 +588,9 @@ Global @@ -588,9 +588,9 @@ Global
{AFE34868-AFA1-4E1C-9450-47AB4BE329D5} = {5FB020B2-B64B-4016-999A-CB8FD9274D72}
{D54BEB89-8CBE-475C-8BB9-836D2FD71260} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{78CC29AC-CC79-4355-B1F2-97936DF198AC} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {D54BEB89-8CBE-475C-8BB9-836D2FD71260}
{7D7E92DF-ACEB-4B69-92C8-8AC7A703CD57} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{CBC6C247-747B-4908-B09A-4D2E0F640B6B} = {11BF9245-88A3-4A0A-9A8A-EC9D98036B0F}
{7019F43E-DFD7-4D1C-8C96-E75D55646DE7} = {39327899-ED91-4F7F-988C-4FE4E17C014D}

13
samples/XamlDesigner/App.xaml

@ -1,13 +0,0 @@ @@ -1,13 +0,0 @@
<Application x:Class="ICSharpCode.XamlDesigner.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Converters="clr-namespace:ICSharpCode.XamlDesigner.Converters"
StartupUri="MainWindow.xaml"
ShutdownMode="OnMainWindowClose">
<Application.Resources>
<Converters:CollapsedWhenFalse x:Key="CollapsedWhenFalse" />
<Converters:FalseWhenZero x:Key="FalseWhenZero" />
</Application.Resources>
</Application>

106
samples/XamlDesigner/App.xaml.cs

@ -1,106 +0,0 @@ @@ -1,106 +0,0 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Windows;
using System.Windows.Threading;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.XamlDesigner.Configuration;
namespace ICSharpCode.XamlDesigner
{
public partial class App
{
public static string[] Args;
protected override void OnStartup(StartupEventArgs e)
{
AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AppDomain_CurrentDomain_AssemblyResolve);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(AppDomain_CurrentDomain_UnhandledException);
DragDropExceptionHandler.UnhandledException += new ThreadExceptionEventHandler(DragDropExceptionHandler_UnhandledException);
DispatcherUnhandledException += App_DispatcherUnhandledException;
Args = e.Args;
base.OnStartup(e);
}
private static bool internalLoad = false;
private static string lastRequesting = null;
Assembly AppDomain_CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
var assList = AppDomain.CurrentDomain.GetAssemblies();
var loaded = assList.FirstOrDefault(x => x.FullName == args.Name);
if (loaded != null)
{
return loaded;
}
if (internalLoad)
return null;
if (args.Name.Split(new [] { ',' })[0].Trim().EndsWith(".resources"))
return null;
internalLoad = true;
Assembly ass = null;
try {
ass = Assembly.Load(args.Name);
}
catch (Exception) { }
if (ass == null && args.RequestingAssembly != null) {
lastRequesting = args.RequestingAssembly.Location;
var dir = Path.GetDirectoryName(args.RequestingAssembly.Location);
var file = args.Name.Split(new [] { ',' })[0].Trim() + ".dll";
try {
ass = Assembly.LoadFrom(Path.Combine(dir, file));
}
catch (Exception) { }
}
else if (lastRequesting != null) {
var dir = Path.GetDirectoryName(lastRequesting);
var file = args.Name.Split(new [] { ',' })[0].Trim() + ".dll";
try {
ass = Assembly.LoadFrom(Path.Combine(dir, file));
}
catch (Exception) { }
}
internalLoad = false;
return ass;
}
void DragDropExceptionHandler_UnhandledException(object sender, ThreadExceptionEventArgs e)
{
Shell.ReportException(e.Exception);
}
void AppDomain_CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
Shell.ReportException(e.ExceptionObject as Exception);
}
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
Shell.ReportException(e.Exception);
e.Handled = true;
}
protected override void OnExit(ExitEventArgs e)
{
Settings.Default.Save();
base.OnExit(e);
}
}
}

32
samples/XamlDesigner/BitmapButton.xaml

@ -1,32 +0,0 @@ @@ -1,32 +0,0 @@
<Button x:Class="ICSharpCode.XamlDesigner.BitmapButton"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Focusable="False">
<Button.Template>
<ControlTemplate TargetType="Button">
<Image x:Name="image1"
Stretch="None"
Source="{Binding ImageNormal}" />
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter Property="Source"
Value="{Binding ImageHover}"
TargetName="image1" />
</Trigger>
<Trigger Property="IsPressed"
Value="True">
<Setter Property="Source"
Value="{Binding ImagePressed}"
TargetName="image1" />
</Trigger>
<Trigger Property="IsEnabled"
Value="False">
<Setter Property="Source"
Value="{Binding ImageDisabled}"
TargetName="image1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Template>
</Button>

45
samples/XamlDesigner/BitmapButton.xaml.cs

@ -1,45 +0,0 @@ @@ -1,45 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace ICSharpCode.XamlDesigner
{
public partial class BitmapButton
{
public BitmapButton()
{
InitializeComponent();
DataContext = this;
}
public string ImageHover {
get { return "Images/" + GetType().Name + ".Hover.png"; }
}
public string ImageNormal {
get { return "Images/" + GetType().Name + ".Normal.png"; }
}
public string ImagePressed {
get { return "Images/" + GetType().Name + ".Pressed.png"; }
}
public string ImageDisabled {
get { return "Images/" + GetType().Name + ".Disabled.png"; }
}
}
class CloseButton : BitmapButton
{
}
}

33
samples/XamlDesigner/Configuration/AssemblyInfo.cs

@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("XamlDesigner")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]

119
samples/XamlDesigner/Configuration/Settings.Designer.cs generated

@ -1,119 +0,0 @@ @@ -1,119 +0,0 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3031
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace ICSharpCode.XamlDesigner.Configuration {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0,0,0,0")]
public global::System.Windows.Rect MainWindowRect {
get {
return ((global::System.Windows.Rect)(this["MainWindowRect"]));
}
set {
this["MainWindowRect"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute(@"<DockingManager version=""1.3.0"">
<ResizingPanel ResizeWidth=""*"" ResizeHeight=""*"" EffectiveSize=""0,0"" Orientation=""Vertical"">
<ResizingPanel ResizeWidth=""*"" ResizeHeight=""*"" EffectiveSize=""1920,1153.04"" Orientation=""Horizontal"">
<ResizingPanel ResizeWidth=""250"" ResizeHeight=""*"" EffectiveSize=""250,1153.04"" Orientation=""Vertical"">
<DockablePane ResizeWidth=""0.742440632565806*"" ResizeHeight=""0.742440632565806*"" EffectiveSize=""250,851.609103178282"" ID=""bb7a5fd3-be24-4636-8fd6-a50a09e65e69"" Anchor=""Left"" IsAutoHidden=""false"">
<DockableContent Name=""content1"" FloatingWindowSize=""250,400"" ChildIndex=""0"" Width=""315"" Height=""1153.04"" Anchor=""Right"" State=""Docked"" />
</DockablePane>
<DockablePane ResizeWidth=""0.257559367434194*"" ResizeHeight=""0.257559367434194*"" EffectiveSize=""250,295.430896821718"" ID=""17cd1941-1004-4ed9-8cda-03c254681289"" Anchor=""Left"" IsAutoHidden=""false"">
<DockableContent Name=""content2"" FloatingWindowSize=""250,400"" ChildIndex=""0"" Width=""328"" Height=""1153.04"" Anchor=""Right"" State=""Docked"" />
</DockablePane>
</ResizingPanel>
<ResizingPanel ResizeWidth=""*"" ResizeHeight=""*"" EffectiveSize=""1408,1153.04"" Orientation=""Vertical"">
<DocumentPaneResizingPanel ResizeWidth=""*"" ResizeHeight=""*"" EffectiveSize=""1408,965.04"" Orientation=""Vertical"">
<DocumentPane IsMain=""true"" ResizeWidth=""*"" ResizeHeight=""*"" EffectiveSize=""1408,965.04"" />
</DocumentPaneResizingPanel>
<DockablePane ResizeWidth=""*"" ResizeHeight=""182"" EffectiveSize=""1408,182"" ID=""ebd34b7e-6a89-42c6-b172-0e666b0d8a0a"" Anchor=""Bottom"" IsAutoHidden=""false"">
<DockableContent Name=""content3"" FloatingWindowSize=""250,400"" ChildIndex=""0"" Width=""1920"" Height=""400"" Anchor=""Bottom"" State=""Docked"" />
</DockablePane>
</ResizingPanel>
<ResizingPanel ResizeWidth=""250"" ResizeHeight=""*"" EffectiveSize=""250,1153.04"" Orientation=""Vertical"">
<DockablePane ResizeWidth=""0.145251345356991*"" ResizeHeight=""0.145251345356991*"" EffectiveSize=""250,166.609103178283"" ID=""aa545474-48b3-49a6-b76c-b0c625e79e4c"" Anchor=""Right"" IsAutoHidden=""false"">
<DockableContent Name=""content5"" FloatingWindowSize=""250,400"" ChildIndex=""0"" Width=""550.666666666667"" Height=""1153.04"" Anchor=""Right"" State=""Docked"" />
</DockablePane>
<DockablePane ResizeWidth=""0.854748654643009*"" ResizeHeight=""0.854748654643009*"" EffectiveSize=""250,980.430896821717"" ID=""64e5518b-2c83-4e22-908d-a510a6995c27"" Anchor=""Right"" IsAutoHidden=""false"">
<DockableContent Name=""content4"" FloatingWindowSize=""250,400"" ChildIndex=""0"" Width=""399.967430639324"" Height=""1153.04"" Anchor=""Right"" State=""Docked"" />
</DockablePane>
</ResizingPanel>
</ResizingPanel>
</ResizingPanel>
<Hidden />
<Windows />
</DockingManager>")]
public string AvalonDockLayout {
get {
return ((string)(this["AvalonDockLayout"]));
}
set {
this["AvalonDockLayout"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
public global::System.Collections.Specialized.StringCollection RecentFiles {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["RecentFiles"]));
}
set {
this["RecentFiles"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute(@"<?xml version=""1.0"" encoding=""utf-16""?>
<ArrayOfString xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">
<string>%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll</string>
</ArrayOfString>")]
public global::System.Collections.Specialized.StringCollection AssemblyList {
get {
return ((global::System.Collections.Specialized.StringCollection)(this["AssemblyList"]));
}
set {
this["AssemblyList"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Maximized")]
public global::System.Windows.WindowState MainWindowState {
get {
return ((global::System.Windows.WindowState)(this["MainWindowState"]));
}
set {
this["MainWindowState"] = value;
}
}
}
}

55
samples/XamlDesigner/Configuration/Settings.settings

@ -1,55 +0,0 @@ @@ -1,55 +0,0 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="ICSharpCode.XamlDesigner.Configuration" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="MainWindowRect" Type="System.Windows.Rect" Scope="User">
<Value Profile="(Default)">0,0,0,0</Value>
</Setting>
<Setting Name="AvalonDockLayout" Type="System.String" Scope="User">
<Value Profile="(Default)">&lt;DockingManager version="1.3.0"&gt;
&lt;ResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="0,0" Orientation="Vertical"&gt;
&lt;ResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="1920,1153.04" Orientation="Horizontal"&gt;
&lt;ResizingPanel ResizeWidth="250" ResizeHeight="*" EffectiveSize="250,1153.04" Orientation="Vertical"&gt;
&lt;DockablePane ResizeWidth="0.742440632565806*" ResizeHeight="0.742440632565806*" EffectiveSize="250,851.609103178282" ID="bb7a5fd3-be24-4636-8fd6-a50a09e65e69" Anchor="Left" IsAutoHidden="false"&gt;
&lt;DockableContent Name="content1" FloatingWindowSize="250,400" ChildIndex="0" Width="315" Height="1153.04" Anchor="Right" State="Docked" /&gt;
&lt;/DockablePane&gt;
&lt;DockablePane ResizeWidth="0.257559367434194*" ResizeHeight="0.257559367434194*" EffectiveSize="250,295.430896821718" ID="17cd1941-1004-4ed9-8cda-03c254681289" Anchor="Left" IsAutoHidden="false"&gt;
&lt;DockableContent Name="content2" FloatingWindowSize="250,400" ChildIndex="0" Width="328" Height="1153.04" Anchor="Right" State="Docked" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;ResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="1408,1153.04" Orientation="Vertical"&gt;
&lt;DocumentPaneResizingPanel ResizeWidth="*" ResizeHeight="*" EffectiveSize="1408,965.04" Orientation="Vertical"&gt;
&lt;DocumentPane IsMain="true" ResizeWidth="*" ResizeHeight="*" EffectiveSize="1408,965.04" /&gt;
&lt;/DocumentPaneResizingPanel&gt;
&lt;DockablePane ResizeWidth="*" ResizeHeight="182" EffectiveSize="1408,182" ID="ebd34b7e-6a89-42c6-b172-0e666b0d8a0a" Anchor="Bottom" IsAutoHidden="false"&gt;
&lt;DockableContent Name="content3" FloatingWindowSize="250,400" ChildIndex="0" Width="1920" Height="400" Anchor="Bottom" State="Docked" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;ResizingPanel ResizeWidth="250" ResizeHeight="*" EffectiveSize="250,1153.04" Orientation="Vertical"&gt;
&lt;DockablePane ResizeWidth="0.145251345356991*" ResizeHeight="0.145251345356991*" EffectiveSize="250,166.609103178283" ID="aa545474-48b3-49a6-b76c-b0c625e79e4c" Anchor="Right" IsAutoHidden="false"&gt;
&lt;DockableContent Name="content5" FloatingWindowSize="250,400" ChildIndex="0" Width="550.666666666667" Height="1153.04" Anchor="Right" State="Docked" /&gt;
&lt;/DockablePane&gt;
&lt;DockablePane ResizeWidth="0.854748654643009*" ResizeHeight="0.854748654643009*" EffectiveSize="250,980.430896821717" ID="64e5518b-2c83-4e22-908d-a510a6995c27" Anchor="Right" IsAutoHidden="false"&gt;
&lt;DockableContent Name="content4" FloatingWindowSize="250,400" ChildIndex="0" Width="399.967430639324" Height="1153.04" Anchor="Right" State="Docked" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;/ResizingPanel&gt;
&lt;/ResizingPanel&gt;
&lt;Hidden /&gt;
&lt;Windows /&gt;
&lt;/DockingManager&gt;</Value>
</Setting>
<Setting Name="RecentFiles" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="AssemblyList" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
&lt;string&gt;%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll&lt;/string&gt;
&lt;/ArrayOfString&gt;</Value>
</Setting>
<Setting Name="MainWindowState" Type="System.Windows.WindowState" Scope="User">
<Value Profile="(Default)">Maximized</Value>
</Setting>
</Settings>
</SettingsFile>

51
samples/XamlDesigner/Configuration/app.config

@ -1,51 +0,0 @@ @@ -1,51 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ICSharpCode.XamlDesigner.Configuration.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<userSettings>
<ICSharpCode.XamlDesigner.Configuration.Settings>
<setting name="MainWindowRect" serializeAs="String">
<value>0,0,0,0</value>
</setting>
<setting name="AvalonDockLayout" serializeAs="String">
<value>&lt;DockingManager&gt;
&lt;ResizingPanel Orientation="Horizontal"&gt;
&lt;ResizingPanel ResizeWidth="200" Orientation="Vertical"&gt;
&lt;DockablePane ResizeHeight="441.36166666666668" Anchor="Left"&gt;
&lt;DockableContent Name="content1" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;DockablePane ResizeWidth="200" Anchor="Left"&gt;
&lt;DockableContent Name="content2" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;ResizingPanel Orientation="Vertical"&gt;
&lt;DocumentPanePlaceHolder /&gt;
&lt;DockablePane ResizeHeight="138" Anchor="Bottom"&gt;
&lt;DockableContent Name="content3" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;DockablePane ResizeWidth="271" Anchor="Right"&gt;
&lt;DockableContent Name="content4" AutoHide="false" /&gt;
&lt;/DockablePane&gt;
&lt;/ResizingPanel&gt;
&lt;Hidden /&gt;
&lt;Windows /&gt;
&lt;/DockingManager&gt;</value>
</setting>
<setting name="AssemblyList" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<string>%ProgramFiles%\Reference Assemblies\Microsoft\Framework\v3.0\PresentationFramework.dll</string>
</ArrayOfString>
</value>
</setting>
<setting name="MainWindowState" serializeAs="String">
<value>Maximized</value>
</setting>
</ICSharpCode.XamlDesigner.Configuration.Settings>
</userSettings>
</configuration>

29
samples/XamlDesigner/Configuration/app.manifest

@ -1,29 +0,0 @@ @@ -1,29 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity>
</dependentAssembly>
</dependency>
</asmv1:assembly>

66
samples/XamlDesigner/Converters.cs

@ -1,66 +0,0 @@ @@ -1,66 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
using System.Windows;
using System.Collections;
namespace ICSharpCode.XamlDesigner.Converters
{
public class EnumToIntConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
public class CollapsedWhenFalse : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class FalseWhenZero : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || (int)value == 0) {
return false;
}
return true;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class LevelConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return new Thickness(5 + 19 * (int)value, 0, 5, 0);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

253
samples/XamlDesigner/Document.cs

@ -1,253 +0,0 @@ @@ -1,253 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.IO;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System.Xml;
using ICSharpCode.WpfDesign;
using ICSharpCode.WpfDesign.Designer.Services;
using System.Diagnostics;
using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.XamlDesigner
{
public class Document : INotifyPropertyChanged
{
public Document(string tempName, string text)
{
this.tempName = tempName;
Text = text;
IsDirty = false;
}
public Document(string filePath)
{
this.filePath = filePath;
ReloadFile();
}
string tempName;
DesignSurface designSurface = new DesignSurface();
string text;
public string Text {
get {
return text;
}
set {
if (text != value) {
text = value;
IsDirty = true;
RaisePropertyChanged("Text");
}
}
}
DocumentMode mode;
public DocumentMode Mode {
get {
return mode;
}
set {
mode = value;
if (InDesignMode) {
UpdateDesign();
}
else {
UpdateXaml();
}
RaisePropertyChanged("Mode");
RaisePropertyChanged("InXamlMode");
RaisePropertyChanged("InDesignMode");
}
}
public bool InXamlMode {
get { return Mode == DocumentMode.Xaml; }
}
public bool InDesignMode {
get { return Mode == DocumentMode.Design; }
}
string filePath;
public string FilePath {
get {
return filePath;
}
private set {
filePath = value;
RaisePropertyChanged("FilePath");
RaisePropertyChanged("FileName");
RaisePropertyChanged("Title");
RaisePropertyChanged("Name");
}
}
bool isDirty;
public bool IsDirty {
get {
return isDirty;
}
private set {
isDirty = value;
RaisePropertyChanged("IsDirty");
RaisePropertyChanged("Name");
RaisePropertyChanged("Title");
}
}
public string FileName {
get {
if (FilePath == null) return null;
return Path.GetFileName(FilePath);
}
}
public string Name {
get {
return FileName ?? tempName;
}
}
public string Title {
get {
return IsDirty ? Name + "*" : Name;
}
}
public DesignSurface DesignSurface {
get { return designSurface; }
}
public DesignContext DesignContext {
get { return designSurface.DesignContext; }
}
public UndoService UndoService {
get { return DesignContext.Services.GetService<UndoService>(); }
}
public ISelectionService SelectionService {
get {
if (InDesignMode) {
return DesignContext.Services.Selection;
}
return null;
}
}
public XamlErrorService XamlErrorService {
get {
if (DesignContext != null) {
return DesignContext.Services.GetService<XamlErrorService>();
}
return null;
}
}
IOutlineNode outlineRoot;
public IOutlineNode OutlineRoot {
get {
return outlineRoot;
}
private set {
outlineRoot = value;
RaisePropertyChanged("OutlineRoot");
}
}
void ReloadFile()
{
Text = File.ReadAllText(FilePath);
UpdateDesign();
IsDirty = false;
}
public void Save()
{
if (InDesignMode) {
UpdateXaml();
}
File.WriteAllText(FilePath, Text);
IsDirty = false;
}
public void SaveAs(string filePath)
{
FilePath = filePath;
Save();
}
public void Refresh()
{
UpdateXaml();
UpdateDesign();
}
void UpdateXaml()
{
var sb = new StringBuilder();
using (var xmlWriter = new XamlXmlWriter(sb)) {
DesignSurface.SaveDesigner(xmlWriter);
Text = XamlFormatter.Format(sb.ToString());
}
}
void UpdateDesign()
{
OutlineRoot = null;
using (var xmlReader = XmlReader.Create(new StringReader(Text))) {
XamlLoadSettings settings = new XamlLoadSettings();
foreach (var assNode in Toolbox.Instance.AssemblyNodes)
{
settings.DesignerAssemblies.Add(assNode.Assembly);
}
settings.TypeFinder = MyTypeFinder.Instance;
DesignSurface.LoadDesigner(xmlReader, settings);
}
if (DesignContext.RootItem != null) {
OutlineRoot = OutlineNode.Create(DesignContext.RootItem);
UndoService.UndoStackChanged += new EventHandler(UndoService_UndoStackChanged);
}
RaisePropertyChanged("SelectionService");
RaisePropertyChanged("XamlErrorService");
}
void UndoService_UndoStackChanged(object sender, EventArgs e)
{
IsDirty = true;
if (InXamlMode) {
UpdateXaml();
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
public enum DocumentMode
{
Xaml, Design
}
}

22
samples/XamlDesigner/DocumentView.xaml

@ -1,22 +0,0 @@ @@ -1,22 +0,0 @@
<UserControl
x:Class="ICSharpCode.XamlDesigner.DocumentView"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner"
xmlns:DesignerControls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:AvalonEdit="http://icsharpcode.net/sharpdevelop/avalonedit"
>
<DockPanel>
<DesignerControls:EnumBar
Value="{Binding Mode}"
DockPanel.Dock="Bottom"/>
<Grid>
<AvalonEdit:TextEditor
x:Name="uxTextEditor"
SyntaxHighlighting="XML" ShowLineNumbers="True"
Visibility="{Binding InXamlMode, Converter={StaticResource CollapsedWhenFalse}}" />
<ContentPresenter Content="{Binding DesignSurface}"
Visibility="{Binding InDesignMode, Converter={StaticResource CollapsedWhenFalse}}"/>
</Grid>
</DockPanel>
</UserControl>

68
samples/XamlDesigner/DocumentView.xaml.cs

@ -1,68 +0,0 @@ @@ -1,68 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Threading;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.XamlDesigner
{
public partial class DocumentView
{
public DocumentView(Document doc)
{
InitializeComponent();
Document = doc;
Shell.Instance.Views[doc] = this;
//uxTextEditor.DataBindings.Add("Text", doc, "Text", true, System.Windows.Forms.DataSourceUpdateMode.OnPropertyChanged);
Document.Mode = DocumentMode.Design;
Document.PropertyChanged += new PropertyChangedEventHandler(Document_PropertyChanged);
uxTextEditor.TextChanged += new EventHandler(uxTextEditor_TextChanged);
}
void uxTextEditor_TextChanged(object sender, EventArgs e)
{
Document.Text = uxTextEditor.Text;
}
void Document_PropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == "Text" && Document.Text != uxTextEditor.Text)
uxTextEditor.Text = Document.Text;
}
public Document Document { get; private set; }
public void JumpToError(XamlError error)
{
Document.Mode = DocumentMode.Xaml;
try {
uxTextEditor.ScrollTo(error.Line, error.Column);
uxTextEditor.CaretOffset = uxTextEditor.Document.GetOffset(error.Line, error.Column);
int n = 0;
char chr;
while ((chr = uxTextEditor.Document.GetCharAt(uxTextEditor.CaretOffset + n)) != ' ' && chr != '.' && chr != '<' && chr != '>' && chr != '"')
{ n++; }
uxTextEditor.SelectionLength = n;
}
catch (ArgumentException) {
// invalid line number
}
}
}
}

7
samples/XamlDesigner/EnumBar.xaml

@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
<UserControl
x:Class="ICSharpCode.XamlDesigner.EnumBar"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel x:Name="uxPanel"
Orientation="Horizontal" />
</UserControl>

72
samples/XamlDesigner/EnumBar.xaml.cs

@ -1,72 +0,0 @@ @@ -1,72 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.XamlDesigner
{
public partial class EnumBar
{
public EnumBar()
{
InitializeComponent();
}
Type currentEnumType;
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(object), typeof(EnumBar),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public object Value {
get { return (object)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == ValueProperty) {
var type = e.NewValue.GetType();
if (currentEnumType != type) {
currentEnumType = type;
uxPanel.Children.Clear();
foreach (var v in Enum.GetValues(type)) {
var b = new EnumButton();
b.Value = v;
b.Content = Enum.GetName(type, v);
b.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(button_PreviewMouseLeftButtonDown);
uxPanel.Children.Add(b);
}
}
foreach (EnumButton c in uxPanel.Children) {
if (c.Value.Equals(Value)) {
c.IsChecked = true;
}
else {
c.IsChecked = false;
}
}
}
}
void button_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Value = (sender as EnumButton).Value;
e.Handled = true;
}
}
}

26
samples/XamlDesigner/EnumButton.cs

@ -1,26 +0,0 @@ @@ -1,26 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls.Primitives;
using System.Windows;
namespace ICSharpCode.XamlDesigner
{
public class EnumButton : ToggleButton
{
static EnumButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(EnumButton),
new FrameworkPropertyMetadata(typeof(EnumButton)));
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(object), typeof(EnumButton));
public object Value {
get { return (object)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
}
}

23
samples/XamlDesigner/ErrorListView.xaml

@ -1,23 +0,0 @@ @@ -1,23 +0,0 @@
<ListBox x:Class="ICSharpCode.XamlDesigner.ErrorListView"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Services="clr-namespace:ICSharpCode.WpfDesign.Designer.Services;assembly=ICSharpCode.WpfDesign.Designer">
<Control.Resources>
<DataTemplate DataType="{x:Type Services:XamlError}">
<StackPanel Orientation="Horizontal">
<Image Source="Images/Error.png"
Stretch="None"
Margin="2"/>
<TextBlock TextAlignment="Right" Text="{Binding Line}" Width="25"
VerticalAlignment="Center"/>
<TextBlock Text=" / "
VerticalAlignment="Center"/>
<TextBlock Text="{Binding Column}" Width="25"
VerticalAlignment="Center"/>
<TextBlock Text=" - " />
<TextBlock Text="{Binding Message}"
VerticalAlignment="Center"/>
</StackPanel>
</DataTemplate>
</Control.Resources>
</ListBox>

33
samples/XamlDesigner/ErrorListView.xaml.cs

@ -1,33 +0,0 @@ @@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.XamlDesigner
{
public partial class ErrorListView
{
public ErrorListView()
{
InitializeComponent();
}
protected override void OnMouseDoubleClick(MouseButtonEventArgs e)
{
var error = e.GetDataContext() as XamlError;
if (error != null) {
Shell.Instance.JumpToError(error);
}
}
}
}

102
samples/XamlDesigner/ExtensionMethods.cs

@ -1,102 +0,0 @@ @@ -1,102 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Documents;
using System.Windows.Media;
using System.IO;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Collections;
namespace ICSharpCode.XamlDesigner
{
static class ExtensionMethods
{
public static IEnumerable<string> Paths(this IDataObject data)
{
string[] paths = (string[])data.GetData(DataFormats.FileDrop);
if (paths != null) {
foreach (var path in paths) {
yield return path;
}
}
}
public static T GetObject<T>(this IDataObject data)
{
return (T)data.GetData(typeof(T).FullName);
}
public static Stream ToStream(this string s)
{
return new MemoryStream(Encoding.UTF8.GetBytes(s));
}
public static void AddRange<T>(this ObservableCollection<T> col, IEnumerable<T> items)
{
foreach (var item in items) {
col.Add(item);
}
}
public static void KeepSyncronizedWith<S>(this IList target, ObservableCollection<S> source, Func<S, object> convert)
{
target.Clear();
foreach (var item in source) {
target.Add(convert(item));
}
source.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) {
switch (e.Action) {
case NotifyCollectionChangedAction.Add:
target.Add(convert((S)e.NewItems[0]));
break;
case NotifyCollectionChangedAction.Remove:
target.RemoveAt(e.OldStartingIndex);
break;
case NotifyCollectionChangedAction.Move:
target.RemoveAt(e.OldStartingIndex);
target.Insert(e.NewStartingIndex, e.NewItems[0]);
break;
case NotifyCollectionChangedAction.Replace:
target[e.NewStartingIndex] = convert((S)e.NewItems[0]);
break;
case NotifyCollectionChangedAction.Reset:
target.Clear();
break;
}
};
}
public static object GetDataContext(this RoutedEventArgs e)
{
var f = e.OriginalSource as FrameworkElement;
if (f != null) return f.DataContext;
return null;
}
}
}

BIN
samples/XamlDesigner/Images/Error.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 701 B

BIN
samples/XamlDesigner/Images/Reference.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

BIN
samples/XamlDesigner/Images/Tag.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 389 B

133
samples/XamlDesigner/MainWindow.xaml

@ -1,133 +0,0 @@ @@ -1,133 +0,0 @@
<Window x:Class="ICSharpCode.XamlDesigner.MainWindow"
x:Name="root"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sd="http://sharpdevelop.net"
xmlns:AvalonDock="clr-namespace:AvalonDock;assembly=AvalonDock"
xmlns:Outline="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner"
SnapsToDevicePixels="True"
AllowDrop="True"
Title="{Binding Title}">
<Window.CommandBindings>
<CommandBinding Command="New"
Executed="NewCommand_Executed" />
<CommandBinding Command="Open"
Executed="OpenCommand_Executed" />
<CommandBinding Command="Close"
Executed="CloseCommand_Executed"
CanExecute="CurrentDocument_CanExecute"
PreviewExecuted="CloseCommand_PreviewExecuted"/>
<CommandBinding Command="Default:MainWindow.CloseAllCommand"
Executed="CloseAllCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Save"
Executed="SaveCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="SaveAs"
Executed="SaveAsCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Default:MainWindow.SaveAllCommand"
Executed="SaveAllCommand_Executed"
CanExecute="CurrentDocument_CanExecute" />
<CommandBinding Command="Default:MainWindow.ExitCommand"
Executed="ExitCommand_Executed" />
<CommandBinding Command="Default:MainWindow.RunCommand"
Executed="RunCommand_Executed" />
<CommandBinding Command="Default:MainWindow.RenderToBitmapCommand"
Executed="RenderToBitmapCommand_Executed" />
</Window.CommandBindings>
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="File">
<MenuItem Command="New" />
<MenuItem Command="Open" />
<Separator />
<MenuItem Command="Close" />
<MenuItem Command="Default:MainWindow.CloseAllCommand" />
<Separator />
<MenuItem Command="Save" />
<MenuItem Command="SaveAs" />
<MenuItem Command="Default:MainWindow.SaveAllCommand" />
<Separator />
<MenuItem Header="Recent Files"
ItemsSource="{Binding RecentFiles}"
IsEnabled="{Binding RecentFiles.Count, Converter={StaticResource FalseWhenZero}}"
Click="RecentFiles_Click"/>
<Separator />
<MenuItem Command="Default:MainWindow.ExitCommand" />
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Command="Undo" />
<MenuItem Command="Redo" />
<Separator />
<MenuItem Command="Cut" />
<MenuItem Command="Copy" />
<MenuItem Command="Paste" />
<MenuItem Command="Delete" />
<MenuItem Command="SelectAll" />
<Separator />
<MenuItem Command="Default:MainWindow.RefreshCommand" />
<MenuItem Command="Find" />
</MenuItem>
<MenuItem Header="Test">
<MenuItem Command="Default:MainWindow.RunCommand" />
<MenuItem Command="Default:MainWindow.RenderToBitmapCommand" />
</MenuItem>
</Menu>
<AvalonDock:DockingManager x:Name="uxDockingManager">
<AvalonDock:ResizingPanel>
<AvalonDock:DocumentPane x:Name="uxDocumentPane"
SelectedValue="{Binding CurrentDocument}"
SelectedValuePath="DataContext"/>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content1" Title="Toolbox">
<Default:ToolboxView />
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content2" Title="Outline">
<Outline:Outline Root="{Binding CurrentDocument.OutlineRoot}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content3" Title="Errors">
<Default:ErrorListView ItemsSource="{Binding CurrentDocument.XamlErrorService.Errors}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content4" Title="Properties">
<sd:PropertyGridView x:Name="uxPropertyGridView"
SelectedItems="{Binding DataContext.CurrentDocument.SelectionService.SelectedItems, ElementName=root, FallbackValue={x:Null}}"/>
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
<AvalonDock:DockablePane>
<AvalonDock:DockableContent x:Name="content5" Title="Thumbnail">
<sd:ThumbnailView x:Name="uxThumbnailView" DesignSurface="{Binding DataContext.CurrentDocument.DesignSurface, ElementName=root, FallbackValue={x:Null}}" />
</AvalonDock:DockableContent>
</AvalonDock:DockablePane>
</AvalonDock:ResizingPanel>
</AvalonDock:DockingManager>
</DockPanel>
</Window>

191
samples/XamlDesigner/MainWindow.xaml.cs

@ -1,191 +0,0 @@ @@ -1,191 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ICSharpCode.XamlDesigner.Configuration;
using System.ComponentModel;
using Microsoft.Win32;
using AvalonDock;
using System.IO;
using System.Collections.Specialized;
using ICSharpCode.WpfDesign.Designer;
namespace ICSharpCode.XamlDesigner
{
public partial class MainWindow
{
public MainWindow()
{
Instance = this;
DataContext = Shell.Instance;
RenameCommands();
BasicMetadata.Register();
InitializeComponent();
Shell.Instance.PropertyGrid = uxPropertyGridView.PropertyGrid;
AvalonDockWorkaround();
RouteDesignSurfaceCommands();
this.AddCommandHandler(RefreshCommand, Shell.Instance.Refresh, Shell.Instance.CanRefresh);
LoadSettings();
ProcessPaths(App.Args);
ApplicationCommands.New.Execute(null, this);
}
public static MainWindow Instance;
OpenFileDialog openFileDialog;
SaveFileDialog saveFileDialog;
protected override void OnDragEnter(DragEventArgs e)
{
ProcessDrag(e);
}
protected override void OnDragOver(DragEventArgs e)
{
ProcessDrag(e);
}
protected override void OnDrop(DragEventArgs e)
{
ProcessPaths(e.Data.Paths());
}
protected override void OnClosing(CancelEventArgs e)
{
if (Shell.Instance.PrepareExit()) {
SaveSettings();
}
else {
e.Cancel = true;
}
base.OnClosing(e);
}
void RecentFiles_Click(object sender, RoutedEventArgs e)
{
var path = (string)(e.OriginalSource as MenuItem).Header;
Shell.Instance.Open(path);
}
void ProcessDrag(DragEventArgs e)
{
e.Effects = DragDropEffects.None;
e.Handled = true;
foreach (var path in e.Data.Paths()) {
if (path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) ||
path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) {
e.Effects = DragDropEffects.Copy;
break;
}
else if (path.EndsWith(".xaml", StringComparison.InvariantCultureIgnoreCase)) {
e.Effects = DragDropEffects.Copy;
break;
}
}
}
void ProcessPaths(IEnumerable<string> paths)
{
foreach (var path in paths) {
if (path.EndsWith(".dll", StringComparison.InvariantCultureIgnoreCase) ||
path.EndsWith(".exe", StringComparison.InvariantCultureIgnoreCase)) {
Toolbox.Instance.AddAssembly(path);
}
else if (path.EndsWith(".xaml", StringComparison.InvariantCultureIgnoreCase)) {
Shell.Instance.Open(path);
}
}
}
public string AskOpenFileName()
{
if (openFileDialog == null) {
openFileDialog = new OpenFileDialog();
openFileDialog.Filter = "Xaml Documents (*.xaml)|*.xaml";
}
if ((bool)openFileDialog.ShowDialog()) {
return openFileDialog.FileName;
}
return null;
}
public string AskSaveFileName(string initName)
{
if (saveFileDialog == null) {
saveFileDialog = new SaveFileDialog();
saveFileDialog.Filter = "Xaml Documents (*.xaml)|*.xaml";
}
saveFileDialog.FileName = initName;
if ((bool)saveFileDialog.ShowDialog()) {
return saveFileDialog.FileName;
}
return null;
}
void LoadSettings()
{
WindowState = Settings.Default.MainWindowState;
Rect r = Settings.Default.MainWindowRect;
if (r != new Rect()) {
Left = r.Left;
Top = r.Top;
Width = r.Width;
Height = r.Height;
}
uxDockingManager.Loaded += delegate {
if (Settings.Default.AvalonDockLayout != null) {
uxDockingManager.RestoreLayout(Settings.Default.AvalonDockLayout.ToStream());
}
};
}
void SaveSettings()
{
Settings.Default.MainWindowState = WindowState;
if (WindowState == WindowState.Normal) {
Settings.Default.MainWindowRect = new Rect(Left, Top, Width, Height);
}
var writer = new StringWriter();
uxDockingManager.SaveLayout(writer);
Settings.Default.AvalonDockLayout = writer.ToString();
Shell.Instance.SaveSettings();
}
#region AvalonDockWorkaround
void AvalonDockWorkaround()
{
uxDocumentPane.Items.KeepSyncronizedWith(Shell.Instance.Documents, d => CreateContentFor(d));
}
DocumentContent CreateContentFor(Document doc)
{
var content = new DocumentContent() {
DataContext = doc,
Content = new DocumentView(doc)
};
content.SetBinding(DocumentContent.TitleProperty, "Title");
return content;
}
#endregion
}
}

177
samples/XamlDesigner/MainWindow_Commands.cs

@ -1,177 +0,0 @@ @@ -1,177 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Xml;
using Microsoft.Win32;
namespace ICSharpCode.XamlDesigner
{
public partial class MainWindow
{
public static SimpleCommand CloseAllCommand = new SimpleCommand("Close All");
public static SimpleCommand SaveAllCommand = new SimpleCommand("Save All", ModifierKeys.Control | ModifierKeys.Shift, Key.S);
public static SimpleCommand ExitCommand = new SimpleCommand("Exit");
public static SimpleCommand RefreshCommand = new SimpleCommand("Refresh", Key.F5);
public static SimpleCommand RunCommand = new SimpleCommand("Run", ModifierKeys.Shift, Key.F5);
public static SimpleCommand RenderToBitmapCommand = new SimpleCommand("Render to Bitmap");
static void RenameCommands()
{
ApplicationCommands.Open.Text = "Open...";
ApplicationCommands.SaveAs.Text = "Save As...";
}
void NewCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
Shell.Instance.New();
}
void OpenCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
Shell.Instance.Open();
}
void CloseCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
Shell.Instance.CloseCurrentDocument();
}
void CloseCommand_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
{
Shell.Instance.CloseCurrentDocument();
}
void CloseAllCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
Shell.Instance.CloseAll();
}
void SaveCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
Shell.Instance.SaveCurrentDocument();
}
void SaveAsCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
Shell.Instance.SaveCurrentDocumentAs();
}
void SaveAllCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
Shell.Instance.SaveAll();
}
void RunCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
StringBuilder sb = new StringBuilder();
var xmlWriter = XmlWriter.Create(new StringWriter(sb));
Shell.Instance.CurrentDocument.DesignSurface.SaveDesigner(xmlWriter);
var txt = sb.ToString();
var xmlReader = XmlReader.Create(new StringReader(txt));
var ctl = XamlReader.Load(xmlReader);
Window wnd = ctl as Window;
if (wnd == null) {
wnd = new Window();
wnd.Content = ctl;
}
wnd.Show();
}
void RenderToBitmapCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
int desiredWidth = 300;
int desiredHeight = 300;
StringBuilder sb = new StringBuilder();
var xmlWriter = XmlWriter.Create(new StringWriter(sb));
Shell.Instance.CurrentDocument.DesignSurface.SaveDesigner(xmlWriter);
var txt = sb.ToString();
var xmlReader = XmlReader.Create(new StringReader(txt));
var ctl = XamlReader.Load(xmlReader) as Control;
if (ctl is Window) {
var wnd = ctl as Window;
wnd.Width = desiredWidth;
wnd.Height = desiredHeight;
wnd.Top = -10000;
wnd.Left = -10000;
wnd.Show();
} else {
ctl.Measure(new Size(desiredWidth, desiredHeight));
ctl.Arrange(new Rect(new Size(desiredWidth, desiredHeight)));
}
RenderTargetBitmap bmp = new RenderTargetBitmap(300, 300, 96, 96, PixelFormats.Default);
bmp.Render(ctl);
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(bmp));
var dlg = new SaveFileDialog();
dlg.Filter = "*.png|*.png";
if (dlg.ShowDialog() == true) {
using (Stream stm = File.OpenWrite(dlg.FileName)) {
encoder.Save(stm);
stm.Flush();
}
}
if (ctl is Window) {
var wnd = ctl as Window;
wnd.Close();
}
}
void ExitCommand_Executed(object sender, ExecutedRoutedEventArgs e)
{
Shell.Instance.Exit();
}
void CurrentDocument_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = Shell.Instance.CurrentDocument != null;
}
void RouteDesignSurfaceCommands()
{
RouteDesignSurfaceCommand(ApplicationCommands.Undo);
RouteDesignSurfaceCommand(ApplicationCommands.Redo);
RouteDesignSurfaceCommand(ApplicationCommands.Copy);
RouteDesignSurfaceCommand(ApplicationCommands.Cut);
RouteDesignSurfaceCommand(ApplicationCommands.Paste);
RouteDesignSurfaceCommand(ApplicationCommands.SelectAll);
RouteDesignSurfaceCommand(ApplicationCommands.Delete);
}
void RouteDesignSurfaceCommand(RoutedCommand command)
{
var cb = new CommandBinding(command);
cb.CanExecute += delegate(object sender, CanExecuteRoutedEventArgs e) {
if (Shell.Instance.CurrentDocument != null) {
Shell.Instance.CurrentDocument.DesignSurface.RaiseEvent(e);
}else {
e.CanExecute = false;
}
};
cb.Executed += delegate(object sender, ExecutedRoutedEventArgs e) {
Shell.Instance.CurrentDocument.DesignSurface.RaiseEvent(e);
};
CommandBindings.Add(cb);
}
}
}

49
samples/XamlDesigner/MyTypeFinder.cs

@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.XamlDesigner
{
public class MyTypeFinder : XamlTypeFinder
{
public override Assembly LoadAssembly(string name)
{
foreach (var assemblyNode in Toolbox.Instance.AssemblyNodes)
{
if (assemblyNode.Name == name)
return assemblyNode.Assembly;
}
return null;
}
public override XamlTypeFinder Clone()
{
return _instance;
}
private static object lockObj = new object();
private static MyTypeFinder _instance;
public static MyTypeFinder Instance
{
get
{
lock (lockObj)
{
if (_instance == null)
{
_instance = new MyTypeFinder();
_instance.ImportFrom(CreateWpfTypeFinder());
}
}
return _instance;
}
}
}
}

4
samples/XamlDesigner/NewFileTemplate.xaml

@ -1,4 +0,0 @@ @@ -1,4 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Canvas />
</Window>

260
samples/XamlDesigner/Shell.cs

@ -1,260 +0,0 @@ @@ -1,260 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Collections.ObjectModel;
using ICSharpCode.WpfDesign.Designer.PropertyGrid;
using ICSharpCode.XamlDesigner.Configuration;
using System.Collections.Specialized;
using System.IO;
using System.Windows;
using System.Diagnostics;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.XamlDesigner
{
public class Shell : INotifyPropertyChanged
{
public Shell()
{
Documents = new ObservableCollection<Document>();
RecentFiles = new ObservableCollection<string>();
Views = new Dictionary<object, FrameworkElement>();
LoadSettings();
}
public static Shell Instance = new Shell();
public const string ApplicationTitle = "Xaml Designer";
//public Toolbox Toolbox { get; set; }
//public SceneTree SceneTree { get; set; }
public IPropertyGrid PropertyGrid { get; internal set; }
//public ErrorList ErrorList { get; set; }
public ObservableCollection<Document> Documents { get; private set; }
public ObservableCollection<string> RecentFiles { get; private set; }
public Dictionary<object, FrameworkElement> Views { get; private set; }
Document currentDocument;
public Document CurrentDocument {
get {
return currentDocument;
}
set {
currentDocument = value;
RaisePropertyChanged("CurrentDocument");
RaisePropertyChanged("Title");
}
}
public string Title {
get {
if (CurrentDocument != null) {
return CurrentDocument.Title + " - " + ApplicationTitle;
}
return ApplicationTitle;
}
}
void LoadSettings()
{
if (Settings.Default.RecentFiles != null) {
RecentFiles.AddRange(Settings.Default.RecentFiles.Cast<string>());
}
}
public void SaveSettings()
{
if (Settings.Default.RecentFiles == null) {
Settings.Default.RecentFiles = new StringCollection();
}
else {
Settings.Default.RecentFiles.Clear();
}
foreach (var f in RecentFiles) {
Settings.Default.RecentFiles.Add(f);
}
}
public static void ReportException(Exception x)
{
MessageBox.Show(x.ToString());
}
public void JumpToError(XamlError error)
{
if (CurrentDocument != null) {
(Views[CurrentDocument] as DocumentView).JumpToError(error);
}
}
public bool CanRefresh()
{
return CurrentDocument != null;
}
public void Refresh()
{
CurrentDocument.Refresh();
}
#region Files
bool IsSomethingDirty {
get {
foreach (var doc in Shell.Instance.Documents) {
if (doc.IsDirty) return true;
}
return false;
}
}
static int nonameIndex = 1;
public void New()
{
Document doc = new Document("New" + nonameIndex++, File.ReadAllText("NewFileTemplate.xaml"));
Documents.Add(doc);
CurrentDocument = doc;
}
public void Open()
{
var path = MainWindow.Instance.AskOpenFileName();
if (path != null) {
Open(path);
}
}
public void Open(string path)
{
path = Path.GetFullPath(path);
if (RecentFiles.Contains(path)) {
RecentFiles.Remove(path);
}
RecentFiles.Insert(0, path);
foreach (var doc in Documents) {
if (doc.FilePath == path) {
CurrentDocument = doc;
return;
}
}
var newDoc = new Document(path);
Documents.Add(newDoc);
CurrentDocument = newDoc;
}
public bool Save(Document doc)
{
if (doc.IsDirty) {
if (doc.FilePath == null) {
return SaveAs(doc);
}
doc.Save();
}
return true;
}
public bool SaveAs(Document doc)
{
var initName = doc.FileName ?? doc.Name + ".xaml";
var path = MainWindow.Instance.AskSaveFileName(initName);
if (path != null) {
doc.SaveAs(path);
return true;
}
return false;
}
public bool SaveAll()
{
foreach (var doc in Documents) {
if (!Save(doc)) return false;
}
return true;
}
public bool Close(Document doc)
{
if (doc.IsDirty) {
var result = MessageBox.Show("Save \"" + doc.Name + "\" ?", Shell.ApplicationTitle,
MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes) {
if (!Save(doc)) return false;
}
else if (result == MessageBoxResult.Cancel) {
return false;
}
}
Documents.Remove(doc);
Views.Remove(doc);
return true;
}
public bool CloseAll()
{
foreach (var doc in Documents.ToArray()) {
if (!Close(doc)) return false;
}
return true;
}
public bool PrepareExit()
{
if (IsSomethingDirty) {
var result = MessageBox.Show("Save All?", Shell.ApplicationTitle,
MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
if (result == MessageBoxResult.Yes) {
if (!SaveAll()) return false;
}
else if (result == MessageBoxResult.Cancel) {
return false;
}
}
return true;
}
public void Exit()
{
MainWindow.Instance.Close();
}
public void SaveCurrentDocument()
{
Save(CurrentDocument);
}
public void SaveCurrentDocumentAs()
{
SaveAs(CurrentDocument);
}
public void CloseCurrentDocument()
{
Close(CurrentDocument);
}
#endregion
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
void RaisePropertyChanged(string name)
{
if (PropertyChanged != null) {
PropertyChanged(this, new PropertyChangedEventArgs(name));
}
}
#endregion
}
}

27
samples/XamlDesigner/SimpleCommand.cs

@ -1,27 +0,0 @@ @@ -1,27 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
namespace ICSharpCode.XamlDesigner
{
public class SimpleCommand : RoutedUICommand
{
public SimpleCommand(string text)
{
Text = text;
}
public SimpleCommand(string text, ModifierKeys modifiers, Key key)
{
InputGestures.Add(new KeyGesture(key, modifiers));
Text = text;
}
public SimpleCommand(string text, Key key)
: this(text, ModifierKeys.None, key)
{
}
}
}

31
samples/XamlDesigner/TestFiles/1.xaml

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowTitle"
BorderThickness="10"
Width="400"
Height="300">
<StackPanel>
<Canvas Height="50">
<Button>CB</Button>
</Canvas>
<TabControl MinHeight="150">
<TabItem Header="StackPanel">
<StackPanel>
<Button>a</Button>
</StackPanel>
</TabItem>
<TabItem Header="Button">
<Button>button on page 2</Button>
</TabItem>
<TabItem Header="Canvas">
<Canvas />
</TabItem>
<TabItem Header="Grid">
<Grid />
</TabItem>
<TabItem Header="DockPanel">
<DockPanel />
</TabItem>
</TabControl>
</StackPanel>
</Window>

53
samples/XamlDesigner/TestFiles/2.xaml

@ -1,53 +0,0 @@ @@ -1,53 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="524"
Height="385">
<Canvas>
<Ellipse Width="146"
Height="63"
Fill="#FF5DAF05"
Stroke="#FF000000"
StrokeThickness="8"
Canvas.Left="8"
Canvas.Top="158.9" />
<Grid Width="279"
Height="336.99999999999989"
Background="#FFFFFFE1"
Canvas.Left="226.99999999999994"
Canvas.Top="8.0000000000000853">
<Panel.Children>
<TextBlock Width="59"
Height="39"
Margin="0,10,12,0"
HorizontalAlignment="Right"
VerticalAlignment="Top"
FontSize="33"
Text="Grid"
Grid.Column="0"
Grid.Row="0" />
</Panel.Children>
</Grid>
<GroupBox Content="GroupBox"
Width="175.39666666666668"
Height="116"
Canvas.Left="8"
Canvas.Top="8" />
<TextBlock Width="66.710000000000008"
FontSize="14"
Text="StackPanel"
Canvas.Left="8"
Canvas.Top="133" />
<StackPanel Width="209.99999999999994"
Height="114.09999999999991"
Background="#FFEDEDED"
Canvas.Left="8"
Canvas.Top="230.90000000000012">
<Panel.Children />
</StackPanel>
<Button Content="bla-blakjh"
Width="54.999999999999886"
Height="88.900000000000091"
Canvas.Left="163.00000000000006"
Canvas.Top="133.00000000000003" />
</Canvas>
</Window>

16
samples/XamlDesigner/TestFiles/3.xaml

@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Name="root"
Title="Hydralisk">
<Window.Resources>
<sys:String x:Key="r1">Title</sys:String>
<sys:String x:Key="r2">Width</sys:String>
</Window.Resources>
<StackPanel>
<Button Name="b1"
Width="100"
Content="Button" />
<TextBlock Text="{Binding Path={StaticResource r1}, ElementName=root}" />
</StackPanel>
</Window>

16
samples/XamlDesigner/TestFiles/4.xaml

@ -1,16 +0,0 @@ @@ -1,16 +0,0 @@
<Window xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Name="root"
Title="Hydralisk">
<Window.Resources>
<sys:String x:Key="r1">Title</sys:String>
<sys:String x:Key="r2">Width</sys:String>
</Window.Resources>
<StackPanel>
<Button Name="b1"
Width="100"
Content="Button" />
<TextBlock Text="{Binding Path={StaticResource r1}, ElementName=root}" />
</StackPanel>
</Window>

6
samples/XamlDesigner/Themes/Generic.xaml

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner"
xmlns:Converters="clr-namespace:ICSharpCode.XamlDesigner.Converters">
</ResourceDictionary>

109
samples/XamlDesigner/Toolbox.cs

@ -1,109 +0,0 @@ @@ -1,109 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Collections.ObjectModel;
using ICSharpCode.XamlDesigner.Configuration;
using System.Windows;
using System.Collections.Specialized;
using ICSharpCode.WpfDesign;
namespace ICSharpCode.XamlDesigner
{
public class Toolbox
{
public Toolbox()
{
AssemblyNodes = new ObservableCollection<AssemblyNode>();
LoadSettings();
}
public static Toolbox Instance = new Toolbox();
public ObservableCollection<AssemblyNode> AssemblyNodes { get; private set; }
public void AddAssembly(string path)
{
AddAssembly(path, true);
}
void AddAssembly(string path, bool updateSettings)
{
var assembly = Assembly.LoadFile(path);
MyTypeFinder.Instance.RegisterAssembly(assembly);
var node = new AssemblyNode();
node.Assembly = assembly;
node.Path = path;
foreach (var t in assembly.GetExportedTypes()) {
if (IsControl(t) /* && Metadata.IsPopularControl(t) */) {
node.Controls.Add(new ControlNode() { Type = t });
}
}
node.Controls.Sort(delegate(ControlNode c1, ControlNode c2) {
return c1.Name.CompareTo(c2.Name);
});
AssemblyNodes.Add(node);
if (updateSettings) {
if (Settings.Default.AssemblyList == null) {
Settings.Default.AssemblyList = new StringCollection();
}
Settings.Default.AssemblyList.Add(path);
}
}
public void Remove(AssemblyNode node)
{
AssemblyNodes.Remove(node);
Settings.Default.AssemblyList.Remove(node.Path);
}
public void LoadSettings()
{
if (Settings.Default.AssemblyList != null) {
foreach (var path in Settings.Default.AssemblyList) {
try
{
AddAssembly(Environment.ExpandEnvironmentVariables(path), false);
}
catch (Exception)
{ }
}
}
}
static bool IsControl(Type t)
{
return !t.IsAbstract && !t.IsGenericTypeDefinition && t.IsSubclassOf(typeof(UIElement)) && t.GetConstructor(BindingFlags.Public | BindingFlags.Instance, null, Type.EmptyTypes, null) != null;
}
}
public class AssemblyNode
{
public AssemblyNode()
{
Controls = new List<ControlNode>();
}
public Assembly Assembly { get; set; }
public List<ControlNode> Controls { get; private set; }
public string Path { get; set; }
public string Name {
get { return Assembly.GetName().Name; }
}
}
public class ControlNode
{
public Type Type { get; set; }
public string Name {
get { return Type.Name; }
}
}
}

31
samples/XamlDesigner/ToolboxView.xaml

@ -1,31 +0,0 @@ @@ -1,31 +0,0 @@
<UserControl x:Class="ICSharpCode.XamlDesigner.ToolboxView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Outline="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner">
<UserControl.ContextMenu>
<ContextMenu>
<MenuItem Header="Browse..." Click="BrowseForAssemblies_OnClick"></MenuItem>
</ContextMenu>
</UserControl.ContextMenu>
<UserControl.Resources>
<HierarchicalDataTemplate DataType="{x:Type Default:AssemblyNode}"
ItemsSource="{Binding Controls}">
<Outline:IconItem Icon="Images/Reference.png"
Text="{Binding Name}"
ToolTip="{Binding Path}" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type Default:ControlNode}">
<Outline:IconItem Icon="Images/Tag.png"
Text="{Binding Type.Name}" />
</DataTemplate>
</UserControl.Resources>
<TreeView x:Name="uxTreeView"
ItemsSource="{Binding AssemblyNodes}"
BorderThickness="0"/>
</UserControl>

94
samples/XamlDesigner/ToolboxView.xaml.cs

@ -1,94 +0,0 @@ @@ -1,94 +0,0 @@
using System.IO;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Designer.Services;
using Microsoft.Win32;
namespace ICSharpCode.XamlDesigner
{
public partial class ToolboxView
{
public ToolboxView()
{
DataContext = Toolbox.Instance;
InitializeComponent();
new DragListener(this).DragStarted += Toolbox_DragStarted;
uxTreeView.SelectedItemChanged += uxTreeView_SelectedItemChanged;
uxTreeView.GotKeyboardFocus += uxTreeView_GotKeyboardFocus;
}
void uxTreeView_GotKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
{
PrepareTool(uxTreeView.SelectedItem as ControlNode, false);
}
void uxTreeView_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
{
PrepareTool(uxTreeView.SelectedItem as ControlNode, false);
}
void Toolbox_DragStarted(object sender, MouseButtonEventArgs e)
{
PrepareTool(e.GetDataContext() as ControlNode, true);
}
void PrepareTool(ControlNode node, bool drag)
{
if (node != null) {
var tool = new CreateComponentTool(node.Type);
if (Shell.Instance.CurrentDocument != null) {
Shell.Instance.CurrentDocument.DesignContext.Services.Tool.CurrentTool = tool;
if (drag) {
DragDrop.DoDragDrop(this, tool, DragDropEffects.Copy);
}
}
}
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Delete) {
Remove();
}
}
void Remove()
{
AssemblyNode node = uxTreeView.SelectedItem as AssemblyNode;
if (node != null) {
Toolbox.Instance.Remove(node);
}
}
private void BrowseForAssemblies_OnClick(object sender, RoutedEventArgs e)
{
var dlg = new OpenFileDialog();
dlg.Filter = "Assemblies (*.dll)|*.dll";
dlg.Multiselect = true;
dlg.CheckFileExists = true;
if (dlg.ShowDialog().Value)
{
foreach (var fileName in dlg.FileNames)
{
Toolbox.Instance.AddAssembly(fileName);
}
}
}
}
}

214
samples/XamlDesigner/XamlDesigner.csproj

@ -1,214 +0,0 @@ @@ -1,214 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{27DA2B5C-2AAA-4478-AB00-3E184273C241}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>ICSharpCode.XamlDesigner</RootNamespace>
<AssemblyName>XamlDesigner</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<ApplicationManifest>Configuration\app.manifest</ApplicationManifest>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="AvalonDock">
<HintPath>..\..\bin\AvalonDock.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.AvalonEdit">
<HintPath>..\..\bin\ICSharpCode.AvalonEdit.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
</Reference>
<Reference Include="ICSharpCode.SharpDevelop.Widgets">
<HintPath>..\..\bin\ICSharpCode.SharpDevelop.Widgets.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="UIAutomationProvider">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationCore">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
<Reference Include="PresentationFramework">
<RequiredTargetFramework>3.0</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<ProjectReference Include="..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj">
<Project>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</Project>
<Name>WpfDesign.XamlDom</Name>
</ProjectReference>
<ProjectReference Include="..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj">
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Compile Include="..\..\src\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="BitmapButton.xaml.cs">
<DependentUpon>BitmapButton.xaml</DependentUpon>
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Configuration\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="Converters.cs" />
<Compile Include="Document.cs" />
<Compile Include="DocumentView.xaml.cs">
<DependentUpon>DocumentView.xaml</DependentUpon>
</Compile>
<Compile Include="ErrorListView.xaml.cs">
<DependentUpon>ErrorListView.xaml</DependentUpon>
</Compile>
<Compile Include="ExtensionMethods.cs" />
<Compile Include="MainWindow_Commands.cs" />
<Compile Include="MyTypeFinder.cs" />
<Compile Include="Shell.cs" />
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
</Compile>
<Compile Include="SimpleCommand.cs" />
<Compile Include="Toolbox.cs" />
<Compile Include="ToolboxView.xaml.cs">
<DependentUpon>ToolboxView.xaml</DependentUpon>
</Compile>
<Compile Include="XamlFormatter.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="NewFileTemplate.xaml">
<SubType>Designer</SubType>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Page Include="BitmapButton.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="DocumentView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ErrorListView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="MainWindow.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<None Include="TestFiles\1.xaml">
<SubType>Designer</SubType>
</None>
<None Include="TestFiles\2.xaml">
<SubType>Designer</SubType>
</None>
<None Include="TestFiles\3.xaml">
<SubType>Designer</SubType>
</None>
<None Include="TestFiles\4.xaml">
<SubType>Designer</SubType>
</None>
<Page Include="Themes\Generic.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="ToolboxView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="Configuration\app.config" />
<None Include="Configuration\app.manifest" />
<None Include="Configuration\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Reference.png" />
<Resource Include="Images\Tag.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Error.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

47
samples/XamlDesigner/XamlDesigner.sln

@ -1,47 +0,0 @@ @@ -1,47 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
# SharpDevelop 5.1
VisualStudioVersion = 12.0.20827.3
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlDesigner", "XamlDesigner.csproj", "{27DA2B5C-2AAA-4478-AB00-3E184273C241}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Tests", "..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Tests\WpfDesign.Tests.csproj", "{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "..\..\src\AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{27DA2B5C-2AAA-4478-AB00-3E184273C241}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{27DA2B5C-2AAA-4478-AB00-3E184273C241}.Debug|Any CPU.Build.0 = Debug|Any CPU
{27DA2B5C-2AAA-4478-AB00-3E184273C241}.Release|Any CPU.ActiveCfg = Release|Any CPU
{27DA2B5C-2AAA-4478-AB00-3E184273C241}.Release|Any CPU.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.Build.0 = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{943DBBB3-E84E-4CF4-917C-C05AFA8743C1}.Release|Any CPU.Build.0 = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

203
samples/XamlDesigner/XamlFormatter.cs

@ -1,203 +0,0 @@ @@ -1,203 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace ICSharpCode.XamlDesigner
{
public static class XamlFormatter
{
public static char IndentChar = ' ';
public static int Indenation = 2;
public static int LengthBeforeNewLine = 60;
static StringBuilder sb;
static int currentColumn;
static int nextColumn;
public static string Format(string xaml)
{
sb = new StringBuilder();
currentColumn = 0;
nextColumn = 0;
try {
var doc = XDocument.Parse(xaml);
WalkContainer(doc);
return sb.ToString();
}
catch {
return xaml;
}
}
static void WalkContainer(XContainer node)
{
foreach (var c in node.Nodes()) {
if (c is XElement) {
WalkElement(c as XElement);
} else {
NewLine();
Append(c.ToString().Trim());
}
}
}
static void WalkElement(XElement e)
{
NewLine();
string prefix1 = e.GetPrefixOfNamespace(e.Name.Namespace);
string name1 = prefix1 == null ? e.Name.LocalName : prefix1 + ":" + e.Name.LocalName;
Append("<" + name1);
List<AttributeString> list = new List<AttributeString>();
int length = name1.Length;
foreach (var a in e.Attributes()) {
string prefix2 = e.GetPrefixOfNamespace(a.Name.Namespace);
var g = new AttributeString() { Name = a.Name, Prefix = prefix2, Value = a.Value };
list.Add(g);
length += g.FinalString.Length;
}
list.Sort(AttributeComparrer.Instance);
if (length > LengthBeforeNewLine) {
nextColumn = currentColumn + 1;
for (int i = 0; i < list.Count; i++) {
if (i > 0) {
NewLine();
}
else {
Append(" ");
}
Append(list[i].FinalString);
}
nextColumn -= name1.Length + 2;
}
else {
foreach (var a in list) {
Append(" " + a.FinalString);
}
}
if (e.Nodes().Count() > 0) {
Append(">");
nextColumn += Indenation;
WalkContainer(e);
nextColumn -= Indenation;
NewLine();
Append("</" + name1 + ">");
}
else {
Append(" />");
}
}
static void NewLine()
{
if (sb.Length > 0) {
sb.AppendLine();
sb.Append(new string(' ', nextColumn));
currentColumn = nextColumn;
}
}
static void Append(string s)
{
sb.Append(s);
currentColumn += s.Length;
}
enum AttributeLayout
{
X,
XmlnsMicrosoft,
Xmlns,
XmlnsWithClr,
SpecialOrder,
ByName,
Attached,
WithPrefix
}
class AttributeString
{
public XName Name;
public string Prefix;
public string Value;
public string LocalName {
get { return Name.LocalName; }
}
public string FinalName {
get {
return Prefix == null ? Name.LocalName : Prefix + ":" + Name.LocalName;
}
}
public string FinalString {
get {
return FinalName + "=\"" + Value + "\"";
}
}
public AttributeLayout GetAttributeLayout()
{
if (Prefix == "xmlns" || LocalName == "xmlns") {
if (Value.StartsWith("http://schemas.microsoft.com")) return AttributeLayout.XmlnsMicrosoft;
if (Value.StartsWith("clr")) return AttributeLayout.XmlnsWithClr;
return AttributeLayout.Xmlns;
}
if (Prefix == "x") return AttributeLayout.X;
if (Prefix != null) return AttributeLayout.WithPrefix;
if (LocalName.Contains(".")) return AttributeLayout.Attached;
if (AttributeComparrer.SpecialOrder.Contains(LocalName)) return AttributeLayout.SpecialOrder;
return AttributeLayout.ByName;
}
}
class AttributeComparrer : IComparer<AttributeString>
{
public static AttributeComparrer Instance = new AttributeComparrer();
public int Compare(AttributeString a1, AttributeString a2)
{
var y1 = a1.GetAttributeLayout();
var y2 = a2.GetAttributeLayout();
if (y1 == y2) {
if (y1 == AttributeLayout.SpecialOrder) {
return
Array.IndexOf(SpecialOrder, a1.LocalName).CompareTo(
Array.IndexOf(SpecialOrder, a2.LocalName));
}
return a1.FinalName.CompareTo(a2.FinalName);
}
return y1.CompareTo(y2);
}
public static string[] SpecialOrder = new string[] {
"Name",
"Content",
"Command",
"Executed",
"CanExecute",
"Width",
"Height",
"Margin",
"HorizontalAlignment",
"VerticalAlignment",
"HorizontalContentAlignment",
"VerticalContentAlignment",
"StartPoint",
"EndPoint",
"Offset",
"Color"
};
}
}
}

6
samples/XamlDesigner/app.config

@ -1,6 +0,0 @@ @@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj

@ -109,6 +109,18 @@ @@ -109,6 +109,18 @@
<Name>ICSharpCode.NRefactory</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\WpfDesigner\WpfDesign.Designer\Project\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\WpfDesigner\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj">
<Project>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</Project>
<Name>WpfDesign.XamlDom</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Libraries\WpfDesigner\WpfDesign\Project\WpfDesign.csproj">
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
@ -134,21 +146,6 @@ @@ -134,21 +146,6 @@
<Name>ICSharpCode.SharpDevelop.Widgets</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\WpfDesign.Designer\Project\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj">
<Project>{88DA149F-21B2-48AB-82C4-28FB6BDFD783}</Project>
<Name>WpfDesign.XamlDom</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\WpfDesign\Project\WpfDesign.csproj">
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
<Private>False</Private>
</ProjectReference>
<Page Include="Src\ImageSourceEditor\ChooseImageDialog.xaml" />
<Page Include="Src\ImageSourceEditor\ImageSourceEditor.xaml" />
<Page Include="Src\ObjectEditor.xaml" />

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ArrangeDirection.cs

@ -1,18 +0,0 @@ @@ -1,18 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ICSharpCode.WpfDesign.Designer
{
public enum ArrangeDirection
{
Top,
VerticalMiddle,
Bottom,
Left,
HorizontalMiddle,
Right,
}
}

327
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/BasicMetadata.cs

@ -1,327 +0,0 @@ @@ -1,327 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Media;
using System.Windows;
using System.Windows.Input;
using System.Windows.Documents;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media.Imaging;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
using System.Windows.Media.Animation;
using System.Windows.Data;
using System.Windows.Automation;
using System.Windows.Media.Effects;
using System.Windows.Navigation;
namespace ICSharpCode.WpfDesign.Designer
{
public static class BasicMetadata
{
static bool registered;
public static void Register()
{
if (registered) return;
registered = true;
Metadata.AddStandardValues(typeof(Brush), typeof(Brushes));
Metadata.AddStandardValues(typeof(Color), typeof(Colors));
Metadata.AddStandardValues(typeof(FontStretch), typeof(FontStretches));
Metadata.AddStandardValues(typeof(FontWeight), typeof(FontWeights));
Metadata.AddStandardValues(typeof(FontStyle), typeof(FontStyles));
Metadata.AddStandardValues(typeof(Cursor), typeof(Cursors));
Metadata.AddStandardValues(typeof(PixelFormat), typeof(PixelFormats));
Metadata.AddStandardValues(typeof(TextDecorationCollection), typeof(TextDecorations));
Metadata.AddStandardValues(typeof(FontFamily), Fonts.SystemFontFamilies);
Metadata.AddStandardValues(typeof(ICommand), typeof(ApplicationCommands));
Metadata.AddStandardValues(typeof(ICommand), typeof(EditingCommands));
Metadata.AddStandardValues(typeof(ICommand), typeof(NavigationCommands));
Metadata.AddStandardValues(typeof(ICommand), typeof(ComponentCommands));
Metadata.AddStandardValues(typeof(ICommand), typeof(MediaCommands));
Metadata.AddPopularProperty(Line.Y2Property);
Metadata.AddPopularProperty(NavigationWindow.ShowsNavigationUIProperty);
Metadata.AddPopularProperty(FlowDocumentScrollViewer.DocumentProperty);
Metadata.AddPopularProperty(GridViewRowPresenterBase.ColumnsProperty);
Metadata.AddPopularProperty(ListView.ViewProperty);
Metadata.AddPopularProperty(DocumentPageView.PageNumberProperty);
Metadata.AddPopularProperty(Popup.PlacementProperty);
Metadata.AddPopularProperty(Popup.PopupAnimationProperty);
Metadata.AddPopularProperty(ScrollBar.ViewportSizeProperty);
Metadata.AddPopularProperty(UniformGrid.RowsProperty);
Metadata.AddPopularProperty(TabControl.TabStripPlacementProperty);
Metadata.AddPopularProperty(Line.X1Property);
Metadata.AddPopularProperty(Line.Y1Property);
Metadata.AddPopularProperty(Line.X2Property);
Metadata.AddPopularProperty(Polygon.PointsProperty);
Metadata.AddPopularProperty(Polyline.PointsProperty);
Metadata.AddPopularProperty(Path.DataProperty);
Metadata.AddPopularProperty(HeaderedContentControl.HeaderProperty);
Metadata.AddPopularProperty(MediaElement.UnloadedBehaviorProperty);
Metadata.AddPopularProperty(Shape.FillProperty);
Metadata.AddPopularProperty(Page.TitleProperty);
Metadata.AddPopularProperty(ItemsControl.ItemsSourceProperty);
Metadata.AddPopularProperty(Image.SourceProperty);
Metadata.AddPopularProperty(TextBlock.TextProperty);
Metadata.AddPopularProperty(DockPanel.LastChildFillProperty);
Metadata.AddPopularProperty(Expander.IsExpandedProperty);
Metadata.AddPopularProperty(Shape.StrokeProperty);
Metadata.AddPopularProperty(RangeBase.ValueProperty);
Metadata.AddPopularProperty(ItemsControl.ItemContainerStyleProperty);
Metadata.AddPopularProperty(ToggleButton.IsCheckedProperty);
Metadata.AddPopularProperty(Window.TitleProperty);
Metadata.AddPopularProperty(Viewport3DVisual.CameraProperty);
Metadata.AddPopularProperty(Frame.SourceProperty);
Metadata.AddPopularProperty(Rectangle.RadiusXProperty);
Metadata.AddPopularProperty(Rectangle.RadiusYProperty);
Metadata.AddPopularProperty(FrameworkElement.HeightProperty);
Metadata.AddPopularProperty(FrameworkElement.WidthProperty);
Metadata.AddPopularProperty(UniformGrid.ColumnsProperty);
Metadata.AddPopularProperty(RangeBase.MinimumProperty);
Metadata.AddPopularProperty(RangeBase.MaximumProperty);
Metadata.AddPopularProperty(ScrollBar.OrientationProperty);
Metadata.AddPopularProperty(ContentControl.ContentProperty);
Metadata.AddPopularProperty(Popup.IsOpenProperty);
Metadata.AddPopularProperty(TextElement.FontSizeProperty);
Metadata.AddPopularProperty(FrameworkElement.NameProperty);
Metadata.AddPopularProperty(Popup.HorizontalOffsetProperty);
Metadata.AddPopularProperty(Popup.VerticalOffsetProperty);
Metadata.AddPopularProperty(Window.WindowStyleProperty);
Metadata.AddPopularProperty(Shape.StrokeThicknessProperty);
Metadata.AddPopularProperty(TextElement.ForegroundProperty);
Metadata.AddPopularProperty(FrameworkElement.VerticalAlignmentProperty);
Metadata.AddPopularProperty(Button.IsDefaultProperty);
Metadata.AddPopularProperty(UIElement.RenderTransformOriginProperty);
Metadata.AddPopularProperty(TextElement.FontFamilyProperty);
Metadata.AddPopularProperty(FrameworkElement.HorizontalAlignmentProperty);
Metadata.AddPopularProperty(ToolBar.BandProperty);
Metadata.AddPopularProperty(ToolBar.BandIndexProperty);
Metadata.AddPopularProperty(ItemsControl.ItemTemplateProperty);
Metadata.AddPopularProperty(TextBlock.TextWrappingProperty);
Metadata.AddPopularProperty(FrameworkElement.MarginProperty);
Metadata.AddPopularProperty(RangeBase.LargeChangeProperty);
Metadata.AddPopularProperty(RangeBase.SmallChangeProperty);
Metadata.AddPopularProperty(Panel.BackgroundProperty);
Metadata.AddPopularProperty(Shape.StrokeMiterLimitProperty);
Metadata.AddPopularProperty(TextElement.FontWeightProperty);
Metadata.AddPopularProperty(StackPanel.OrientationProperty);
Metadata.AddPopularProperty(ListBox.SelectionModeProperty);
Metadata.AddPopularProperty(FrameworkElement.StyleProperty);
Metadata.AddPopularProperty(TextBox.TextProperty);
Metadata.AddPopularProperty(Window.SizeToContentProperty);
Metadata.AddPopularProperty(Window.ResizeModeProperty);
Metadata.AddPopularProperty(TextBlock.TextTrimmingProperty);
Metadata.AddPopularProperty(Window.ShowInTaskbarProperty);
Metadata.AddPopularProperty(Window.IconProperty);
Metadata.AddPopularProperty(UIElement.RenderTransformProperty);
Metadata.AddPopularProperty(Button.IsCancelProperty);
Metadata.AddPopularProperty(Border.BorderBrushProperty);
Metadata.AddPopularProperty(Block.TextAlignmentProperty);
Metadata.AddPopularProperty(Border.CornerRadiusProperty);
Metadata.AddPopularProperty(Border.BorderThicknessProperty);
Metadata.AddPopularProperty(TreeViewItem.IsSelectedProperty);
Metadata.AddPopularProperty(Border.PaddingProperty);
Metadata.AddPopularProperty(Shape.StretchProperty);
Metadata.AddPopularProperty(Control.VerticalContentAlignmentProperty);
Metadata.AddPopularProperty(Control.HorizontalContentAlignmentProperty);
Metadata.AddPopularProperty(Grid.RowProperty);
Metadata.AddPopularProperty(Grid.RowSpanProperty);
Metadata.AddPopularProperty(Grid.ColumnProperty);
Metadata.AddPopularProperty(Grid.ColumnSpanProperty);
Metadata.AddPopularProperty(DockPanel.DockProperty);
Metadata.AddPopularProperty(Canvas.LeftProperty);
Metadata.AddPopularProperty(Canvas.TopProperty);
Metadata.AddPopularProperty(Canvas.RightProperty);
Metadata.AddPopularProperty(Canvas.BottomProperty);
Metadata.AddPopularProperty(typeof(Binding), "Path");
Metadata.AddPopularProperty(typeof(Binding), "Source");
Metadata.AddPopularProperty(typeof(Binding), "Mode");
Metadata.AddPopularProperty(typeof(Binding), "RelativeSource");
Metadata.AddPopularProperty(typeof(Binding), "ElementName");
Metadata.AddPopularProperty(typeof(Binding), "Converter");
Metadata.AddPopularProperty(typeof(Binding), "XPath");
Metadata.AddPopularProperty(typeof(ItemsControl), "Items");
Metadata.AddValueRange(Block.LineHeightProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Canvas.BottomProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Canvas.LeftProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Canvas.TopProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Canvas.RightProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(ColumnDefinition.MaxWidthProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(DocumentViewer.MaxPagesAcrossProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Figure.HorizontalOffsetProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Figure.VerticalOffsetProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(FlowDocument.MaxPageWidthProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(FlowDocument.MaxPageHeightProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(FlowDocumentPageViewer.ZoomProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(FlowDocumentPageViewer.ZoomIncrementProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(FlowDocumentPageViewer.MinZoomProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(FlowDocumentPageViewer.MaxZoomProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(FrameworkElement.MaxHeightProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(FrameworkElement.MaxWidthProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(Grid.ColumnSpanProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Grid.RowSpanProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(GridSplitter.KeyboardIncrementProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(GridSplitter.DragIncrementProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(InkCanvas.BottomProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(InkCanvas.TopProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(InkCanvas.RightProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(InkCanvas.LeftProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Line.Y2Property, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Line.X1Property, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Line.Y1Property, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Line.X2Property, double.MinValue, double.MaxValue);
Metadata.AddValueRange(List.MarkerOffsetProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(List.StartIndexProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Paragraph.TextIndentProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(RangeBase.ValueProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(RangeBase.MaximumProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(RangeBase.MinimumProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(RepeatButton.IntervalProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(RowDefinition.MaxHeightProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(Selector.SelectedIndexProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Slider.TickFrequencyProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Slider.SelectionStartProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(Slider.SelectionEndProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(TableCell.RowSpanProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(TableCell.ColumnSpanProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(TextBox.MinLinesProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(TextBox.MaxLinesProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(TextBoxBase.UndoLimitProperty, double.MinValue, double.MaxValue);
Metadata.AddValueRange(TextElement.FontSizeProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Timeline.SpeedRatioProperty, double.Epsilon, double.MaxValue);
Metadata.AddValueRange(Timeline.DecelerationRatioProperty, 0, 1);
Metadata.AddValueRange(Timeline.AccelerationRatioProperty, 0, 1);
Metadata.AddValueRange(Track.ViewportSizeProperty, 0, double.PositiveInfinity);
Metadata.AddValueRange(UIElement.OpacityProperty, 0, 1);
Metadata.HideProperty(typeof(UIElement), "RenderSize");
Metadata.HideProperty(FrameworkElement.NameProperty);
//Metadata.HideProperty(typeof(FrameworkElement), "Resources");
Metadata.HideProperty(typeof(Window), "Owner");
//Metadata.DisablePlacement(typeof(Button));
Metadata.AddPopularControl(typeof(Button));
Metadata.AddPopularControl(typeof(Border));
Metadata.AddPopularControl(typeof(Canvas));
Metadata.AddPopularControl(typeof(CheckBox));
Metadata.AddPopularControl(typeof(ComboBox));
Metadata.AddPopularControl(typeof(DataGrid));
Metadata.AddPopularControl(typeof(DockPanel));
Metadata.AddPopularControl(typeof(Expander));
Metadata.AddPopularControl(typeof(Grid));
Metadata.AddPopularControl(typeof(GroupBox));
Metadata.AddPopularControl(typeof(Image));
Metadata.AddPopularControl(typeof(InkCanvas));
Metadata.AddPopularControl(typeof(Label));
Metadata.AddPopularControl(typeof(ListBox));
Metadata.AddPopularControl(typeof(ListView));
Metadata.AddPopularControl(typeof(MediaElement));
Metadata.AddPopularControl(typeof(Menu));
Metadata.AddPopularControl(typeof(PasswordBox));
Metadata.AddPopularControl(typeof(ProgressBar));
Metadata.AddPopularControl(typeof(RadioButton));
Metadata.AddPopularControl(typeof(RichTextBox));
Metadata.AddPopularControl(typeof(StackPanel));
Metadata.AddPopularControl(typeof(ScrollViewer));
Metadata.AddPopularControl(typeof(Slider));
Metadata.AddPopularControl(typeof(TabControl));
Metadata.AddPopularControl(typeof(TextBlock));
Metadata.AddPopularControl(typeof(TextBox));
Metadata.AddPopularControl(typeof(TreeView));
Metadata.AddPopularControl(typeof(ToolBar));
Metadata.AddPopularControl(typeof(Viewbox));
Metadata.AddPopularControl(typeof(Viewport3D));
Metadata.AddPopularControl(typeof(WrapPanel));
Metadata.AddPopularControl(typeof(Line));
Metadata.AddPopularControl(typeof(Polyline));
Metadata.AddPopularControl(typeof(Ellipse));
Metadata.AddPopularControl(typeof(Rectangle));
Metadata.AddPopularControl(typeof(Path));
//Basic Metadata Size of double.NaN, means no Size should be set.
Metadata.AddDefaultSize(typeof(TextBlock), new Size(double.NaN, double.NaN));
Metadata.AddDefaultSize(typeof(CheckBox), new Size(double.NaN, double.NaN));
Metadata.AddDefaultSize(typeof(Image), new Size(double.NaN, double.NaN));
Metadata.AddDefaultSize(typeof(UIElement), new Size(120, 100));
Metadata.AddDefaultSize(typeof(ContentControl), new Size(120, 20));
Metadata.AddDefaultSize(typeof(Button), new Size(75, 23));
Metadata.AddDefaultSize(typeof(ToggleButton), new Size(75, 23));
Metadata.AddDefaultSize(typeof(Slider), new Size(120, 20));
Metadata.AddDefaultSize(typeof(TextBox), new Size(120, 20));
Metadata.AddDefaultSize(typeof(PasswordBox), new Size(120, 20));
Metadata.AddDefaultSize(typeof(ComboBox), new Size(120, 20));
Metadata.AddDefaultSize(typeof(ProgressBar), new Size(120, 20));
Metadata.AddDefaultSize(typeof(ToolBar), new Size(120, 20));
Metadata.AddDefaultSize(typeof(Menu), new Size(120, 20));
Metadata.AddDefaultSize(typeof(InkCanvas), new Size(120, 120));
Metadata.AddDefaultSize(typeof(TreeView), new Size(120, 120));
Metadata.AddDefaultSize(typeof(Label), new Size(130, 120));
Metadata.AddDefaultSize(typeof(Expander), new Size(130, 120));
Metadata.AddDefaultPropertyValue(typeof(Line), Line.X1Property, 0.0);
Metadata.AddDefaultPropertyValue(typeof(Line), Line.Y1Property, 0.0);
Metadata.AddDefaultPropertyValue(typeof(Line), Line.X2Property, 20.0);
Metadata.AddDefaultPropertyValue(typeof(Line), Line.Y2Property, 20.0);
Metadata.AddDefaultPropertyValue(typeof(Line), Line.StrokeProperty, Brushes.Black);
Metadata.AddDefaultPropertyValue(typeof(Line), Line.StrokeThicknessProperty, 2d);
Metadata.AddDefaultPropertyValue(typeof(Line), Line.StretchProperty, Stretch.None);
Metadata.AddDefaultPropertyValue(typeof(Polyline), Polyline.PointsProperty, new PointCollection() { new Point(0, 0), new Point(20, 0), new Point(20, 20) });
Metadata.AddDefaultPropertyValue(typeof(Polyline), Polyline.StrokeProperty, Brushes.Black);
Metadata.AddDefaultPropertyValue(typeof(Polyline), Polyline.StrokeThicknessProperty, 2d);
Metadata.AddDefaultPropertyValue(typeof(Polyline), Polyline.StretchProperty, Stretch.None);
Metadata.AddDefaultPropertyValue(typeof(Polygon), Polygon.PointsProperty, new PointCollection() { new Point(0, 20), new Point(20, 20), new Point(10, 0) });
Metadata.AddDefaultPropertyValue(typeof(Polygon), Polygon.StrokeProperty, Brushes.Black);
Metadata.AddDefaultPropertyValue(typeof(Polygon), Polygon.StrokeThicknessProperty, 2d);
Metadata.AddDefaultPropertyValue(typeof(Polygon), Polygon.StretchProperty, Stretch.None);
Metadata.AddDefaultPropertyValue(typeof(Path), Path.StrokeProperty, Brushes.Black);
Metadata.AddDefaultPropertyValue(typeof(Path), Path.StrokeThicknessProperty, 2d);
Metadata.AddDefaultPropertyValue(typeof(Path), Path.StretchProperty, Stretch.None);
Metadata.AddDefaultPropertyValue(typeof(Rectangle), Rectangle.FillProperty, Brushes.Transparent);
Metadata.AddDefaultPropertyValue(typeof(Rectangle), Rectangle.StrokeProperty, Brushes.Black);
Metadata.AddDefaultPropertyValue(typeof(Rectangle), Rectangle.StrokeThicknessProperty, 2d);
Metadata.AddDefaultPropertyValue(typeof(Ellipse), Ellipse.FillProperty, Brushes.Transparent);
Metadata.AddDefaultPropertyValue(typeof(Ellipse), Ellipse.StrokeProperty, Brushes.Black);
Metadata.AddDefaultPropertyValue(typeof(Ellipse), Ellipse.StrokeThicknessProperty, 2d);
}
}
}

127
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/CallExtension.cs

@ -1,127 +0,0 @@ @@ -1,127 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;
using System.Windows;
using System.Windows.Data;
using System.Windows.Input;
using System.Reflection;
namespace ICSharpCode.WpfDesign.Designer
{
public class CallExtension : MarkupExtension
{
public CallExtension(string methodName)
{
this.methodName = methodName;
}
string methodName;
public override object ProvideValue(IServiceProvider serviceProvider)
{
var t = (IProvideValueTarget)serviceProvider.GetService(typeof(IProvideValueTarget));
return new CallCommand(t.TargetObject as FrameworkElement, methodName);
}
}
public class CallCommand : DependencyObject, ICommand
{
public CallCommand(FrameworkElement element, string methodName)
{
this.element = element;
this.methodName = methodName;
element.DataContextChanged += target_DataContextChanged;
BindingOperations.SetBinding(this, CanCallProperty, new Binding("DataContext.Can" + methodName) {
Source = element
});
GetMethod();
}
FrameworkElement element;
string methodName;
MethodInfo method;
public static readonly DependencyProperty CanCallProperty =
DependencyProperty.Register("CanCall", typeof(bool), typeof(CallCommand),
new PropertyMetadata(true));
public bool CanCall {
get { return (bool)GetValue(CanCallProperty); }
set { SetValue(CanCallProperty, value); }
}
public object DataContext {
get { return element.DataContext; }
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == CanCallProperty) {
RaiseCanExecuteChanged();
}
}
void GetMethod()
{
if (DataContext == null) {
method = null;
}
else {
method = DataContext.GetType().GetMethod(methodName, Type.EmptyTypes);
}
}
void target_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
{
GetMethod();
RaiseCanExecuteChanged();
}
void RaiseCanExecuteChanged()
{
if (CanExecuteChanged != null) {
CanExecuteChanged(this, EventArgs.Empty);
}
}
#region ICommand Members
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
return method != null && CanCall;
}
public void Execute(object parameter)
{
method.Invoke(DataContext, null);
}
#endregion
}
}

42
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Commands.cs

@ -1,42 +0,0 @@ @@ -1,42 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.Designer
{
/// <summary>
/// Description of Commands.
/// </summary>
public static class Commands
{
public static ICommand AlignTopCommand = new RoutedCommand();
public static ICommand AlignMiddleCommand = new RoutedCommand();
public static ICommand AlignBottomCommand = new RoutedCommand();
public static ICommand AlignLeftCommand = new RoutedCommand();
public static ICommand AlignCenterCommand = new RoutedCommand();
public static ICommand AlignRightCommand = new RoutedCommand();
public static ICommand RotateLeftCommand = new RoutedCommand();
public static ICommand RotateRightCommand = new RoutedCommand();
static Commands()
{
}
}
}

68
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/AssemblyInfo.cs

@ -1,68 +0,0 @@ @@ -1,68 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
#region Using directives
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Resources;
using System.Globalization;
using System.Windows;
using System.Runtime.InteropServices;
using ICSharpCode.WpfDesign.Extensions;
using System.Windows.Markup;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WpfDesign.Designer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: CLSCompliant(true)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
[assembly: XmlnsPrefix("http://sharpdevelop.net", "sd")]
[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer")]
[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.Controls")]
[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.PropertyGrid")]
[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors")]
[assembly: XmlnsDefinition("http://sharpdevelop.net", "ICSharpCode.WpfDesign.Designer.ThumbnailView")]

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Configuration/CodeAnalysisDictionary.xml

@ -1,24 +0,0 @@ @@ -1,24 +0,0 @@
<?xml version="1.0"?>
<Dictionary>
<Words>
<Recognized>
<!-- add words specific to your application here -->
<Word>Headered</Word> <!-- HeaderedContentControl -->
<Word>Snapline</Word>
</Recognized>
<Unrecognized>
<!-- Disable Lineup as a single word - LineUp is the spelling used in WPF -->
<Word>Lineup</Word>
</Unrecognized>
<Deprecated>
<!-- Use this section to deprecate terms -->
<Term PreferredAlternate="Best">Bestest</Term>
</Deprecated>
</Words>
<Acronyms>
<CasingExceptions>
<!-- Use this section to tell FxCop the correct casing of acronyms. -->
<Acronym>WiX</Acronym>
</CasingExceptions>
</Acronyms>
</Dictionary>

336
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/AdornerLayer.cs

@ -1,336 +0,0 @@ @@ -1,336 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//#define DEBUG_ADORNERLAYER
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using ICSharpCode.WpfDesign.Adorners;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A control that displays adorner panels.
/// </summary>
public sealed class AdornerLayer : Panel
{
#region AdornerPanelCollection
internal sealed class AdornerPanelCollection : ICollection<AdornerPanel>, IReadOnlyCollection<AdornerPanel>
{
readonly AdornerLayer _layer;
public AdornerPanelCollection(AdornerLayer layer)
{
this._layer = layer;
}
public int Count {
get { return _layer.Children.Count; }
}
public bool IsReadOnly {
get { return false; }
}
public void Add(AdornerPanel item)
{
if (item == null)
throw new ArgumentNullException("item");
_layer.AddAdorner(item);
}
public void Clear()
{
_layer.ClearAdorners();
}
public bool Contains(AdornerPanel item)
{
if (item == null)
throw new ArgumentNullException("item");
return VisualTreeHelper.GetParent(item) == _layer;
}
public void CopyTo(AdornerPanel[] array, int arrayIndex)
{
foreach (AdornerPanel panel in this)
array[arrayIndex++] = panel;
}
public bool Remove(AdornerPanel item)
{
if (item == null)
throw new ArgumentNullException("item");
return _layer.RemoveAdorner(item);
}
public IEnumerator<AdornerPanel> GetEnumerator()
{
foreach (AdornerPanel panel in _layer.Children) {
yield return panel;
}
}
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
#endregion
AdornerPanelCollection _adorners;
readonly UIElement _designPanel;
#if DEBUG_ADORNERLAYER
int _totalAdornerCount;
#endif
internal AdornerLayer(UIElement designPanel)
{
this._designPanel = designPanel;
this.LayoutUpdated += OnLayoutUpdated;
_adorners = new AdornerPanelCollection(this);
}
void OnLayoutUpdated(object sender, EventArgs e)
{
UpdateAllAdorners(false);
#if DEBUG_ADORNERLAYER
Debug.WriteLine("Adorner LayoutUpdated. AdornedElements=" + _dict.Count +
", visible adorners=" + VisualChildrenCount + ", total adorners=" + (_totalAdornerCount));
#endif
}
protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
{
base.OnRenderSizeChanged(sizeInfo);
UpdateAllAdorners(true);
}
internal AdornerPanelCollection Adorners {
get {
return _adorners;
}
}
sealed class AdornerInfo
{
internal readonly List<AdornerPanel> adorners = new List<AdornerPanel>();
internal bool isVisible;
internal Rect position;
}
// adorned element => AdornerInfo
Dictionary<UIElement, AdornerInfo> _dict = new Dictionary<UIElement, AdornerInfo>();
void ClearAdorners()
{
if (_dict.Count == 0)
return; // already empty
this.Children.Clear();
_dict = new Dictionary<UIElement, AdornerInfo>();
#if DEBUG_ADORNERLAYER
_totalAdornerCount = 0;
Debug.WriteLine("AdornerLayer cleared.");
#endif
}
AdornerInfo GetOrCreateAdornerInfo(UIElement adornedElement)
{
AdornerInfo info;
if (!_dict.TryGetValue(adornedElement, out info)) {
info = _dict[adornedElement] = new AdornerInfo();
info.isVisible = adornedElement.IsDescendantOf(_designPanel);
}
return info;
}
AdornerInfo GetExistingAdornerInfo(UIElement adornedElement)
{
AdornerInfo info;
_dict.TryGetValue(adornedElement, out info);
return info;
}
void AddAdorner(AdornerPanel adornerPanel)
{
if (adornerPanel.AdornedElement == null)
throw new DesignerException("adornerPanel.AdornedElement must be set");
AdornerInfo info = GetOrCreateAdornerInfo(adornerPanel.AdornedElement);
info.adorners.Add(adornerPanel);
if (info.isVisible) {
AddAdornerToChildren(adornerPanel);
}
#if DEBUG_ADORNERLAYER
Debug.WriteLine("Adorner added. AdornedElements=" + _dict.Count +
", visible adorners=" + VisualChildrenCount + ", total adorners=" + (++_totalAdornerCount));
#endif
}
void AddAdornerToChildren(AdornerPanel adornerPanel)
{
UIElementCollection children = this.Children;
int i = 0;
for (i = 0; i < children.Count; i++) {
AdornerPanel p = (AdornerPanel)children[i];
if (p.Order > adornerPanel.Order) {
break;
}
}
children.Insert(i, adornerPanel);
}
protected override Size MeasureOverride(Size availableSize)
{
Size infiniteSize = new Size(double.PositiveInfinity, double.PositiveInfinity);
foreach (AdornerPanel adorner in this.Children) {
adorner.Measure(infiniteSize);
}
return new Size(0, 0);
}
protected override Size ArrangeOverride(Size finalSize)
{
foreach (AdornerPanel adorner in this.Children) {
if (adorner.AdornedElement.IsDescendantOf(_designPanel))
{
var transform = adorner.AdornedElement.TransformToAncestor(_designPanel);
var rt = transform as MatrixTransform;
if (rt != null && adorner.AdornedDesignItem != null && adorner.AdornedDesignItem.Parent != null && adorner.AdornedDesignItem.Parent.View is Canvas && adorner.AdornedElement.RenderSize.Height == 0 && adorner.AdornedElement.RenderSize.Width == 0)
{
var width = ((FrameworkElement) adorner.AdornedElement).Width;
width = width > 0 ? width : 2.0;
var height = ((FrameworkElement)adorner.AdornedElement).Height;
height = height > 0 ? height : 2.0;
var xOffset = rt.Matrix.OffsetX - (width / 2);
var yOffset = rt.Matrix.OffsetY - (height / 2);
rt = new MatrixTransform(new Matrix(rt.Matrix.M11, rt.Matrix.M12, rt.Matrix.M21, rt.Matrix.M22, xOffset, yOffset));
}
else if (transform is GeneralTransformGroup)
{
//var intTrans = ((GeneralTransformGroup) transform).Children.FirstOrDefault(x => x.GetType().Name == "GeneralTransform2DTo3DTo2D");
//var prp = intTrans.GetType().GetField("_worldTransformation", BindingFlags.Instance | BindingFlags.NonPublic);
//var mtx = (Matrix3D) prp.GetValue(intTrans);
//var mtx2D = new Matrix(mtx.M11, mtx.M12, mtx.M21, mtx.M22, mtx.OffsetX, mtx.OffsetY);
//rt = new MatrixTransform(mtx2D);
rt = ((GeneralTransformGroup)transform).Children.OfType<MatrixTransform>().LastOrDefault();
}
adorner.RenderTransform = rt;
}
adorner.Arrange(new Rect(new Point(0, 0), adorner.DesiredSize));
}
return finalSize;
}
bool RemoveAdorner(AdornerPanel adornerPanel)
{
if (adornerPanel.AdornedElement == null)
return false;
AdornerInfo info = GetExistingAdornerInfo(adornerPanel.AdornedElement);
if (info == null)
return false;
if (info.adorners.Remove(adornerPanel)) {
if (info.isVisible) {
this.Children.Remove(adornerPanel);
}
if (info.adorners.Count == 0) {
_dict.Remove(adornerPanel.AdornedElement);
}
#if DEBUG_ADORNERLAYER
Debug.WriteLine("Adorner removed. AdornedElements=" + _dict.Count +
", visible adorners=" + VisualChildrenCount + ", total adorners=" + (--_totalAdornerCount));
#endif
return true;
} else {
return false;
}
}
public void UpdateAdornersForElement(UIElement element, bool forceInvalidate)
{
AdornerInfo info = GetExistingAdornerInfo(element);
if (info != null) {
UpdateAdornersForElement(element, info, forceInvalidate);
}
}
Rect GetPositionCache(UIElement element)
{
var t = element.TransformToAncestor(_designPanel);
var p = t.Transform(new Point(0, 0));
return new Rect(p, element.RenderSize);
}
void UpdateAdornersForElement(UIElement element, AdornerInfo info, bool forceInvalidate)
{
if (element.IsDescendantOf(_designPanel)) {
if (!info.isVisible) {
info.isVisible = true;
// make adorners visible:
info.adorners.ForEach(AddAdornerToChildren);
}
Rect c = GetPositionCache(element);
if (forceInvalidate || !info.position.Equals(c)) {
info.position = c;
foreach (AdornerPanel p in info.adorners) {
p.InvalidateMeasure();
}
this.InvalidateArrange();
}
} else {
if (info.isVisible) {
info.isVisible = false;
// make adorners invisible:
info.adorners.ForEach(this.Children.Remove);
}
}
}
void UpdateAllAdorners(bool forceInvalidate)
{
foreach (KeyValuePair<UIElement, AdornerInfo> pair in _dict) {
UpdateAdornersForElement(pair.Key, pair.Value, forceInvalidate);
}
}
}
}

233
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/CanvasPositionHandle.cs

@ -1,233 +0,0 @@ @@ -1,233 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Input;
using System.Globalization;
using System.ComponentModel;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Media3D;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Adorners;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Adorner that displays the margin of a control in a Grid.
/// </summary>
public class CanvasPositionHandle : MarginHandle
{
static CanvasPositionHandle()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CanvasPositionHandle), new FrameworkPropertyMetadata(typeof(CanvasPositionHandle)));
HandleLengthOffset=2;
}
private Path line1;
private Path line2;
public override void OnApplyTemplate()
{
line1 = GetTemplateChild("line1") as Path;
line2 = GetTemplateChild("line2") as Path;
base.OnApplyTemplate();
}
readonly Canvas canvas;
readonly DesignItem adornedControlItem;
readonly AdornerPanel adornerPanel;
readonly HandleOrientation orientation;
readonly FrameworkElement adornedControl;
/// <summary> This grid contains the handle line and the endarrow.</summary>
// Grid lineArrow;
private DependencyPropertyDescriptor leftDescriptor;
private DependencyPropertyDescriptor rightDescriptor;
private DependencyPropertyDescriptor topDescriptor;
private DependencyPropertyDescriptor bottomDescriptor;
private DependencyPropertyDescriptor widthDescriptor;
private DependencyPropertyDescriptor heightDescriptor;
public CanvasPositionHandle(DesignItem adornedControlItem, AdornerPanel adornerPanel, HandleOrientation orientation)
{
Debug.Assert(adornedControlItem != null);
this.adornedControlItem = adornedControlItem;
this.adornerPanel = adornerPanel;
this.orientation = orientation;
Angle = (double) orientation;
canvas = (Canvas) adornedControlItem.Parent.Component;
adornedControl = (FrameworkElement) adornedControlItem.Component;
Stub = new MarginStub(this);
ShouldBeVisible = true;
leftDescriptor = DependencyPropertyDescriptor.FromProperty(Canvas.LeftProperty,
adornedControlItem.Component.GetType());
leftDescriptor.AddValueChanged(adornedControl, OnPropertyChanged);
rightDescriptor = DependencyPropertyDescriptor.FromProperty(Canvas.RightProperty,
adornedControlItem.Component.GetType());
rightDescriptor.AddValueChanged(adornedControl, OnPropertyChanged);
topDescriptor = DependencyPropertyDescriptor.FromProperty(Canvas.TopProperty,
adornedControlItem.Component.GetType());
topDescriptor.AddValueChanged(adornedControl, OnPropertyChanged);
bottomDescriptor = DependencyPropertyDescriptor.FromProperty(Canvas.BottomProperty,
adornedControlItem.Component.GetType());
bottomDescriptor.AddValueChanged(adornedControl, OnPropertyChanged);
widthDescriptor = DependencyPropertyDescriptor.FromProperty(Control.WidthProperty,
adornedControlItem.Component.GetType());
widthDescriptor.AddValueChanged(adornedControl, OnPropertyChanged);
heightDescriptor = DependencyPropertyDescriptor.FromProperty(Control.WidthProperty,
adornedControlItem.Component.GetType());
heightDescriptor.AddValueChanged(adornedControl, OnPropertyChanged);
BindAndPlaceHandle();
}
void OnPropertyChanged(object sender, EventArgs e)
{
BindAndPlaceHandle();
}
/// <summary>
/// Gets/Sets the angle by which the Canvas display has to be rotated
/// </summary>
public override double TextTransform
{
get
{
if ((double)orientation == 90 || (double)orientation == 180)
return 180;
if ((double)orientation == 270)
return 0;
return (double)orientation;
}
set { }
}
/// <summary>
/// Binds the <see cref="MarginHandle.HandleLength"/> to the margin and place the handles.
/// </summary>
void BindAndPlaceHandle()
{
if (!adornerPanel.Children.Contains(this))
adornerPanel.Children.Add(this);
if (!adornerPanel.Children.Contains(Stub))
adornerPanel.Children.Add(Stub);
RelativePlacement placement=new RelativePlacement();
switch (orientation)
{
case HandleOrientation.Left:
{
var wr = (double) leftDescriptor.GetValue(adornedControl);
if (double.IsNaN(wr))
{
wr = (double) rightDescriptor.GetValue(adornedControl);
wr = canvas.ActualWidth - (PlacementOperation.GetRealElementSize(adornedControl).Width + wr);
}
else
{
if (line1 != null)
{
line1.StrokeDashArray.Clear();
line2.StrokeDashArray.Clear();
}
}
this.HandleLength = wr;
placement = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Center);
placement.XOffset = -HandleLengthOffset;
break;
}
case HandleOrientation.Top:
{
var wr = (double)topDescriptor.GetValue(adornedControl);
if (double.IsNaN(wr))
{
wr = (double)bottomDescriptor.GetValue(adornedControl);
wr = canvas.ActualHeight - (PlacementOperation.GetRealElementSize(adornedControl).Height + wr);
}
else
{
if (line1 != null)
{
line1.StrokeDashArray.Clear();
line2.StrokeDashArray.Clear();
}
}
this.HandleLength = wr;
placement = new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Top);
placement.YOffset = -HandleLengthOffset;
break;
}
case HandleOrientation.Right:
{
var wr = (double) rightDescriptor.GetValue(adornedControl);
if (double.IsNaN(wr))
{
wr = (double) leftDescriptor.GetValue(adornedControl);
wr = canvas.ActualWidth - (PlacementOperation.GetRealElementSize(adornedControl).Width + wr);
}
else
{
if (line1 != null)
{
line1.StrokeDashArray.Clear();
line2.StrokeDashArray.Clear();
}
}
this.HandleLength = wr;
placement = new RelativePlacement(HorizontalAlignment.Right, VerticalAlignment.Center);
placement.XOffset = HandleLengthOffset;
break;
}
case HandleOrientation.Bottom:
{
var wr = (double)bottomDescriptor.GetValue(adornedControl);
if (double.IsNaN(wr))
{
wr = (double)topDescriptor.GetValue(adornedControl);
wr = canvas.ActualHeight - (PlacementOperation.GetRealElementSize(adornedControl).Height + wr);
}
else
{
if (line1 != null)
{
line1.StrokeDashArray.Clear();
line2.StrokeDashArray.Clear();
}
}
this.HandleLength = wr;
placement = new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Bottom);
placement.YOffset = HandleLengthOffset;
break;
}
}
AdornerPanel.SetPlacement(this, placement);
this.Visibility = Visibility.Visible;
}
}
}

100
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ClearableTextBox.cs

@ -1,100 +0,0 @@ @@ -1,100 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Data;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class ClearableTextBox : EnterTextBox
{
private Button textRemoverButton;
static ClearableTextBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof (ClearableTextBox),
new FrameworkPropertyMetadata(typeof (ClearableTextBox)));
}
public ClearableTextBox()
{
this.GotFocus += this.TextBoxGotFocus;
this.LostFocus += this.TextBoxLostFocus;
this.TextChanged += this.TextBoxTextChanged;
this.KeyUp += this.ClearableTextBox_KeyUp;
}
void ClearableTextBox_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Escape)
this.TextRemoverClick(sender, null);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
this.textRemoverButton = this.GetTemplateChild("TextRemover") as Button;
if (null != this.textRemoverButton)
{
this.textRemoverButton.Click += this.TextRemoverClick;
}
this.UpdateState();
}
protected void UpdateState()
{
if (string.IsNullOrEmpty(this.Text))
{
VisualStateManager.GoToState(this, "TextRemoverHidden", true);
}
else
{
VisualStateManager.GoToState(this, "TextRemoverVisible", true);
}
}
private void TextBoxTextChanged(object sender, TextChangedEventArgs e)
{
this.UpdateState();
}
private void TextRemoverClick(object sender, RoutedEventArgs e)
{
this.Text = string.Empty;
this.Focus();
}
private void TextBoxGotFocus(object sender, RoutedEventArgs e)
{
this.UpdateState();
}
private void TextBoxLostFocus(object sender, RoutedEventArgs e)
{
this.UpdateState();
}
}
}

198
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/CollapsiblePanel.cs

@ -1,198 +0,0 @@ @@ -1,198 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media.Animation;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Allows animated collapsing of the content of this panel.
/// </summary>
public class CollapsiblePanel : ContentControl
{
static CollapsiblePanel()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(typeof(CollapsiblePanel)));
FocusableProperty.OverrideMetadata(typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(false));
}
public static readonly DependencyProperty IsCollapsedProperty = DependencyProperty.Register(
"IsCollapsed", typeof(bool), typeof(CollapsiblePanel),
new UIPropertyMetadata(false, new PropertyChangedCallback(OnIsCollapsedChanged)));
public bool IsCollapsed {
get { return (bool)GetValue(IsCollapsedProperty); }
set { SetValue(IsCollapsedProperty, value); }
}
public static readonly DependencyProperty CollapseOrientationProperty =
DependencyProperty.Register("CollapseOrientation", typeof(Orientation), typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(Orientation.Vertical));
public Orientation CollapseOrientation {
get { return (Orientation)GetValue(CollapseOrientationProperty); }
set { SetValue(CollapseOrientationProperty, value); }
}
public static readonly DependencyProperty DurationProperty = DependencyProperty.Register(
"Duration", typeof(TimeSpan), typeof(CollapsiblePanel),
new UIPropertyMetadata(TimeSpan.FromMilliseconds(250)));
/// <summary>
/// The duration in milliseconds of the animation.
/// </summary>
public TimeSpan Duration {
get { return (TimeSpan)GetValue(DurationProperty); }
set { SetValue(DurationProperty, value); }
}
protected internal static readonly DependencyProperty AnimationProgressProperty = DependencyProperty.Register(
"AnimationProgress", typeof(double), typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(1.0));
/// <summary>
/// Value between 0 and 1 specifying how far the animation currently is.
/// </summary>
protected internal double AnimationProgress {
get { return (double)GetValue(AnimationProgressProperty); }
set { SetValue(AnimationProgressProperty, value); }
}
protected internal static readonly DependencyProperty AnimationProgressXProperty = DependencyProperty.Register(
"AnimationProgressX", typeof(double), typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(1.0));
/// <summary>
/// Value between 0 and 1 specifying how far the animation currently is.
/// </summary>
protected internal double AnimationProgressX {
get { return (double)GetValue(AnimationProgressXProperty); }
set { SetValue(AnimationProgressXProperty, value); }
}
protected internal static readonly DependencyProperty AnimationProgressYProperty = DependencyProperty.Register(
"AnimationProgressY", typeof(double), typeof(CollapsiblePanel),
new FrameworkPropertyMetadata(1.0));
/// <summary>
/// Value between 0 and 1 specifying how far the animation currently is.
/// </summary>
protected internal double AnimationProgressY {
get { return (double)GetValue(AnimationProgressYProperty); }
set { SetValue(AnimationProgressYProperty, value); }
}
static void OnIsCollapsedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
((CollapsiblePanel)d).SetupAnimation((bool)e.NewValue);
}
void SetupAnimation(bool isCollapsed)
{
if (this.IsLoaded) {
// If the animation is already running, calculate remaining portion of the time
double currentProgress = AnimationProgress;
if (!isCollapsed) {
currentProgress = 1.0 - currentProgress;
}
DoubleAnimation animation = new DoubleAnimation();
animation.To = isCollapsed ? 0.0 : 1.0;
animation.Duration = TimeSpan.FromSeconds(Duration.TotalSeconds * currentProgress);
animation.FillBehavior = FillBehavior.HoldEnd;
this.BeginAnimation(AnimationProgressProperty, animation);
if (CollapseOrientation == Orientation.Horizontal) {
this.BeginAnimation(AnimationProgressXProperty, animation);
this.AnimationProgressY = 1.0;
} else {
this.AnimationProgressX = 1.0;
this.BeginAnimation(AnimationProgressYProperty, animation);
}
} else {
this.AnimationProgress = isCollapsed ? 0.0 : 1.0;
this.AnimationProgressX = (CollapseOrientation == Orientation.Horizontal) ? this.AnimationProgress : 1.0;
this.AnimationProgressY = (CollapseOrientation == Orientation.Vertical) ? this.AnimationProgress : 1.0;
}
}
}
sealed class CollapsiblePanelProgressToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is double)
return (double)value > 0 ? Visibility.Visible : Visibility.Collapsed;
else
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class SelfCollapsingPanel : CollapsiblePanel
{
public static readonly DependencyProperty CanCollapseProperty =
DependencyProperty.Register("CanCollapse", typeof(bool), typeof(SelfCollapsingPanel),
new FrameworkPropertyMetadata(false, new PropertyChangedCallback(OnCanCollapseChanged)));
public bool CanCollapse {
get { return (bool)GetValue(CanCollapseProperty); }
set { SetValue(CanCollapseProperty, value); }
}
static void OnCanCollapseChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
SelfCollapsingPanel panel = (SelfCollapsingPanel)d;
if ((bool)e.NewValue) {
if (!panel.HeldOpenByMouse)
panel.IsCollapsed = true;
} else {
panel.IsCollapsed = false;
}
}
bool HeldOpenByMouse {
get { return IsMouseOver || IsMouseCaptureWithin; }
}
protected override void OnMouseLeave(MouseEventArgs e)
{
base.OnMouseLeave(e);
if (CanCollapse && !HeldOpenByMouse)
IsCollapsed = true;
}
protected override void OnLostMouseCapture(MouseEventArgs e)
{
base.OnLostMouseCapture(e);
if (CanCollapse && !HeldOpenByMouse)
IsCollapsed = true;
}
}
}

110
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ColorHelper.cs

@ -1,110 +0,0 @@ @@ -1,110 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public static class ColorHelper
{
public static Color ColorFromString(string s)
{
if (string.IsNullOrEmpty(s)) {
return Colors.White;
}
if (s[0] != '#') s = "#" + s;
try {
return (Color)ColorConverter.ConvertFromString(s);
}
catch {
return Colors.White;
}
}
public static string StringFromColor(Color c)
{
return c.ToString().Substring(1);
}
public static Color ColorFromHsv(double h, double s, double v)
{
double r, g, b;
RgbFromHsv(h, s, v, out r, out g, out b);
return Color.FromRgb((byte)(r * 255), (byte)(g * 255), (byte)(b * 255));
}
public static void HsvFromColor(Color c, out double h, out double s, out double v)
{
HsvFromRgb(c.R / 255.0, c.G / 255.0, c.B / 255.0, out h, out s, out v);
}
// http://en.wikipedia.org/wiki/HSV_color_space
public static void HsvFromRgb(double r, double g, double b, out double h, out double s, out double v)
{
var max = Math.Max(r, Math.Max(g, b));
var min = Math.Min(r, Math.Min(g, b));
if (max == min) {
h = 0;
}
else if (max == r) {
h = (60 * (g - b) / (max - min)) % 360;
}
else if (max == g) {
h = 60 * (b - r) / (max - min) + 120;
}
else {
h = 60 * (r - g) / (max - min) + 240;
}
if (h < 0) h += 360; // C# '%' can return negative values, use real modulus instead
if (max == 0) {
s = 0;
}
else {
s = 1 - min / max;
}
v = max;
}
// http://en.wikipedia.org/wiki/HSV_color_space
public static void RgbFromHsv(double h, double s, double v, out double r, out double g, out double b)
{
h = h % 360;
if (h < 0) h += 360; // C# '%' can return negative values, use real modulus instead
int hi = (int)(h / 60) % 6;
var f = h / 60 - (int)(h / 60);
var p = v * (1 - s);
var q = v * (1 - f * s);
var t = v * (1 - (1 - f) * s);
switch (hi) {
case 0: r = v; g = t; b = p; break;
case 1: r = q; g = v; b = p; break;
case 2: r = p; g = v; b = t; break;
case 3: r = p; g = q; b = v; break;
case 4: r = t; g = p; b = v; break;
default: r = v; g = p; b = q; break;
}
}
}
}

232
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ColorPicker.xaml

@ -1,232 +0,0 @@ @@ -1,232 +0,0 @@
<UserControl x:Class="ICSharpCode.WpfDesign.Designer.Controls.ColorPicker"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:widgets="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
x:Name="this"
Padding="5"
Width="373">
<UserControl.Resources>
<DrawingBrush x:Key="ChessBrush"
TileMode="Tile"
ViewportUnits="Absolute"
Viewport="0 0 9 9">
<DrawingBrush.Drawing>
<DrawingGroup>
<GeometryDrawing Brush="White">
<GeometryDrawing.Geometry>
<RectangleGeometry Rect="0 0 2 2" />
</GeometryDrawing.Geometry>
</GeometryDrawing>
<GeometryDrawing Brush="Gray">
<GeometryDrawing.Geometry>
<GeometryGroup>
<RectangleGeometry Rect="0 0 1 1" />
<RectangleGeometry Rect="1 1 1 1" />
</GeometryGroup>
</GeometryDrawing.Geometry>
</GeometryDrawing>
</DrawingGroup>
</DrawingBrush.Drawing>
</DrawingBrush>
</UserControl.Resources>
<DockPanel>
<StackPanel VerticalAlignment="Top"
DockPanel.Dock="Right"
Margin="10 0 0 0">
<Border Background="{StaticResource ChessBrush}"
HorizontalAlignment="Right"
BorderBrush="Black"
BorderThickness="1"
Height="50"
Width="70">
<Rectangle>
<Rectangle.Fill>
<SolidColorBrush Color="{Binding Color, ElementName=this}" />
</Rectangle.Fill>
</Rectangle>
</Border>
<DockPanel Margin="0 3 0 0">
<widgets:HexTextBox Text="{Binding Hex, ElementName=this, UpdateSourceTrigger=PropertyChanged}"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="#"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<widgets:NumericUpDown Value="{Binding H, ElementName=this}"
Maximum="360"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="H"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<widgets:NumericUpDown Value="{Binding S, ElementName=this}"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="S"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<widgets:NumericUpDown Value="{Binding V, ElementName=this}"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="V"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<widgets:NumericUpDown Value="{Binding R, ElementName=this}"
Maximum="255"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="R"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<widgets:NumericUpDown Value="{Binding G, ElementName=this}"
Maximum="255"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="G"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<widgets:NumericUpDown Value="{Binding B, ElementName=this}"
Maximum="255"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="B"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
<DockPanel Margin="0 3 0 0">
<widgets:NumericUpDown Value="{Binding A, ElementName=this}"
Maximum="255"
Width="70"
Margin="5 0 0 0"
DockPanel.Dock="Right" />
<TextBlock Text="A"
VerticalAlignment="Center"
HorizontalAlignment="Right" />
</DockPanel>
</StackPanel>
<Border Margin="10 0 0 0"
DockPanel.Dock="Right">
<widgets:Picker Orientation="Vertical"
Value="{Binding H, ElementName=this}"
Minimum="360"
Maximum="0"
Marker="{Binding ElementName=arrows}"
Width="20">
<Border Margin="0 -1">
<Border.Background>
<LinearGradientBrush EndPoint="0 1">
<GradientStop Offset="0"
Color="#F00" />
<GradientStop Offset="0.16"
Color="#F0F" />
<GradientStop Offset="0.33"
Color="#00F" />
<GradientStop Offset="0.5"
Color="#0FF" />
<GradientStop Offset="0.76"
Color="#0F0" />
<GradientStop Offset="0.85"
Color="#FF0" />
<GradientStop Offset="1"
Color="#F00" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Grid x:Name="arrows"
IsHitTestVisible="False"
VerticalAlignment="Top"
Margin="-5">
<Path HorizontalAlignment="Left"
Data="M 0 0 L 5 5 L 0 10 Z"
Fill="Black" />
<Path HorizontalAlignment="Right"
Data="M 0 0 L -5 5 L 0 10 Z"
Fill="Black" />
</Grid>
</widgets:Picker>
</Border>
<Border BorderBrush="Black"
BorderThickness="1">
<widgets:Picker Value="{Binding S, ElementName=this}"
Marker="{Binding ElementName=point}"
ClipToBounds="True">
<widgets:Picker Orientation="Vertical"
Value="{Binding V, ElementName=this}"
Minimum="100"
Maximum="0"
Marker="{Binding ElementName=point}">
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="1 0">
<GradientStop Offset="0"
Color="White" />
<GradientStop Offset="1"
Color="{Binding HueColor, ElementName=this}" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Rectangle>
<Rectangle.Fill>
<LinearGradientBrush EndPoint="0 1">
<GradientStop Offset="0"
Color="#0000" />
<GradientStop Offset="1"
Color="#F000" />
</LinearGradientBrush>
</Rectangle.Fill>
</Rectangle>
<Grid x:Name="point"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Width="12"
Height="12"
Margin="-6 -6 0 0">
<Ellipse Stroke="Black"
IsHitTestVisible="False" />
<Ellipse Stroke="White"
Margin="1"
IsHitTestVisible="False" />
</Grid>
</widgets:Picker>
</widgets:Picker>
</Border>
</DockPanel>
</UserControl>

191
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ColorPicker.xaml.cs

@ -1,191 +0,0 @@ @@ -1,191 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public partial class ColorPicker
{
public ColorPicker()
{
InitializeComponent();
}
public static readonly DependencyProperty ColorProperty =
DependencyProperty.Register("Color", typeof(Color), typeof(ColorPicker),
new FrameworkPropertyMetadata(new Color(), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public Color Color {
get { return (Color)GetValue(ColorProperty); }
set { SetValue(ColorProperty, value); }
}
public static readonly DependencyProperty HProperty =
DependencyProperty.Register("H", typeof(int), typeof(ColorPicker));
public int H {
get { return (int)GetValue(HProperty); }
set { SetValue(HProperty, value); }
}
public static readonly DependencyProperty SProperty =
DependencyProperty.Register("S", typeof(int), typeof(ColorPicker));
public int S {
get { return (int)GetValue(SProperty); }
set { SetValue(SProperty, value); }
}
public static readonly DependencyProperty VProperty =
DependencyProperty.Register("V", typeof(int), typeof(ColorPicker));
public int V {
get { return (int)GetValue(VProperty); }
set { SetValue(VProperty, value); }
}
public static readonly DependencyProperty RProperty =
DependencyProperty.Register("R", typeof(byte), typeof(ColorPicker));
public byte R {
get { return (byte)GetValue(RProperty); }
set { SetValue(RProperty, value); }
}
public static readonly DependencyProperty GProperty =
DependencyProperty.Register("G", typeof(byte), typeof(ColorPicker));
public byte G {
get { return (byte)GetValue(GProperty); }
set { SetValue(GProperty, value); }
}
public static readonly DependencyProperty BProperty =
DependencyProperty.Register("B", typeof(byte), typeof(ColorPicker));
public byte B {
get { return (byte)GetValue(BProperty); }
set { SetValue(BProperty, value); }
}
public static readonly DependencyProperty AProperty =
DependencyProperty.Register("A", typeof(byte), typeof(ColorPicker));
public byte A {
get { return (byte)GetValue(AProperty); }
set { SetValue(AProperty, value); }
}
public static readonly DependencyProperty HexProperty =
DependencyProperty.Register("Hex", typeof(string), typeof(ColorPicker));
public string Hex {
get { return (string)GetValue(HexProperty); }
set { SetValue(HexProperty, value); }
}
public static readonly DependencyProperty HueColorProperty =
DependencyProperty.Register("HueColor", typeof(Color), typeof(ColorPicker));
public Color HueColor {
get { return (Color)GetValue(HueColorProperty); }
set { SetValue(HueColorProperty, value); }
}
bool updating;
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (updating) return;
updating = true;
try {
if (e.Property == ColorProperty) {
UpdateSource(ColorSource.Hsv);
UpdateRest(ColorSource.Hsv);
} else if (e.Property == HProperty || e.Property == SProperty || e.Property == VProperty) {
var c = ColorHelper.ColorFromHsv(H, S / 100.0, V / 100.0);
c.A = A;
Color = c;
UpdateRest(ColorSource.Hsv);
} else if (e.Property == RProperty || e.Property == GProperty || e.Property == BProperty || e.Property == AProperty) {
Color = Color.FromArgb(A, R, G, B);
UpdateRest(ColorSource.Rgba);
} else if (e.Property == HexProperty) {
Color = ColorHelper.ColorFromString(Hex);
UpdateRest(ColorSource.Hex);
}
} finally {
updating = false;
}
}
void UpdateRest(ColorSource source)
{
HueColor = ColorHelper.ColorFromHsv(H, 1, 1);
UpdateSource((ColorSource)(((int)source + 1) % 3));
UpdateSource((ColorSource)(((int)source + 2) % 3));
}
void UpdateSource(ColorSource source)
{
if (source == ColorSource.Hsv) {
double h, s, v;
ColorHelper.HsvFromColor(Color, out h, out s, out v);
H = (int)h;
S = (int)(s * 100);
V = (int)(v * 100);
}
else if (source == ColorSource.Rgba) {
R = Color.R;
G = Color.G;
B = Color.B;
A = Color.A;
}
else {
Hex = ColorHelper.StringFromColor(Color);
}
}
enum ColorSource
{
Hsv, Rgba, Hex
}
}
class HexTextBox : TextBox
{
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Enter) {
var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
if (b != null) {
b.UpdateTarget();
}
SelectAll();
}
}
}
}

70
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ContainerDragHandle.cs

@ -1,70 +0,0 @@ @@ -1,70 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Controls;
using System.Windows;
using System.Windows.Media;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.Designer.Converters;
using System.Globalization;
using System.Windows.Data;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A thumb where the look can depend on the IsPrimarySelection property.
/// Used by UIElementSelectionRectangle.
/// </summary>
public class ContainerDragHandle : Control
{
static ContainerDragHandle()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(ContainerDragHandle), new FrameworkPropertyMetadata(typeof(ContainerDragHandle)));
}
private ScaleTransform scaleTransform;
public ContainerDragHandle()
{
scaleTransform = new ScaleTransform(1.0, 1.0);
this.LayoutTransform = scaleTransform;
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var surface = this.TryFindParent<DesignSurface>();
if (surface != null && surface.ZoomControl != null)
{
var bnd = new Binding("CurrentZoom") { Source = surface.ZoomControl };
bnd.Converter = InvertedZoomConverter.Instance;
BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleXProperty, bnd);
BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleYProperty, bnd);
}
}
}
}

699
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ControlStyles.xaml

@ -1,699 +0,0 @@ @@ -1,699 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
xmlns:ControlConvertors="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls.Converters"
xmlns:Converters="clr-namespace:ICSharpCode.WpfDesign.Designer.Converters"
xmlns:Widgets="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls">
<!--
This file contains the default styles used by the Controls in ICSharpCode.WpfDesign.Designer.Controls
-->
<Converters:LevelConverter x:Key="FormatDoubleConverter" />
<ControlConvertors:HandleLengthWithOffset x:Key="HandleLengthWithOffset" />
<SolidColorBrush Color="#FF474747" x:Key="HandleBrush" />
<Style TargetType="{x:Type Controls:PanelMoveAdorner}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:PanelMoveAdorner}">
<Border BorderThickness="4" Margin="-2" BorderBrush="Transparent" Cursor="SizeAll" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:EnumButton}" BasedOn="{StaticResource {x:Type ToggleButton}}">
<Setter Property="Margin" Value="3 3 0 3" />
<Setter Property="Foreground" Value="#FF000000"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="Black"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ToggleButton">
<Grid>
<Border x:Name="Background" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}">
<Grid Background="{TemplateBinding Background}">
<Border Opacity="0" x:Name="BackgroundAnimation" Background="#FF448DCA" />
</Grid>
</Border>
<ContentPresenter
x:Name="contentPresenter"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Margin="{TemplateBinding Padding}"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter Property="Background" Value="SkyBlue" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="{x:Type Controls:DesignerThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:DesignerThumb}">
<Grid>
<Rectangle Name="thumbRectangle" SnapsToDevicePixels="True" Stroke="Black" Fill="White" RadiusX="1.414" RadiusY="1.414" />
<Menu Height="15" HorizontalAlignment="Left" Margin="0,-19,-19,0" VerticalAlignment="Top" Width="15" BorderThickness="0" Background="Transparent" Visibility="{Binding Path=OperationMenu, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNull.Instance}}" >
<MenuItem Height="15" Width="15" Padding="0" Background="Transparent" BorderThickness="1" ItemsSource="{TemplateBinding OperationMenu}">
<MenuItem.Header>
<Path Data="M3.5,5.5 L11.5,5.5 L7.5,11 z" Fill="Black" Stroke="Gray" StrokeThickness="1" />
</MenuItem.Header>
</MenuItem>
</Menu>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsPrimarySelection" Value="False">
<Setter TargetName="thumbRectangle" Property="Stroke" Value="White" />
<Setter TargetName="thumbRectangle" Property="Fill" Value="Black" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="thumbRectangle" Property="Fill" Value="Gray" />
</Trigger>
<Trigger Property="ThumbVisible" Value="False">
<Setter TargetName="thumbRectangle" Property="Visibility" Value="Hidden" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:PointThumb}">
<Setter Property="Foreground" Value="Black" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:PointThumb}">
<Grid Margin="-3.5,-3.5,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.Resources>
<Converters:DoubleOffsetConverter x:Key="PointOffset" Offset="3.5" />
</Grid.Resources>
<Line HorizontalAlignment="Left" VerticalAlignment="Top" Stroke="{TemplateBinding Foreground}" StrokeThickness="1" StrokeDashArray="2 2" X1="3.5" Y1="3.5" X2="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource PointOffset}, Path=RelativeToPoint.X}" Y2="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource PointOffset}, Path=RelativeToPoint.Y}" Visibility="{Binding Path=RelativeToPoint, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNull.Instance}}" />
<Grid Width="7" Height="7" HorizontalAlignment="Left" VerticalAlignment="Top">
<Grid.Resources>
<Style TargetType="MenuItem">
<Setter Property="HorizontalContentAlignment" Value="Left" />
<Setter Property="VerticalContentAlignment" Value="Center" />
</Style>
</Grid.Resources>
<Rectangle HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbRectangle" SnapsToDevicePixels="True" Stroke="{TemplateBinding Foreground}" Fill="White" RadiusX="1.414" RadiusY="1.414" />
<Ellipse HorizontalAlignment="Left" VerticalAlignment="Top" Width="7" Height="7" Name="thumbElipse" Stroke="{TemplateBinding Foreground}" SnapsToDevicePixels="True" Fill="White" Visibility="Collapsed" />
<Menu Foreground="Black" Height="15" HorizontalAlignment="Left" Margin="0,-19,-19,0" VerticalAlignment="Top" Width="15" BorderThickness="0" Background="Transparent" Visibility="{Binding Path=OperationMenu, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNull.Instance}}" >
<MenuItem RenderTransform="{TemplateBinding InnerRenderTransform}" Height="15" Width="15" Padding="0" Background="Transparent" BorderThickness="1" ItemsSource="{TemplateBinding OperationMenu}">
<MenuItem.Header>
<Path Data="M3.5,5.5 L11.5,5.5 L7.5,11 z" Fill="Black" Stroke="Gray" StrokeThickness="1" />
</MenuItem.Header>
</MenuItem>
</Menu>
</Grid>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsPrimarySelection" Value="False">
<Setter TargetName="thumbRectangle" Property="Stroke" Value="White" />
<Setter TargetName="thumbRectangle" Property="Fill" Value="Black" />
<Setter TargetName="thumbElipse" Property="Fill" Value="Black" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="thumbRectangle" Property="Fill" Value="Gray" />
</Trigger>
<Trigger Property="IsEllipse" Value="True">
<Setter TargetName="thumbRectangle" Property="Visibility" Value="Hidden" />
<Setter TargetName="thumbElipse" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="ThumbVisible" Value="False">
<Setter TargetName="thumbRectangle" Property="Visibility" Value="Hidden" />
<Setter TargetName="thumbElipse" Property="Visibility" Value="Hidden" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:RotateThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:RotateThumb}">
<Grid>
<Rectangle VerticalAlignment="Top" Width="2" Height="30" Fill="Black" Margin="0,0,0,0" />
<Ellipse VerticalAlignment="Top" StrokeThickness="1" Name="thumbRectangle" SnapsToDevicePixels="True" Stroke="Black"
Width="7" Height="7" Fill="Black">
</Ellipse>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:SelectionFrame}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:SelectionFrame}">
<Rectangle Fill="#519ABFE5" Stroke="#FF7A8787" StrokeThickness="1" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:ContainerDragHandle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ContainerDragHandle}">
<Canvas Height="13" Width="13" Name="Canvas" SnapsToDevicePixels="True">
<Rectangle Height="13" Width="13" RadiusX="2" RadiusY="2" Fill="#889ABFE5" Name="BorderRectangle" Stroke="#FF7A8FB5" StrokeThickness="1" />
<Path Fill="#FF748EAA" Canvas.Left="1" Canvas.Top="1">
<Path.Data>
<GeometryGroup>
<PathGeometry Figures="M5.5,0L3,3L8,3 M11,5.5L8,3L8,8 M5.5,11L3,8L8,8 M0,5.5L3,3L3,8" />
<RectangleGeometry Rect="3,5,5,1" />
<RectangleGeometry Rect="5,3,1,5" />
<RectangleGeometry Rect="5,5,1,1" />
</GeometryGroup>
</Path.Data>
</Path>
</Canvas>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:WindowClone}">
<Setter Property="Width" Value="640" />
<Setter Property="Height" Value="480" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:WindowClone}">
<Border Background="{DynamicResource {x:Static SystemColors.GradientActiveCaptionBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1,1,1,1">
<DockPanel Margin="4,0,4,4">
<DockPanel Height="26" DockPanel.Dock="Top">
<Image Width="16" Height="16" Margin="1,0,0,0" Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.32x32.EmptyProjectIcon.png" Visibility="{Binding Path=(Window.Icon), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenNotNull.Instance}}" />
<Image Width="16" Height="16" Margin="1,0,0,0" Source="{TemplateBinding Window.Icon}" Visibility="{Binding Path=(Window.Icon), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:CollapsedWhenZero.Instance}}" />
<Button Content="r" FontFamily="Marlett" Name="CloseButton" VerticalAlignment="Top" Width="43" Height="17" DockPanel.Dock="Right" />
<Button Content="1" FontFamily="Marlett" Name="MinimizeButton" VerticalAlignment="Top" Width="25" Height="17" DockPanel.Dock="Right" Visibility="{Binding Path=(Window.ResizeMode), Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:EnumCollapsed.Instance}, ConverterParameter=NoResize}" />
<Button Content="0" FontFamily="Marlett" Name="MaximiseButton" VerticalAlignment="Top" Width="25" Height="17" DockPanel.Dock="Right" Visibility="{Binding Path=(Window.ResizeMode), Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static Converters:EnumCollapsed.Instance}, ConverterParameter=NoResize}" />
<Label Margin="4,0,0,0" Content="{TemplateBinding Window.Title}" />
</DockPanel>
<Border Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
<Border ClipToBounds="True" BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" Background="{TemplateBinding Panel.Background}">
<AdornerDecorator>
<ContentPresenter ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" Content="{TemplateBinding ContentControl.Content}" />
</AdornerDecorator>
</Border>
</Border>
</DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:ErrorBalloon}">
<Setter Property="WindowStyle" Value="None" />
<Setter Property="AllowsTransparency" Value="True" />
<Setter Property="SizeToContent" Value="WidthAndHeight" />
<Setter Property="ShowInTaskbar" Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ErrorBalloon}">
<Grid x:Name="LayoutRoot">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle RadiusX="10" RadiusY="10" Margin="12,36,4,4">
<Rectangle.Fill>
<SolidColorBrush Color="#41626262" />
</Rectangle.Fill>
</Rectangle>
<Border Margin="8,32,8,8" Background="{DynamicResource {x:Static SystemColors.InfoBrushKey}}" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1,1,1,1" CornerRadius="10,10,10,10" Padding="10,10,10,10">
<Border BorderBrush="{TemplateBinding Border.BorderBrush}" BorderThickness="{TemplateBinding Border.BorderThickness}" Background="{TemplateBinding Panel.Background}">
<AdornerDecorator>
<ContentPresenter ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" Content="{TemplateBinding ContentControl.Content}" />
</AdornerDecorator>
</Border>
</Border>
<Path Fill="{DynamicResource {x:Static SystemColors.InfoBrushKey}}" Stretch="Fill" HorizontalAlignment="Left" Margin="34.75,9.25,0,0" VerticalAlignment="Top" Width="15.25" Height="24.5" Data="M34.75,33.75 L40.5,9.25 50,33.5 z" />
<Path Stretch="Fill" Stroke="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" HorizontalAlignment="Left" Margin="34.5,9.25,0,0" VerticalAlignment="Top" Width="16" Height="24" Data="M35,32.75 L40.5,9.25 50,32.75" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:GridRowSplitterAdorner}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:GridRowSplitterAdorner}">
<Grid Height="{x:Static Controls:GridRailAdorner.SplitterWidth}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="10" />
<!-- 10=RailSize -->
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<!-- put a transparent rectangle in the rail so the user does not have to hit the small railHandle -->
<Rectangle Fill="Transparent" />
<Path Name="railHandle" Fill="#FFE6E6FF" Stretch="Fill" Stroke="DodgerBlue" Data="M0,0 L0,1 1,0.5 z" />
<Path Name="line" Stretch="Fill" Stroke="DodgerBlue" Grid.Column="2" Margin="-1 0 0 0" Data="M0,0.5 L1,0.5" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="railHandle" Property="Fill" Value="#FFFFB74F" />
</Trigger>
<Trigger Property="IsPreview" Value="True">
<Setter TargetName="railHandle" Property="Stroke" Value="#D0FFB74F" />
<Setter TargetName="line" Property="Stroke" Value="#D0FFB74F" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:GridColumnSplitterAdorner}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:GridColumnSplitterAdorner}">
<Grid Width="{x:Static Controls:GridRailAdorner.SplitterWidth}">
<Grid.RowDefinitions>
<RowDefinition Height="10" />
<!-- 10=RailSize -->
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<!-- put a transparent rectangle in the rail so the user does not have to hit the small railHandle -->
<Rectangle Fill="Transparent" />
<Path Name="railHandle" Fill="#FFE6E6FF" Stretch="Fill" Stroke="DodgerBlue" Data="M0,0 L1,0 0.5,1 z" />
<Path Name="line" Stretch="Fill" Stroke="DodgerBlue" Grid.Row="2" Margin="0 -1 0 0" Data="M0.5,0 L0.5,1" />
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="railHandle" Property="Fill" Value="#FFFFB74F" />
</Trigger>
<Trigger Property="IsPreview" Value="True">
<Setter TargetName="railHandle" Property="Stroke" Value="#D0FFB74F" />
<Setter TargetName="line" Property="Stroke" Value="#D0FFB74F" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:CanvasPositionHandle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:MarginHandle}">
<Grid Height="10" Width="{Binding Path=HandleLength, Converter={x:Static ControlConvertors:HandleLengthWithOffset.Instance}, RelativeSource={RelativeSource Mode=TemplatedParent}}" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Path Name="startArrow" Fill="{StaticResource HandleBrush}" Stretch="Fill" Stroke="{TemplateBinding Panel.Background}" StrokeThickness="0.5" Margin="0,1,0,1" Data="M0,0 L0,1 1,0.5 z" Grid.Column="0" />
<!-- Wrap the handle-line and endArrow in this grid. It's visiblity is subjected to HandleLength -->
<Grid Height="10" Grid.Column="1" Name="lineArrow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="20" MinWidth="10" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Rectangle Fill="Transparent" Height="10" Grid.Column="0" Grid.ColumnSpan="4" />
<Path Name="line1" StrokeDashArray="2,2" Stretch="Fill" Stroke="{StaticResource HandleBrush}" StrokeThickness="1.5" Margin="0 0 0 0" Data="M0,-0.75 L1,-0.75" Grid.Column="0" />
<TextBlock Grid.Column="1" Text="{Binding Path=HandleLength, Mode=OneWay, Converter={x:Static Converters:FormatDoubleConverter.Instance }, RelativeSource={RelativeSource Mode=TemplatedParent}}" FontSize="9" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="1,1,1,1">
<TextBlock.LayoutTransform>
<RotateTransform Angle="{Binding Path=TextTransform, RelativeSource={RelativeSource Mode=TemplatedParent}}" CenterX="0.5" CenterY="0.5">
</RotateTransform>
</TextBlock.LayoutTransform>
</TextBlock>
<Path Name="line2" StrokeDashArray="2,2" Stretch="Fill" Stroke="{StaticResource HandleBrush}" StrokeThickness="1.5" Margin="0 0 0 0" Data="M0,-0.75 L1,-0.75" Grid.Column="2" />
<!--<Path Name="arrow2" Margin="0,1,0,1" Fill="{StaticResource HandleBrush}" Stretch="Fill" Stroke="{TemplateBinding Panel.Background}" StrokeThickness="0.5" Data="M0,0 L0,1 1,0.5 z" Grid.Column="3" />-->
<!--<Rectangle Width="1.5" Fill="{StaticResource HandleBrush}" Grid.Column="4"/>-->
</Grid>
<!-- Rotate the handle and angle of rotation being set by the Margin type. See enum HandleOrientation -->
<Grid.LayoutTransform>
<RotateTransform Angle="{Binding Path=Angle, RelativeSource={RelativeSource Mode=TemplatedParent}}">
</RotateTransform>
</Grid.LayoutTransform>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:MarginHandle}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:MarginHandle}">
<Grid Height="10" Width="{Binding Path=HandleLength, Converter={x:Static ControlConvertors:HandleLengthWithOffset.Instance}, RelativeSource={RelativeSource Mode=TemplatedParent}}" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="8" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Path Name="startArrow" Fill="{StaticResource HandleBrush}" Stretch="Fill" Stroke="{TemplateBinding Panel.Background}" StrokeThickness="0.5" Margin="0,1,0,1" Data="M0,0 L0,1 1,0.5 z" Grid.Column="0" />
<!-- Wrap the handle-line and endArrow in this grid. It's visiblity is subjected to HandleLength -->
<Grid Height="10" Grid.Column="1" Name="lineArrow">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="20" MinWidth="10" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="8" />
<ColumnDefinition Width="1.5"/>
</Grid.ColumnDefinitions>
<Rectangle Fill="Transparent" Height="10" Grid.Column="0" Grid.ColumnSpan="4" />
<Path Name="line1" Stretch="Fill" Stroke="{StaticResource HandleBrush}" StrokeThickness="1.5" Margin="0 0 0 0" Data="M0,-0.75 L1,-0.75" Grid.Column="0" />
<TextBlock Grid.Column="1" Text="{Binding Path=HandleLength, Mode=OneWay, Converter={x:Static Converters:FormatDoubleConverter.Instance }, RelativeSource={RelativeSource Mode=TemplatedParent}}" FontSize="9" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="1,1,1,1">
<TextBlock.LayoutTransform>
<RotateTransform Angle="{Binding Path=TextTransform, RelativeSource={RelativeSource Mode=TemplatedParent}}" CenterX="0.5" CenterY="0.5">
</RotateTransform>
</TextBlock.LayoutTransform>
</TextBlock>
<Path Name="line2" Stretch="Fill" Stroke="{StaticResource HandleBrush}" StrokeThickness="1.5" Margin="0 0 0 0" Data="M0,-0.75 L1,-0.75" Grid.Column="2" />
<Path Name="arrow2" Margin="0,1,0,1" Fill="{StaticResource HandleBrush}" Stretch="Fill" Stroke="{TemplateBinding Panel.Background}" StrokeThickness="0.5" Data="M0,0 L0,1 1,0.5 z" Grid.Column="3" />
<Rectangle Width="1.5" Fill="{StaticResource HandleBrush}" Grid.Column="4"/>
</Grid>
<!-- Rotate the handle and angle of rotation being set by the Margin type. See enum HandleOrientation -->
<Grid.LayoutTransform>
<RotateTransform Angle="{Binding Path=Angle, RelativeSource={RelativeSource Mode=TemplatedParent}}">
</RotateTransform>
</Grid.LayoutTransform>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:MarginStub}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:MarginStub}">
<Grid SnapsToDevicePixels="True" Height="10" Width="10">
<Rectangle Fill="Transparent" />
<Ellipse Fill="{TemplateBinding Panel.Background}" Height="7" Width="7" StrokeThickness="1" Stroke="{StaticResource HandleBrush}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:HeightDisplay}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:HeightDisplay}">
<Grid Width="22">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition MaxHeight="20" MinHeight="5" />
<RowDefinition Height="5" />
</Grid.RowDefinitions>
<Path SnapsToDevicePixels="True" Grid.Row="0" Stroke="#AC0000" StrokeThickness="1.0" Data="M0,0 L1,0 M0.75,0 L0.75,1" Stretch="Fill" />
<TextBlock HorizontalAlignment="Center" Margin="8,0,0,1" Padding="1,1,1,1" FontSize="10" Grid.Row="1">
<TextBlock.Text>
<MultiBinding Converter="{x:Static Converters:ControlToRealHeightConverter.Instance}" StringFormat="0">
<MultiBinding.Bindings>
<Binding />
<Binding Path="ActualHeight" UpdateSourceTrigger="PropertyChanged" />
<Binding Path="Height" UpdateSourceTrigger="PropertyChanged" />
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Text>
<TextBlock.LayoutTransform>
<RotateTransform Angle="270" CenterX="0.5" CenterY="0.5" />
</TextBlock.LayoutTransform>
</TextBlock>
<Path SnapsToDevicePixels="True" Grid.Row="2" Stroke="#AC0000" StrokeThickness="1.0" Data="M0.75,0 L0.75,3 M0,3 L1,3 " Stretch="Fill" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:WidthDisplay}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:WidthDisplay}">
<Grid Height="22" SnapsToDevicePixels="True">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition MaxWidth="20" MinWidth="5" />
<ColumnDefinition Width="5" />
</Grid.ColumnDefinitions>
<Path Grid.Column="0" Stroke="#AC0000" StrokeThickness="1" Data="M0,0 L0,1 M0,0.75 L1,0.75" Stretch="Fill" SnapsToDevicePixels="True" />
<TextBlock HorizontalAlignment="Center" Margin="0,8,0,0" Padding="1,1,1,1" FontSize="10" Grid.Column="1">
<TextBlock.Text>
<MultiBinding Converter="{x:Static Converters:ControlToRealWidthConverter.Instance}" StringFormat="0">
<MultiBinding.Bindings>
<Binding />
<Binding Path="ActualWidth" UpdateSourceTrigger="PropertyChanged" />
<Binding Path="Width" UpdateSourceTrigger="PropertyChanged" />
</MultiBinding.Bindings>
</MultiBinding>
</TextBlock.Text>
</TextBlock>
<Path Grid.Column="2" Stroke="#AC0000" StrokeThickness="1" Data="M0,0.75 L3,0.75 M3,0 L3,1 " Stretch="Fill" SnapsToDevicePixels="True" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:InPlaceEditor}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:InPlaceEditor}">
<TextBox Name="editor" SnapsToDevicePixels="True" Padding="{Binding Path=Padding}" FontSize="{Binding Path=FontSize}" FontFamily="{Binding Path=FontFamily}" FontStyle="{Binding Path=FontStyle}" FontStretch="{Binding Path=FontStretch}" FontWeight="{Binding Path=FontWeight}" Text="{Binding Path=Bind, RelativeSource={RelativeSource Mode=TemplatedParent}, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" AcceptsReturn="True" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:QuickOperationMenu}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:QuickOperationMenu}">
<Menu Height="15" HorizontalAlignment="Left" Name="menu1" VerticalAlignment="Top" Width="15" BorderThickness="0" Background="Transparent">
<MenuItem Height="15" Width="15" Padding="0" Background="Transparent" BorderThickness="1" Name="MainHeader">
<MenuItem.Header>
<Path Data="M3.5,5.5 L11.5,5.5 L7.5,11 z" Fill="Black" Stroke="Gray" StrokeThickness="1" />
</MenuItem.Header>
</MenuItem>
</Menu>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:ZoomControl}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ZoomControl}">
<Grid Background="{TemplateBinding Panel.Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Widgets:SelfCollapsingPanel Grid.Column="0" Grid.Row="1" CollapseOrientation="Horizontal" CanCollapse="{Binding Path=ComputedZoomButtonCollapsed, Mode=OneWay, RelativeSource={RelativeSource Mode=TemplatedParent}}">
<Widgets:ZoomButtons x:Name="zoomButtons" Value="{Binding Path=CurrentZoom, RelativeSource={RelativeSource Mode=TemplatedParent}}" Minimum="{TemplateBinding MinimumZoom}" Maximum="{TemplateBinding MaximumZoom}" />
</Widgets:SelfCollapsingPanel>
<Rectangle Grid.Column="2" Grid.Row="1" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
<ScrollContentPresenter Name="PART_Presenter" Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0" Margin="{TemplateBinding Control.Padding}" Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}">
<ScrollContentPresenter.LayoutTransform>
<ScaleTransform ScaleX="{Binding Path=CurrentZoom, RelativeSource={RelativeSource Mode=TemplatedParent}}" ScaleY="{Binding Path=CurrentZoom, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</ScrollContentPresenter.LayoutTransform>
</ScrollContentPresenter>
<ContentControl Grid.Column="1" Grid.Row="1" Content="{TemplateBinding AdditionalControls}" />
<ScrollBar Name="PART_VerticalScrollBar" Grid.Column="3" Grid.Row="0" Minimum="0" Maximum="{TemplateBinding ScrollableHeight}" ViewportSize="{TemplateBinding ViewportHeight}" Value="{TemplateBinding VerticalOffset}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />
<ScrollBar Name="PART_HorizontalScrollBar" Orientation="Horizontal" Grid.Column="2" Grid.Row="1" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Value="{TemplateBinding HorizontalOffset}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Button}" x:Key="ClearButtonStyle">
<Setter Property="Background" Value="#FFaaaaaa" />
<Setter Property="BorderBrush" Value="#FFaaaaaa" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Width="14" Height="14">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused" />
<VisualState x:Name="Unfocused" />
</VisualStateGroup>
<VisualStateGroup x:Name="CommonStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00.2000000" />
</VisualStateGroup.Transitions>
<VisualState x:Name="Normal" />
<VisualState x:Name="MouseOver">
<Storyboard>
<DoubleAnimation Duration="0"
Storyboard.TargetName="ellipseHighlight"
Storyboard.TargetProperty="(UIElement.Opacity)"
To="1" />
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<DoubleAnimation Duration="0"
Storyboard.TargetName="ellipseHighlight"
Storyboard.TargetProperty="(UIElement.Opacity)"
To="1" />
<DoubleAnimation Duration="0"
Storyboard.TargetName="pathHighlight"
Storyboard.TargetProperty="(UIElement.Opacity)"
To="1" />
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled" />
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Ellipse x:Name="ellipse"
Fill="{TemplateBinding Background}"
Stroke="{TemplateBinding BorderBrush}" />
<Ellipse x:Name="ellipseHighlight"
Fill="#FFBD7777"
Opacity="0"
Stroke="Red" />
<Path x:Name="path"
Margin="4.5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M0.5,0.5 L8.5,8.5 M8.5000095,0.50000072 L0.50000954,8.500001"
Stretch="Fill"
Stroke="{TemplateBinding Foreground}"
UseLayoutRounding="False" />
<Path x:Name="pathHighlight"
Margin="4.5"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M0.5,0.5 L8.5,8.5 M8.5000095,0.50000072 L0.50000954,8.500001"
Opacity="0"
Stretch="Fill"
Stroke="Red"
UseLayoutRounding="False" />
<ContentPresenter x:Name="contentPresenter"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Visibility="Collapsed" />
<Rectangle x:Name="DisabledVisualElement"
Fill="#FFFFFFFF"
IsHitTestVisible="false"
Opacity="0"
RadiusX="3"
RadiusY="3" />
<Rectangle x:Name="FocusVisualElement"
Margin="1"
IsHitTestVisible="false"
Opacity="0"
RadiusX="2"
RadiusY="2"
Stroke="#FF6DBDD1"
StrokeThickness="1" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:ClearableTextBox}">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" />
<Setter Property="BorderBrush" Value="#888" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="1,0,0,0" />
<Setter Property="AllowDrop" Value="true" />
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="ScrollViewer.PanningMode" Value="VerticalFirst" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ClearableTextBox}">
<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="TextRemoverStates">
<VisualStateGroup.Transitions>
<VisualTransition GeneratedDuration="00:00:00.3000000" />
</VisualStateGroup.Transitions>
<VisualState x:Name="TextRemoverVisible">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="TextRemover"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="TextRemover"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="1" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="TextRemover"
Storyboard.TargetProperty="(UIElement.Opacity)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="1" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="TextRemoverHidden">
<Storyboard>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="TextRemover"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="TextRemover"
Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0" />
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00"
Duration="00:00:00.0010000"
Storyboard.TargetName="TextRemover"
Storyboard.TargetProperty="(UIElement.Opacity)">
<EasingDoubleKeyFrame KeyTime="00:00:00" Value="0" />
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="Border"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="1" />
<ScrollViewer x:Name="PART_ContentHost" VerticalAlignment="Center"
Margin="0,0,18,0"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Viewbox Stretch="Uniform" HorizontalAlignment="Right" VerticalAlignment="Stretch" Margin="0,3,3,3">
<Button x:Name="TextRemover"
Width="14"
Height="14"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
IsTabStop="False"
RenderTransformOrigin="0.5,0.5"
Style="{StaticResource ClearButtonStyle}">
<Button.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1" />
<SkewTransform />
<RotateTransform />
<TranslateTransform />
</TransformGroup>
</Button.RenderTransform>
</Button>
</Viewbox>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:RenderTransformOriginThumb}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:RenderTransformOriginThumb}">
<Grid Width="10" Height="10" Margin="-5,-5,-5,-5">
<Ellipse Width="2" Height="2" Fill="Black"/>
<Ellipse Width="10" Height="10" Fill="Transparent" Stroke="Black" StrokeThickness="1" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

157
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DragListener.cs

@ -1,157 +0,0 @@ @@ -1,157 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Input;
using System.Diagnostics;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public delegate void DragHandler(DragListener drag);
public class DragListener
{
static DragListener()
{
InputManager.Current.PostProcessInput += new ProcessInputEventHandler(PostProcessInput);
}
public Transform Transform { get; set; }
public DragListener(IInputElement target)
{
Target = target;
Target.PreviewMouseLeftButtonDown += Target_MouseDown;
Target.PreviewMouseMove += Target_MouseMove;
Target.PreviewMouseLeftButtonUp += Target_MouseUp;
}
public void ExternalStart()
{
Target_MouseDown(null, null);
}
public void ExternalMouseMove(MouseEventArgs e)
{
Target_MouseMove(null, e);
}
public void ExternalStop()
{
Target_MouseUp(null, null);
}
static DragListener CurrentListener;
static void PostProcessInput(object sender, ProcessInputEventArgs e)
{
if (CurrentListener != null) {
var a = e.StagingItem.Input as KeyEventArgs;
if (a != null && a.Key == Key.Escape) {
Mouse.Capture(null);
CurrentListener.IsDown = false;
CurrentListener.IsCanceled = true;
CurrentListener.Complete();
}
}
}
void Target_MouseDown(object sender, MouseButtonEventArgs e)
{
StartPoint = Mouse.GetPosition(null);
CurrentPoint = StartPoint;
DeltaDelta = new Vector();
IsDown = true;
IsCanceled = false;
if (MouseDown != null)
MouseDown(this);
}
void Target_MouseMove(object sender, MouseEventArgs e)
{
if (IsDown) {
DeltaDelta = e.GetPosition(null) - CurrentPoint;
CurrentPoint += DeltaDelta;
if (!IsActive) {
if (Math.Abs(Delta.X) >= SystemParameters.MinimumHorizontalDragDistance ||
Math.Abs(Delta.Y) >= SystemParameters.MinimumVerticalDragDistance) {
IsActive = true;
CurrentListener = this;
if (Started != null) {
Started(this);
}
}
}
if (IsActive && Changed != null) {
Changed(this);
}
}
}
void Target_MouseUp(object sender, MouseButtonEventArgs e)
{
IsDown = false;
if (IsActive) {
Complete();
}
}
void Complete()
{
IsActive = false;
CurrentListener = null;
if (Completed != null) {
Completed(this);
}
}
public event DragHandler MouseDown;
public event DragHandler Started;
public event DragHandler Changed;
public event DragHandler Completed;
public IInputElement Target { get; private set; }
public Point StartPoint { get; private set; }
public Point CurrentPoint { get; private set; }
public Vector DeltaDelta { get; private set; }
public bool IsActive { get; private set; }
public bool IsDown { get; private set; }
public bool IsCanceled { get; private set; }
public Vector Delta {
get {
if (Transform != null) {
var matrix = Transform.Value;
matrix.Invert();
return matrix.Transform(CurrentPoint - StartPoint);
}
return CurrentPoint - StartPoint;
}
}
}
}

44
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/DropDownButton.cs

@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Shapes;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A button with a drop-down arrow.
/// </summary>
public class DropDownButton : Button
{
static readonly Geometry triangle = (Geometry)new GeometryConverter().ConvertFromInvariantString("M0,0 L1,0 0.5,1 z");
public DropDownButton()
{
Content = new Path {
Fill = Brushes.Black,
Data = triangle,
Width = 7,
Height = 3.5,
Stretch = Stretch.Fill
};
}
}
}

49
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnterTextBox.cs

@ -1,49 +0,0 @@ @@ -1,49 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Data;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class EnterTextBox : TextBox
{
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Enter) {
var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
if (b != null) {
b.UpdateSource();
}
SelectAll();
}
else if (e.Key == Key.Escape) {
var b = BindingOperations.GetBindingExpressionBase(this, TextProperty);
if (b != null) {
b.UpdateTarget();
}
}
}
}
}

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml

@ -1,7 +0,0 @@ @@ -1,7 +0,0 @@
<UserControl
x:Class="ICSharpCode.WpfDesign.Designer.Controls.EnumBar"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<StackPanel x:Name="uxPanel"
Orientation="Horizontal" />
</UserControl>

146
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs

@ -1,146 +0,0 @@ @@ -1,146 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public partial class EnumBar
{
public EnumBar()
{
SpecialInitializeComponent();
}
/// <summary>
/// Fixes InitializeComponent with multiple Versions of same Assembly loaded
/// </summary>
public void SpecialInitializeComponent()
{
if (!this._contentLoaded) {
this._contentLoaded = true;
Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
Application.LoadComponent(this, resourceLocator);
}
this.InitializeComponent();
}
Type currentEnumType;
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(object), typeof(EnumBar),
new FrameworkPropertyMetadata(null, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods")]
public object Value {
get { return (object)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
public static readonly DependencyProperty ContainerProperty =
DependencyProperty.Register("Container", typeof(Panel), typeof(EnumBar));
public Panel Container {
get { return (Panel)GetValue(ContainerProperty); }
set { SetValue(ContainerProperty, value); }
}
public static readonly DependencyProperty ButtonStyleProperty =
DependencyProperty.Register("ButtonStyle", typeof(Style), typeof(EnumBar));
public Style ButtonStyle {
get { return (Style)GetValue(ButtonStyleProperty); }
set { SetValue(ButtonStyleProperty, value); }
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == ValueProperty) {
var type = e.NewValue.GetType();
if (currentEnumType != type) {
currentEnumType = type;
uxPanel.Children.Clear();
foreach (var v in Enum.GetValues(type)) {
var b = new EnumButton();
b.Value = v;
b.Content = Enum.GetName(type, v);
b.SetBinding(StyleProperty, new Binding("ButtonStyle") { Source = this });
b.PreviewMouseLeftButtonDown += new MouseButtonEventHandler(button_PreviewMouseLeftButtonDown);
uxPanel.Children.Add(b);
}
}
UpdateButtons();
UpdateContainer();
} else if (e.Property == ContainerProperty) {
UpdateContainer();
}
}
void UpdateButtons()
{
foreach (EnumButton c in uxPanel.Children) {
if (c.Value.Equals(Value)) {
c.IsChecked = true;
}
else {
c.IsChecked = false;
}
}
}
void UpdateContainer()
{
if (Container != null) {
for (int i = 0; i < uxPanel.Children.Count; i++) {
var c = uxPanel.Children[i] as EnumButton;
if (c.IsChecked.Value)
Container.Children[i].Visibility = Visibility.Visible;
else
Container.Children[i].Visibility = Visibility.Collapsed;
}
}
}
void button_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Value = (sender as EnumButton).Value;
e.Handled = true;
}
}
}

44
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumButton.cs

@ -1,44 +0,0 @@ @@ -1,44 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls.Primitives;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class EnumButton : ToggleButton
{
static EnumButton()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(EnumButton),
new FrameworkPropertyMetadata(typeof(EnumButton)));
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(object), typeof(EnumButton));
public object Value {
get { return (object)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
}
}

34
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ErrorBalloon.cs

@ -1,34 +0,0 @@ @@ -1,34 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// An ErrorBalloon window.
/// </summary>
public class ErrorBalloon : Window
{
static ErrorBalloon()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ErrorBalloon), new FrameworkPropertyMetadata(typeof(ErrorBalloon)));
}
}
}

134
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GrayOutDesignerExceptActiveArea.cs

@ -1,134 +0,0 @@ @@ -1,134 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
using System.Windows.Media.Animation;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Gray out everything except a specific area.
/// </summary>
sealed class GrayOutDesignerExceptActiveArea : FrameworkElement
{
Geometry designSurfaceRectangle;
Geometry activeAreaGeometry;
Geometry combinedGeometry;
Brush grayOutBrush;
AdornerPanel adornerPanel;
IDesignPanel designPanel;
const double MaxOpacity = 0.3;
public GrayOutDesignerExceptActiveArea()
{
this.GrayOutBrush = new SolidColorBrush(SystemColors.GrayTextColor);
this.GrayOutBrush.Opacity = MaxOpacity;
this.IsHitTestVisible = false;
}
public Brush GrayOutBrush {
get { return grayOutBrush; }
set { grayOutBrush = value; }
}
public Geometry ActiveAreaGeometry {
get { return activeAreaGeometry; }
set {
activeAreaGeometry = value;
combinedGeometry = new CombinedGeometry(GeometryCombineMode.Exclude, designSurfaceRectangle, activeAreaGeometry);
}
}
protected override void OnRender(DrawingContext drawingContext)
{
drawingContext.DrawGeometry(grayOutBrush, null, combinedGeometry);
}
Rect currentAnimateActiveAreaRectToTarget;
internal void AnimateActiveAreaRectTo(Rect newRect)
{
if (newRect.Equals(currentAnimateActiveAreaRectToTarget))
return;
activeAreaGeometry.BeginAnimation(
RectangleGeometry.RectProperty,
new RectAnimation(newRect, new Duration(new TimeSpan(0,0,0,0,100))),
HandoffBehavior.SnapshotAndReplace);
currentAnimateActiveAreaRectToTarget = newRect;
}
internal static void Start(ref GrayOutDesignerExceptActiveArea grayOut, ServiceContainer services, UIElement activeContainer)
{
Debug.Assert(activeContainer != null);
Start(ref grayOut, services, activeContainer, new Rect(activeContainer.RenderSize));
}
internal static void Start(ref GrayOutDesignerExceptActiveArea grayOut, ServiceContainer services, UIElement activeContainer, Rect activeRectInActiveContainer)
{
Debug.Assert(services != null);
Debug.Assert(activeContainer != null);
DesignPanel designPanel = services.GetService<IDesignPanel>() as DesignPanel;
OptionService optionService = services.GetService<OptionService>();
if (designPanel != null && grayOut == null && optionService != null && optionService.GrayOutDesignSurfaceExceptParentContainerWhenDragging) {
grayOut = new GrayOutDesignerExceptActiveArea();
grayOut.designSurfaceRectangle = new RectangleGeometry(
new Rect(0, 0, ((Border)designPanel.Child).Child.RenderSize.Width, ((Border)designPanel.Child).Child.RenderSize.Height));
grayOut.designPanel = designPanel;
grayOut.adornerPanel = new AdornerPanel();
grayOut.adornerPanel.Order = AdornerOrder.BehindForeground;
grayOut.adornerPanel.SetAdornedElement(designPanel.Context.RootItem.View, null);
grayOut.adornerPanel.Children.Add(grayOut);
grayOut.ActiveAreaGeometry = new RectangleGeometry(activeRectInActiveContainer, 0, 0, (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement));
Animate(grayOut.GrayOutBrush, Brush.OpacityProperty, MaxOpacity);
designPanel.Adorners.Add(grayOut.adornerPanel);
}
}
static readonly TimeSpan animationTime = new TimeSpan(2000000);
static void Animate(Animatable element, DependencyProperty property, double to)
{
element.BeginAnimation(property, new DoubleAnimation(to, new Duration(animationTime), FillBehavior.HoldEnd),
HandoffBehavior.SnapshotAndReplace);
}
internal static void Stop(ref GrayOutDesignerExceptActiveArea grayOut)
{
if (grayOut != null) {
Animate(grayOut.GrayOutBrush, Brush.OpacityProperty, 0);
IDesignPanel designPanel = grayOut.designPanel;
AdornerPanel adornerPanelToRemove = grayOut.adornerPanel;
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = animationTime;
timer.Tick += delegate {
timer.Stop();
designPanel.Adorners.Remove(adornerPanelToRemove);
};
timer.Start();
grayOut = null;
}
}
}
}

673
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridAdorner.cs

@ -1,673 +0,0 @@ @@ -1,673 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.WpfDesign.Adorners;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Adorner that displays the blue bar next to grids that can be used to create new rows/column.
/// </summary>
public class GridRailAdorner : FrameworkElement
{
static GridRailAdorner()
{
bgBrush = new SolidColorBrush(Color.FromArgb(0x35, 0x1E, 0x90, 0xff));
bgBrush.Freeze();
}
readonly DesignItem gridItem;
readonly Grid grid;
readonly AdornerPanel adornerPanel;
readonly GridSplitterAdorner previewAdorner;
readonly Orientation orientation;
readonly GridUnitSelector unitSelector;
static readonly SolidColorBrush bgBrush;
public const double RailSize = 10;
public const double RailDistance = 6;
public const double SplitterWidth = 10;
bool displayUnitSelector; // Indicates whether Grid UnitSeletor should be displayed.
public GridRailAdorner(DesignItem gridItem, AdornerPanel adornerPanel, Orientation orientation)
{
Debug.Assert(gridItem != null);
Debug.Assert(adornerPanel != null);
this.gridItem = gridItem;
this.grid = (Grid)gridItem.Component;
this.adornerPanel = adornerPanel;
this.orientation = orientation;
this.displayUnitSelector=false;
this.unitSelector = new GridUnitSelector(this);
adornerPanel.Children.Add(unitSelector);
if (orientation == Orientation.Horizontal) {
this.Height = RailSize;
previewAdorner = new GridColumnSplitterAdorner(this, gridItem, null, null);
} else { // vertical
this.Width = RailSize;
previewAdorner = new GridRowSplitterAdorner(this, gridItem, null, null);
}
unitSelector.Orientation = orientation;
previewAdorner.IsPreview = true;
previewAdorner.IsHitTestVisible = false;
unitSelector.Visibility = Visibility.Hidden;
}
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (orientation == Orientation.Horizontal) {
Rect bgRect = new Rect(0, 0, grid.ActualWidth, RailSize);
drawingContext.DrawRectangle(bgBrush, null, bgRect);
DesignItemProperty colCollection = gridItem.Properties["ColumnDefinitions"];
foreach (var colItem in colCollection.CollectionElements) {
ColumnDefinition column = colItem.Component as ColumnDefinition;
if (column.ActualWidth < 0) continue;
GridLength len = (GridLength)column.GetValue(ColumnDefinition.WidthProperty);
FormattedText text = new FormattedText(GridLengthToText(len), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Sergio UI"), 10, Brushes.Black);
text.TextAlignment = TextAlignment.Center;
drawingContext.DrawText(text, new Point(column.Offset + column.ActualWidth / 2, 0));
}
} else {
Rect bgRect = new Rect(0, 0, RailSize, grid.ActualHeight);
drawingContext.DrawRectangle(bgBrush, null, bgRect);
DesignItemProperty rowCollection = gridItem.Properties["RowDefinitions"];
foreach (var rowItem in rowCollection.CollectionElements) {
RowDefinition row = rowItem.Component as RowDefinition;
if (row.ActualHeight < 0) continue;
GridLength len = (GridLength)row.GetValue(RowDefinition.HeightProperty);
FormattedText text = new FormattedText(GridLengthToText(len), CultureInfo.CurrentCulture, FlowDirection.LeftToRight, new Typeface("Sergio UI"), 10, Brushes.Black);
text.TextAlignment = TextAlignment.Center;
drawingContext.PushTransform(new RotateTransform(-90));
drawingContext.DrawText(text, new Point((row.Offset + row.ActualHeight / 2)*-1, 0));
drawingContext.Pop();
}
}
}
#region Handle mouse events to add a new row/column
protected override void OnMouseEnter(MouseEventArgs e)
{
base.OnMouseEnter(e);
this.Cursor = Cursors.Cross;
RelativePlacement rpUnitSelector = new RelativePlacement();
if (orientation == Orientation.Vertical)
{
double insertionPosition = e.GetPosition(this).Y;
RowDefinition current = grid.RowDefinitions
.FirstOrDefault(r => insertionPosition >= r.Offset &&
insertionPosition <= (r.Offset + r.ActualHeight));
if (current != null)
{
DesignItem component = this.gridItem.Services.Component.GetDesignItem(current);
rpUnitSelector.XOffset = -(RailSize + RailDistance) * 2.75;
rpUnitSelector.WidthOffset = RailSize + RailDistance;
rpUnitSelector.WidthRelativeToContentWidth = 1;
rpUnitSelector.HeightOffset = 55;
rpUnitSelector.YOffset = current.Offset + current.ActualHeight / 2 - 25;
unitSelector.SelectedItem = component;
unitSelector.Unit = ((GridLength)component.Properties[RowDefinition.HeightProperty].ValueOnInstance).GridUnitType;
displayUnitSelector = true;
}
else
{
displayUnitSelector = false;
}
}
else
{
double insertionPosition = e.GetPosition(this).X;
ColumnDefinition current = grid.ColumnDefinitions
.FirstOrDefault(r => insertionPosition >= r.Offset &&
insertionPosition <= (r.Offset + r.ActualWidth));
if (current != null)
{
DesignItem component = this.gridItem.Services.Component.GetDesignItem(current);
Debug.Assert(component != null);
rpUnitSelector.YOffset = -(RailSize + RailDistance) * 2.20;
rpUnitSelector.HeightOffset = RailSize + RailDistance;
rpUnitSelector.HeightRelativeToContentHeight = 1;
rpUnitSelector.WidthOffset = 75;
rpUnitSelector.XOffset = current.Offset + current.ActualWidth / 2 - 35;
unitSelector.SelectedItem = component;
unitSelector.Unit = ((GridLength)component.Properties[ColumnDefinition.WidthProperty].ValueOnInstance).GridUnitType;
displayUnitSelector = true;
}
else
{
displayUnitSelector = false;
}
}
if(displayUnitSelector)
unitSelector.Visibility = Visibility.Visible;
if(!adornerPanel.Children.Contains(previewAdorner))
adornerPanel.Children.Add(previewAdorner);
}
protected override void OnMouseMove(MouseEventArgs e)
{
base.OnMouseMove(e);
RelativePlacement rp = new RelativePlacement();
RelativePlacement rpUnitSelector = new RelativePlacement();
if (orientation == Orientation.Vertical)
{
double insertionPosition = e.GetPosition(this).Y;
RowDefinition current = grid.RowDefinitions
.FirstOrDefault(r => insertionPosition >= r.Offset &&
insertionPosition <= (r.Offset + r.ActualHeight));
rp.XOffset = -(RailSize + RailDistance);
rp.WidthOffset = RailSize + RailDistance;
rp.WidthRelativeToContentWidth = 1;
rp.HeightOffset = SplitterWidth;
rp.YOffset = e.GetPosition(this).Y - SplitterWidth / 2;
if (current != null)
{
DesignItem component = this.gridItem.Services.Component.GetDesignItem(current);
rpUnitSelector.XOffset = -(RailSize + RailDistance) * 2.75;
rpUnitSelector.WidthOffset = RailSize + RailDistance;
rpUnitSelector.WidthRelativeToContentWidth = 1;
rpUnitSelector.HeightOffset = 55;
rpUnitSelector.YOffset = current.Offset + current.ActualHeight / 2 - 25;
unitSelector.SelectedItem = component;
unitSelector.Unit = ((GridLength)component.Properties[RowDefinition.HeightProperty].ValueOnInstance).GridUnitType;
displayUnitSelector = true;
}
else
{
displayUnitSelector = false;
}
}
else
{
double insertionPosition = e.GetPosition(this).X;
ColumnDefinition current = grid.ColumnDefinitions
.FirstOrDefault(r => insertionPosition >= r.Offset &&
insertionPosition <= (r.Offset + r.ActualWidth));
rp.YOffset = -(RailSize + RailDistance);
rp.HeightOffset = RailSize + RailDistance;
rp.HeightRelativeToContentHeight = 1;
rp.WidthOffset = SplitterWidth;
rp.XOffset = e.GetPosition(this).X - SplitterWidth / 2;
if (current != null)
{
DesignItem component = this.gridItem.Services.Component.GetDesignItem(current);
Debug.Assert(component != null);
rpUnitSelector.YOffset = -(RailSize + RailDistance) * 2.20;
rpUnitSelector.HeightOffset = RailSize + RailDistance;
rpUnitSelector.HeightRelativeToContentHeight = 1;
rpUnitSelector.WidthOffset = 75;
rpUnitSelector.XOffset = current.Offset + current.ActualWidth / 2 - 35;
unitSelector.SelectedItem = component;
unitSelector.Unit = ((GridLength)component.Properties[ColumnDefinition.WidthProperty].ValueOnInstance).GridUnitType;
displayUnitSelector = true;
}
else
{
displayUnitSelector = false;
}
}
AdornerPanel.SetPlacement(previewAdorner, rp);
if (displayUnitSelector)
AdornerPanel.SetPlacement(unitSelector, rpUnitSelector);
}
protected override void OnMouseLeave(MouseEventArgs e)
{
base.OnMouseLeave(e);
Mouse.UpdateCursor();
if (!unitSelector.IsMouseOver)
{
unitSelector.Visibility = Visibility.Hidden;
displayUnitSelector = false;
}
if(adornerPanel.Children.Contains(previewAdorner))
adornerPanel.Children.Remove(previewAdorner);
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
e.Handled = true;
Focus();
adornerPanel.Children.Remove(previewAdorner);
if (orientation == Orientation.Vertical) {
double insertionPosition = e.GetPosition(this).Y;
DesignItemProperty rowCollection = gridItem.Properties["RowDefinitions"];
DesignItem currentRow = null;
using (ChangeGroup changeGroup = gridItem.OpenGroup("Split grid row")) {
if (rowCollection.CollectionElements.Count == 0) {
DesignItem firstRow = gridItem.Services.Component.RegisterComponentForDesigner(new RowDefinition());
rowCollection.CollectionElements.Add(firstRow);
grid.UpdateLayout(); // let WPF assign firstRow.ActualHeight
currentRow = firstRow;
} else {
RowDefinition current = grid.RowDefinitions
.FirstOrDefault(r => insertionPosition >= r.Offset &&
insertionPosition <= (r.Offset + r.ActualHeight));
if (current != null)
currentRow = gridItem.Services.Component.GetDesignItem(current);
}
if (currentRow == null)
currentRow = gridItem.Services.Component.GetDesignItem(grid.RowDefinitions.Last());
unitSelector.SelectedItem = currentRow;
for (int i = 0; i < grid.RowDefinitions.Count; i++) {
RowDefinition row = grid.RowDefinitions[i];
if (row.Offset > insertionPosition) continue;
if (row.Offset + row.ActualHeight < insertionPosition) continue;
// split row
GridLength oldLength = (GridLength)row.GetValue(RowDefinition.HeightProperty);
GridLength newLength1, newLength2;
SplitLength(oldLength, insertionPosition - row.Offset, row.ActualHeight, out newLength1, out newLength2);
DesignItem newRowDefinition = gridItem.Services.Component.RegisterComponentForDesigner(new RowDefinition());
rowCollection.CollectionElements.Insert(i + 1, newRowDefinition);
rowCollection.CollectionElements[i].Properties[RowDefinition.HeightProperty].SetValue(newLength1);
newRowDefinition.Properties[RowDefinition.HeightProperty].SetValue(newLength2);
grid.UpdateLayout();
FixIndicesAfterSplit(i, Grid.RowProperty, Grid.RowSpanProperty,insertionPosition);
grid.UpdateLayout();
changeGroup.Commit();
break;
}
}
} else {
double insertionPosition = e.GetPosition(this).X;
DesignItemProperty columnCollection = gridItem.Properties["ColumnDefinitions"];
DesignItem currentColumn = null;
using (ChangeGroup changeGroup = gridItem.OpenGroup("Split grid column")) {
if (columnCollection.CollectionElements.Count == 0) {
DesignItem firstColumn = gridItem.Services.Component.RegisterComponentForDesigner(new ColumnDefinition());
columnCollection.CollectionElements.Add(firstColumn);
grid.UpdateLayout(); // let WPF assign firstColumn.ActualWidth
currentColumn = firstColumn;
} else {
ColumnDefinition current = grid.ColumnDefinitions
.FirstOrDefault(r => insertionPosition >= r.Offset &&
insertionPosition <= (r.Offset + r.ActualWidth));
if (current != null)
currentColumn = gridItem.Services.Component.GetDesignItem(current);
}
if (currentColumn == null)
currentColumn = gridItem.Services.Component.GetDesignItem(grid.ColumnDefinitions.Last());
unitSelector.SelectedItem = currentColumn;
for (int i = 0; i < grid.ColumnDefinitions.Count; i++) {
ColumnDefinition column = grid.ColumnDefinitions[i];
if (column.Offset > insertionPosition) continue;
if (column.Offset + column.ActualWidth < insertionPosition) continue;
// split column
GridLength oldLength = (GridLength)column.GetValue(ColumnDefinition.WidthProperty);
GridLength newLength1, newLength2;
SplitLength(oldLength, insertionPosition - column.Offset, column.ActualWidth, out newLength1, out newLength2);
DesignItem newColumnDefinition = gridItem.Services.Component.RegisterComponentForDesigner(new ColumnDefinition());
columnCollection.CollectionElements.Insert(i + 1, newColumnDefinition);
columnCollection.CollectionElements[i].Properties[ColumnDefinition.WidthProperty].SetValue(newLength1);
newColumnDefinition.Properties[ColumnDefinition.WidthProperty].SetValue(newLength2);
grid.UpdateLayout();
FixIndicesAfterSplit(i, Grid.ColumnProperty, Grid.ColumnSpanProperty,insertionPosition);
changeGroup.Commit();
grid.UpdateLayout();
break;
}
}
}
InvalidateVisual();
}
private void FixIndicesAfterSplit(int splitIndex, DependencyProperty idxProperty, DependencyProperty spanProperty, double insertionPostion)
{
if (orientation == Orientation.Horizontal) {
// increment ColSpan of all controls in the split column, increment Column of all controls in later columns:
foreach (DesignItem child in gridItem.Properties["Children"].CollectionElements) {
Point topLeft = child.View.TranslatePoint(new Point(0, 0), grid);
var margin = (Thickness) child.Properties[FrameworkElement.MarginProperty].ValueOnInstance;
var start = (int) child.Properties.GetAttachedProperty(idxProperty).ValueOnInstance;
var span = (int) child.Properties.GetAttachedProperty(spanProperty).ValueOnInstance;
if (start <= splitIndex && splitIndex < start + span) {
var width = (double) child.Properties[FrameworkElement.ActualWidthProperty].ValueOnInstance;
if (insertionPostion >= topLeft.X + width) {
continue;
}
if (insertionPostion > topLeft.X)
child.Properties.GetAttachedProperty(spanProperty).SetValue(span + 1);
else {
child.Properties.GetAttachedProperty(idxProperty).SetValue(start + 1);
margin.Left = topLeft.X - insertionPostion;
child.Properties[FrameworkElement.MarginProperty].SetValue(margin);
}
}
else if (start > splitIndex)
{
child.Properties.GetAttachedProperty(idxProperty).SetValue(start + 1);
}
}
}
else
{
foreach (DesignItem child in gridItem.Properties["Children"].CollectionElements)
{
Point topLeft = child.View.TranslatePoint(new Point(0, 0), grid);
var margin = (Thickness)child.Properties[FrameworkElement.MarginProperty].ValueOnInstance;
var start = (int)child.Properties.GetAttachedProperty(idxProperty).ValueOnInstance;
var span = (int)child.Properties.GetAttachedProperty(spanProperty).ValueOnInstance;
if (start <= splitIndex && splitIndex < start + span)
{
var height = (double)child.Properties[FrameworkElement.ActualHeightProperty].ValueOnInstance;
if (insertionPostion >= topLeft.Y + height)
continue;
if (insertionPostion > topLeft.Y)
child.Properties.GetAttachedProperty(spanProperty).SetValue(span + 1);
else {
child.Properties.GetAttachedProperty(idxProperty).SetValue(start + 1);
margin.Top=topLeft.Y-insertionPostion;
child.Properties[FrameworkElement.MarginProperty].SetValue(margin);
}
}
else if (start > splitIndex)
{
child.Properties.GetAttachedProperty(idxProperty).SetValue(start + 1);
}
}
}
}
static void SplitLength(GridLength oldLength, double insertionPosition, double oldActualValue,
out GridLength newLength1, out GridLength newLength2)
{
if (oldLength.IsAuto) {
oldLength = new GridLength(oldActualValue);
}
double percentage = insertionPosition / oldActualValue;
newLength1 = new GridLength(oldLength.Value * percentage, oldLength.GridUnitType);
newLength2 = new GridLength(oldLength.Value - newLength1.Value, oldLength.GridUnitType);
}
#endregion
string GridLengthToText(GridLength len)
{
switch (len.GridUnitType) {
case GridUnitType.Auto:
return "Auto";
case GridUnitType.Star:
return len.Value == 1 ? "*" : Math.Round(len.Value, 2) + "*";
case GridUnitType.Pixel:
return Math.Round(len.Value, 2) + "px";
}
return string.Empty;
}
public void SetGridLengthUnit(GridUnitType unit)
{
DesignItem item = unitSelector.SelectedItem;
grid.UpdateLayout();
Debug.Assert(item != null);
if (orientation == Orientation.Vertical) {
SetGridLengthUnit(unit, item, RowDefinition.HeightProperty);
} else {
SetGridLengthUnit(unit, item, ColumnDefinition.WidthProperty);
}
grid.UpdateLayout();
InvalidateVisual();
}
void SetGridLengthUnit(GridUnitType unit, DesignItem item, DependencyProperty property)
{
DesignItemProperty itemProperty = item.Properties[property];
GridLength oldValue = (GridLength)itemProperty.ValueOnInstance;
GridLength value = GetNewGridLength(unit, oldValue);
if (value != oldValue) {
itemProperty.SetValue(value);
}
}
GridLength GetNewGridLength(GridUnitType unit, GridLength oldValue)
{
if (unit == GridUnitType.Auto) {
return GridLength.Auto;
}
return new GridLength(oldValue.Value, unit);
}
}
public abstract class GridSplitterAdorner : Control
{
public static readonly DependencyProperty IsPreviewProperty
= DependencyProperty.Register("IsPreview", typeof(bool), typeof(GridSplitterAdorner), new PropertyMetadata(SharedInstances.BoxedFalse));
protected readonly Grid grid;
protected readonly DesignItem gridItem;
protected readonly DesignItem firstRow, secondRow; // can also be columns
protected readonly GridRailAdorner rail;
internal GridSplitterAdorner(GridRailAdorner rail, DesignItem gridItem, DesignItem firstRow, DesignItem secondRow)
{
Debug.Assert(gridItem != null);
this.grid = (Grid)gridItem.Component;
this.gridItem = gridItem;
this.firstRow = firstRow;
this.secondRow = secondRow;
this.rail = rail;
}
public bool IsPreview {
get { return (bool)GetValue(IsPreviewProperty); }
set { SetValue(IsPreviewProperty, SharedInstances.Box(value)); }
}
ChangeGroup activeChangeGroup;
double mouseStartPos;
bool mouseIsDown;
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
e.Handled = true;
if (CaptureMouse()) {
Focus();
mouseStartPos = GetCoordinate(e.GetPosition(grid));
mouseIsDown = true;
}
}
protected override void OnMouseMove(MouseEventArgs e)
{
if (mouseIsDown) {
double mousePos = GetCoordinate(e.GetPosition(grid));
if (activeChangeGroup == null) {
if (Math.Abs(mousePos - mouseStartPos)
>= GetCoordinate(new Point(SystemParameters.MinimumHorizontalDragDistance, SystemParameters.MinimumVerticalDragDistance))) {
activeChangeGroup = gridItem.OpenGroup("Change grid row/column size");
RememberOriginalSize();
}
}
if (activeChangeGroup != null) {
ChangeSize(mousePos - mouseStartPos);
}
}
}
protected GridLength original1, original2;
protected double originalPixelSize1, originalPixelSize2;
protected abstract double GetCoordinate(Point point);
protected abstract void RememberOriginalSize();
protected abstract DependencyProperty RowColumnSizeProperty { get; }
void ChangeSize(double delta)
{
// delta = difference in pixels
if (delta < -originalPixelSize1) delta = -originalPixelSize1;
if (delta > originalPixelSize2) delta = originalPixelSize2;
// replace Auto lengths with absolute lengths if necessary
if (original1.IsAuto) original1 = new GridLength(originalPixelSize1);
if (original2.IsAuto) original2 = new GridLength(originalPixelSize2);
GridLength new1;
if (original1.IsStar && originalPixelSize1 > 0)
new1 = new GridLength(original1.Value * (originalPixelSize1 + delta) / originalPixelSize1, GridUnitType.Star);
else
new1 = new GridLength(originalPixelSize1 + delta);
GridLength new2;
if (original2.IsStar && originalPixelSize2 > 0)
new2 = new GridLength(original2.Value * (originalPixelSize2 - delta) / originalPixelSize2, GridUnitType.Star);
else
new2 = new GridLength(originalPixelSize2 - delta);
firstRow.Properties[RowColumnSizeProperty].SetValue(new1);
secondRow.Properties[RowColumnSizeProperty].SetValue(new2);
UIElement e = ((UIElement)VisualTreeHelper.GetParent(this));
e.InvalidateArrange();
rail.InvalidateVisual();
}
protected override void OnMouseUp(MouseButtonEventArgs e)
{
if (activeChangeGroup != null) {
activeChangeGroup.Commit();
activeChangeGroup = null;
}
Stop();
}
protected override void OnLostMouseCapture(MouseEventArgs e)
{
Stop();
}
protected override void OnKeyDown(KeyEventArgs e)
{
if (e.Key == Key.Escape) {
e.Handled = true;
Stop();
}
}
protected void Stop()
{
ReleaseMouseCapture();
mouseIsDown = false;
if (activeChangeGroup != null) {
activeChangeGroup.Abort();
activeChangeGroup = null;
}
}
}
public class GridRowSplitterAdorner : GridSplitterAdorner
{
static GridRowSplitterAdorner()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(GridRowSplitterAdorner), new FrameworkPropertyMetadata(typeof(GridRowSplitterAdorner)));
CursorProperty.OverrideMetadata(typeof(GridRowSplitterAdorner), new FrameworkPropertyMetadata(Cursors.SizeNS));
}
internal GridRowSplitterAdorner(GridRailAdorner rail, DesignItem gridItem, DesignItem firstRow, DesignItem secondRow)
: base(rail, gridItem, firstRow, secondRow)
{
}
protected override double GetCoordinate(Point point)
{
return point.Y;
}
protected override void RememberOriginalSize()
{
RowDefinition r1 = (RowDefinition)firstRow.Component;
RowDefinition r2 = (RowDefinition)secondRow.Component;
original1 = (GridLength)r1.GetValue(RowDefinition.HeightProperty);
original2 = (GridLength)r2.GetValue(RowDefinition.HeightProperty);
originalPixelSize1 = r1.ActualHeight;
originalPixelSize2 = r2.ActualHeight;
}
protected override DependencyProperty RowColumnSizeProperty {
get { return RowDefinition.HeightProperty; }
}
}
public sealed class GridColumnSplitterAdorner : GridSplitterAdorner
{
static GridColumnSplitterAdorner()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(GridColumnSplitterAdorner), new FrameworkPropertyMetadata(typeof(GridColumnSplitterAdorner)));
CursorProperty.OverrideMetadata(typeof(GridColumnSplitterAdorner), new FrameworkPropertyMetadata(Cursors.SizeWE));
}
internal GridColumnSplitterAdorner(GridRailAdorner rail, DesignItem gridItem, DesignItem firstRow, DesignItem secondRow)
: base(rail, gridItem, firstRow, secondRow)
{
}
protected override double GetCoordinate(Point point)
{
return point.X;
}
protected override void RememberOriginalSize()
{
ColumnDefinition r1 = (ColumnDefinition)firstRow.Component;
ColumnDefinition r2 = (ColumnDefinition)secondRow.Component;
original1 = (GridLength)r1.GetValue(ColumnDefinition.WidthProperty);
original2 = (GridLength)r2.GetValue(ColumnDefinition.WidthProperty);
originalPixelSize1 = r1.ActualWidth;
originalPixelSize2 = r2.ActualWidth;
}
protected override DependencyProperty RowColumnSizeProperty {
get { return ColumnDefinition.WidthProperty; }
}
}
}

60
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridUnitSelector.xaml

@ -1,60 +0,0 @@ @@ -1,60 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<UserControl
x:Class="ICSharpCode.WpfDesign.Designer.Controls.GridUnitSelector" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Name="control"
HorizontalContentAlignment="Left"
VerticalContentAlignment="Top">
<UserControl.Resources>
<Style
TargetType="RadioButton">
<Setter
Property="Template">
<Setter.Value>
<ControlTemplate>
<ToggleButton
IsChecked="{Binding Path=IsChecked, RelativeSource={RelativeSource TemplatedParent}, Mode=TwoWay}"
Content="{Binding Path=Content, RelativeSource={RelativeSource TemplatedParent}}"
Padding="{Binding Path=Padding, RelativeSource={RelativeSource TemplatedParent}}"
Name="toggleButton" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Border
CornerRadius="3"
BorderBrush="CornflowerBlue"
Background="LightBlue"
BorderThickness="1">
<StackPanel
Orientation="{Binding Orientation, ElementName=control}">
<RadioButton
x:Name="fixed"
Content="Fixed"
Margin="1"
FontSize="8"
ToolTip="Fixed - Column size is fixed width"
GroupName="group"
Checked="FixedChecked" />
<RadioButton
x:Name="star"
Margin="1"
FontSize="16"
ToolTip="Star - Column size is weighted proportion"
GroupName="group"
Checked="StarChecked">
<TextBlock
Text="*"
Margin="3,-4,3,-8" />
</RadioButton>
<RadioButton
x:Name="auto"
Content="Auto"
Margin="1"
FontSize="8"
ToolTip="Auto - Column size is determined by the Content(s)"
GroupName="group"
Checked="AutoChecked" />
</StackPanel>
</Border>
</UserControl>

122
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridUnitSelector.xaml.cs

@ -1,122 +0,0 @@ @@ -1,122 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Interaction logic for GridUnitSelector.xaml
/// </summary>
public partial class GridUnitSelector : UserControl
{
GridRailAdorner rail;
public GridUnitSelector(GridRailAdorner rail)
{
SpecialInitializeComponent();
this.rail = rail;
}
/// <summary>
/// Fixes InitializeComponent with multiple Versions of same Assembly loaded
/// </summary>
public void SpecialInitializeComponent()
{
if (!this._contentLoaded) {
this._contentLoaded = true;
Uri resourceLocator = new Uri(VersionedAssemblyResourceDictionary.GetXamlNameForType(this.GetType()), UriKind.Relative);
Application.LoadComponent(this, resourceLocator);
}
this.InitializeComponent();
}
void FixedChecked(object sender, RoutedEventArgs e)
{
this.rail.SetGridLengthUnit(Unit);
}
void StarChecked(object sender, RoutedEventArgs e)
{
this.rail.SetGridLengthUnit(Unit);
}
void AutoChecked(object sender, RoutedEventArgs e)
{
this.rail.SetGridLengthUnit(Unit);
}
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(GridUnitSelector),
new FrameworkPropertyMetadata());
public Orientation Orientation
{
get { return (Orientation)GetValue(OrientationProperty); }
set { SetValue(OrientationProperty, value); }
}
public DesignItem SelectedItem { get; set; }
public GridUnitType Unit
{
get
{
if (auto.IsChecked == true)
return GridUnitType.Auto;
if (star.IsChecked == true)
return GridUnitType.Star;
return GridUnitType.Pixel;
}
set
{
switch (value)
{
case GridUnitType.Auto:
auto.IsChecked = true;
break;
case GridUnitType.Star:
star.IsChecked = true;
break;
default:
@fixed.IsChecked = true;
break;
}
}
}
protected override void OnMouseLeave(MouseEventArgs e)
{
base.OnMouseLeave(e);
this.Visibility = Visibility.Hidden;
}
}
}

207
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/InPlaceEditor.cs

@ -1,207 +0,0 @@ @@ -1,207 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Data;
using System.Windows.Markup.Primitives;
using System.Windows.Controls;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Supports editing Text in the Designer
/// </summary>
public class InPlaceEditor : TextBox
{
static InPlaceEditor()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof (InPlaceEditor), new FrameworkPropertyMetadata(typeof (InPlaceEditor)));
}
/// <summary>
/// This property is binded to the Text Property of the editor.
/// </summary>
public static readonly DependencyProperty BindProperty =
DependencyProperty.Register("Bind", typeof (string), typeof (InPlaceEditor), new FrameworkPropertyMetadata());
public string Bind{
get { return (string) GetValue(BindProperty); }
set { SetValue(BindProperty, value); }
}
readonly DesignItem designItem;
ChangeGroup changeGroup;
TextBlock textBlock;
TextBox editor;
bool _isChangeGroupOpen;
/// <summary>
/// This is the name of the property that is being edited for example Window.Title, Button.Content .
/// </summary>
string property;
public InPlaceEditor(DesignItem designItem)
{
this.designItem=designItem;
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
editor = new TextBox();
editor = Template.FindName("editor", this) as TextBox; // Gets the TextBox-editor from the Template
Debug.Assert(editor != null);
editor.PreviewKeyDown+= delegate(object sender, KeyEventArgs e) {
if (e.Key == Key.Enter && (e.KeyboardDevice.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift)
{
e.Handled = true;
} };
ToolTip = "Edit the Text. Press"+Environment.NewLine+"Enter to make changes."+Environment.NewLine+"Shift+Enter to insert a newline."+Environment.NewLine+"Esc to cancel editing.";
}
/// <summary>
/// Binds the Text Property of the element extended with <see cref="Bind"/>.
/// </summary>
/// <param name="textBlock"></param>
public void SetBinding(TextBlock textBlock)
{
Debug.Assert(textBlock!=null);
this.textBlock = textBlock;
Binding binding = new Binding("Text");
binding.Source = this.textBlock;
binding.Mode = BindingMode.TwoWay;
SetBinding(BindProperty, binding);
property=PropertyUpdated(textBlock);
}
/// <summary>
/// Returns the property that is being edited in the element for example editing Window Title returns "Title",
/// Button text as "Content".
/// </summary>
private string PropertyUpdated(TextBlock text)
{
MarkupObject obj = MarkupWriter.GetMarkupObjectFor(designItem.Component);
foreach (MarkupProperty property in obj.Properties) {
if (property.DependencyProperty != null && property.StringValue == textBlock.Text)
return property.Name;
}
return null;
}
protected override void OnGotKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
base.OnGotKeyboardFocus(e);
StartEditing();
}
protected override void OnLostKeyboardFocus(KeyboardFocusChangedEventArgs e)
{
if (changeGroup != null && _isChangeGroupOpen){
changeGroup.Abort();
_isChangeGroupOpen=false;
}
if (textBlock != null)
textBlock.Visibility = Visibility.Visible;
Reset();
base.OnLostKeyboardFocus(e);
}
/// <summary>
/// Change is committed if the user releases the Escape Key.
/// </summary>
/// <param name="e"></param>
protected override void OnKeyUp(KeyEventArgs e)
{
base.OnKeyUp(e);
if(e.KeyboardDevice.Modifiers != ModifierKeys.Shift) {
switch(e.Key) {
case Key.Enter:
// Commit the changes to DOM.
if(property!=null)
designItem.Properties[property].SetValue(Bind);
if(designItem.Properties[Control.FontFamilyProperty].ValueOnInstance!=editor.FontFamily)
designItem.Properties[Control.FontFamilyProperty].SetValue(editor.FontFamily);
if((double)designItem.Properties[Control.FontSizeProperty].ValueOnInstance!=editor.FontSize)
designItem.Properties[Control.FontSizeProperty].SetValue(editor.FontSize);
if((FontStretch)designItem.Properties[Control.FontStretchProperty].ValueOnInstance!=editor.FontStretch)
designItem.Properties[Control.FontStretchProperty].SetValue(editor.FontStretch);
if((FontStyle)designItem.Properties[Control.FontStyleProperty].ValueOnInstance!=editor.FontStyle)
designItem.Properties[Control.FontStyleProperty].SetValue(editor.FontStyle);
if((FontWeight)designItem.Properties[Control.FontWeightProperty].ValueOnInstance!=editor.FontWeight)
designItem.Properties[Control.FontWeightProperty].SetValue(editor.FontWeight);
if (changeGroup != null && _isChangeGroupOpen){
changeGroup.Commit();
_isChangeGroupOpen=false;
}
changeGroup = null;
this.Visibility = Visibility.Hidden;
textBlock.Visibility = Visibility.Visible;
break;
case Key.Escape:
AbortEditing();
break;
}
}else if(e.Key == Key.Enter){
editor.Text.Insert(editor.CaretIndex, Environment.NewLine);
}
}
private void Reset()
{
if (textBlock != null) {
if (property != null)
textBlock.Text = (string) designItem.Properties[property].ValueOnInstance;
textBlock.FontFamily = (System.Windows.Media.FontFamily)designItem.Properties[Control.FontFamilyProperty].ValueOnInstance;
textBlock.FontSize = (double) designItem.Properties[Control.FontSizeProperty].ValueOnInstance;
textBlock.FontStretch = (FontStretch) designItem.Properties[Control.FontStretchProperty].ValueOnInstance;
textBlock.FontStretch = (FontStretch) designItem.Properties[Control.FontStretchProperty].ValueOnInstance;
textBlock.FontWeight = (FontWeight) designItem.Properties[Control.FontWeightProperty].ValueOnInstance;
}
}
public void AbortEditing()
{
if(changeGroup!=null && _isChangeGroupOpen){
Reset();
changeGroup.Abort();
_isChangeGroupOpen=false;
}
this.Visibility= Visibility.Hidden;
if(textBlock!=null)
textBlock.Visibility=Visibility.Visible;
Reset();
}
public void StartEditing()
{
if(changeGroup==null){
changeGroup = designItem.OpenGroup("Change Text");
_isChangeGroupOpen=true;
}
this.Visibility=Visibility.Visible;
if(textBlock!=null)
textBlock.Visibility=Visibility.Hidden;
}
}
}

116
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/InfoTextEnterArea.cs

@ -1,116 +0,0 @@ @@ -1,116 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Threading;
using System.Windows.Media.Animation;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Services;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Gray out everything except a specific area.
/// </summary>
sealed class InfoTextEnterArea : FrameworkElement
{
Geometry designSurfaceRectangle;
Geometry activeAreaGeometry;
Geometry combinedGeometry;
AdornerPanel adornerPanel;
IDesignPanel designPanel;
const double MaxOpacity = 0.3;
public InfoTextEnterArea()
{
this.IsHitTestVisible = false;
}
public Geometry ActiveAreaGeometry {
get { return activeAreaGeometry; }
set {
activeAreaGeometry = value;
combinedGeometry = activeAreaGeometry;
}
}
Rect currentAnimateActiveAreaRectToTarget;
internal void AnimateActiveAreaRectTo(Rect newRect)
{
if (newRect.Equals(currentAnimateActiveAreaRectToTarget))
return;
activeAreaGeometry.BeginAnimation(
RectangleGeometry.RectProperty,
new RectAnimation(newRect, new Duration(new TimeSpan(0,0,0,0,100))),
HandoffBehavior.SnapshotAndReplace);
currentAnimateActiveAreaRectToTarget = newRect;
}
internal static void Start(ref InfoTextEnterArea grayOut, ServiceContainer services, UIElement activeContainer, string text)
{
Debug.Assert(activeContainer != null);
Start(ref grayOut, services, activeContainer, new Rect(activeContainer.RenderSize), text);
}
internal static void Start(ref InfoTextEnterArea grayOut, ServiceContainer services, UIElement activeContainer, Rect activeRectInActiveContainer, string text)
{
Debug.Assert(services != null);
Debug.Assert(activeContainer != null);
DesignPanel designPanel = services.GetService<IDesignPanel>() as DesignPanel;
OptionService optionService = services.GetService<OptionService>();
if (designPanel != null && grayOut == null && optionService != null && optionService.GrayOutDesignSurfaceExceptParentContainerWhenDragging) {
grayOut = new InfoTextEnterArea();
grayOut.designSurfaceRectangle = new RectangleGeometry(
new Rect(0, 0, ((Border)designPanel.Child).Child.RenderSize.Width, ((Border)designPanel.Child).Child.RenderSize.Height));
grayOut.designPanel = designPanel;
grayOut.adornerPanel = new AdornerPanel();
grayOut.adornerPanel.Order = AdornerOrder.Background;
grayOut.adornerPanel.SetAdornedElement(designPanel.Context.RootItem.View, null);
grayOut.ActiveAreaGeometry = new RectangleGeometry(activeRectInActiveContainer, 0, 0, (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement));
var tb = new TextBlock(){Text = text};
tb.FontSize = 10;
tb.ClipToBounds = true;
tb.Width = ((FrameworkElement) activeContainer).ActualWidth;
tb.Height = ((FrameworkElement) activeContainer).ActualHeight;
tb.VerticalAlignment = VerticalAlignment.Top;
tb.HorizontalAlignment = HorizontalAlignment.Left;
tb.RenderTransform = (Transform)activeContainer.TransformToVisual(grayOut.adornerPanel.AdornedElement);
grayOut.adornerPanel.Children.Add(tb);
designPanel.Adorners.Add(grayOut.adornerPanel);
}
}
static readonly TimeSpan animationTime = new TimeSpan(2000000);
internal static void Stop(ref InfoTextEnterArea grayOut)
{
if (grayOut != null) {
IDesignPanel designPanel = grayOut.designPanel;
AdornerPanel adornerPanelToRemove = grayOut.adornerPanel;
designPanel.Adorners.Remove(adornerPanelToRemove);
grayOut = null;
}
}
}
}

359
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/MarginHandle.cs

@ -1,359 +0,0 @@ @@ -1,359 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Input;
using System.Globalization;
using System.ComponentModel;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Adorner that displays the margin of a control in a Grid.
/// </summary>
public class MarginHandle : Control
{
/// <summary>
/// Places the Handle with a certain offset so the Handle does not interfere with selection outline.
/// </summary>
public static double HandleLengthOffset;
static MarginHandle()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MarginHandle), new FrameworkPropertyMetadata(typeof(MarginHandle)));
HandleLengthOffset=2;
}
/// <summary>
/// Dependency property for <see cref="HandleLength"/>.
/// </summary>
public static readonly DependencyProperty HandleLengthProperty
= DependencyProperty.Register("HandleLength", typeof(double), typeof(MarginHandle), new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.AffectsRender, new PropertyChangedCallback(OnHandleLengthChanged)));
/// <summary>
/// Gets/Sets the length of Margin Handle.
/// </summary>
public double HandleLength{
get { return (double)GetValue(HandleLengthProperty); }
set { SetValue(HandleLengthProperty, value); }
}
readonly Grid grid;
readonly DesignItem adornedControlItem;
readonly AdornerPanel adornerPanel;
readonly HandleOrientation orientation;
readonly FrameworkElement adornedControl;
/// <summary> This grid contains the handle line and the endarrow.</summary>
Grid lineArrow;
/// <summary>
/// Gets the Stub for this handle
/// </summary>
public MarginStub Stub {get; protected set;}
/// <summary>
/// Gets/Sets the angle by which handle rotates.
/// </summary>
public double Angle { get; set; }
/// <summary>
/// Gets/Sets the angle by which the Margin display has to be rotated
/// </summary>
public virtual double TextTransform{
get{
if((double)orientation==90 || (double)orientation == 180)
return 180;
if ((double)orientation == 270)
return 0;
return (double)orientation;
}
set{ }
}
/// <summary>
/// Decides the visiblity of handle/stub when <see cref="HandleLength"/> changes
/// </summary>
/// <param name="d"></param>
/// <param name="e"></param>
public static void OnHandleLengthChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
MarginHandle mar=(MarginHandle)d;
mar.DecideVisiblity((double)e.NewValue);
}
/// <summary>
/// Decides whether to permanently display the handle or not.
/// </summary>
public bool ShouldBeVisible { get; set; }
/// <summary>
/// Decides whether stub has to be only displayed.
/// </summary>
public bool DisplayOnlyStub { get; set; }
/// <summary>
/// Gets the orientation of the handle.
/// </summary>
public HandleOrientation Orientation {
get { return orientation; }
}
protected MarginHandle()
{ }
public MarginHandle(DesignItem adornedControlItem, AdornerPanel adornerPanel, HandleOrientation orientation)
{
Debug.Assert(adornedControlItem!=null);
this.adornedControlItem = adornedControlItem;
this.adornerPanel = adornerPanel;
this.orientation = orientation;
Angle = (double)orientation;
grid=(Grid)adornedControlItem.Parent.Component;
adornedControl=(FrameworkElement)adornedControlItem.Component;
Stub = new MarginStub(this);
ShouldBeVisible=true;
BindAndPlaceHandle();
adornedControlItem.PropertyChanged += OnPropertyChanged;
OnPropertyChanged(this.adornedControlItem, new PropertyChangedEventArgs("HorizontalAlignment"));
OnPropertyChanged(this.adornedControlItem, new PropertyChangedEventArgs("VerticalAlignment"));
}
/// <summary>
/// Binds the <see cref="HandleLength"/> to the margin and place the handles.
/// </summary>
void BindAndPlaceHandle()
{
if (!adornerPanel.Children.Contains(this))
adornerPanel.Children.Add(this);
if (!adornerPanel.Children.Contains(Stub))
adornerPanel.Children.Add(Stub);
RelativePlacement placement=new RelativePlacement();
Binding binding = new Binding();
binding.Source = adornedControl;
switch (orientation)
{
case HandleOrientation.Left:
binding.Path = new PropertyPath("Margin.Left");
placement = new RelativePlacement(HorizontalAlignment.Left, VerticalAlignment.Center);
placement.XOffset=-HandleLengthOffset;
break;
case HandleOrientation.Top:
binding.Path = new PropertyPath("Margin.Top");
placement = new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Top);
placement.YOffset=-HandleLengthOffset;
break;
case HandleOrientation.Right:
binding.Path = new PropertyPath("Margin.Right");
placement = new RelativePlacement(HorizontalAlignment.Right, VerticalAlignment.Center);
placement.XOffset=HandleLengthOffset;
break;
case HandleOrientation.Bottom:
binding.Path = new PropertyPath("Margin.Bottom");
placement = new RelativePlacement(HorizontalAlignment.Center, VerticalAlignment.Bottom);
placement.YOffset=HandleLengthOffset;
break;
}
binding.Mode = BindingMode.TwoWay;
SetBinding(HandleLengthProperty, binding);
AdornerPanel.SetPlacement(this, placement);
AdornerPanel.SetPlacement(Stub, placement);
DecideVisiblity(this.HandleLength);
}
/// <summary>
/// Decides the visibllity of Handle or stub,whichever is set and hides the line-endarrow if the control is near the Grid or goes out of it.
/// </summary>
public void DecideVisiblity(double handleLength)
{
if (ShouldBeVisible)
{
if (!DisplayOnlyStub)
{
this.Visibility = handleLength != 0.0 ? Visibility.Visible : Visibility.Hidden;
if (this.lineArrow != null)
{
lineArrow.Visibility = handleLength < 25 ? Visibility.Hidden : Visibility.Visible;
}
Stub.Visibility = this.Visibility == Visibility.Visible ? Visibility.Hidden : Visibility.Visible;
}
else
{
this.Visibility = Visibility.Hidden;
Stub.Visibility = Visibility.Visible;
}
}
else {
this.Visibility = Visibility.Hidden;
Stub.Visibility = Visibility.Hidden;
}
}
void OnPropertyChanged(object sender,PropertyChangedEventArgs e)
{
if(e.PropertyName=="HorizontalAlignment" && (orientation==HandleOrientation.Left || orientation==HandleOrientation.Right)) {
var ha = (HorizontalAlignment) adornedControlItem.Properties[FrameworkElement.HorizontalAlignmentProperty].ValueOnInstance;
if(ha==HorizontalAlignment.Stretch) {
DisplayOnlyStub = false;
}else if(ha==HorizontalAlignment.Center) {
DisplayOnlyStub = true;
} else
DisplayOnlyStub = ha.ToString() != orientation.ToString();
}
if(e.PropertyName=="VerticalAlignment" && (orientation==HandleOrientation.Top || orientation==HandleOrientation.Bottom)) {
var va = (VerticalAlignment)adornedControlItem.Properties[FrameworkElement.VerticalAlignmentProperty].ValueOnInstance;
if(va==VerticalAlignment.Stretch) {
DisplayOnlyStub = false;
} else if(va==VerticalAlignment.Center) {
DisplayOnlyStub = true;
} else
DisplayOnlyStub = va.ToString() != orientation.ToString();
}
DecideVisiblity(this.HandleLength);
}
protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseEnter(e);
this.Cursor = Cursors.Hand;
}
protected override void OnMouseLeave(MouseEventArgs e)
{
base.OnMouseLeave(e);
this.Cursor = Cursors.Arrow;
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
lineArrow = new Grid();
lineArrow = (Grid)Template.FindName("lineArrow", this) as Grid;
Debug.Assert(lineArrow != null);
}
}
/// <summary>
/// Display a stub indicating that the margin is not set.
/// </summary>
public class MarginStub : Control
{
MarginHandle marginHandle;
/// <summary>
/// Gets the margin handle using this stub.
/// </summary>
public MarginHandle Handle{
get { return marginHandle; }
}
static MarginStub()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(MarginStub), new FrameworkPropertyMetadata(typeof(MarginStub)));
}
public MarginStub(MarginHandle marginHandle)
{
this.marginHandle = marginHandle;
}
protected override void OnMouseLeftButtonDown(System.Windows.Input.MouseButtonEventArgs e)
{
base.OnMouseLeftButtonDown(e);
marginHandle.DecideVisiblity(marginHandle.HandleLength);
}
protected override void OnMouseEnter(System.Windows.Input.MouseEventArgs e)
{
base.OnMouseEnter(e);
this.Cursor = Cursors.Hand;
}
protected override void OnMouseLeave(MouseEventArgs e)
{
base.OnMouseLeave(e);
this.Cursor = Cursors.Arrow;
}
}
/// <summary>
/// Specifies the Handle orientation
/// </summary>
public enum HandleOrientation
{
/* Rotation of the handle is done with respect to right orientation and in clockwise direction*/
/// <summary>
/// Indicates that the margin handle is left-oriented and rotated 180 degrees with respect to <see cref="Right"/>.
/// </summary>
Left = 180,
/// <summary>
/// Indicates that the margin handle is top-oriented and rotated 270 degrees with respect to <see cref="Right"/>.
/// </summary>
Top = 270,
/// <summary>
/// Indicates that the margin handle is right.
/// </summary>
Right = 0,
/// <summary>
/// Indicates that the margin handle is left-oriented and rotated 180 degrees with respect to <see cref="Right"/>.
/// </summary>
Bottom = 90
}
}
namespace ICSharpCode.WpfDesign.Designer.Controls.Converters
{
/// <summary>
/// Offset the Handle Length with MarginHandle.HandleLengthOffset
/// </summary>
public class HandleLengthWithOffset : IValueConverter
{
public static HandleLengthWithOffset Instance = new HandleLengthWithOffset();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if(value is double) {
return Math.Max((double)value - MarginHandle.HandleLengthOffset,0);
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
}

68
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NullableComboBox.cs

@ -1,68 +0,0 @@ @@ -1,68 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A ComboBox wich is Nullable
/// </summary>
public class NullableComboBox : ComboBox
{
static NullableComboBox()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(NullableComboBox), new FrameworkPropertyMetadata(typeof(NullableComboBox)));
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var btn = GetTemplateChild("PART_ClearButton") as Button;
btn.Click += btn_Click;
}
void btn_Click(object sender, RoutedEventArgs e)
{
var clearButton = (Button)sender;
var parent = VisualTreeHelper.GetParent(clearButton);
while (!(parent is ComboBox))
{
parent = VisualTreeHelper.GetParent(parent);
}
var comboBox = (ComboBox)parent;
comboBox.SelectedIndex = -1;
}
public bool IsNullable
{
get { return (bool)GetValue(IsNullableProperty); }
set { SetValue(IsNullableProperty, value); }
}
public static readonly DependencyProperty IsNullableProperty =
DependencyProperty.Register("IsNullable", typeof(bool), typeof(NullableComboBox), new PropertyMetadata(true));
}
}

249
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NullableComboBox.xaml

@ -1,249 +0,0 @@ @@ -1,249 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
xmlns:local="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls"
xmlns:converters="clr-namespace:ICSharpCode.WpfDesign.Designer.Converters">
<converters:CollapsedWhenFalse x:Key="TrueVisibleConverter" />
<Style x:Key="ClearSelectionButtonStyle" TargetType="Button">
<Setter Property="Background" Value="#FF3C688D"/>
<Setter Property="BorderBrush" Value="#FF617584"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Width" Value="15"/>
<Setter Property="Height" Value="15"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="Transparent">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver">
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MouseOverElement">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Pressed">
<Storyboard>
<ObjectAnimationUsingKeyFrames Duration="0" Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="MouseOverElement">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<VisualState x:Name="Disabled"/>
</VisualStateGroup>
<VisualStateGroup x:Name="FocusStates">
<VisualState x:Name="Focused"/>
<VisualState x:Name="Unfocused"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Border x:Name="MouseOverElement" BorderThickness="{TemplateBinding BorderThickness}" Background="#FFC8E4ED" BorderBrush="#FF3F6A8E" Visibility="Collapsed"/>
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" HorizontalAlignment="Center" Margin="{TemplateBinding Padding}" VerticalAlignment="Center"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ComboBoxFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="4,4,21,4" SnapsToDevicePixels="true" Stroke="Black" StrokeThickness="1" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<LinearGradientBrush x:Key="ButtonNormalBackground" EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#F3F3F3" Offset="0"/>
<GradientStop Color="#EBEBEB" Offset="0.5"/>
<GradientStop Color="#DDDDDD" Offset="0.5"/>
<GradientStop Color="#CDCDCD" Offset="1"/>
</LinearGradientBrush>
<SolidColorBrush x:Key="ButtonNormalBorder" Color="#FF707070"/>
<Geometry x:Key="DownArrowGeometry">M 0 0 L 3.5 4 L 7 0 Z</Geometry>
<Style x:Key="ComboBoxReadonlyToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="ClickMode" Value="Press"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Themes:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" SnapsToDevicePixels="true">
<Grid HorizontalAlignment="Right" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
<Path x:Name="Arrow" Data="{StaticResource DownArrowGeometry}" Fill="Black" HorizontalAlignment="Center" Margin="3,1,0,0" VerticalAlignment="Center"/>
</Grid>
</Themes:ButtonChrome>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="RenderPressed" TargetName="Chrome" Value="true"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="Arrow" Value="#AFAFAF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<LinearGradientBrush x:Key="TextBoxBorder" EndPoint="0,20" MappingMode="Absolute" StartPoint="0,0">
<GradientStop Color="#ABADB3" Offset="0.05"/>
<GradientStop Color="#E2E3EA" Offset="0.07"/>
<GradientStop Color="#E3E9EF" Offset="1"/>
</LinearGradientBrush>
<Style x:Key="ComboBoxEditableTextBox" TargetType="{x:Type TextBox}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="AllowDrop" Value="true"/>
<Setter Property="MinWidth" Value="0"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TextBox}">
<ScrollViewer x:Name="PART_ContentHost" Background="Transparent" Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ComboBoxToggleButton" TargetType="{x:Type ToggleButton}">
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Focusable" Value="false"/>
<Setter Property="ClickMode" Value="Press"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ToggleButton}">
<Themes:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" RoundCorners="false" SnapsToDevicePixels="true" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
<Path x:Name="Arrow" Data="{StaticResource DownArrowGeometry}" Fill="Black" HorizontalAlignment="Center" Margin="0,1,0,0" VerticalAlignment="Center"/>
</Themes:ButtonChrome>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="true">
<Setter Property="RenderPressed" TargetName="Chrome" Value="true"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Fill" TargetName="Arrow" Value="#AFAFAF"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<ControlTemplate x:Key="ComboBoxEditableTemplate" TargetType="{x:Type ComboBox}">
<Grid x:Name="Placement" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
<Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=Placement}">
<Border x:Name="DropDownBorder" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
<ScrollViewer>
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
</Themes:SystemDropShadowChrome>
</Popup>
<Themes:ListBoxChrome x:Name="Border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}"/>
<TextBox x:Name="PART_EditableTextBox" Margin="3,3,23,3" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxEditableTextBox}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"/>
<ToggleButton Grid.Column="1" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxToggleButton}"/>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsKeyboardFocusWithin" Value="true">
<Setter Property="Foreground" Value="Black"/>
</Trigger>
<Trigger Property="IsDropDownOpen" Value="true">
<Setter Property="RenderFocused" TargetName="Border" Value="true"/>
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
<Setter Property="Background" Value="#FFF4F4F4"/>
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style TargetType="{x:Type local:NullableComboBox}">
<Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
<Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Padding" Value="4,3"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type local:NullableComboBox}">
<Grid x:Name="MainGrid" SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
</Grid.ColumnDefinitions>
<Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
<Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=MainGrid}">
<Border x:Name="DropDownBorder" BorderBrush="{DynamicResource {x:Static SystemColors.WindowFrameBrushKey}}" BorderThickness="1" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}">
<ScrollViewer CanContentScroll="true">
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
</Themes:SystemDropShadowChrome>
</Popup>
<ToggleButton BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{StaticResource ComboBoxReadonlyToggleButton}"/>
<ContentPresenter ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="3,3,18,3" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
<Button Style="{StaticResource ClearSelectionButtonStyle}" x:Name="PART_ClearButton" Visibility="{Binding IsNullable, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource TrueVisibleConverter}}" HorizontalAlignment="Right" Margin="0,0,0,0">
<Path Data="M0,0 L1.6,0 L3,1.56 L4.4,0 L6,0 L3.8,2.5 L6,5 L4.4,5 L3,3.49 L1.59,5 L-4.2E-09,5 L2.18,2.5 z" Fill="#CC111111" Height="5" Stretch="Fill" Width="7"/>
</Button>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="true">
<Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
<Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
</Trigger>
<Trigger Property="HasItems" Value="false">
<Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
</Trigger>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
<Setter Property="Background" Value="#FFF4F4F4"/>
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEditable" Value="true">
<Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}"/>
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="IsTabStop" Value="false"/>
<Setter Property="Padding" Value="3"/>
<Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}"/>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary>

323
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.cs

@ -1,323 +0,0 @@ @@ -1,323 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class NumericUpDown : Control
{
static NumericUpDown()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(NumericUpDown),
new FrameworkPropertyMetadata(typeof(NumericUpDown)));
}
TextBox textBox;
DragRepeatButton upButton;
DragRepeatButton downButton;
public static readonly DependencyProperty DecimalPlacesProperty =
DependencyProperty.Register("DecimalPlaces", typeof(int), typeof(NumericUpDown));
public int DecimalPlaces {
get { return (int)GetValue(DecimalPlacesProperty); }
set { SetValue(DecimalPlacesProperty, value); }
}
public static readonly DependencyProperty MinimumProperty =
DependencyProperty.Register("Minimum", typeof(double), typeof(NumericUpDown));
public double Minimum {
get { return (double)GetValue(MinimumProperty); }
set { SetValue(MinimumProperty, value); }
}
public static readonly DependencyProperty MaximumProperty =
DependencyProperty.Register("Maximum", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(100.0));
public double Maximum {
get { return (double)GetValue(MaximumProperty); }
set { SetValue(MaximumProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public double Value {
get { return (double)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
public static readonly DependencyProperty SmallChangeProperty =
DependencyProperty.Register("SmallChange", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(1.0));
public double SmallChange {
get { return (double)GetValue(SmallChangeProperty); }
set { SetValue(SmallChangeProperty, value); }
}
public static readonly DependencyProperty LargeChangeProperty =
DependencyProperty.Register("LargeChange", typeof(double), typeof(NumericUpDown),
new FrameworkPropertyMetadata(10.0));
public double LargeChange {
get { return (double)GetValue(LargeChangeProperty); }
set { SetValue(LargeChangeProperty, value); }
}
bool IsDragging {
get {
return upButton.IsDragging;
}
set {
upButton.IsDragging = value; downButton.IsDragging = value;
}
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
upButton = (DragRepeatButton)Template.FindName("PART_UpButton", this);
downButton = (DragRepeatButton)Template.FindName("PART_DownButton", this);
textBox = (TextBox)Template.FindName("PART_TextBox", this);
upButton.Click += upButton_Click;
downButton.Click += downButton_Click;
textBox.LostFocus += (sender, e) => OnLostFocus(e);
var upDrag = new DragListener(upButton);
var downDrag = new DragListener(downButton);
upDrag.Started += drag_Started;
upDrag.Changed += drag_Changed;
upDrag.Completed += drag_Completed;
downDrag.Started += drag_Started;
downDrag.Changed += drag_Changed;
downDrag.Completed += drag_Completed;
Print();
}
void drag_Started(DragListener drag)
{
OnDragStarted();
}
void drag_Changed(DragListener drag)
{
IsDragging = true;
MoveValue(-drag.DeltaDelta.Y * SmallChange);
}
void drag_Completed(DragListener drag)
{
IsDragging = false;
OnDragCompleted();
}
void downButton_Click(object sender, RoutedEventArgs e)
{
if (!IsDragging) SmallDown();
}
void upButton_Click(object sender, RoutedEventArgs e)
{
if (!IsDragging) SmallUp();
}
protected virtual void OnDragStarted()
{
}
protected virtual void OnDragCompleted()
{
}
public void SmallUp()
{
MoveValue(SmallChange);
}
public void SmallDown()
{
MoveValue(-SmallChange);
}
public void LargeUp()
{
MoveValue(LargeChange);
}
public void LargeDown()
{
MoveValue(-LargeChange);
}
void MoveValue(double delta)
{
double result;
if (double.IsNaN(Value) || double.IsInfinity(Value)) {
SetValue(delta);
}
else if (double.TryParse(textBox.Text, out result)) {
SetValue(result + delta);
}
else {
SetValue(Value + delta);
}
}
void Print()
{
if (textBox != null) {
textBox.Text = Value.ToString("F" + DecimalPlaces);
textBox.CaretIndex = int.MaxValue;
}
}
//wpf bug?: Value = -1 updates bindings without coercing, workaround
//update: not derived from RangeBase - no problem
void SetValue(double newValue)
{
newValue = CoerceValue(newValue);
if (Value != newValue) {
Value = newValue;
}
}
double CoerceValue(double newValue)
{
return Math.Max(Minimum, Math.Min(newValue, Maximum));
}
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
base.OnPreviewKeyDown(e);
switch (e.Key) {
case Key.Enter:
SetInputValue();
textBox.SelectAll();
e.Handled = true;
break;
case Key.Up:
SmallUp();
e.Handled = true;
break;
case Key.Down:
SmallDown();
e.Handled = true;
break;
case Key.PageUp:
LargeUp();
e.Handled = true;
break;
case Key.PageDown:
LargeDown();
e.Handled = true;
break;
// case Key.Home:
// Maximize();
// e.Handled = true;
// break;
// case Key.End:
// Minimize();
// e.Handled = true;
// break;
}
}
void SetInputValue()
{
double result;
if (double.TryParse(textBox.Text, out result)) {
SetValue(result);
} else {
Print();
}
}
protected override void OnLostFocus(RoutedEventArgs e)
{
base.OnLostFocus(e);
SetInputValue();
}
//protected override void OnMouseWheel(MouseWheelEventArgs e)
//{
// if (e.Delta > 0)
// {
// if (Keyboard.IsKeyDown(Key.LeftShift))
// {
// LargeUp();
// }
// else
// {
// SmallUp();
// }
// }
// else
// {
// if (Keyboard.IsKeyDown(Key.LeftShift))
// {
// LargeDown();
// }
// else
// {
// SmallDown();
// }
// }
// e.Handled = true;
//}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == ValueProperty) {
Value = CoerceValue((double)e.NewValue);
Print();
}
else if (e.Property == SmallChangeProperty &&
ReadLocalValue(LargeChangeProperty) == DependencyProperty.UnsetValue) {
LargeChange = SmallChange * 10;
}
}
}
public class DragRepeatButton : RepeatButton
{
public static readonly DependencyProperty IsDraggingProperty =
DependencyProperty.Register("IsDragging", typeof(bool), typeof(DragRepeatButton));
public bool IsDragging {
get { return (bool)GetValue(IsDraggingProperty); }
set { SetValue(IsDraggingProperty, value); }
}
}
}

140
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/NumericUpDown.xaml

@ -1,140 +0,0 @@ @@ -1,140 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls">
<Brush x:Key="ButtonNormal">#DADFEA</Brush>
<Brush x:Key="ButtonHover">#E6EBEF</Brush>
<Brush x:Key="ButtonPressed">#B6BDD3</Brush>
<Brush x:Key="BorderBrush">#7F9DB9</Brush>
<Brush x:Key="ArrowBrush">Black</Brush>
<Brush x:Key="ArrowsBorderBrush">#B6BDD3</Brush>
<Style x:Key="UpButton"
TargetType="RepeatButton">
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:DragRepeatButton}">
<Border x:Name="bg"
Background="{StaticResource ButtonNormal}"
CornerRadius="2 2 0 0">
<Path Fill="{StaticResource ArrowBrush}"
Data="M 0 3 L 3.5 0 L 7 3"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonHover}" />
</Trigger>
<Trigger Property="IsMouseCaptured"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonPressed}" />
</Trigger>
<Trigger Property="IsDragging"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonPressed}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="DownButton"
TargetType="RepeatButton">
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:DragRepeatButton}">
<Border x:Name="bg"
Background="{StaticResource ButtonNormal}"
CornerRadius="0 0 2 2">
<Path Fill="{StaticResource ArrowBrush}"
Data="M 0 0 L 3.5 3 L 7 0"
HorizontalAlignment="Center"
VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonHover}" />
</Trigger>
<Trigger Property="IsMouseCaptured"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonPressed}" />
</Trigger>
<Trigger Property="IsDragging"
Value="True">
<Setter TargetName="bg"
Property="Background"
Value="{StaticResource ButtonPressed}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:NumericUpDown}">
<Setter Property="Background"
Value="White" />
<Setter Property="BorderThickness"
Value="1" />
<Setter Property="BorderBrush"
Value="{StaticResource BorderBrush}" />
<Setter Property="Focusable"
Value="False" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:NumericUpDown}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Padding="1">
<Grid>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="15" />
</Grid.ColumnDefinitions>
<TextBox x:Name="PART_TextBox"
BorderThickness="0"
Background="{x:Null}"
Foreground="{TemplateBinding Foreground}"
Grid.RowSpan="2" />
<Controls:DragRepeatButton x:Name="PART_UpButton"
Style="{StaticResource UpButton}"
Grid.Column="1" />
<Controls:DragRepeatButton x:Name="PART_DownButton"
Style="{StaticResource DownButton}"
Grid.Column="1"
Grid.Row="1" />
<Border Grid.Column="1"
Grid.RowSpan="2"
BorderBrush="{StaticResource ArrowsBorderBrush}"
BorderThickness="1"
CornerRadius="2" />
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

185
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PageClone.cs

@ -1,185 +0,0 @@ @@ -1,185 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Navigation;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Description of PageClone.
/// </summary>
[ContentProperty("Content")]
public class PageClone : FrameworkElement, IAddChild
{
static PageClone()
{
Control.IsTabStopProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(SharedInstances.BoxedFalse));
KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
FocusManager.IsFocusScopeProperty.OverrideMetadata(typeof(PageClone), new FrameworkPropertyMetadata(SharedInstances.BoxedTrue));
}
public static readonly DependencyProperty ContentProperty = Page.ContentProperty.AddOwner(typeof(PageClone));
ContentPresenter content;
public PageClone()
{
content = new ContentPresenter();
content.SetBinding(ContentPresenter.ContentProperty, new Binding("Content") { Source = this });
AddVisualChild(content);
}
protected override int VisualChildrenCount {
get { return 1; }
}
protected override Visual GetVisualChild(int index)
{
if (index != 0)
throw new ArgumentOutOfRangeException();
return content;
}
protected override Size ArrangeOverride(Size finalSize)
{
content.Arrange(new Rect(finalSize));
return finalSize;
}
protected override Size MeasureOverride(Size availableSize)
{
content.Measure(availableSize);
return content.DesiredSize;
}
[Category("Appearance")]
public Brush Background {
get { return (Brush)GetValue(Page.BackgroundProperty); }
set { SetValue(Page.BackgroundProperty, value); }
}
public object Content {
get {
VerifyAccess();
return GetValue(ContentProperty);
}
set {
VerifyAccess();
SetValue(ContentProperty, value);
}
}
[Bindable(true), Category("Appearance"), Localizability(LocalizationCategory.Font, Modifiability = Modifiability.Unmodifiable)]
public FontFamily FontFamily {
get { return (FontFamily)GetValue(Page.FontFamilyProperty); }
set { SetValue(Page.FontFamilyProperty, value); }
}
[Bindable(true), Category("Appearance"), TypeConverter(typeof(FontSizeConverter)), Localizability(LocalizationCategory.None)]
public double FontSize {
get { return (double)GetValue(Page.FontSizeProperty); }
set { SetValue(Page.FontSizeProperty, value); }
}
[Bindable(true), Category("Appearance")]
public Brush Foreground {
get { return (Brush)GetValue(Page.ForegroundProperty); }
set { SetValue(Page.ForegroundProperty, value); }
}
public bool KeepAlive {
get { return JournalEntry.GetKeepAlive(this); }
set { JournalEntry.SetKeepAlive(this, value); }
}
public NavigationService NavigationService {
get { return NavigationService.GetNavigationService(this); }
}
public ControlTemplate Template {
get { return (ControlTemplate)GetValue(Page.TemplateProperty); }
set { SetValue(Page.TemplateProperty, value); }
}
public bool ShowsNavigationUI { get; set; }
public string Title {
get { return (string)base.GetValue(Page.TitleProperty); }
set { base.SetValue(Page.TitleProperty, value); }
}
public string WindowTitle {
get { return Title; }
set { Title = value; }
}
public double WindowWidth { get; set; }
public double WindowHeight { get; set; }
void IAddChild.AddChild(object value)
{
base.VerifyAccess();
if (this.Content == null || value == null)
this.Content = value;
else
throw new InvalidOperationException();
}
void IAddChild.AddText(string text)
{
if (text == null)
return;
for (int i = 0; i < text.Length; i++) {
if (!char.IsWhiteSpace(text[i]))
throw new ArgumentException();
}
}
}
/// <summary>
/// A <see cref="CustomInstanceFactory"/> for <see cref="Page"/>
/// (and derived classes, unless they specify their own <see cref="CustomInstanceFactory"/>).
/// </summary>
[ExtensionFor(typeof(Page))]
public class PageCloneExtension : CustomInstanceFactory
{
/// <summary>
/// Used to create instances of <see cref="PageClone"/>.
/// </summary>
public override object CreateInstance(Type type, params object[] arguments)
{
Debug.Assert(arguments.Length == 0);
return new PageClone();
}
}
}

76
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/PanelMoveAdorner.cs

@ -1,76 +0,0 @@ @@ -1,76 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Windows.Controls;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.WpfDesign.Designer.Services;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Converters;
using System.Windows.Data;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class PanelMoveAdorner : Control
{
static PanelMoveAdorner()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(PanelMoveAdorner),
new FrameworkPropertyMetadata(typeof(PanelMoveAdorner)));
}
private ScaleTransform scaleTransform;
public PanelMoveAdorner(DesignItem item)
{
this.item = item;
scaleTransform = new ScaleTransform(1.0, 1.0);
this.LayoutTransform = scaleTransform;
}
DesignItem item;
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
{
e.Handled = true;
//item.Services.Selection.SetSelectedComponents(new DesignItem [] { item }, SelectionTypes.Auto);
new DragMoveMouseGesture(item, false).Start(item.Services.DesignPanel, e);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var bnd = new Binding("IsVisible") {Source = item.Component};
bnd.Converter = CollapsedWhenFalse.Instance;
BindingOperations.SetBinding(this, UIElement.VisibilityProperty, bnd);
var surface = this.TryFindParent<DesignSurface>();
if (surface != null && surface.ZoomControl != null)
{
bnd = new Binding("CurrentZoom") {Source = surface.ZoomControl};
bnd.Converter = InvertedZoomConverter.Instance;
BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleXProperty, bnd);
BindingOperations.SetBinding(scaleTransform, ScaleTransform.ScaleYProperty, bnd);
}
}
}
}

151
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Picker.cs

@ -1,151 +0,0 @@ @@ -1,151 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Data;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class Picker : Grid
{
public Picker()
{
SizeChanged += delegate { UpdateValueOffset(); };
}
public static readonly DependencyProperty MarkerProperty =
DependencyProperty.Register("Marker", typeof(UIElement), typeof(Picker));
public UIElement Marker {
get { return (UIElement)GetValue(MarkerProperty); }
set { SetValue(MarkerProperty, value); }
}
public static readonly DependencyProperty ValueProperty =
DependencyProperty.Register("Value", typeof(double), typeof(Picker),
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
public double Value {
get { return (double)GetValue(ValueProperty); }
set { SetValue(ValueProperty, value); }
}
public static readonly DependencyProperty ValueOffsetProperty =
DependencyProperty.Register("ValueOffset", typeof(double), typeof(Picker));
public double ValueOffset {
get { return (double)GetValue(ValueOffsetProperty); }
set { SetValue(ValueOffsetProperty, value); }
}
public static readonly DependencyProperty OrientationProperty =
DependencyProperty.Register("Orientation", typeof(Orientation), typeof(Picker));
public Orientation Orientation {
get { return (Orientation)GetValue(OrientationProperty); }
set { SetValue(OrientationProperty, value); }
}
public static readonly DependencyProperty MinimumProperty =
DependencyProperty.Register("Minimum", typeof(double), typeof(Picker));
public double Minimum {
get { return (double)GetValue(MinimumProperty); }
set { SetValue(MinimumProperty, value); }
}
public static readonly DependencyProperty MaximumProperty =
DependencyProperty.Register("Maximum", typeof(double), typeof(Picker),
new FrameworkPropertyMetadata(100.0));
public double Maximum {
get { return (double)GetValue(MaximumProperty); }
set { SetValue(MaximumProperty, value); }
}
protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
if (e.Property == MarkerProperty) {
TranslateTransform t = Marker.RenderTransform as TranslateTransform;
if (t == null) {
t = new TranslateTransform();
Marker.RenderTransform = t;
}
var property = Orientation == Orientation.Horizontal ? TranslateTransform.XProperty : TranslateTransform.YProperty;
BindingOperations.SetBinding(t, property, new Binding("ValueOffset") {
Source = this
});
}
else if (e.Property == ValueProperty) {
UpdateValueOffset();
}
}
bool isMouseDown;
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
{
isMouseDown = true;
CaptureMouse();
UpdateValue();
}
protected override void OnPreviewMouseMove(MouseEventArgs e)
{
if (isMouseDown) {
UpdateValue();
}
}
protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
{
isMouseDown = false;
ReleaseMouseCapture();
}
void UpdateValue()
{
Point p = Mouse.GetPosition(this);
double length = 0, pos = 0;
if (Orientation == Orientation.Horizontal) {
length = ActualWidth;
pos = p.X;
}
else {
length = ActualHeight;
pos = p.Y;
}
pos = Math.Max(0, Math.Min(length, pos));
Value = Minimum + (Maximum - Minimum) * pos / length;
}
void UpdateValueOffset()
{
var length = Orientation == Orientation.Horizontal ? ActualWidth : ActualHeight;
ValueOffset = length * (Value - Minimum) / (Maximum - Minimum);
}
}
}

140
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/QuickOperationMenu.cs

@ -1,140 +0,0 @@ @@ -1,140 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Converters;
using System.Windows.Data;
using ICSharpCode.WpfDesign.UIExtensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A Small icon which shows up a menu containing common properties
/// </summary>
public class QuickOperationMenu : Control
{
static QuickOperationMenu()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof (QuickOperationMenu), new FrameworkPropertyMetadata(typeof (QuickOperationMenu)));
}
public QuickOperationMenu()
{ }
private MenuItem _mainHeader;
/// <summary>
/// Contains Default values in the Sub menu for example "HorizontalAlignment" has "HorizontalAlignment.Stretch" as it's value.
/// </summary>
private readonly Dictionary<MenuItem, MenuItem> _defaults = new Dictionary<MenuItem, MenuItem>();
/// <summary>
/// Is the main header menu which brings up all the menus.
/// </summary>
public MenuItem MainHeader {
get { return _mainHeader; }
}
/// <summary>
/// Add a submenu with checkable values.
/// </summary>
/// <param name="parent">The parent menu under which to add.</param>
/// <param name="enumValues">All the values of an enum to be showed in the menu</param>
/// <param name="defaultValue">The default value out of all the enums.</param>
/// <param name="setValue">The presently set value out of the enums</param>
public void AddSubMenuCheckable(MenuItem parent, Array enumValues, string defaultValue, string setValue)
{
foreach (var enumValue in enumValues) {
var menuItem = new MenuItem {Header = enumValue.ToString(), IsCheckable = true};
parent.Items.Add(menuItem);
if (enumValue.ToString() == defaultValue)
_defaults.Add(parent, menuItem);
if (enumValue.ToString() == setValue)
menuItem.IsChecked = true;
}
}
/// <summary>
/// Add a menu in the main header.
/// </summary>
/// <param name="menuItem">The menu to add.</param>
public void AddSubMenuInTheHeader(MenuItem menuItem)
{
if (_mainHeader != null)
_mainHeader.Items.Add(menuItem);
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var mainHeader = Template.FindName("MainHeader", this) as MenuItem;
if (mainHeader != null) {
_mainHeader = mainHeader;
}
}
/// <summary>
/// Checks a menu item and making it exclusive. If the check was toggled then the default menu item is selected.
/// </summary>
/// <param name="parent">The parent item of the sub menu</param>
/// <param name="clickedOn">The Item clicked on</param>
/// <returns>Returns the Default value if the checkable menu item is toggled or otherwise the new checked menu item.</returns>
public string UncheckChildrenAndSelectClicked(MenuItem parent, MenuItem clickedOn)
{
MenuItem defaultMenuItem;
_defaults.TryGetValue(parent, out defaultMenuItem);
if (IsAnyItemChecked(parent)) {
foreach (var item in parent.Items) {
var menuItem = item as MenuItem;
if (menuItem != null) menuItem.IsChecked = false;
}
clickedOn.IsChecked = true;
return (string) clickedOn.Header;
} else {
if (defaultMenuItem != null) {
defaultMenuItem.IsChecked = true;
return (string) defaultMenuItem.Header;
}
}
return null;
}
/// <summary>
/// Checks in the sub-menu whether aby items has been checked or not
/// </summary>
/// <param name="parent"></param>
/// <returns></returns>
private bool IsAnyItemChecked(MenuItem parent)
{
bool check = false;
if (parent.HasItems) {
foreach (var item in parent.Items) {
var menuItem = item as MenuItem;
if (menuItem != null && menuItem.IsChecked)
check = true;
}
}
return check;
}
}
}

118
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/RelayCommand.cs

@ -1,118 +0,0 @@ @@ -1,118 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A command that invokes a delegate.
/// The command parameter must be of type T.
/// </summary>
public class RelayCommand<T> : ICommand
{
readonly Predicate<T> canExecute;
readonly Action<T> execute;
public RelayCommand(Action<T> execute)
{
if (execute == null)
throw new ArgumentNullException("execute");
this.execute = execute;
}
public RelayCommand(Action<T> execute, Predicate<T> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
this.execute = execute;
this.canExecute = canExecute;
}
public event EventHandler CanExecuteChanged {
add {
if (canExecute != null)
CommandManager.RequerySuggested += value;
}
remove {
if (canExecute != null)
CommandManager.RequerySuggested -= value;
}
}
public bool CanExecute(object parameter)
{
if (parameter != null && !(parameter is T))
return false;
return canExecute == null ? true : canExecute((T)parameter);
}
public void Execute(object parameter)
{
execute((T)parameter);
}
}
/// <summary>
/// A command that invokes a delegate.
/// This class does not provide the command parameter to the delegate -
/// if you need that, use the generic version of this class instead.
/// </summary>
public class RelayCommand : ICommand
{
readonly Func<bool> canExecute;
readonly Action execute;
public RelayCommand(Action execute)
{
if (execute == null)
throw new ArgumentNullException("execute");
this.execute = execute;
}
public RelayCommand(Action execute, Func<bool> canExecute)
{
if (execute == null)
throw new ArgumentNullException("execute");
this.execute = execute;
this.canExecute = canExecute;
}
public event EventHandler CanExecuteChanged {
add {
if (canExecute != null)
CommandManager.RequerySuggested += value;
}
remove {
if (canExecute != null)
CommandManager.RequerySuggested -= value;
}
}
public bool CanExecute(object parameter)
{
return canExecute == null ? true : canExecute();
}
public void Execute(object parameter)
{
execute();
}
}
}

43
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/RenderTransformOriginThumb.cs

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Windows;
using System.Windows.Input;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Description of RenderTransformThumb.
/// </summary>
public class RenderTransformOriginThumb : Thumb
{
static RenderTransformOriginThumb()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(RenderTransformOriginThumb), new FrameworkPropertyMetadata(typeof(RenderTransformOriginThumb)));
}
}
}

43
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SelectionFrame.cs

@ -1,43 +0,0 @@ @@ -1,43 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// The rectangle shown during a rubber-band selecting operation.
/// </summary>
public class SelectionFrame : Control
{
static SelectionFrame()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(SelectionFrame), new FrameworkPropertyMetadata(typeof(SelectionFrame)));
}
}
}

50
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/SizeDisplay.cs

@ -1,50 +0,0 @@ @@ -1,50 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Diagnostics;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Display height of the element.
/// </summary>
class HeightDisplay : Control
{
static HeightDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(HeightDisplay), new FrameworkPropertyMetadata(typeof(HeightDisplay)));
}
}
/// <summary>
/// Display width of the element.
/// </summary>
class WidthDisplay : Control
{
static WidthDisplay()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(WidthDisplay), new FrameworkPropertyMetadata(typeof(WidthDisplay)));
}
}
}

90
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/DesignerThumb.cs

@ -1,90 +0,0 @@ @@ -1,90 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.WpfDesign.UIExtensions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A thumb where the look can depend on the IsPrimarySelection property.
/// </summary>
public class DesignerThumb : Thumb
{
/// <summary>
/// Dependency property for <see cref="IsPrimarySelection"/>.
/// </summary>
public static readonly DependencyProperty IsPrimarySelectionProperty
= DependencyProperty.Register("IsPrimarySelection", typeof(bool), typeof(DesignerThumb));
/// <summary>
/// Dependency property for <see cref="IsPrimarySelection"/>.
/// </summary>
public static readonly DependencyProperty ThumbVisibleProperty
= DependencyProperty.Register("ThumbVisible", typeof(bool), typeof(DesignerThumb), new FrameworkPropertyMetadata(true));
/// <summary>
/// Dependency property for <see cref="OperationMenu"/>.
/// </summary>
public static readonly DependencyProperty OperationMenuProperty =
DependencyProperty.Register("OperationMenu", typeof(Control[]), typeof(DesignerThumb), new PropertyMetadata(null));
internal PlacementAlignment Alignment;
static DesignerThumb()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(DesignerThumb), new FrameworkPropertyMetadata(typeof(DesignerThumb)));
}
public void ReDraw()
{
var parent = this.TryFindParent<FrameworkElement>();
if (parent != null)
parent.InvalidateArrange();
}
/// <summary>
/// Gets/Sets if the resize thumb is attached to the primary selection.
/// </summary>
public bool IsPrimarySelection {
get { return (bool)GetValue(IsPrimarySelectionProperty); }
set { SetValue(IsPrimarySelectionProperty, value); }
}
/// <summary>
/// Gets/Sets if the resize thumb is visible.
/// </summary>
public bool ThumbVisible {
get { return (bool)GetValue(ThumbVisibleProperty); }
set { SetValue(ThumbVisibleProperty, value); }
}
/// <summary>
/// Gets/Sets the OperationMenu.
/// </summary>
public Control[] OperationMenu
{
get { return (Control[])GetValue(OperationMenuProperty); }
set { SetValue(OperationMenuProperty, value); }
}
}
}

52
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/MultiPointThumb.cs

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Windows;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Description of MultiPointThumb.
/// </summary>
internal sealed class MultiPointThumb : DesignerThumb
{
private int _index;
public int Index
{
get { return _index; }
set
{
_index = value;
var p = AdornerPlacement as PointTrackerPlacementSupport;
if (p != null)
p.Index = value;
}
}
private AdornerPlacement _adornerPlacement;
public AdornerPlacement AdornerPlacement
{
get { return _adornerPlacement; }
set { _adornerPlacement = value; }
}
}
}

115
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/PointThumb.cs

@ -1,115 +0,0 @@ @@ -1,115 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Windows;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Adorners;
using System.Windows.Data;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Description of MultiPointThumb.
/// </summary>
public class PointThumb : DesignerThumb
{
public Transform InnerRenderTransform
{
get { return (Transform)GetValue(InnerRenderTransformProperty); }
set { SetValue(InnerRenderTransformProperty, value); }
}
// Using a DependencyProperty as the backing store for InnerRenderTransform. This enables animation, styling, binding, etc...
public static readonly DependencyProperty InnerRenderTransformProperty =
DependencyProperty.Register("InnerRenderTransform", typeof(Transform), typeof(PointThumb), new PropertyMetadata(null));
public bool IsEllipse
{
get { return (bool)GetValue(IsEllipseProperty); }
set { SetValue(IsEllipseProperty, value); }
}
// Using a DependencyProperty as the backing store for IsEllipse. This enables animation, styling, binding, etc...
public static readonly DependencyProperty IsEllipseProperty =
DependencyProperty.Register("IsEllipse", typeof(bool), typeof(PointThumb), new PropertyMetadata(false));
public Point Point
{
get { return (Point)GetValue(PointProperty); }
set { SetValue(PointProperty, value); }
}
// Using a DependencyProperty as the backing store for Point. This enables animation, styling, binding, etc...
public static readonly DependencyProperty PointProperty =
DependencyProperty.Register("Point", typeof(Point), typeof(PointThumb), new PropertyMetadata(OnPointChanged));
private static void OnPointChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
var pt = (PointThumb)d;
((PointPlacementSupport)pt.AdornerPlacement).p = (Point)e.NewValue;
var bndExpr = pt.GetBindingExpression(PointThumb.RelativeToPointProperty);
if (bndExpr != null)
bndExpr.UpdateTarget();
((PointThumb)d).ReDraw();
}
public Point? RelativeToPoint
{
get { return (Point?)GetValue(RelativeToPointProperty); }
set { SetValue(RelativeToPointProperty, value); }
}
// Using a DependencyProperty as the backing store for RelativeToPoint. This enables animation, styling, binding, etc...
public static readonly DependencyProperty RelativeToPointProperty =
DependencyProperty.Register("RelativeToPoint", typeof(Point?), typeof(PointThumb), new PropertyMetadata(null));
static PointThumb()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(PointThumb), new FrameworkPropertyMetadata(typeof(PointThumb)));
}
public PointThumb(Point point)
{
this.AdornerPlacement = new PointPlacementSupport(point);
Point = point;
}
public PointThumb()
{
this.AdornerPlacement = new PointPlacementSupport(Point);
}
public AdornerPlacement AdornerPlacement { get; private set; }
private class PointPlacementSupport : AdornerPlacement
{
public Point p;
public PointPlacementSupport(Point point)
{
this.p = point;
}
public override void Arrange(AdornerPanel panel, UIElement adorner, Size adornedElementSize)
{
adorner.Arrange(new Rect(p.X, p.Y, adornedElementSize.Width, adornedElementSize.Height));
}
}
}
}

52
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/ResizeThumb.cs

@ -1,52 +0,0 @@ @@ -1,52 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.Diagnostics;
using System.Windows;
using ICSharpCode.WpfDesign.Adorners;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// Resize thumb that automatically disappears if the adornered element is too small.
/// </summary>
public sealed class ResizeThumb : DesignerThumb
{
bool checkWidth, checkHeight;
internal ResizeThumb(bool checkWidth, bool checkHeight)
{
Debug.Assert((checkWidth && checkHeight) == false);
this.checkWidth = checkWidth;
this.checkHeight = checkHeight;
}
protected override Size ArrangeOverride(Size arrangeBounds)
{
AdornerPanel parent = this.Parent as AdornerPanel;
if (parent != null && parent.AdornedElement != null)
{
if (checkWidth)
this.ThumbVisible = PlacementOperation.GetRealElementSize(parent.AdornedElement).Width > 14;
else if (checkHeight)
this.ThumbVisible = PlacementOperation.GetRealElementSize(parent.AdornedElement).Height > 14;
}
return base.ArrangeOverride(arrangeBounds);
}
}
}

37
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/RotateThumb.cs

@ -1,37 +0,0 @@ @@ -1,37 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Linq;
using System.Windows;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class RotateThumb : DesignerThumb
{
static RotateThumb()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(RotateThumb), new FrameworkPropertyMetadata(typeof(RotateThumb)));
}
public RotateThumb()
{
this.ThumbVisible = true;
}
}
}

30
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/Thumbs/UserControlPointsObjectThumb.cs

@ -1,30 +0,0 @@ @@ -1,30 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using ICSharpCode.WpfDesign.UIExtensions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class UserControlPointsObjectThumb : DesignerThumb
{
public DependencyProperty DependencyProperty { get; set; }
}
}

252
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/WindowClone.cs

@ -1,252 +0,0 @@ @@ -1,252 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Shell;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
/// <summary>
/// A custom control that imitates the properties of <see cref="Window"/>, but is not a top-level control.
/// </summary>
public class WindowClone : ContentControl
{
static WindowClone()
{
//This OverrideMetadata call tells the system that this element wants to provide a style that is different than its base class.
//This style is defined in themes\generic.xaml
DefaultStyleKeyProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(typeof(WindowClone)));
Control.IsTabStopProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances.BoxedFalse));
KeyboardNavigation.DirectionalNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
KeyboardNavigation.TabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
KeyboardNavigation.ControlTabNavigationProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(KeyboardNavigationMode.Cycle));
FocusManager.IsFocusScopeProperty.OverrideMetadata(typeof(WindowClone), new FrameworkPropertyMetadata(SharedInstances.BoxedTrue));
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public bool AllowsTransparency {
get { return (bool)GetValue(Window.AllowsTransparencyProperty); }
set { SetValue(Window.AllowsTransparencyProperty, SharedInstances.Box(value)); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
[Browsable(false), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), TypeConverter(typeof(DialogResultConverter))]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public bool? DialogResult {
get {
return null;
}
set { }
}
public ImageSource Icon
{
get { return (ImageSource)GetValue(Window.IconProperty); }
set { SetValue(Window.IconProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
[TypeConverter(typeof(LengthConverter))]
public double Left {
get { return (double)GetValue(Window.LeftProperty); }
set { SetValue(Window.LeftProperty, value); }
}
Window owner;
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public Window Owner {
get { return owner; }
set { owner = value; }
}
/// <summary>
/// Gets or sets the resize mode.
/// </summary>
public ResizeMode ResizeMode
{
get { return (ResizeMode)GetValue(Window.ResizeModeProperty); }
set { SetValue(Window.ResizeModeProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public bool ShowActivated {
get { return (bool)GetValue(Window.ShowActivatedProperty); }
set { SetValue(Window.ShowActivatedProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public bool ShowInTaskbar {
get { return (bool)GetValue(Window.ShowInTaskbarProperty); }
set { SetValue(Window.ShowInTaskbarProperty, SharedInstances.Box(value)); }
}
/// <summary>
/// Gets or sets a value that specifies whether a window will automatically size itself to fit the size of its content.
/// </summary>
public SizeToContent SizeToContent {
get { return (SizeToContent)GetValue(Window.SizeToContentProperty); }
set { SetValue(Window.SizeToContentProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public TaskbarItemInfo TaskbarItemInfo {
get { return (TaskbarItemInfo)GetValue(Window.TaskbarItemInfoProperty); }
set { SetValue(Window.TaskbarItemInfoProperty, value); }
}
/// <summary>
/// The title to display in the Window's title bar.
/// </summary>
public string Title {
get { return (string)GetValue(Window.TitleProperty); }
set { SetValue(Window.TitleProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
[TypeConverter(typeof(LengthConverter))]
public double Top {
get { return (double)GetValue(Window.TopProperty); }
set { SetValue(Window.TopProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public bool Topmost {
get { return (bool)GetValue(Window.TopmostProperty); }
set { SetValue(Window.TopmostProperty, SharedInstances.Box(value)); }
}
WindowStartupLocation windowStartupLocation;
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public WindowStartupLocation WindowStartupLocation {
get { return windowStartupLocation; }
set { windowStartupLocation = value; }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public WindowState WindowState {
get { return (WindowState) GetValue(Window.WindowStateProperty); }
set { SetValue(Window.WindowStateProperty, value); }
}
/// <summary>
/// This property has no effect. (for compatibility with <see cref="Window"/> only).
/// </summary>
public WindowStyle WindowStyle {
get { return (WindowStyle)GetValue(Window.WindowStyleProperty); }
set { SetValue(Window.WindowStyleProperty, value); }
}
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Activated { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Closed { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Closing { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler ContentRendered { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler Deactivated { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler LocationChanged { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler SourceInitialized { add {} remove {} }
/// <summary>
/// This event is never raised. (for compatibility with <see cref="Window"/> only).
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA1801:ReviewUnusedParameters", MessageId = "value")]
public event EventHandler StateChanged { add {} remove {} }
}
/// <summary>
/// A <see cref="CustomInstanceFactory"/> for <see cref="Window"/>
/// (and derived classes, unless they specify their own <see cref="CustomInstanceFactory"/>).
/// </summary>
[ExtensionFor(typeof(Window))]
public class WindowCloneExtension : CustomInstanceFactory
{
/// <summary>
/// Used to create instances of <see cref="WindowClone"/>.
/// </summary>
public override object CreateInstance(Type type, params object[] arguments)
{
Debug.Assert(arguments.Length == 0);
return new WindowClone();
}
}
}

66
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomButtons.cs

@ -1,66 +0,0 @@ @@ -1,66 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows;
using System.Windows.Controls.Primitives;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class ZoomButtons : RangeBase
{
static ZoomButtons()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ZoomButtons),
new FrameworkPropertyMetadata(typeof(ZoomButtons)));
}
public override void OnApplyTemplate()
{
base.OnApplyTemplate();
var uxPlus = (ButtonBase)Template.FindName("uxPlus", this);
var uxMinus = (ButtonBase)Template.FindName("uxMinus", this);
var uxReset = (ButtonBase)Template.FindName("uxReset", this);
if (uxPlus != null)
uxPlus.Click += OnZoomInClick;
if (uxMinus != null)
uxMinus.Click += OnZoomOutClick;
if (uxReset != null)
uxReset.Click += OnResetClick;
}
const double ZoomFactor = 1.1;
void OnZoomInClick(object sender, EventArgs e)
{
SetCurrentValue(ValueProperty, ZoomScrollViewer.RoundToOneIfClose(this.Value * ZoomFactor));
}
void OnZoomOutClick(object sender, EventArgs e)
{
SetCurrentValue(ValueProperty, ZoomScrollViewer.RoundToOneIfClose(this.Value / ZoomFactor));
}
void OnResetClick(object sender, EventArgs e)
{
SetCurrentValue(ValueProperty, 1.0);
}
}
}

157
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomControl.cs

@ -1,157 +0,0 @@ @@ -1,157 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System.IO;
using System.Reflection;
using System.Resources;
using System.Windows;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class ZoomControl : ZoomScrollViewer
{
static ZoomControl()
{
PanToolCursor = GetCursor("Images/PanToolCursor.cur");
PanToolCursorMouseDown = GetCursor("Images/PanToolCursorMouseDown.cur");
DefaultStyleKeyProperty.OverrideMetadata(typeof(ZoomControl), new FrameworkPropertyMetadata(typeof(ZoomControl)));
}
public object AdditionalControls
{
get { return (object)GetValue(AdditionalControlsProperty); }
set { SetValue(AdditionalControlsProperty, value); }
}
public static readonly DependencyProperty AdditionalControlsProperty =
DependencyProperty.Register("AdditionalControls", typeof(object), typeof(ZoomControl), new PropertyMetadata(null));
internal static Cursor GetCursor(string path)
{
var a = Assembly.GetExecutingAssembly();
var m = new ResourceManager(a.GetName().Name + ".g", a);
using (Stream s = m.GetStream(path.ToLowerInvariant())) {
return new Cursor(s);
}
}
static Cursor PanToolCursor;
static Cursor PanToolCursorMouseDown;
double startHorizontalOffset;
double startVericalOffset;
Point startPoint;
bool isMouseDown;
bool pan;
protected override void OnKeyDown(KeyEventArgs e)
{
if (!pan && e.Key == Key.Space) {
pan = true;
Mouse.UpdateCursor();
}
base.OnKeyDown(e);
}
protected override void OnKeyUp(KeyEventArgs e)
{
if (e.Key == Key.Space) {
pan = false;
Mouse.UpdateCursor();
}
base.OnKeyUp(e);
}
protected override void OnPreviewMouseDown(MouseButtonEventArgs e)
{
if (!pan && e.MiddleButton == MouseButtonState.Pressed)
{
pan = true;
Mouse.UpdateCursor();
}
if (pan && !e.Handled) {
if (Mouse.Capture(this)) {
isMouseDown = true;
e.Handled = true;
startPoint = e.GetPosition(this);
PanStart();
Mouse.UpdateCursor();
}
}
base.OnPreviewMouseDown(e);
}
protected override void OnPreviewMouseMove(MouseEventArgs e)
{
if (isMouseDown) {
var endPoint = e.GetPosition(this);
PanContinue(endPoint - startPoint);
}
base.OnPreviewMouseMove(e);
}
protected override void OnPreviewMouseUp(MouseButtonEventArgs e)
{
if (pan && e.MiddleButton != MouseButtonState.Pressed && !Keyboard.IsKeyDown(Key.Space))
{
pan = false;
Mouse.UpdateCursor();
}
if (isMouseDown) {
isMouseDown = false;
ReleaseMouseCapture();
Mouse.UpdateCursor();
}
base.OnPreviewMouseUp(e);
}
protected override void OnLostMouseCapture(MouseEventArgs e)
{
if (isMouseDown) {
isMouseDown = false;
ReleaseMouseCapture();
Mouse.UpdateCursor();
}
base.OnLostMouseCapture(e);
}
protected override void OnQueryCursor(QueryCursorEventArgs e)
{
base.OnQueryCursor(e);
if (!e.Handled && (pan || isMouseDown)) {
e.Handled = true;
e.Cursor = isMouseDown ? PanToolCursorMouseDown : PanToolCursor;
}
}
void PanStart()
{
startHorizontalOffset = this.HorizontalOffset;
startVericalOffset = this.VerticalOffset;
}
void PanContinue(Vector delta)
{
this.ScrollToHorizontalOffset(startHorizontalOffset - delta.X / this.CurrentZoom);
this.ScrollToVerticalOffset(startVericalOffset - delta.Y / this.CurrentZoom);
}
}
}

184
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomScrollViewer.cs

@ -1,184 +0,0 @@ @@ -1,184 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
namespace ICSharpCode.WpfDesign.Designer.Controls
{
public class ZoomScrollViewer : ScrollViewer
{
static ZoomScrollViewer()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(typeof(ZoomScrollViewer)));
}
public static readonly DependencyProperty CurrentZoomProperty =
DependencyProperty.Register("CurrentZoom", typeof(double), typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(1.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, CalculateZoomButtonCollapsed, CoerceZoom));
public double CurrentZoom {
get { return (double)GetValue(CurrentZoomProperty); }
set { SetValue(CurrentZoomProperty, value); }
}
static object CoerceZoom(DependencyObject d, object baseValue)
{
var zoom = (double)baseValue;
ZoomScrollViewer sv = (ZoomScrollViewer)d;
return Math.Max(sv.MinimumZoom, Math.Min(sv.MaximumZoom, zoom));
}
public static readonly DependencyProperty MinimumZoomProperty =
DependencyProperty.Register("MinimumZoom", typeof(double), typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(0.2));
public double MinimumZoom {
get { return (double)GetValue(MinimumZoomProperty); }
set { SetValue(MinimumZoomProperty, value); }
}
public static readonly DependencyProperty MaximumZoomProperty =
DependencyProperty.Register("MaximumZoom", typeof(double), typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(5.0));
public double MaximumZoom {
get { return (double)GetValue(MaximumZoomProperty); }
set { SetValue(MaximumZoomProperty, value); }
}
public static readonly DependencyProperty MouseWheelZoomProperty =
DependencyProperty.Register("MouseWheelZoom", typeof(bool), typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(true));
public bool MouseWheelZoom {
get { return (bool)GetValue(MouseWheelZoomProperty); }
set { SetValue(MouseWheelZoomProperty, value); }
}
public static readonly DependencyProperty AlwaysShowZoomButtonsProperty =
DependencyProperty.Register("AlwaysShowZoomButtons", typeof(bool), typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(false, CalculateZoomButtonCollapsed));
public bool AlwaysShowZoomButtons {
get { return (bool)GetValue(AlwaysShowZoomButtonsProperty); }
set { SetValue(AlwaysShowZoomButtonsProperty, value); }
}
static readonly DependencyPropertyKey ComputedZoomButtonCollapsedPropertyKey =
DependencyProperty.RegisterReadOnly("ComputedZoomButtonCollapsed", typeof(bool), typeof(ZoomScrollViewer),
new FrameworkPropertyMetadata(true));
public static readonly DependencyProperty ComputedZoomButtonCollapsedProperty = ComputedZoomButtonCollapsedPropertyKey.DependencyProperty;
public bool ComputedZoomButtonCollapsed {
get { return (bool)GetValue(ComputedZoomButtonCollapsedProperty); }
private set { SetValue(ComputedZoomButtonCollapsedPropertyKey, value); }
}
static void CalculateZoomButtonCollapsed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
ZoomScrollViewer z = d as ZoomScrollViewer;
if (z != null)
z.ComputedZoomButtonCollapsed = (z.AlwaysShowZoomButtons == false) && (z.CurrentZoom == 1.0);
}
protected override void OnMouseWheel(MouseWheelEventArgs e)
{
if (!e.Handled && Keyboard.Modifiers == ModifierKeys.Control && MouseWheelZoom) {
double oldZoom = CurrentZoom;
double newZoom = RoundToOneIfClose(CurrentZoom * Math.Pow(1.001, e.Delta));
newZoom = Math.Max(this.MinimumZoom, Math.Min(this.MaximumZoom, newZoom));
// adjust scroll position so that mouse stays over the same virtual coordinate
ContentPresenter presenter = Template.FindName("PART_Presenter", this) as ContentPresenter;
Vector relMousePos;
if (presenter != null) {
Point mousePos = e.GetPosition(presenter);
relMousePos = new Vector(mousePos.X / presenter.ActualWidth, mousePos.Y / presenter.ActualHeight);
} else {
relMousePos = new Vector(0.5, 0.5);
}
Point scrollOffset = new Point(this.HorizontalOffset, this.VerticalOffset);
Vector oldHalfViewport = new Vector(this.ViewportWidth / 2, this.ViewportHeight / 2);
Vector newHalfViewport = oldHalfViewport / newZoom * oldZoom;
Point oldCenter = scrollOffset + oldHalfViewport;
Point virtualMousePos = scrollOffset + new Vector(relMousePos.X * this.ViewportWidth, relMousePos.Y * this.ViewportHeight);
// As newCenter, we want to choose a point between oldCenter and virtualMousePos. The more we zoom in, the closer
// to virtualMousePos. We'll create the line x = oldCenter + lambda * (virtualMousePos-oldCenter).
// On this line, we need to choose lambda between -1 and 1:
// -1 = zoomed out completely
// 0 = zoom unchanged
// +1 = zoomed in completely
// But the zoom factor (newZoom/oldZoom) we have is in the range [0,+Infinity].
// Basically, I just played around until I found a function that maps this to [-1,1] and works well.
// "f" is squared because otherwise the mouse simply stays over virtualMousePos, but I wanted virtualMousePos
// to move towards the middle -> squaring f causes lambda to be closer to 1, giving virtualMousePos more weight
// then oldCenter.
double f = Math.Min(newZoom, oldZoom) / Math.Max(newZoom, oldZoom);
double lambda = 1 - f*f;
if (oldZoom > newZoom)
lambda = -lambda;
Point newCenter = oldCenter + lambda * (virtualMousePos - oldCenter);
scrollOffset = newCenter - newHalfViewport;
SetCurrentValue(CurrentZoomProperty, newZoom);
this.ScrollToHorizontalOffset(scrollOffset.X);
this.ScrollToVerticalOffset(scrollOffset.Y);
e.Handled = true;
}
base.OnMouseWheel(e);
}
internal static double RoundToOneIfClose(double val)
{
if (Math.Abs(val - 1.0) < 0.001)
return 1.0;
else
return val;
}
}
sealed class IsNormalZoomConverter : IValueConverter
{
public static readonly IsNormalZoomConverter Instance = new IsNormalZoomConverter();
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (parameter is bool && (bool)parameter)
return true;
return ((double)value) == 1.0;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

94
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/ZoomScrollViewer.xaml

@ -1,94 +0,0 @@ @@ -1,94 +0,0 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Controls="clr-namespace:ICSharpCode.WpfDesign.Designer.Controls">
<Style TargetType="{x:Type Controls:ZoomScrollViewer}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ZoomScrollViewer}">
<Grid Background="{TemplateBinding Panel.Background}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Controls:SelfCollapsingPanel Grid.Column="0" Grid.Row="1" CollapseOrientation="Horizontal" CanCollapse="{Binding Path=ComputedZoomButtonCollapsed, Mode=OneWay, RelativeSource={RelativeSource Mode=TemplatedParent}}">
<Controls:ZoomButtons x:Name="zoomButtons" Value="{Binding Path=CurrentZoom, RelativeSource={RelativeSource Mode=TemplatedParent}}" Minimum="{TemplateBinding MinimumZoom}" Maximum="{TemplateBinding MaximumZoom}" />
</Controls:SelfCollapsingPanel>
<Rectangle Grid.Column="2" Grid.Row="1" Fill="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" />
<ScrollContentPresenter Name="PART_Presenter" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="0" Margin="{TemplateBinding Control.Padding}" Content="{TemplateBinding ContentControl.Content}" ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}" CanContentScroll="{TemplateBinding ScrollViewer.CanContentScroll}">
<ScrollContentPresenter.LayoutTransform>
<ScaleTransform ScaleX="{Binding Path=CurrentZoom, RelativeSource={RelativeSource Mode=TemplatedParent}}" ScaleY="{Binding Path=CurrentZoom, RelativeSource={RelativeSource Mode=TemplatedParent}}"/>
</ScrollContentPresenter.LayoutTransform>
</ScrollContentPresenter>
<ScrollBar Name="PART_VerticalScrollBar" Grid.Column="2" Grid.Row="0" Minimum="0" Maximum="{TemplateBinding ScrollableHeight}" ViewportSize="{TemplateBinding ViewportHeight}" Value="{TemplateBinding VerticalOffset}" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />
<ScrollBar Name="PART_HorizontalScrollBar" Orientation="Horizontal" Grid.Column="1" Grid.Row="1" Minimum="0" Maximum="{TemplateBinding ScrollableWidth}" ViewportSize="{TemplateBinding ViewportWidth}" Value="{TemplateBinding HorizontalOffset}" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="ZoomButtonStyle"
TargetType="RepeatButton">
<Setter Property="Delay" Value="0" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Opacity" Value="0.5" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RepeatButton">
<ContentPresenter />
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="{x:Type Controls:ZoomButtons}">
<Setter Property="Minimum" Value="0.2"/>
<Setter Property="Maximum" Value="10"/>
<Setter Property="Value" Value="1"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Controls:ZoomButtons}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<StackPanel Orientation="Horizontal"
Background="#3000">
<RepeatButton x:Name="uxPlus"
Width="16" Height="16" Padding="0" BorderThickness="0"
Style="{StaticResource ZoomButtonStyle}">
<Image Source="Images/ZoomIn.png"
Stretch="Uniform"/>
</RepeatButton>
<RepeatButton x:Name="uxMinus"
Width="16" Height="16" Padding="0" BorderThickness="0"
Style="{StaticResource ZoomButtonStyle}">
<Image Source="Images/ZoomOut.png"
Stretch="Uniform" />
</RepeatButton>
<RepeatButton x:Name="uxReset"
Width="16" Height="16" Padding="0" BorderThickness="0"
Style="{StaticResource ZoomButtonStyle}">
<Border Background="#5000">
<TextBlock Foreground="White"
HorizontalAlignment="Center"
VerticalAlignment="Center">1</TextBlock>
</Border>
</RepeatButton>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>

382
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Converters.cs

@ -1,382 +0,0 @@ @@ -1,382 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Globalization;
using System.Windows;
using System.Collections;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.Designer.Converters
{
public class IntFromEnumConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly IntFromEnumConverter Instance = new IntFromEnumConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (int)value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return Enum.ToObject(targetType, (int)value);
}
}
public class HiddenWhenFalse : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly HiddenWhenFalse Instance = new HiddenWhenFalse();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? Visibility.Visible : Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class CollapsedWhenFalse : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly CollapsedWhenFalse Instance = new CollapsedWhenFalse();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class LevelConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly LevelConverter Instance = new LevelConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return new Thickness(2 + 14 * (int)value, 0, 0, 0);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class CollapsedWhenZero : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly CollapsedWhenZero Instance = new CollapsedWhenZero();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || (value is int && (int)value == 0)) {
return Visibility.Collapsed;
}
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class CollapsedWhenNotNull : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly CollapsedWhenNotNull Instance = new CollapsedWhenNotNull();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
return Visibility.Collapsed;
}
return Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class CollapsedWhenNull : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly CollapsedWhenNull Instance = new CollapsedWhenNull();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value != null)
{
return Visibility.Visible;
}
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class FalseWhenNull : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly FalseWhenNull Instance = new FalseWhenNull();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class BoldWhenTrue : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly BoldWhenTrue Instance = new BoldWhenTrue();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? FontWeights.Bold : FontWeights.Normal;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
// Boxed int throw exception without converter (wpf bug?)
public class DummyConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly DummyConverter Instance = new DummyConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value;
}
}
public class ControlToRealWidthConverter : IMultiValueConverter
{
public static readonly ControlToRealWidthConverter Instance = new ControlToRealWidthConverter();
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return PlacementOperation.GetRealElementSize((UIElement)values[0]).Width;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class ControlToRealHeightConverter : IMultiValueConverter
{
public static readonly ControlToRealHeightConverter Instance = new ControlToRealHeightConverter();
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
return PlacementOperation.GetRealElementSize((UIElement)values[0]).Height;
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class FormatDoubleConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly FormatDoubleConverter Instance=new FormatDoubleConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return Math.Round((double)value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class DoubleOffsetConverter : IValueConverter
{
public double Offset { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (double)value + Offset;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return (double)value - Offset;
}
}
public class BlackWhenTrue : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly BlackWhenTrue Instance = new BlackWhenTrue();
private Brush black = new SolidColorBrush(Colors.Black);
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return (bool)value ? black : null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
public class EnumBoolean : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly EnumBoolean Instance = new EnumBoolean();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
if (Enum.IsDefined(value.GetType(), value) == false)
return DependencyProperty.UnsetValue;
object parameterValue = Enum.Parse(value.GetType(), parameterString);
return parameterValue.Equals(value);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
return Enum.Parse(targetType, parameterString);
}
}
public class EnumVisibility : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly EnumVisibility Instance = new EnumVisibility();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
if (Enum.IsDefined(value.GetType(), value) == false)
return DependencyProperty.UnsetValue;
object parameterValue = Enum.Parse(value.GetType(), parameterString);
return parameterValue.Equals(value) ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
return Enum.Parse(targetType, parameterString);
}
}
public class EnumCollapsed : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly EnumCollapsed Instance = new EnumCollapsed();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
if (Enum.IsDefined(value.GetType(), value) == false)
return DependencyProperty.UnsetValue;
object parameterValue = Enum.Parse(value.GetType(), parameterString);
return parameterValue.Equals(value) ? Visibility.Collapsed : Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string parameterString = parameter as string;
if (parameterString == null)
return DependencyProperty.UnsetValue;
return Enum.Parse(targetType, parameterString);
}
}
public class InvertedZoomConverter : IValueConverter
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2104:DoNotDeclareReadOnlyMutableReferenceTypes", Justification = "converter is immutable")]
public static readonly InvertedZoomConverter Instance = new InvertedZoomConverter();
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return 1.0 / ((double)value);
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return 1.0 / ((double)value);
}
}
}

575
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs

@ -1,575 +0,0 @@ @@ -1,575 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Threading;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.UIExtensions;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer
{
public sealed class DesignPanel : Decorator, IDesignPanel, INotifyPropertyChanged
{
#region Hit Testing
private List<DependencyObject> hitTestElements = new List<DependencyObject>();
private DependencyObject lastElement;
/// <summary>
/// this element is always hit (unless HitTestVisible is set to false)
/// </summary>
sealed class EatAllHitTestRequests : UIElement
{
protected override GeometryHitTestResult HitTestCore(GeometryHitTestParameters hitTestParameters)
{
return new GeometryHitTestResult(this, IntersectionDetail.FullyContains);
}
protected override HitTestResult HitTestCore(PointHitTestParameters hitTestParameters)
{
return new PointHitTestResult(this, hitTestParameters.HitPoint);
}
}
void RunHitTest(Visual reference, Point point, HitTestFilterCallback filterCallback, HitTestResultCallback resultCallback)
{
VisualTreeHelper.HitTest(reference, filterCallback, resultCallback,
new PointHitTestParameters(point));
}
HitTestFilterBehavior FilterHitTestInvisibleElements(DependencyObject potentialHitTestTarget)
{
UIElement element = potentialHitTestTarget as UIElement;
if (element != null) {
if (!(element.IsHitTestVisible && element.Visibility == Visibility.Visible)) {
return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
}
var designItem = Context.Services.Component.GetDesignItem(element) as XamlDesignItem;
if (designItem != null && designItem.IsDesignTimeLocked) {
return HitTestFilterBehavior.ContinueSkipSelfAndChildren;
}
}
hitTestElements.Add(element);
return HitTestFilterBehavior.Continue;
}
/// <summary>
/// Performs a custom hit testing lookup for the specified mouse event args.
/// </summary>
public DesignPanelHitTestResult HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, HitTestType hitTestType)
{
hitTestElements.Clear();
DesignPanelHitTestResult result = DesignPanelHitTestResult.NoHit;
HitTest(mousePosition, testAdorners, testDesignSurface,
delegate(DesignPanelHitTestResult r) {
result = r;
return false;
}, hitTestType);
return result;
}
/// <summary>
/// Performs a hit test on the design surface, raising <paramref name="callback"/> for each match.
/// Hit testing continues while the callback returns true.
/// </summary>
public void HitTest(Point mousePosition, bool testAdorners, bool testDesignSurface, Predicate<DesignPanelHitTestResult> callback, HitTestType hitTestType)
{
if (mousePosition.X < 0 || mousePosition.Y < 0 || mousePosition.X > this.RenderSize.Width || mousePosition.Y > this.RenderSize.Height) {
return;
}
// First try hit-testing on the adorner layer.
bool continueHitTest = true;
HitTestFilterCallback filterBehavior = CustomHitTestFilterBehavior ?? FilterHitTestInvisibleElements;
CustomHitTestFilterBehavior = null;
hitTestElements.Clear();
if (testAdorners) {
RunHitTest(
_adornerLayer, mousePosition, filterBehavior,
delegate(HitTestResult result) {
if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
DependencyObject obj = result.VisualHit;
while (obj != null && obj != _adornerLayer) {
AdornerPanel adorner = obj as AdornerPanel;
if (adorner != null) {
customResult.AdornerHit = adorner;
}
obj = VisualTreeHelper.GetParent(obj);
}
continueHitTest = callback(customResult);
return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop;
} else {
return HitTestResultBehavior.Continue;
}
});
}
if (continueHitTest && testDesignSurface) {
RunHitTest(
this.Child, mousePosition, filterBehavior,
delegate(HitTestResult result) {
if (result != null && result.VisualHit != null && result.VisualHit is Visual) {
DesignPanelHitTestResult customResult = new DesignPanelHitTestResult((Visual)result.VisualHit);
ViewService viewService = _context.Services.View;
DependencyObject obj = result.VisualHit;
if (hitTestType == HitTestType.ElementSelection)
{
if (Keyboard.IsKeyDown(Key.LeftAlt))
if (lastElement != null && lastElement != _context.RootItem.Component &&
hitTestElements.Contains(lastElement))
{
var idx = hitTestElements.IndexOf(lastElement) - 1;
if (idx >= 0)
obj = hitTestElements[idx];
}
}
while (obj != null) {
if ((customResult.ModelHit = viewService.GetModel(obj)) != null)
break;
obj = VisualTreeHelper.GetParent(obj);
}
if (customResult.ModelHit == null) {
customResult.ModelHit = _context.RootItem;
}
if (hitTestType == HitTestType.ElementSelection)
{
lastElement = obj;
}
continueHitTest = callback(customResult);
return continueHitTest ? HitTestResultBehavior.Continue : HitTestResultBehavior.Stop;
} else {
return HitTestResultBehavior.Continue;
}
}
);
}
}
#endregion
#region Fields + Constructor
DesignContext _context;
readonly EatAllHitTestRequests _eatAllHitTestRequests;
readonly AdornerLayer _adornerLayer;
public DesignPanel()
{
this.Focusable = true;
this.Margin = new Thickness(16);
DesignerProperties.SetIsInDesignMode(this, true);
_eatAllHitTestRequests = new EatAllHitTestRequests();
_eatAllHitTestRequests.MouseDown += delegate {
// ensure the design panel has focus while the user is interacting with it
this.Focus();
};
_eatAllHitTestRequests.AllowDrop = true;
_adornerLayer = new AdornerLayer(this);
this.PreviewKeyUp += DesignPanel_KeyUp;
this.PreviewKeyDown += DesignPanel_KeyDown;
}
#endregion
#region Properties
public DesignSurface DesignSurface { get; internal set; }
//Set custom HitTestFilterCallbak
public HitTestFilterCallback CustomHitTestFilterBehavior { get; set; }
public AdornerLayer AdornerLayer
{
get
{
return _adornerLayer;
}
}
/// <summary>
/// Gets/Sets the design context.
/// </summary>
public DesignContext Context {
get { return _context; }
set { _context = value; }
}
public ICollection<AdornerPanel> Adorners {
get {
return _adornerLayer.Adorners;
}
}
/// <summary>
/// Gets/Sets if the design content is visible for hit-testing purposes.
/// </summary>
public bool IsContentHitTestVisible {
get { return !_eatAllHitTestRequests.IsHitTestVisible; }
set { _eatAllHitTestRequests.IsHitTestVisible = !value; }
}
/// <summary>
/// Gets/Sets if the adorner layer is visible for hit-testing purposes.
/// </summary>
public bool IsAdornerLayerHitTestVisible {
get { return _adornerLayer.IsHitTestVisible; }
set { _adornerLayer.IsHitTestVisible = value; }
}
/// <summary>
/// Enables / Disables the Snapline Placement
/// </summary>
private bool _useSnaplinePlacement = true;
public bool UseSnaplinePlacement {
get { return _useSnaplinePlacement; }
set {
if (_useSnaplinePlacement != value) {
_useSnaplinePlacement = value;
OnPropertyChanged("UseSnaplinePlacement");
}
}
}
/// <summary>
/// Enables / Disables the Raster Placement
/// </summary>
private bool _useRasterPlacement = false;
public bool UseRasterPlacement {
get { return _useRasterPlacement; }
set {
if (_useRasterPlacement != value) {
_useRasterPlacement = value;
OnPropertyChanged("UseRasterPlacement");
}
}
}
/// <summary>
/// Sets the with of the Raster when using Raster Placement
/// </summary>
private int _rasterWidth = 5;
public int RasterWidth {
get { return _rasterWidth; }
set {
if (_rasterWidth != value) {
_rasterWidth = value;
OnPropertyChanged("RasterWidth");
}
}
}
#endregion
#region Visual Child Management
public override UIElement Child {
get { return base.Child; }
set {
if (base.Child == value)
return;
if (value == null) {
// Child is being set from some value to null
// remove _adornerLayer and _eatAllHitTestRequests
RemoveVisualChild(_adornerLayer);
RemoveVisualChild(_eatAllHitTestRequests);
} else if (base.Child == null) {
// Child is being set from null to some value
AddVisualChild(_adornerLayer);
AddVisualChild(_eatAllHitTestRequests);
}
base.Child = value;
}
}
protected override Visual GetVisualChild(int index)
{
if (base.Child != null) {
if (index == 0)
return base.Child;
else if (index == 1)
return _eatAllHitTestRequests;
else if (index == 2)
return _adornerLayer;
}
return base.GetVisualChild(index);
}
protected override int VisualChildrenCount {
get {
if (base.Child != null)
return 3;
else
return base.VisualChildrenCount;
}
}
protected override Size MeasureOverride(Size constraint)
{
Size result = base.MeasureOverride(constraint);
if (this.Child != null) {
_adornerLayer.Measure(constraint);
_eatAllHitTestRequests.Measure(constraint);
}
return result;
}
protected override Size ArrangeOverride(Size arrangeSize)
{
Size result = base.ArrangeOverride(arrangeSize);
if (this.Child != null) {
Rect r = new Rect(new Point(0, 0), arrangeSize);
_adornerLayer.Arrange(r);
_eatAllHitTestRequests.Arrange(r);
}
return result;
}
#endregion
PlacementOperation placementOp;
int dx = 0;
int dy = 0;
/// <summary>
/// If interface implementing class sets this to false defaultkeyaction will be
/// </summary>
/// <param name="e"></param>
/// <returns></returns>
bool InvokeDefaultKeyDownAction(Extension e)
{
var keyDown = e as IKeyDown;
if (keyDown != null) {
return keyDown.InvokeDefaultAction;
}
return true;
}
private void DesignPanel_KeyUp(object sender, KeyEventArgs e)
{
if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down)
{
e.Handled = true;
if (placementOp != null) {
placementOp.Commit();
placementOp = null;
}
}
//pass the key event to the underlying objects if they have implemented IKeyUp interface
//OBS!!!! this call needs to be here, after the placementOp.Commit().
//In case the underlying object has a operation of its own this operation needs to be commited first
foreach (DesignItem di in Context.Services.Selection.SelectedItems.Reverse()) {
foreach (Extension ext in di.Extensions) {
var keyUp = ext as IKeyUp;
if (keyUp != null) {
keyUp.KeyUpAction(sender, e);
}
}
}
}
void DesignPanel_KeyDown(object sender, KeyEventArgs e)
{
//pass the key event down to the underlying objects if they have implemented IKeyUp interface
//OBS!!!! this call needs to be here, before the PlacementOperation.Start.
//In case the underlying object has a operation of its own this operation needs to be set first
foreach (DesignItem di in Context.Services.Selection.SelectedItems) {
foreach (Extension ext in di.Extensions) {
var keyDown = ext as IKeyDown;
if (keyDown != null) {
keyDown.KeyDownAction(sender, e);
}
}
}
if (e.Key == Key.Left || e.Key == Key.Right || e.Key == Key.Up || e.Key == Key.Down) {
e.Handled = true;
PlacementType placementType = Keyboard.IsKeyDown(Key.LeftCtrl) ? PlacementType.Resize : PlacementType.Move;
if (placementOp != null && placementOp.Type != placementType) {
placementOp.Commit();
placementOp = null;
}
if (placementOp == null) {
//check if any objects don't want the default action to be invoked
List<DesignItem> placedItems = Context.Services.Selection.SelectedItems.Where(x => x.Extensions.All(InvokeDefaultKeyDownAction)).ToList();
//if no remaining objects, break
if (placedItems.Count < 1) return;
dx = 0;
dy = 0;
placementOp = PlacementOperation.Start(placedItems, placementType);
}
switch (e.Key) {
case Key.Left:
dx += Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1;
break;
case Key.Up:
dy += Keyboard.IsKeyDown(Key.LeftShift) ? -10 : -1;
break;
case Key.Right:
dx += Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1;
break;
case Key.Down:
dy += Keyboard.IsKeyDown(Key.LeftShift) ? 10 : 1;
break;
}
foreach (PlacementInformation info in placementOp.PlacedItems)
{
var bounds = info.OriginalBounds;
if (placementType == PlacementType.Move) {
info.Bounds = new Rect(bounds.Left + dx,
bounds.Top + dy,
bounds.Width,
bounds.Height);
} else if (placementType == PlacementType.Resize) {
if (bounds.Width + dx >= 0 && bounds.Height + dy >= 0) {
info.Bounds = new Rect(bounds.Left,
bounds.Top,
bounds.Width + dx,
bounds.Height + dy);
}
}
placementOp.CurrentContainerBehavior.SetPosition(info);
}
}
}
static bool IsPropertySet(UIElement element, DependencyProperty d)
{
return element.ReadLocalValue(d) != DependencyProperty.UnsetValue;
}
protected override void OnQueryCursor(QueryCursorEventArgs e)
{
base.OnQueryCursor(e);
if (_context != null) {
Cursor cursor = _context.Services.Tool.CurrentTool.Cursor;
if (cursor != null) {
e.Cursor = cursor;
e.Handled = true;
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
}
#region ContextMenu
private Dictionary<ContextMenu, Tuple<int,List<object>>> contextMenusAndEntries = new Dictionary<ContextMenu, Tuple<int,List<object>>>();
public Action<ContextMenu> ContextMenuHandler { get; set; }
public void AddContextMenu(ContextMenu contextMenu)
{
contextMenusAndEntries.Add(contextMenu, new Tuple<int, List<object>>(contextMenusAndEntries.Count, new List<object>(contextMenu.Items.Cast<object>())));
contextMenu.Items.Clear();
UpdateContextMenu();
}
public void RemoveContextMenu(ContextMenu contextMenu)
{
contextMenusAndEntries.Remove(contextMenu);
UpdateContextMenu();
}
public void ClearContextMenu()
{
contextMenusAndEntries.Clear();
ContextMenu = null;
}
private void UpdateContextMenu()
{
if (this.ContextMenu != null)
{
this.ContextMenu.Items.Clear();
this.ContextMenu = null;
}
var contextMenu = new ContextMenu();
foreach (var entries in contextMenusAndEntries.Values.OrderBy(x => x.Item1).Select(x => x.Item2))
{
if (contextMenu.Items.Count > 0)
contextMenu.Items.Add(new Separator());
foreach (var entry in entries)
{
var ctl = ((FrameworkElement)entry).TryFindParent<ItemsControl>();
if (ctl != null)
ctl.Items.Remove(entry);
contextMenu.Items.Add(entry);
}
}
if (ContextMenuHandler != null)
ContextMenuHandler(contextMenu);
else
this.ContextMenu = contextMenu;
}
#endregion
}
}

388
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs

@ -1,388 +0,0 @@ @@ -1,388 +0,0 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of this
// software and associated documentation files (the "Software"), to deal in the Software
// without restriction, including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
// to whom the Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all copies or
// substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
// PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
// FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Xml;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
using System.Diagnostics;
using ICSharpCode.WpfDesign.XamlDom;
using System.Threading;
using System.Globalization;
namespace ICSharpCode.WpfDesign.Designer
{
/// <summary>
/// Surface hosting the WPF designer.
/// </summary>
[TemplatePart(Name = "PART_DesignContent", Type = typeof(ContentControl))]
[TemplatePart(Name = "PART_Zoom", Type = typeof(ZoomControl))]
public partial class DesignSurface : ContentControl, INotifyPropertyChanged
{
private FocusNavigator _focusNav;
static DesignSurface()
{
DefaultStyleKeyProperty.OverrideMetadata(typeof(DesignSurface), new FrameworkPropertyMetadata(typeof(DesignSurface)));
}
public DesignSurface()
{
//TODO: this is for converters (see PropertyGrid)
Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
this.AddCommandHandler(ApplicationCommands.Undo, Undo, CanUndo);
this.AddCommandHandler(ApplicationCommands.Redo, Redo, CanRedo);
this.AddCommandHandler(ApplicationCommands.Copy, Copy, CanCopyOrCut);
this.AddCommandHandler(ApplicationCommands.Cut, Cut, CanCopyOrCut);
this.AddCommandHandler(ApplicationCommands.Delete, Delete, CanDelete);
this.AddCommandHandler(ApplicationCommands.Paste, Paste, CanPaste);
this.AddCommandHandler(ApplicationCommands.SelectAll, SelectAll, CanSelectAll);
this.AddCommandHandler(Commands.AlignTopCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Top), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
this.AddCommandHandler(Commands.AlignMiddleCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.VerticalMiddle), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
this.AddCommandHandler(Commands.AlignBottomCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Bottom), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
this.AddCommandHandler(Commands.AlignLeftCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Left), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
this.AddCommandHandler(Commands.AlignCenterCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.HorizontalMiddle), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
this.AddCommandHandler(Commands.AlignRightCommand, () => ModelTools.ArrangeItems(this.DesignContext.Services.Selection.SelectedItems, ArrangeDirection.Right), () => this.DesignContext.Services.Selection.SelectedItems.Count() > 1);
this.AddCommandHandler(Commands.RotateLeftCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(-90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);
this.AddCommandHandler(Commands.RotateRightCommand, () => ModelTools.ApplyTransform(this.DesignContext.Services.Selection.PrimarySelection, new RotateTransform(90)), () => this.DesignContext.Services.Selection.PrimarySelection != null);
_sceneContainer = new Border() { AllowDrop = false, UseLayoutRounding = true };
_sceneContainer.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal);
_designPanel = new DesignPanel() {Child = _sceneContainer, DesignSurface = this};
}
internal DesignPanel _designPanel;
private ContentControl _partDesignContent;
private Border _sceneContainer;
public override void OnApplyTemplate()
{
_partDesignContent = this.Template.FindName("PART_DesignContent", this) as ContentControl;
_partDesignContent.Content = _designPanel;
_partDesignContent.RequestBringIntoView += _partDesignContent_RequestBringIntoView;
this.ZoomControl = this.Template.FindName("PART_Zoom", this) as ZoomControl;
OnPropertyChanged("ZoomControl");
base.OnApplyTemplate();
}
private bool enableBringIntoView = false;
public void ScrollIntoView(DesignItem designItem)
{
enableBringIntoView = true;
LogicalTreeHelper.BringIntoView(designItem.View);
enableBringIntoView = false;
}
void _partDesignContent_RequestBringIntoView(object sender, RequestBringIntoViewEventArgs e)
{
if (!enableBringIntoView)
e.Handled = true;
enableBringIntoView = false;
}
protected override void OnPreviewMouseLeftButtonDown(MouseButtonEventArgs e)
{
if (ZoomControl != null && e.OriginalSource == ZoomControl)
{
UnselectAll();
}
}
public ZoomControl ZoomControl { get; private set; }
DesignContext _designContext;
/// <summary>
/// Gets the active design context.
/// </summary>
public DesignContext DesignContext {
get { return _designContext; }
}
/// <summary>
/// Gets the DesignPanel
/// </summary>
public DesignPanel DesignPanel {
get { return _designPanel; }
}
/// <summary>
/// Initializes the designer content from the specified XmlReader.
/// </summary>
public void LoadDesigner(XmlReader xamlReader, XamlLoadSettings loadSettings)
{
UnloadDesigner();
loadSettings = loadSettings ?? new XamlLoadSettings();
loadSettings.CustomServiceRegisterFunctions.Add(
context => context.Services.AddService(typeof(IDesignPanel), _designPanel));
InitializeDesigner(new XamlDesignContext(xamlReader, loadSettings));
}
/// <summary>
/// Saves the designer content into the specified XmlWriter.
/// </summary>
public void SaveDesigner(XmlWriter writer)
{
_designContext.Save(writer);
}
void InitializeDesigner(DesignContext context)
{
_designContext = context;
_designPanel.Context = context;
_designPanel.ClearContextMenu();
if (context.RootItem != null) {
_sceneContainer.Child = context.RootItem.View;
}
context.Services.RunWhenAvailable<UndoService>(
undoService => undoService.UndoStackChanged += delegate {
CommandManager.InvalidateRequerySuggested();
}
);
context.Services.Selection.SelectionChanged += delegate {
CommandManager.InvalidateRequerySuggested();
};
context.Services.AddService(typeof(IKeyBindingService), new DesignerKeyBindings(this));
_focusNav=new FocusNavigator(this);
_focusNav.Start();
OnPropertyChanged("DesignContext");
}
/// <summary>
/// Unloads the designer content.
/// </summary>
public void UnloadDesigner()
{
if (_designContext != null) {
foreach (object o in _designContext.Services.AllServices) {
IDisposable d = o as IDisposable;
if (d != null) d.Dispose();
}
}
_designContext = null;
_designPanel.Context = null;
_sceneContainer.Child = null;
_designPanel.Adorners.Clear();
}
#region Commands
public bool CanUndo()
{
UndoService undoService = GetService<UndoService>();
return undoService != null && undoService.CanUndo;
}
public void Undo()
{
UndoService undoService = GetService<UndoService>();
IUndoAction action = undoService.UndoActions.First();
Debug.WriteLine("Undo " + action.Title);
undoService.Undo();
_designContext.Services.Selection.SetSelectedComponents(GetLiveElements(action.AffectedElements));
}
public bool CanRedo()
{
UndoService undoService = GetService<UndoService>();
return undoService != null && undoService.CanRedo;
}
public void Redo()
{
UndoService undoService = GetService<UndoService>();
IUndoAction action = undoService.RedoActions.First();
Debug.WriteLine("Redo " + action.Title);
undoService.Redo();
_designContext.Services.Selection.SetSelectedComponents(GetLiveElements(action.AffectedElements));
}
public bool CanCopyOrCut()
{
ISelectionService selectionService = GetService<ISelectionService>();
if(selectionService!=null){
if (selectionService.SelectedItems.Count == 0)
return false;
if (selectionService.SelectedItems.Count == 1 && selectionService.PrimarySelection == DesignContext.RootItem)
return false;
}
return true;
}
public void Copy()
{
XamlDesignContext xamlContext = _designContext as XamlDesignContext;
ISelectionService selectionService = GetService<ISelectionService>();
if(xamlContext != null && selectionService != null){
xamlContext.XamlEditAction.Copy(selectionService.SelectedItems);
}
}
public void Cut()
{
XamlDesignContext xamlContext = _designContext as XamlDesignContext;
ISelectionService selectionService = GetService<ISelectionService>();
if(xamlContext != null && selectionService != null){
xamlContext.XamlEditAction.Cut(selectionService.SelectedItems);
}
}
public bool CanDelete()
{
if (_designContext != null) {
return ModelTools.CanDeleteComponents(_designContext.Services.Selection.SelectedItems);
}
return false;
}
public void Delete()
{
if (_designContext != null) {
ModelTools.DeleteComponents(_designContext.Services.Selection.SelectedItems);
}
}
public bool CanPaste()
{
ISelectionService selectionService = GetService<ISelectionService>();
if(selectionService!=null && selectionService.SelectedItems.Count!=0){
string xaml = Clipboard.GetText(TextDataFormat.Xaml);
if(xaml != "" && xaml != " ")
return true;
}
return false;
}
public void Paste()
{
XamlDesignContext xamlContext = _designContext as XamlDesignContext;
if(xamlContext != null){
xamlContext.XamlEditAction.Paste();
}
}
public bool CanSelectAll()
{
return DesignContext != null;
}
//TODO: Do not select layout root
public void SelectAll()
{
var items = Descendants(DesignContext.RootItem).Where(item => ModelTools.CanSelectComponent(item)).ToArray();
DesignContext.Services.Selection.SetSelectedComponents(items);
}
public void UnselectAll()
{
DesignContext.Services.Selection.SetSelectedComponents(null);
}
//TODO: Share with Outline / PlacementBehavior
public static IEnumerable<DesignItem> DescendantsAndSelf(DesignItem item)
{
yield return item;
foreach (var child in Descendants(item)) {
yield return child;
}
}
public static IEnumerable<DesignItem> Descendants(DesignItem item)
{
if (item.ContentPropertyName != null) {
var content = item.ContentProperty;
if (content.IsCollection) {
foreach (var child in content.CollectionElements) {
foreach (var child2 in DescendantsAndSelf(child)) {
yield return child2;
}
}
} else {
if (content.Value != null) {
foreach (var child2 in DescendantsAndSelf(content.Value)) {
yield return child2;
}
}
}
}
}
// Filters an element list, dropping all elements that are not part of the xaml document
// (e.g. because they were deleted).
static List<DesignItem> GetLiveElements(ICollection<DesignItem> items)
{
List<DesignItem> result = new List<DesignItem>(items.Count);
foreach (DesignItem item in items) {
if (ModelTools.IsInDocument(item) && ModelTools.CanSelectComponent(item)) {
result.Add(item);
}
}
return result;
}
T GetService<T>() where T : class
{
if (_designContext != null)
return _designContext.Services.GetService<T>();
else
return null;
}
#endregion
#region INotifyPropertyChanged implementation
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
var ev = PropertyChanged;
if (ev != null)
ev(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save