Browse Source

Merge pull request #1 from icsharpcode/master

Trying to update my fork ...
pull/626/head
Oleg Bevz 12 years ago
parent
commit
b3c9ffa9d5
  1. 63
      data/resources/StringResources.resx
  2. 2
      data/templates/file/CSharp/CSharp.Exception.xft
  3. 2
      data/templates/file/VB/VB.Exception.xft
  4. 5
      src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResultsReader.cs
  5. 7
      src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs
  6. 3
      src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin
  7. 41
      src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs
  8. 2
      src/AddIns/Debugger/Debugger.Core/Value.cs
  9. 31
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs
  10. 64
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs
  11. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin
  12. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/EnumBar.xaml.cs
  13. 159
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/GridUnitSelector.xaml.cs
  14. 50
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignPanel.cs
  15. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml.cs
  16. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs
  17. 38
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml
  18. 65
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml.cs
  19. 54
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenuExtension.cs
  20. 48
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
  21. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenu.xaml.cs
  22. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenuExtension.cs
  23. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs
  24. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs
  25. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenuExtension.cs
  26. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs
  27. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs
  28. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenuExtension.cs
  29. 22
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml.cs
  30. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs
  31. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CopyIcon.png
  32. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CutIcon.png
  33. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.DeleteIcon.png
  34. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.PasteIcon.png
  35. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.RedoIcon.png
  36. BIN
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.UndoIcon.png
  37. 30
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs
  38. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs
  39. 6
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml
  40. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs
  41. 31
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs
  42. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs
  43. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs
  44. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs
  45. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs
  46. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs
  47. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs
  48. 26
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ColorEditor.xaml.cs
  49. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ComboBoxEditor.xaml
  50. 20
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs
  51. 25
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs
  52. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FlatCollectionEditor.xaml.cs
  53. 18
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs
  54. 24
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs
  55. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/OpenCollectionEditor.xaml.cs
  56. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TextBoxEditor.xaml
  57. 19
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs
  58. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TimeSpanEditor.xaml.cs
  59. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs
  60. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs
  61. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs
  62. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ClickOrDragMouseGesture.cs
  63. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs
  64. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs
  65. 29
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj
  66. 13
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs
  67. 14
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs
  68. 119
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs
  69. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs
  70. 52
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/VersionedAssemblyResourceDictionary.cs
  71. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml
  72. 68
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs
  73. 22
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs
  74. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs
  75. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs
  76. 27
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignInstanceExtension.cs
  77. 4
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs
  78. 82
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs
  79. 1
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj
  80. 10
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs
  81. 41
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs
  82. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs
  83. 63
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs
  84. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs
  85. 33
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs
  86. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs
  87. 23
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs
  88. 15
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs
  89. 17
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs
  90. 8
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs
  91. 5
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs
  92. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs
  93. 31
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs
  94. 33
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs
  95. 3
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs
  96. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj
  97. 1
      src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj
  98. 14
      src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeFileSystem.cs
  99. 4
      src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementProject.cs
  100. 14
      src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs
  101. Some files were not shown because too many files have changed in this diff Show More

63
data/resources/StringResources.resx

@ -8377,67 +8377,4 @@ Press Esc to cancel this operation.</value> @@ -8377,67 +8377,4 @@ Press Esc to cancel this operation.</value>
<data name="ICSharpCode.WpfDesign.AddIn.PressAltText" xml:space="preserve">
<value>Press "Alt" to enter Container</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo" xml:space="preserve">
<value>Assembly Info</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.AssemblyVersion" xml:space="preserve">
<value>Assembly version:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.Company" xml:space="preserve">
<value>Company:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.Copyright" xml:space="preserve">
<value>Copyright:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.Description" xml:space="preserve">
<value>Description:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.FileVersion" xml:space="preserve">
<value>File version:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.GUID" xml:space="preserve">
<value>GUID:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.MakeAssemblyCOMVisible" xml:space="preserve">
<value>Make assembly COM-visible</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.NeutralLanguage" xml:space="preserve">
<value>Neutral language:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.Product" xml:space="preserve">
<value>Product:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.Title" xml:space="preserve">
<value>Title:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.Trademark" xml:space="preserve">
<value>Trademark:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.AssemblyInfoNotFound" xml:space="preserve">
<value>Assembly info file was not found. Please ensure that the project contains assembly info file.</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.ClsCompliant" xml:space="preserve">
<value>CLS compliant</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.DefaultAlias" xml:space="preserve">
<value>Default alias:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.InformationalVersion" xml:space="preserve">
<value>Informational version:</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.JitOptimization" xml:space="preserve">
<value>JIT optimization</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.JitTracking" xml:space="preserve">
<value>JIT tracking</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.NewGUID" xml:space="preserve">
<value>New GUID</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.IncorrectValue" xml:space="preserve">
<value>One of the assembly info values is incorrect.</value>
</data>
<data name="Dialog.ProjectOptions.AssemblyInfo.None" xml:space="preserve">
<value>None</value>
</data>
</root>

2
data/templates/file/CSharp/CSharp.Exception.xft

@ -28,7 +28,7 @@ using System.Runtime.Serialization; @@ -28,7 +28,7 @@ using System.Runtime.Serialization;
namespace ${StandardNamespace}
{
/// <summary>
/// Desctiption of ${ClassName}.
/// Description of ${ClassName}.
/// </summary>
public class ${ClassName} : Exception, ISerializable
{

2
data/templates/file/VB/VB.Exception.xft

@ -27,7 +27,7 @@ Imports System.Runtime.Serialization @@ -27,7 +27,7 @@ Imports System.Runtime.Serialization
Namespace ${StandardNamespace}
''' <summary>
''' Desctiption of ${ClassName}.
''' Description of ${ClassName}.
''' </summary>
Public Class ${ClassName}
Inherits Exception

5
src/AddIns/Analysis/CodeCoverage/Project/Src/CodeCoverageResultsReader.cs

@ -52,8 +52,9 @@ namespace ICSharpCode.CodeCoverage @@ -52,8 +52,9 @@ namespace ICSharpCode.CodeCoverage
CodeCoverageResults ReadCodeCoverageResults(string fileName)
{
TextReader reader = fileSystem.OpenText(FileName.Create(fileName));
return new CodeCoverageResults(reader);
using (TextReader reader = fileSystem.OpenText(FileName.Create(fileName))) {
return new CodeCoverageResults(reader);
}
}
public IEnumerable<string> GetMissingResultsFiles()

7
src/AddIns/Analysis/CodeCoverage/Project/Src/RunTestWithCodeCoverageCommand.cs

@ -119,7 +119,7 @@ namespace ICSharpCode.CodeCoverage @@ -119,7 +119,7 @@ namespace ICSharpCode.CodeCoverage
void DisplayCodeCoverageResults(CodeCoverageResultsReader coverageResultsReader)
{
foreach (CodeCoverageResults result in coverageResultsReader.GetResults()) {
foreach (CodeCoverageResults result in GetResults(coverageResultsReader)) {
DisplayCodeCoverageResults(result);
}
foreach (string missingFile in coverageResultsReader.GetMissingResultsFiles()) {
@ -127,6 +127,11 @@ namespace ICSharpCode.CodeCoverage @@ -127,6 +127,11 @@ namespace ICSharpCode.CodeCoverage
}
}
IEnumerable<CodeCoverageResults> GetResults(CodeCoverageResultsReader coverageResultsReader)
{
return SD.MainThread.InvokeIfRequired(() => coverageResultsReader.GetResults().ToList());
}
void DisplayCodeCoverageResults(CodeCoverageResults results)
{
SD.MainThread.InvokeIfRequired(() => CodeCoverageService.ShowResults(results));

3
src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin

@ -115,9 +115,6 @@ @@ -115,9 +115,6 @@
<OptionPanel id = "DebugOptions"
label = "${res:Dialog.ProjectOptions.DebugOptions}"
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.DebugOptions"/>
<OptionPanel id = "AssemblyInfo"
label = "${res:Dialog.ProjectOptions.AssemblyInfo}"
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.AssemblyInfoPanel"/>
<!--<OptionPanel id = "Publish"
label = "${res:Dialog.ProjectOptions.Publish}"
class = "ICSharpCode.SharpDevelop.Gui.OptionPanels.Publish"/>-->

41
src/AddIns/Debugger/Debugger.AddIn/NRefactory/ExpressionEvaluationVisitor.cs

@ -444,7 +444,7 @@ namespace Debugger.AddIn @@ -444,7 +444,7 @@ namespace Debugger.AddIn
} else
throw new GetValueException("Invoked member must be a method or property");
Value target = null;
if (!usedMethod.IsStatic)
if (!usedMethod.IsStatic && !usedMethod.IsConstructor)
target = Convert(result.TargetResult).GetPermanentReference(evalThread);
return InvokeMethod(target, usedMethod, result.Arguments.Select(rr => Convert(rr).GetPermanentReference(evalThread)).ToArray());
}
@ -479,26 +479,33 @@ namespace Debugger.AddIn @@ -479,26 +479,33 @@ namespace Debugger.AddIn
}
sb.Append("}");
return sb.ToString();
} else if (val.Type.GetAllBaseTypeDefinitions().Any(def => def.IsKnownType(KnownTypeCode.ICollection))) {
StringBuilder sb = new StringBuilder();
sb.Append(new CSharpAmbience().ConvertType(val.Type));
sb.Append(" {");
val = val.GetPermanentReference(evalThread);
var countProp = val.Type.GetProperties(p => p.Name == "Count" && !p.IsExplicitInterfaceImplementation).Single();
int count = (int)val.GetMemberValue(evalThread, countProp).PrimitiveValue;
for(int i = 0; i < count; i++) {
if (i > 0) sb.Append(", ");
var itemProperty = val.Type.GetProperties(p => p.IsIndexer && p.Name == "Item" && !p.IsExplicitInterfaceImplementation).Single();
Value item = val.GetPropertyValue(evalThread, itemProperty, Eval.CreateValue(evalThread, i));
sb.Append(FormatValue(evalThread, item));
} else if (val.Type.GetAllBaseTypeDefinitions().Any(def => def.IsKnownType(KnownTypeCode.ICollection) || def.IsKnownType(KnownTypeCode.ICollectionOfT))) {
var countProp = val.Type.GetProperties(p => p.Name == "Count" && !p.IsExplicitInterfaceImplementation).SingleOrDefault();
if (countProp != null) {
StringBuilder sb = new StringBuilder();
sb.Append(new CSharpAmbience().ConvertType(val.Type));
val = val.GetPermanentReference(evalThread);
int count = (int)val.GetMemberValue(evalThread, countProp).PrimitiveValue;
var itemProperty = val.Type.GetProperties(p => p.IsIndexer && p.Name == "Item" && !p.IsExplicitInterfaceImplementation).SingleOrDefault();
if (itemProperty != null) {
sb.Append(" {");
for (int i = 0; i < count; i++) {
if (i > 0)
sb.Append(", ");
Value item = val.GetPropertyValue(evalThread, itemProperty, Eval.CreateValue(evalThread, i));
sb.Append(FormatValue(evalThread, item));
}
sb.Append("}");
} else {
sb.AppendFormat(" ({0} elements)", count);
}
return sb.ToString();
}
sb.Append("}");
return sb.ToString();
} else if (val.Type.IsKnownType(KnownTypeCode.String) || val.Type.IsPrimitiveType()) {
return TextWriterTokenWriter.PrintPrimitiveValue(val.PrimitiveValue);
} else {
return val.InvokeToString(evalThread);
}
return val.InvokeToString(evalThread);
}
}

2
src/AddIns/Debugger/Debugger.Core/Value.cs

@ -416,6 +416,8 @@ namespace Debugger @@ -416,6 +416,8 @@ namespace Debugger
if (memberInfo == null)
throw new DebuggerException("memberInfo is null");
if (!memberInfo.IsStatic) {
if (memberInfo.SymbolKind == SymbolKind.Constructor)
throw new GetValueException("Constructor expression");
if (objectInstance == null)
throw new DebuggerException("No target object specified");
if (objectInstance.IsNull)

31
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/MyTypeFinder.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.ExceptionServices;
@ -73,6 +74,36 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -73,6 +74,36 @@ namespace ICSharpCode.WpfDesign.AddIn
}
}
public override Uri ConvertUriToLocalUri(Uri uri)
{
if (!uri.IsAbsoluteUri)
{
var compilation = SD.ParserService.GetCompilationForFile(file.FileName);
var assembly = this.typeResolutionService.LoadAssembly(compilation.MainAssembly);
var prj = SD.ProjectService.CurrentProject;
if (uri.OriginalString.Contains(";"))
{
var parts = uri.OriginalString.Split(';');
if (prj.Name == parts[0].Substring(1))
{
var newUri = new Uri(("file://" + Path.Combine(prj.Directory, parts[1].Substring("component".Length + 1))).Replace("\\", "/"), UriKind.RelativeOrAbsolute);
return newUri;
}
}
else
{
var strg = uri.OriginalString;
if (strg.StartsWith("/"))
strg = strg.Substring(1);
var newUri = new Uri(("file://" + Path.Combine(prj.Directory, strg)).Replace("\\", "/"), UriKind.RelativeOrAbsolute);
return newUri;
}
}
return uri;
}
Assembly FindAssemblyInProjectReferences(string name)
{
IProject pc = GetProject(file);

64
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs

@ -22,16 +22,20 @@ using System.ComponentModel; @@ -22,16 +22,20 @@ using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Markup;
using System.Xml;
using ICSharpCode.Core;
using ICSharpCode.Core.Presentation;
using ICSharpCode.NRefactory.TypeSystem;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Designer;
using ICSharpCode.SharpDevelop.Dom;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
@ -44,6 +48,7 @@ using ICSharpCode.WpfDesign.Designer.OutlineView; @@ -44,6 +48,7 @@ using ICSharpCode.WpfDesign.Designer.OutlineView;
using ICSharpCode.WpfDesign.Designer.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.XamlDom;
namespace ICSharpCode.WpfDesign.AddIn
{
@ -60,6 +65,10 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -60,6 +65,10 @@ namespace ICSharpCode.WpfDesign.AddIn
this.TabPageText = "${res:FormsDesigner.DesignTabPages.DesignTabPage}";
this.IsActiveViewContentChanged += OnIsActiveViewContentChanged;
var compilation = SD.ParserService.GetCompilationForFile(file.FileName);
_path = Path.GetDirectoryName(compilation.MainAssembly.UnresolvedAssembly.Location);
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
}
static WpfViewContent()
@ -101,6 +110,8 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -101,6 +110,8 @@ namespace ICSharpCode.WpfDesign.AddIn
if (outline != null) {
outline.Root = null;
}
using (XmlTextReader r = new XmlTextReader(stream)) {
XamlLoadSettings settings = new XamlLoadSettings();
settings.DesignerAssemblies.Add(typeof(WpfViewContent).Assembly);
@ -117,7 +128,20 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -117,7 +128,20 @@ namespace ICSharpCode.WpfDesign.AddIn
settings.ReportErrors = UpdateTasks;
designer.LoadDesigner(r, settings);
designer.ContextMenuOpening += (sender, e) => MenuService.ShowContextMenu(e.OriginalSource as UIElement, designer, "/AddIns/WpfDesign/Designer/ContextMenu");
designer.DesignPanel.ContextMenuHandler = (contextMenu) => {
var newContextmenu = new ContextMenu();
var sdContextMenuItems = MenuService.CreateMenuItems(newContextmenu, designer, "/AddIns/WpfDesign/Designer/ContextMenu", "ContextMenu");
foreach(var entry in sdContextMenuItems)
newContextmenu.Items.Add(entry);
newContextmenu.Items.Add(new Separator());
var items = contextMenu.Items.Cast<Object>().ToList();
contextMenu.Items.Clear();
foreach(var entry in items)
newContextmenu.Items.Add(entry);
designer.DesignPanel.ContextMenu = newContextmenu;
};
if (outline != null && designer.DesignContext != null && designer.DesignContext.RootItem != null) {
outline.Root = OutlineNode.Create(designer.DesignContext.RootItem);
@ -129,9 +153,46 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -129,9 +153,46 @@ namespace ICSharpCode.WpfDesign.AddIn
} catch (Exception e) {
this.UserContent = new WpfDocumentError(e);
}
try{
var appXaml = SD.ProjectService.CurrentProject.Items.FirstOrDefault(x=>x.FileName.GetFileName().ToLower() == ("app.xaml"));
if (appXaml!=null){
var f=appXaml as FileProjectItem;
OpenedFile a = SD.FileService.GetOrCreateOpenedFile(f.FileName);
var xml = XmlReader.Create(a.OpenRead());
var doc=new XmlDocument();
doc.Load(xml);
var node = doc.FirstChild.ChildNodes.Cast<XmlNode>().FirstOrDefault(x=>x.Name=="Application.Resources");
foreach (XmlAttribute att in doc.FirstChild.Attributes.Cast<XmlAttribute>().ToList())
{
if (att.Name.StartsWith("xmlns"))
node.Attributes.Append(att);
}
var appXamlXml = XmlReader.Create(new StringReader(node.InnerXml));
var parsed = XamlParser.Parse(appXamlXml, ((XamlDesignContext) designer.DesignContext).ParserSettings);
var dict = (ResourceDictionary)parsed.RootInstance;
designer.DesignPanel.Resources.MergedDictionaries.Add(dict);
}
} catch (Exception ex) {
LoggingService.Error("Error in loading app.xaml", ex);
}
}
}
System.Reflection.Assembly CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args)
{
var assemblyName = (new AssemblyName(args.Name));
string fileName = Path.Combine(_path, assemblyName.Name) + ".dll";
if (File.Exists(fileName))
return typeResolutionService.LoadAssembly(fileName);
return null;
}
private TypeResolutionService typeResolutionService = new TypeResolutionService();
private string _path;
private MemoryStream _stream;
bool wasChangedInDesigner;
@ -285,6 +346,7 @@ namespace ICSharpCode.WpfDesign.AddIn @@ -285,6 +346,7 @@ namespace ICSharpCode.WpfDesign.AddIn
public override void Dispose()
{
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve;
SD.ProjectService.ProjectItemAdded -= OnReferenceAdded;
propertyContainer.Clear();

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin

@ -49,7 +49,7 @@ @@ -49,7 +49,7 @@
-->
<Path name="/AddIns/WpfDesign/Designer/ContextMenu">
<MenuItem label="${res:ICSharpCode.WPFDesigner.ContextMenu.ViewXAML}" id="viewXaml" icon="Icons.16x16.XMLFileIcon" class="ICSharpCode.WpfDesign.AddIn.Commands.ViewXaml" />
<MenuItem label="seperator1" type="Separator" />
<!--<MenuItem label="seperator1" type="Separator" />
<Condition name="IsCutCopyEnabled" action="Disable">
<MenuItem id="cut" label="${res:ICSharpCode.WPFDesigner.ContextMenu.Cut}" icon="Icons.16x16.CutIcon" shortcut="Control|X" class="ICSharpCode.WpfDesign.AddIn.Commands.Cut" />
<MenuItem id="copy" label="${res:ICSharpCode.WPFDesigner.ContextMenu.Copy}" icon="Icons.16x16.CopyIcon" shortcut="Control|C" class="ICSharpCode.WpfDesign.AddIn.Commands.Copy" />
@ -66,7 +66,7 @@ @@ -66,7 +66,7 @@
</Condition>
<Condition name="IsRedoEnabled" action="Disable">
<MenuItem id="redo" label="${res:ICSharpCode.WPFDesigner.ContextMenu.Redo}" icon="Icons.16x16.RedoIcon" shortcut="Control|R" class="ICSharpCode.WpfDesign.AddIn.Commands.Redo" />
</Condition>
</Condition>-->
<MenuItem label="seperator3" type="Separator" />
<MenuItem id="tools" label="${res:ICSharpCode.WPFDesigner.ContextMenu.Tools}" icon="PadIcons.Toolbar" shortcut="Control|Alt|X" class="ICSharpCode.WpfDesign.AddIn.Commands.Tools" />
<MenuItem id="properties" label="${res:ICSharpCode.WPFDesigner.ContextMenu.Properties}" icon="Icons.16x16.PropertiesIcon" shortcut="F4" class="ICSharpCode.WpfDesign.AddIn.Commands.Properties" />

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

@ -30,6 +30,7 @@ using System.Windows.Media.Imaging; @@ -30,6 +30,7 @@ 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
{
@ -37,7 +38,21 @@ namespace ICSharpCode.WpfDesign.Designer.Controls @@ -37,7 +38,21 @@ namespace ICSharpCode.WpfDesign.Designer.Controls
{
public EnumBar()
{
InitializeComponent();
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;

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

@ -25,83 +25,98 @@ using System.Windows.Data; @@ -25,83 +25,98 @@ 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)
{
InitializeComponent();
this.rail = rail;
}
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;
}
}
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;
}
}
}

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

@ -32,6 +32,7 @@ using System.Windows.Threading; @@ -32,6 +32,7 @@ using System.Windows.Threading;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Designer.Controls;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.Designer.Xaml;
namespace ICSharpCode.WpfDesign.Designer
@ -389,10 +390,17 @@ namespace ICSharpCode.WpfDesign.Designer @@ -389,10 +390,17 @@ namespace ICSharpCode.WpfDesign.Designer
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) {
dx = 0;
dy = 0;
placementOp = PlacementOperation.Start(Context.Services.Selection.SelectedItems, PlacementType.Move);
placementOp = PlacementOperation.Start(Context.Services.Selection.SelectedItems, placementType);
}
switch (e.Key) {
@ -414,17 +422,17 @@ namespace ICSharpCode.WpfDesign.Designer @@ -414,17 +422,17 @@ namespace ICSharpCode.WpfDesign.Designer
{
var bounds = info.OriginalBounds;
if (!Keyboard.IsKeyDown(Key.LeftCtrl)) {
if (placementType == PlacementType.Move) {
info.Bounds = new Rect(bounds.Left + dx,
bounds.Top + dy,
bounds.Width,
bounds.Height);
} else {
if (info.OriginalBounds.Width + dx >= 0 && info.OriginalBounds.Height + dy >= 0) {
info.Bounds = new Rect(info.OriginalBounds.Left,
info.OriginalBounds.Top,
info.OriginalBounds.Width + dx,
info.OriginalBounds.Height + dy);
} 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);
}
}
@ -461,6 +469,8 @@ namespace ICSharpCode.WpfDesign.Designer @@ -461,6 +469,8 @@ namespace ICSharpCode.WpfDesign.Designer
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>())));
@ -484,24 +494,32 @@ namespace ICSharpCode.WpfDesign.Designer @@ -484,24 +494,32 @@ namespace ICSharpCode.WpfDesign.Designer
private void UpdateContextMenu()
{
if (contextMenusAndEntries.Count == 0)
if (this.ContextMenu != null)
{
this.ContextMenu.Items.Clear();
this.ContextMenu = null;
}
if (this.ContextMenu == null)
this.ContextMenu = new ContextMenu();
this.ContextMenu.Items.Clear();
var contextMenu = new ContextMenu();
foreach (var entries in contextMenusAndEntries.Values.OrderBy(x => x.Item1).Select(x => x.Item2))
{
if (this.ContextMenu.Items.Count > 0)
this.ContextMenu.Items.Add(new Separator());
if (contextMenu.Items.Count > 0)
contextMenu.Items.Add(new Separator());
foreach (var entry in entries)
{
ContextMenu.Items.Add(entry);
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

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/ArrangeItemsContextMenu.xaml.cs

@ -18,6 +18,8 @@ @@ -18,6 +18,8 @@
using System;
using System.Linq;
using System.Windows;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
@ -29,7 +31,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -29,7 +31,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
this.designItem = designItem;
InitializeComponent();
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();
}
void Click_ArrangeLeft(object sender, System.Windows.RoutedEventArgs e)

12
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs

@ -70,21 +70,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -70,21 +70,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (IsPropertySet(child, Canvas.LeftProperty) || !IsPropertySet(child, Canvas.RightProperty)) {
x = GetCanvasProperty(child, Canvas.LeftProperty);
} else {
x = extendedComponent.ActualWidth - GetCanvasProperty(child, Canvas.RightProperty) - PlacementOperation.GetRealElementSize(child).Width;
x = extendedComponent.ActualWidth - GetCanvasProperty(child, Canvas.RightProperty) - PlacementOperation.GetRealElementSize(child).Width;
}
if (IsPropertySet(child, Canvas.TopProperty) || !IsPropertySet(child, Canvas.BottomProperty)) {
y = GetCanvasProperty(child, Canvas.TopProperty);
} else {
y = extendedComponent.ActualHeight - GetCanvasProperty(child, Canvas.BottomProperty) - PlacementOperation.GetRealElementSize(child).Height;
y = extendedComponent.ActualHeight - GetCanvasProperty(child, Canvas.BottomProperty) - PlacementOperation.GetRealElementSize(child).Height;
}
var p = new Point(x, y);
//Fixes, Empty Image Resized to 0
//return new Rect(p, child.RenderSize);
return new Rect(p, PlacementOperation.GetRealElementSize(item.View));
}
//Fixes, Empty Image Resized to 0
//return new Rect(p, child.RenderSize);
return new Rect(p, PlacementOperation.GetRealElementSize(item.View));
}
public override void SetPosition(PlacementInformation info)
{

38
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml

@ -0,0 +1,38 @@ @@ -0,0 +1,38 @@
<ContextMenu x:Class="ICSharpCode.WpfDesign.Designer.Extensions.DefaultCommandsContextMenu"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Translation="clr-namespace:ICSharpCode.WpfDesign.Designer"
>
<MenuItem Command="ApplicationCommands.Cut">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.CutIcon.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="ApplicationCommands.Copy">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.CopyIcon.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="ApplicationCommands.Paste">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.PasteIcon.png" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Command="ApplicationCommands.Delete">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.DeleteIcon.png" />
</MenuItem.Icon>
</MenuItem>
<Separator />
<MenuItem Command="ApplicationCommands.Undo">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.UndoIcon.png" />
</MenuItem.Icon>
</MenuItem>
<MenuItem Command="ApplicationCommands.Redo">
<MenuItem.Icon>
<Image Source="/ICSharpCode.WpfDesign.Designer;component/Images/Icons.16x16.RedoIcon.png" />
</MenuItem.Icon>
</MenuItem>
</ContextMenu>

65
src/Main/Base/Project/Src/Gui/Dialogs/OptionPanels/ProjectOptions/AssemblyInfo/AssemblyInfo.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenu.xaml.cs

@ -1,4 +1,4 @@ @@ -1,4 +1,4 @@
// Copyright (c) 2014 AlphaSierraPapa for the SharpDevelop Team
// 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
@ -17,44 +17,35 @@ @@ -17,44 +17,35 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Linq;
using System.Windows;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.SharpDevelop.Gui.OptionPanels
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
/// <summary>
/// Assembly info parameters model
/// </summary>
public class AssemblyInfo
public partial class DefaultCommandsContextMenu
{
public string Title { get; set; }
public string Description { get; set; }
public string Company { get; set; }
public string Product { get; set; }
public string Copyright { get; set; }
public string Trademark { get; set; }
public string DefaultAlias { get; set; }
public Version AssemblyVersion { get; set; }
public Version AssemblyFileVersion { get; set; }
public Version InformationalVersion { get; set; }
public Guid? Guid { get; set; }
public string NeutralLanguage { get; set; }
public bool ComVisible { get; set; }
public bool ClsCompliant { get; set; }
public bool JitOptimization { get; set; }
public bool JitTracking { get; set; }
private DesignItem designItem;
public DefaultCommandsContextMenu(DesignItem designItem)
{
this.designItem = designItem;
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();
}
}
}

54
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultCommandsContextMenuExtension.cs

@ -0,0 +1,54 @@ @@ -0,0 +1,54 @@
// 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;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Adorners;
using ICSharpCode.WpfDesign.Extensions;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
[ExtensionServer(typeof(PrimarySelectionExtensionServer))]
[ExtensionFor(typeof (UIElement))]
[Extension(Order = 10)]
public class DefaultCommandsContextMenuExtension : SelectionAdornerProvider
{
DesignPanel panel;
ContextMenu contextMenu;
protected override void OnInitialized()
{
base.OnInitialized();
contextMenu = new DefaultCommandsContextMenu(ExtendedItem);
panel = ExtendedItem.Context.Services.DesignPanel as DesignPanel;
if (panel != null)
panel.AddContextMenu(contextMenu);
}
protected override void OnRemove()
{
if (panel != null)
panel.RemoveContextMenu(contextMenu);
base.OnRemove();
}
}
}

48
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs

@ -38,26 +38,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -38,26 +38,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
[ExtensionFor(typeof(Viewbox))]
public class DefaultPlacementBehavior : BehaviorExtension, IPlacementBehavior
{
static List<Type> _contentControlsNotAllowedToAdd;
static DefaultPlacementBehavior()
{
_contentControlsNotAllowedToAdd = new List<Type>();
_contentControlsNotAllowedToAdd.Add(typeof (Frame));
_contentControlsNotAllowedToAdd.Add(typeof (GroupItem));
_contentControlsNotAllowedToAdd.Add(typeof (HeaderedContentControl));
_contentControlsNotAllowedToAdd.Add(typeof (Label));
_contentControlsNotAllowedToAdd.Add(typeof (ListBoxItem));
//_contentControlsNotAllowedToAdd.Add(typeof (ButtonBase));
_contentControlsNotAllowedToAdd.Add(typeof (StatusBarItem));
_contentControlsNotAllowedToAdd.Add(typeof (ToolTip));
}
public static bool CanContentControlAdd(ContentControl control)
{
Debug.Assert(control != null);
return !_contentControlsNotAllowedToAdd.Any(type => type.IsAssignableFrom(control.GetType()));
}
{ }
protected override void OnInitialized()
{
@ -68,7 +50,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -68,7 +50,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
ExtendedItem.AddBehavior(typeof(IPlacementBehavior), this);
}
public virtual bool CanPlace(ICollection<DesignItem> childItems, PlacementType type, PlacementAlignment position)
public virtual bool CanPlace(IEnumerable<DesignItem> childItems, PlacementType type, PlacementAlignment position)
{
return true;
}
@ -81,9 +63,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -81,9 +63,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
InfoTextEnterArea.Stop(ref infoTextEnterArea);
this.ExtendedItem.Services.Selection.SetSelectedComponents(null);
this.ExtendedItem.Services.Selection.SetSelectedComponents(operation.PlacedItems.Select(x => x.Item).ToList());
}
this.ExtendedItem.Services.Selection.SetSelectedComponents(null);
this.ExtendedItem.Services.Selection.SetSelectedComponents(operation.PlacedItems.Select(x => x.Item).ToList());
}
public virtual Rect GetPosition(PlacementOperation operation, DesignItem item)
{
@ -91,17 +73,22 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -91,17 +73,22 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
return Rect.Empty;
var p = item.View.TranslatePoint(new Point(), operation.CurrentContainer.View);
return new Rect(p, PlacementOperation.GetRealElementSize(item.View));
return new Rect(p, PlacementOperation.GetRealElementSize(item.View));
}
public virtual void BeforeSetPosition(PlacementOperation operation)
{
}
public virtual bool CanPlaceItem(PlacementInformation info)
{
return true;
}
public virtual void SetPosition(PlacementInformation info)
{
if (info.Operation.Type != PlacementType.Move)
ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height);
if (info.Operation.Type != PlacementType.Move)
ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height);
}
public virtual bool CanLeaveContainer(PlacementOperation operation)
@ -158,14 +145,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -158,14 +145,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
if (ExtendedItem.ContentProperty.IsCollection)
return CollectionSupport.CanCollectionAdd(ExtendedItem.ContentProperty.ReturnType,
operation.PlacedItems.Select(p => p.Item.Component));
if (ExtendedItem.View is ContentControl) {
if (!CanContentControlAdd((ContentControl) ExtendedItem.View)) {
return false;
}
}
if (ExtendedItem.ContentProperty.ReturnType == typeof(string))
return false;
if (ExtendedItem.ContentProperty.ReturnType == typeof(string))
return false;
if (!ExtendedItem.ContentProperty.IsSet)
return true;

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenu.xaml.cs

@ -26,6 +26,7 @@ using System.Xml; @@ -26,6 +26,7 @@ using System.Xml;
using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
@ -37,7 +38,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -37,7 +38,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
this.designItem = designItem;
InitializeComponent();
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();
}
void Click_EditStyle(object sender, RoutedEventArgs e)

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/EditStyleContextMenuExtension.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
[ExtensionServer(typeof (OnlyOneItemSelectedExtensionServer))]
[ExtensionFor(typeof (Control))]
[Extension(Order = 10)]
[Extension(Order = 30)]
public class EditStyleContextMenuExtension : PrimarySelectionAdornerProvider
{
DesignPanel panel;

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/Initializers.cs

@ -63,9 +63,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers @@ -63,9 +63,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions.Initializers
if (textProperty.ValueOnInstance == null || textProperty.ValueOnInstance.ToString() == "")
{
textProperty.SetValue(item.ComponentType.Name);
item.Properties[FrameworkElement.WidthProperty].Reset();
item.Properties[FrameworkElement.HeightProperty].Reset();
}
item.Properties[FrameworkElement.WidthProperty].Reset();
item.Properties[FrameworkElement.HeightProperty].Reset();
}
DesignItemProperty verticalAlignmentProperty = item.Properties["VerticalAlignment"];
if (verticalAlignmentProperty.ValueOnInstance == null)

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenu.xaml.cs

@ -20,6 +20,7 @@ using System; @@ -20,6 +20,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
@ -31,7 +32,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -31,7 +32,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
this.designItem = designItem;
InitializeComponent();
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();
}
void Click_BringToFront(object sender, RoutedEventArgs e)

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/RightClickContextMenuExtension.cs

@ -30,6 +30,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -30,6 +30,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
/// </summary>
[ExtensionServer(typeof(OnlyOneItemSelectedExtensionServer))]
[ExtensionFor(typeof(UIElement))]
[Extension(Order = 20)]
public sealed class RightClickContextMenuExtension : PrimarySelectionAdornerProvider
{
DesignPanel panel;

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/SnaplinePlacementBehavior.cs

@ -225,9 +225,12 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -225,9 +225,12 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
AddLines(containerRect, 0, false);
if (!CanPlace(operation.PlacedItems.Select(x => x.Item), operation.Type, PlacementAlignment.Center))
return;
foreach (var item in AllDesignItems() /* ExtendedItem.ContentProperty.CollectionElements */
.Except(operation.PlacedItems.Select(f => f.Item))
.Where(x=>!GetDisableSnaplines(x.View))) {
.Where(x=> x.View != null && !GetDisableSnaplines(x.View))) {
if (item != null) {
var bounds = GetPosition(operation, item);

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenu.xaml.cs

@ -21,6 +21,7 @@ using System.Linq; @@ -21,6 +21,7 @@ using System.Linq;
using System.Windows;
using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
@ -32,7 +33,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -32,7 +33,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
this.designItem = designItem;
InitializeComponent();
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();
}
void Click_EditFormatedText(object sender, RoutedEventArgs e)

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/TextBlockRightClickContextMenuExtension.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
[ExtensionServer(typeof (OnlyOneItemSelectedExtensionServer))]
[ExtensionFor(typeof (TextBlock))]
[Extension(Order = 10)]
[Extension(Order = 40)]
public class TextBlockRightClickContextMenuExtension : PrimarySelectionAdornerProvider
{
DesignPanel panel;

22
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemContextMenu.xaml.cs

@ -18,7 +18,9 @@ @@ -18,7 +18,9 @@
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
@ -26,14 +28,28 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -26,14 +28,28 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
private DesignItem designItem;
public WrapItemContextMenu(DesignItem designItem)
public WrapItemContextMenu(DesignItem designItem)
{
this.designItem = designItem;
InitializeComponent();
SpecialInitializeComponent();
}
void Click_WrapInViewbox(object sender, System.Windows.RoutedEventArgs e)
/// <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 Click_WrapInViewbox(object sender, System.Windows.RoutedEventArgs e)
{
ModelTools.WrapItemsNewContainer(this.designItem.Services.Selection.SelectedItems, typeof(Viewbox));
}

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/WrapItemsContextMenu.xaml.cs

@ -18,7 +18,9 @@ @@ -18,7 +18,9 @@
using System;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Extensions
{
@ -30,7 +32,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -30,7 +32,21 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{
this.designItem = designItem;
InitializeComponent();
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();
}
void Click_WrapInCanvas(object sender, System.Windows.RoutedEventArgs e)

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CopyIcon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 675 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.CutIcon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 773 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.DeleteIcon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 663 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.PasteIcon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 685 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.RedoIcon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 613 B

BIN
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Images/Icons.16x16.UndoIcon.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 631 B

30
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/ModelTools.cs

@ -236,7 +236,7 @@ namespace ICSharpCode.WpfDesign.Designer @@ -236,7 +236,7 @@ namespace ICSharpCode.WpfDesign.Designer
return itemPos;
}
public static void WrapItemsNewContainer(IEnumerable<DesignItem> items, Type containerType)
public static Tuple<DesignItem, Rect> WrapItemsNewContainer(IEnumerable<DesignItem> items, Type containerType, bool doInsert = true)
{
var collection = items;
@ -245,18 +245,17 @@ namespace ICSharpCode.WpfDesign.Designer @@ -245,18 +245,17 @@ namespace ICSharpCode.WpfDesign.Designer
var container = collection.First().Parent;
if (collection.Any(x => x.Parent != container))
return;
return null;
//Change Code to use the Placment Operation!
var placement = container.Extensions.OfType<IPlacementBehavior>().FirstOrDefault();
if (placement == null)
return;
return null;
var operation = PlacementOperation.Start(items.ToList(), PlacementType.Move);
var newInstance = Activator.CreateInstance(containerType);
var newInstance = _context.Services.ExtensionManager.CreateInstanceWithCustomInstanceFactory(containerType, null);
DesignItem newPanel = _context.Services.Component.RegisterComponentForDesigner(newInstance);
//var changeGroup = newPanel.OpenGroup("Wrap in Container");
List<ItemPos> itemList = new List<ItemPos>();
@ -326,18 +325,23 @@ namespace ICSharpCode.WpfDesign.Designer @@ -326,18 +325,23 @@ namespace ICSharpCode.WpfDesign.Designer
}
}
PlacementOperation operation2 = PlacementOperation.TryStartInsertNewComponents(
container,
new[] { newPanel },
new[] { new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round() },
PlacementType.AddItem
);
if (doInsert)
{
PlacementOperation operation2 = PlacementOperation.TryStartInsertNewComponents(
container,
new[] {newPanel},
new[] {new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round()},
PlacementType.AddItem
);
operation2.Commit();
operation2.Commit();
_context.Services.Selection.SetSelectedComponents(new[] {newPanel});
}
operation.Commit();
_context.Services.Selection.SetSelectedComponents(new []{ newPanel });
return new Tuple<DesignItem, Rect>(newPanel, new Rect(xmin, ymin, xmax - xmin, ymax - ymin).Round());
}
public static void ArrangeItems(IEnumerable<DesignItem> items, ArrangeDirection arrangeDirection)

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/Outline.xaml.cs

@ -29,6 +29,7 @@ using System.Windows.Media; @@ -29,6 +29,7 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
@ -36,7 +37,21 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView @@ -36,7 +37,21 @@ namespace ICSharpCode.WpfDesign.Designer.OutlineView
{
public Outline()
{
InitializeComponent();
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();
}
public static readonly DependencyProperty RootProperty =

6
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/OutlineView/OutlineView.xaml

@ -97,7 +97,7 @@ @@ -97,7 +97,7 @@
<Setter.Value>
<ControlTemplate TargetType="{x:Type Default:DragTreeViewItem}">
<DockPanel Background="White">
<DockPanel Background="White" ContextMenu="{Binding DesignItem.Services.DesignPanel.ContextMenu}">
<Grid x:Name="bg"
Margin="{TemplateBinding Level, Converter={StaticResource LevelConverter}}"
DockPanel.Dock="Top"
@ -113,7 +113,7 @@ @@ -113,7 +113,7 @@
</Border>
</Grid>
<ItemsPresenter x:Name="itemsHost" />
<DockPanel.ContextMenu>
<!-- <DockPanel.ContextMenu>
<ContextMenu>
<MenuItem Command="ApplicationCommands.Cut" />
<MenuItem Command="ApplicationCommands.Copy" />
@ -121,7 +121,7 @@ @@ -121,7 +121,7 @@
<Separator />
<MenuItem Command="ApplicationCommands.Delete" />
</ContextMenu>
</DockPanel.ContextMenu>
</DockPanel.ContextMenu>-->
<DockPanel.ToolTip>
<ToolTip Background="White">
<Rectangle Width="50" Height="50">

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BoolEditor.xaml.cs

@ -17,19 +17,10 @@ @@ -17,19 +17,10 @@
// 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 ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
@ -38,7 +29,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -38,7 +29,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
public BoolEditor()
{
InitializeComponent();
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();
}
}
}

31
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorPopup.xaml.cs

@ -17,19 +17,10 @@ @@ -17,19 +17,10 @@
// 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.Diagnostics;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
@ -37,13 +28,27 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor @@ -37,13 +28,27 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public BrushEditorPopup()
{
InitializeComponent();
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();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
BrushEditorView.BrushEditor.Commit();
base.OnClosed(e);
BrushEditorView.BrushEditor.Commit();
}
protected override void OnKeyDown(KeyEventArgs e)

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushEditorView.xaml.cs

@ -31,6 +31,7 @@ using System.Windows.Navigation; @@ -31,6 +31,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Diagnostics;
using System.Globalization;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
@ -41,13 +42,27 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor @@ -41,13 +42,27 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
BrushEditor = new BrushEditor();
DataContext = BrushEditor;
InitializeComponent();
SpecialInitializeComponent();
SetBinding(HeightProperty, new Binding("Brush") {
Converter = HeightConverter.Instance
});
}
/// <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();
}
public BrushEditor BrushEditor { get; private set; }
class HeightConverter : IValueConverter

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/BrushTypeEditor.xaml.cs

@ -31,6 +31,7 @@ using System.Windows.Navigation; @@ -31,6 +31,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
@ -39,7 +40,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor @@ -39,7 +40,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public BrushTypeEditor()
{
InitializeComponent();
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();
}
static BrushEditorPopup brushEditorPopup = new BrushEditorPopup();

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientBrushEditor.xaml.cs

@ -17,18 +17,9 @@ @@ -17,18 +17,9 @@
// 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 ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
@ -36,7 +27,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor @@ -36,7 +27,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public GradientBrushEditor()
{
InitializeComponent();
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();
}
}
}

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/GradientSlider.xaml.cs

@ -31,6 +31,7 @@ using System.Windows.Navigation; @@ -31,6 +31,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Controls.Primitives;
using System.ComponentModel;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
@ -38,7 +39,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor @@ -38,7 +39,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public GradientSlider()
{
InitializeComponent();
SpecialInitializeComponent();
BindingOperations.SetBinding(this, SelectedStopProperty, new Binding("SelectedItem") {
Source = itemsControl,
@ -49,6 +50,19 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor @@ -49,6 +50,19 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
strip.DragDelta += new DragDeltaEventHandler(strip_DragDelta);
}
/// <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();
}
static GradientSlider()
{
EventManager.RegisterClassHandler(typeof(GradientSlider),

26
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/BrushEditor/SolidBrushEditor.xaml.cs

@ -17,18 +17,10 @@ @@ -17,18 +17,10 @@
// 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 ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
@ -36,7 +28,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor @@ -36,7 +28,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.BrushEditor
{
public SolidBrushEditor()
{
InitializeComponent();
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();
}
public static readonly DependencyProperty ColorProperty =

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/CollectionEditor.xaml.cs

@ -28,6 +28,7 @@ using System.Windows.Documents; @@ -28,6 +28,7 @@ using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
@ -49,11 +50,25 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -49,11 +50,25 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
private IComponentService _componentService;
public CollectionEditor()
{
InitializeComponent();
SpecialInitializeComponent();
this.Owner = Application.Current.MainWindow;
}
/// <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();
}
public void LoadItemsCollection(DesignItem item)
{
Debug.Assert(item.View is ItemsControl);

26
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ColorEditor.xaml.cs

@ -2,19 +2,11 @@ @@ -2,19 +2,11 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
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.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
@ -23,7 +15,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -23,7 +15,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
public ColorEditor()
{
InitializeComponent();
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();
}
}
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ComboBoxEditor.xaml

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<ComboBox
x:Class="ICSharpCode.WpfDesign.PropertyGrid.Editors.ComboBoxEditor"
x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.ComboBoxEditor"
xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
BorderThickness="0"

20
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/ComboBoxEditor.xaml.cs

@ -31,10 +31,10 @@ using System.Windows.Navigation; @@ -31,10 +31,10 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using System.Windows.Controls.Primitives;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
[TypeEditor(typeof(Enum))]
public partial class ComboBoxEditor
{
/// <summary>
@ -42,7 +42,21 @@ namespace ICSharpCode.WpfDesign.PropertyGrid.Editors @@ -42,7 +42,21 @@ namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
/// </summary>
public ComboBoxEditor()
{
InitializeComponent();
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();
}
/// <inheritdoc/>

25
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/EventEditor.xaml.cs

@ -17,19 +17,12 @@ @@ -17,19 +17,12 @@
// 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 ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
@ -38,7 +31,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -38,7 +31,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
public EventEditor()
{
InitializeComponent();
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();
}
public PropertyNode PropertyNode {

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FlatCollectionEditor.xaml.cs

@ -30,6 +30,7 @@ using System.Windows.Input; @@ -30,6 +30,7 @@ using System.Windows.Input;
using System.Windows.Media;
using System.Linq;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
@ -52,11 +53,25 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -52,11 +53,25 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
public FlatCollectionEditor()
{
InitializeComponent();
SpecialInitializeComponent();
this.Owner = Application.Current.MainWindow;
}
/// <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();
}
public Type GetItemsSourceType(Type t)
{
Type tp = t.GetInterfaces().FirstOrDefault(x => x.IsGenericType && x.GetGenericTypeDefinition() == typeof(ICollection<>));

18
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/FormatedTextEditor/FormatedTextEditor.xaml.cs

@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
// 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.Windows;
@ -24,6 +25,7 @@ using System.Windows.Documents; @@ -24,6 +25,7 @@ using System.Windows.Documents;
using System.Windows.Media;
using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.Designer.UIExtensions;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor
{
@ -36,7 +38,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor @@ -36,7 +38,7 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor
public FormatedTextEditor(DesignItem designItem)
{
InitializeComponent();
SpecialInitializeComponent();
this.designItem = designItem;
@ -54,6 +56,20 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor @@ -54,6 +56,20 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.FormatedTextEditor
richTextBox.Background = tb.Background;
}
/// <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();
}
private void GetDesignItems(TextElementCollection<Block> blocks, List<DesignItem> list)
{
bool first = true;

24
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/NumberEditor.xaml.cs

@ -19,18 +19,11 @@ @@ -19,18 +19,11 @@
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.PropertyGrid;
using System.Reflection;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
@ -76,10 +69,23 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -76,10 +69,23 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
public NumberEditor()
{
InitializeComponent();
SpecialInitializeComponent();
DataContextChanged += new DependencyPropertyChangedEventHandler(NumberEditor_DataContextChanged);
}
/// <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();
}
static Dictionary<Type, double> minimums = new Dictionary<Type, double>();
static Dictionary<Type, double> maximums = new Dictionary<Type, double>();

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/OpenCollectionEditor.xaml.cs

@ -14,6 +14,7 @@ using System.Windows.Navigation; @@ -14,6 +14,7 @@ using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.themes;
//using Xceed.Wpf.Toolkit;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
@ -23,7 +24,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -23,7 +24,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
public OpenCollectionEditor()
{
InitializeComponent();
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();
}
void open_Click(object sender, RoutedEventArgs e)

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TextBoxEditor.xaml

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
<TextBox
x:Class="ICSharpCode.WpfDesign.PropertyGrid.Editors.TextBoxEditor"
x:Class="ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors.TextBoxEditor"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Text="{Binding ValueString}"

19
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs → src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TextBoxEditor.xaml.cs

@ -29,8 +29,9 @@ using System.Windows.Media; @@ -29,8 +29,9 @@ using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
public partial class TextBoxEditor
{
@ -39,7 +40,21 @@ namespace ICSharpCode.WpfDesign.PropertyGrid.Editors @@ -39,7 +40,21 @@ namespace ICSharpCode.WpfDesign.PropertyGrid.Editors
/// </summary>
public TextBoxEditor()
{
InitializeComponent();
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();
}
/// <inheritdoc/>

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/Editors/TimeSpanEditor.xaml.cs

@ -15,6 +15,7 @@ using System.Windows.Media.Imaging; @@ -15,6 +15,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
@ -24,7 +25,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors @@ -24,7 +25,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors
{
public TimeSpanEditor()
{
InitializeComponent();
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();
}
}
}

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/PropertyGrid/PropertyContextMenu.xaml.cs

@ -30,6 +30,7 @@ using System.Windows.Media.Imaging; @@ -30,6 +30,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
@ -37,7 +38,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid @@ -37,7 +38,21 @@ namespace ICSharpCode.WpfDesign.Designer.PropertyGrid
{
public PropertyContextMenu()
{
InitializeComponent();
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();
}
public PropertyNode PropertyNode {

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/RootItemBehavior.cs

@ -38,12 +38,9 @@ namespace ICSharpCode.WpfDesign.Designer @@ -38,12 +38,9 @@ namespace ICSharpCode.WpfDesign.Designer
_rootItem.AddBehavior(typeof(IRootPlacementBehavior),this);
}
public bool CanPlace(System.Collections.Generic.ICollection<DesignItem> childItems, PlacementType type, PlacementAlignment position)
public bool CanPlace(IEnumerable<DesignItem> childItems, PlacementType type, PlacementAlignment position)
{
return type == PlacementType.Resize &&
(position == PlacementAlignment.Right
|| position == PlacementAlignment.BottomRight
|| position == PlacementAlignment.Bottom);
return type == PlacementType.Resize && (position == PlacementAlignment.Right || position == PlacementAlignment.BottomRight || position == PlacementAlignment.Bottom);
}
public void BeginPlacement(PlacementOperation operation)

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ChooseClassDialog.xaml.cs

@ -25,6 +25,7 @@ using System.Windows.Controls; @@ -25,6 +25,7 @@ using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Input;
using ICSharpCode.WpfDesign.Designer.themes;
namespace ICSharpCode.WpfDesign.Designer.Services
{
@ -33,7 +34,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -33,7 +34,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
public ChooseClassDialog(ChooseClass core)
{
DataContext = core;
InitializeComponent();
SpecialInitializeComponent();
uxFilter.Focus();
uxList.MouseDoubleClick += uxList_MouseDoubleClick;
@ -46,6 +47,20 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -46,6 +47,20 @@ namespace ICSharpCode.WpfDesign.Designer.Services
true);
}
/// <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();
}
//HACK: listbox is always highlighted
public static DependencyPropertyKey IsSelectionActivePropertyKey =
(DependencyPropertyKey)typeof(Selector).GetField("IsSelectionActivePropertyKey",

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/ClickOrDragMouseGesture.cs

@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -26,7 +26,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
/// <summary>
/// Base class for mouse gestures that should start dragging only after a minimum drag distance.
/// </summary>
abstract class ClickOrDragMouseGesture : MouseGestureBase
public abstract class ClickOrDragMouseGesture : MouseGestureBase
{
protected Point startPoint;
protected bool hasDragStarted;

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/DragMoveMouseGesture.cs

@ -28,13 +28,13 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -28,13 +28,13 @@ namespace ICSharpCode.WpfDesign.Designer.Services
/// Mouse gesture for moving elements inside a container or between containers.
/// Belongs to the PointerTool.
/// </summary>
sealed class DragMoveMouseGesture : ClickOrDragMouseGesture
public sealed class DragMoveMouseGesture : ClickOrDragMouseGesture
{
bool isDoubleClick;
bool setSelectionIfNotMoving;
MoveLogic moveLogic;
internal DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick, bool setSelectionIfNotMoving = false)
public DragMoveMouseGesture(DesignItem clickedOn, bool isDoubleClick, bool setSelectionIfNotMoving = false)
{
Debug.Assert(clickedOn != null);

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Services/MouseGestureBase.cs

@ -25,7 +25,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services @@ -25,7 +25,7 @@ namespace ICSharpCode.WpfDesign.Designer.Services
/// <summary>
/// Base class for classes handling mouse gestures on the design surface.
/// </summary>
abstract class MouseGestureBase
public abstract class MouseGestureBase
{
/// <summary>
/// Checks if <paramref name="button"/> is the only button that is currently pressed.

29
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -86,6 +86,11 @@ @@ -86,6 +86,11 @@
<Compile Include="ArrangeDirection.cs" />
<Compile Include="Controls\RenderTransformOriginThumb.cs" />
<Compile Include="Extensions\BorderForImageControl.cs" />
<Compile Include="Extensions\DefaultCommandsContextMenu.xaml.cs">
<DependentUpon>DefaultCommandsContextMenu.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Extensions\DefaultCommandsContextMenuExtension.cs" />
<Compile Include="Extensions\PartialPanelSelectionHandler.cs" />
<Compile Include="Extensions\EditStyleContextMenu.xaml.cs">
<DependentUpon>EditStyleContextMenu.xaml</DependentUpon>
@ -119,6 +124,9 @@ @@ -119,6 +124,9 @@
<Compile Include="PropertyGrid\Editors\ColorEditor.xaml.cs">
<DependentUpon>ColorEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\ComboBoxEditor.xaml.cs">
<DependentUpon>ComboBoxEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\FlatCollectionEditor.xaml.cs">
<DependentUpon>FlatCollectionEditor.xaml</DependentUpon>
<SubType>Code</SubType>
@ -129,9 +137,13 @@ @@ -129,9 +137,13 @@
<Compile Include="PropertyGrid\Editors\OpenCollectionEditor.xaml.cs">
<DependentUpon>OpenCollectionEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\TextBoxEditor.xaml.cs">
<DependentUpon>TextBoxEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\TimeSpanEditor.xaml.cs">
<DependentUpon>TimeSpanEditor.xaml</DependentUpon>
</Compile>
<Compile Include="themes\VersionedAssemblyResourceDictionary.cs" />
<Compile Include="Translations.cs" />
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Controls\AdornerLayer.cs" />
@ -289,6 +301,7 @@ @@ -289,6 +301,7 @@
<Resource Include="Images\Tag.png" />
</ItemGroup>
<ItemGroup>
<Page Include="Extensions\DefaultCommandsContextMenu.xaml" />
<Page Include="Extensions\EditStyleContextMenu.xaml">
<SubType>Designer</SubType>
</Page>
@ -306,12 +319,20 @@ @@ -306,12 +319,20 @@
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\ColorEditor.xaml" />
<Page Include="PropertyGrid\Editors\ComboBoxEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\FlatCollectionEditor.xaml" />
<Page Include="PropertyGrid\Editors\FormatedTextEditor\FormatedTextEditor.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PropertyGrid\Editors\OpenCollectionEditor.xaml" />
<Page Include="PropertyGrid\Editors\TextBoxEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\TimeSpanEditor.xaml" />
<Page Include="ThumbnailView\ThumbnailView.xaml" />
<ProjectReference Include="..\..\..\..\..\Main\ICSharpCode.SharpDevelop.Widgets\Project\ICSharpCode.SharpDevelop.Widgets.csproj">
@ -468,4 +489,12 @@ @@ -468,4 +489,12 @@
<ItemGroup>
<Resource Include="Images\Icons.32x32.EmptyProjectIcon.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="Images\Icons.16x16.CopyIcon.png" />
<Resource Include="Images\Icons.16x16.CutIcon.png" />
<Resource Include="Images\Icons.16x16.DeleteIcon.png" />
<Resource Include="Images\Icons.16x16.PasteIcon.png" />
<Resource Include="Images\Icons.16x16.RedoIcon.png" />
<Resource Include="Images\Icons.16x16.UndoIcon.png" />
</ItemGroup>
</Project>

13
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlComponentService.cs

@ -28,6 +28,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -28,6 +28,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
{
sealed class XamlComponentService : IComponentService
{
public event EventHandler<DesignItemPropertyChangedEventArgs> PropertyChanged;
#region IdentityEqualityComparer
sealed class IdentityEqualityComparer : IEqualityComparer<object>
{
@ -140,5 +142,16 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -140,5 +142,16 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
}
return site;
}
/// <summary>
/// raises the Property changed Events
/// </summary>
internal void RaisePropertyChanged(XamlModelProperty property)
{
var ev = this.PropertyChanged;
if (ev != null) {
ev(this, new DesignItemPropertyChangedEventArgs(property.DesignItem, property));
}
}
}
}

14
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignContext.cs

@ -27,6 +27,7 @@ using ICSharpCode.WpfDesign.Extensions; @@ -27,6 +27,7 @@ using ICSharpCode.WpfDesign.Extensions;
using ICSharpCode.WpfDesign.PropertyGrid;
using System.Threading;
using System.Globalization;
using ICSharpCode.WpfDesign.Designer.PropertyGrid.Editors;
namespace ICSharpCode.WpfDesign.Designer.Xaml
{
@ -91,6 +92,9 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -91,6 +92,9 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
this.Services.AddService(typeof(ITopLevelWindowService), new WpfTopLevelWindowService());
}
EditorManager.SetDefaultTextBoxEditorType(typeof(TextBoxEditor));
EditorManager.SetDefaultComboBoxEditorType(typeof(ComboBoxEditor));
// register extensions from the designer assemblies:
foreach (Assembly designerAssembly in loadSettings.DesignerAssemblies) {
this.Services.ExtensionManager.RegisterAssembly(designerAssembly);
@ -116,13 +120,13 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -116,13 +120,13 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
_rootItem = _componentService.RegisterXamlComponentRecursive(_doc.RootElement);
if(_rootItem!=null){
var rootBehavior=new RootItemBehavior();
if (_rootItem != null) {
var rootBehavior = new RootItemBehavior();
rootBehavior.Intialize(this);
}
_xamlEditOperations = new XamlEditOperations(this, _parserSettings);
_xamlEditOperations=new XamlEditOperations(this,_parserSettings);
}
@ -145,8 +149,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -145,8 +149,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
/// Gets the parser Settings being used
/// </summary>
public XamlParserSettings ParserSettings {
get { return _parserSettings; }
}
get { return _parserSettings; }
}
/// <summary>
/// Opens a new change group used to batch several changes.

119
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlDesignItem.cs

@ -20,8 +20,11 @@ @@ -20,8 +20,11 @@
//#define EventHandlerDebugging
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Windows;
using System.Windows.Data;
using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.WpfDesign.Designer.Services;
using System.Windows.Markup;
@ -65,7 +68,11 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -65,7 +68,11 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
void SetNameInternal(string newName)
{
var oldName = Name;
_xamlObject.Name = newName;
FixDesignItemReferencesOnNameChange(oldName, Name);
}
public override string Name {
@ -75,7 +82,101 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -75,7 +82,101 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
if (undoService != null)
undoService.Execute(new SetNameAction(this, value));
else
{
SetNameInternal(value);
}
}
}
/// <summary>
/// Fixes {x:Reference and {Binding ElementName to this Element in XamlDocument
/// </summary>
/// <param name="oldName"></param>
/// <param name="newName"></param>
public void FixDesignItemReferencesOnNameChange(string oldName, string newName)
{
if (!string.IsNullOrEmpty(oldName) && !string.IsNullOrEmpty(newName)) {
var root = GetRootXamlObject(this.XamlObject);
var references = GetAllChildXamlObjects(root).Where(x => x.ElementType == typeof(Reference) && Equals(x.FindOrCreateProperty("Name").ValueOnInstance, oldName));
foreach (var designItem in references)
{
var property = designItem.FindOrCreateProperty("Name");
var propertyValue = designItem.OwnerDocument.CreatePropertyValue(newName, property);
this.ComponentService.RegisterXamlComponentRecursive(propertyValue as XamlObject);
property.PropertyValue = propertyValue;
}
root = GetRootXamlObject(this.XamlObject, true);
var bindings = GetAllChildXamlObjects(root, true).Where(x => x.ElementType == typeof(Binding) && Equals(x.FindOrCreateProperty("ElementName").ValueOnInstance, oldName));
foreach (var designItem in bindings)
{
var property = designItem.FindOrCreateProperty("ElementName");
var propertyValue = designItem.OwnerDocument.CreatePropertyValue(newName, property);
this.ComponentService.RegisterXamlComponentRecursive(propertyValue as XamlObject);
property.PropertyValue = propertyValue;
}
}
}
/// <summary>
/// Find's the Root XamlObject (real Root, or Root Object in Namescope)
/// </summary>
/// <param name="item"></param>
/// <param name="onlyFromSameNamescope"></param>
/// <returns></returns>
private XamlObject GetRootXamlObject(XamlObject item, bool onlyFromSameNamescope = false)
{
var root = item;
while (root.ParentObject != null)
{
if (onlyFromSameNamescope && NameScopeHelper.GetNameScopeFromObject(root) != NameScopeHelper.GetNameScopeFromObject(root.ParentObject))
break;
root = root.ParentObject;
}
return root;
}
/// <summary>
/// Get's all Child XamlObject Instances
/// </summary>
/// <param name="item"></param>
/// <param name="onlyFromSameNamescope"></param>
/// <returns></returns>
private IEnumerable<XamlObject> GetAllChildXamlObjects(XamlObject item, bool onlyFromSameNamescope = false)
{
foreach (var prop in item.Properties)
{
if (prop.PropertyValue as XamlObject != null)
{
if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(prop.PropertyValue as XamlObject))
yield return prop.PropertyValue as XamlObject;
foreach (var i in GetAllChildXamlObjects(prop.PropertyValue as XamlObject))
{
if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(i))
yield return i;
}
}
if (prop.IsCollection)
{
foreach (var collectionElement in prop.CollectionElements)
{
if (collectionElement as XamlObject != null)
{
if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(collectionElement as XamlObject))
yield return collectionElement as XamlObject;
foreach (var i in GetAllChildXamlObjects(collectionElement as XamlObject))
{
if (!onlyFromSameNamescope || NameScopeHelper.GetNameScopeFromObject(item) == NameScopeHelper.GetNameScopeFromObject(i))
yield return i;
}
}
}
}
}
}
@ -163,6 +264,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -163,6 +264,8 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
{
Debug.Assert(property != null);
OnPropertyChanged(new System.ComponentModel.PropertyChangedEventArgs(property.Name));
((XamlComponentService)this.Services.Component).RaisePropertyChanged(property);
}
public override string ContentPropertyName {
@ -191,14 +294,14 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -191,14 +294,14 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
public override DesignItem Clone()
{
DesignItem item = null;
var xaml = XamlStaticTools.GetXaml(this.XamlObject);
XamlDesignItem rootItem = Context.RootItem as XamlDesignItem;
var obj = XamlParser.ParseSnippet(rootItem.XamlObject, xaml, ((XamlDesignContext) Context).ParserSettings);
if (obj != null)
{
item = ((XamlDesignContext)Context)._componentService.RegisterXamlComponentRecursive(obj);
}
return item;
var xaml = XamlStaticTools.GetXaml(this.XamlObject);
XamlDesignItem rootItem = Context.RootItem as XamlDesignItem;
var obj = XamlParser.ParseSnippet(rootItem.XamlObject, xaml, ((XamlDesignContext) Context).ParserSettings);
if (obj != null)
{
item = ((XamlDesignContext)Context)._componentService.RegisterXamlComponentRecursive(obj);
}
return item;
}
sealed class SetNameAction : ITransactionItem

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Xaml/XamlEditOperations.cs

@ -131,7 +131,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml @@ -131,7 +131,7 @@ namespace ICSharpCode.WpfDesign.Designer.Xaml
AddInParent(parent, pastedItems);
pasted = true;
}
} else if (pastedItems.Count == 1 && parent.ContentProperty.Value == null && parent.ContentProperty.ValueOnInstance == null && parent.View is ContentControl && DefaultPlacementBehavior.CanContentControlAdd((ContentControl)parent.View)) {
} else if (pastedItems.Count == 1 && parent.ContentProperty.Value == null && parent.ContentProperty.ValueOnInstance == null && parent.View is ContentControl) {
AddInParent(parent, pastedItems);
pasted = true;
}

52
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/VersionedAssemblyResourceDictionary.cs

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
// 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.Windows;
namespace ICSharpCode.WpfDesign.Designer.themes
{
public class VersionedAssemblyResourceDictionary : ResourceDictionary, ISupportInitialize
{
private static readonly string _uriStart;
private static readonly int _subLength;
static VersionedAssemblyResourceDictionary()
{
var nm = typeof(VersionedAssemblyResourceDictionary).Assembly.GetName();
_uriStart = string.Format( @"{0};v{1};component/", nm.Name, nm.Version);
_subLength = "ICSharpCode.WpfDesign.Designer.".Length;
}
public string RelativePath {get;set;}
void ISupportInitialize.EndInit()
{
this.Source = new Uri(_uriStart + this.RelativePath, UriKind.Relative);
base.EndInit();
}
public static string GetXamlNameForType(Type t)
{
return _uriStart + t.FullName.Substring(_subLength).Replace(".","/").ToLower() + ".xaml";
}
}
}

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/themes/generic.xaml

@ -1,10 +1,13 @@ @@ -1,10 +1,13 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:v="clr-namespace:ICSharpCode.WpfDesign.Designer.themes"
>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/Controls/ControlStyles.xaml" />
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/OutlineView/OutlineView.xaml" />
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/DesignSurface.xaml" />
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/PropertyGrid/PropertyGridView.xaml" />
<ResourceDictionary Source="/ICSharpCode.WpfDesign.Designer;component/ThumbnailView/ThumbnailView.xaml" />
<v:VersionedAssemblyResourceDictionary RelativePath="Controls/ControlStyles.xaml" />
<v:VersionedAssemblyResourceDictionary RelativePath="OutlineView/OutlineView.xaml" />
<v:VersionedAssemblyResourceDictionary RelativePath="DesignSurface.xaml" />
<v:VersionedAssemblyResourceDictionary RelativePath="PropertyGrid/PropertyGridView.xaml" />
<v:VersionedAssemblyResourceDictionary RelativePath="ThumbnailView/ThumbnailView.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

68
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/Designer/ModelTests.cs

@ -596,7 +596,13 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -596,7 +596,13 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
DesignItem textBox = canvas.Services.Component.RegisterComponentForDesigner(new TextBox());
canvas.Properties["Children"].CollectionElements.Add(textBox);
DesignItemProperty resProp = textBox.Properties.GetProperty("Resources");
DesignItemProperty resProp = button.Properties.GetProperty("Resources");
Assert.IsTrue(resProp.IsCollection);
DesignItem dummyItem = canvas.Services.Component.RegisterComponentForDesigner(new ExampleClass());
dummyItem.Key = "dummy";
resProp.CollectionElements.Add(dummyItem);
resProp = textBox.Properties.GetProperty("Resources");
Assert.IsTrue(resProp.IsCollection);
DesignItem exampleClassItem = canvas.Services.Component.RegisterComponentForDesigner(new ExampleClass());
exampleClassItem.Key = "bindingSource";
@ -605,23 +611,39 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -605,23 +611,39 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
DesignItem bindingItem = canvas.Services.Component.RegisterComponentForDesigner(new Binding());
if (!setBindingPropertiesAfterSet) {
bindingItem.Properties["Path"].SetValue("StringProp");
// Using resource "dummy" before "bindingSource" to enable test where not the first set property will require element-style print of the binding
bindingItem.Properties["ConverterParameter"].SetValue(new StaticResourceExtension());
bindingItem.Properties["ConverterParameter"].Value.Properties["ResourceKey"].SetValue("dummy");
bindingItem.Properties["Source"].SetValue(new StaticResourceExtension());
bindingItem.Properties["Source"].Value.Properties["ResourceKey"].SetValue("bindingSource");
}
textBox.Properties[TextBox.TextProperty].SetValue(bindingItem);
if (setBindingPropertiesAfterSet) {
bindingItem.Properties["Path"].SetValue("StringProp");
// Using resource "dummy" before "bindingSource" to enable test where not the first set property will require element-style print of the binding
bindingItem.Properties["ConverterParameter"].SetValue(new StaticResourceExtension());
bindingItem.Properties["ConverterParameter"].Value.Properties["ResourceKey"].SetValue("dummy");
bindingItem.Properties["Source"].SetValue(new StaticResourceExtension());
bindingItem.Properties["Source"].Value.Properties["ResourceKey"].SetValue("bindingSource");
}
string expectedXaml = "<Button />\n" +
"<TextBox>\n" +
" <TextBox.Resources>\n" +
" <t:ExampleClass x:Key=\"bindingSource\" />\n" +
" </TextBox.Resources>\n" +
" <Binding Path=\"StringProp\" Source=\"{StaticResource bindingSource}\" />\n" +
"</TextBox>";
var binding = bindingItem.Component as Binding;
Assert.IsNotNull(binding);
Assert.IsNotNull(binding.Source);
Assert.IsNotNull(exampleClassItem.Component);
Assert.AreSame(exampleClassItem.Component, binding.Source);
const string expectedXaml = "<Button>\n" +
" <Button.Resources>\n" +
" <t:ExampleClass x:Key=\"dummy\" />\n" +
" </Button.Resources>\n" +
"</Button>\n" +
"<TextBox>\n" +
" <TextBox.Resources>\n" +
" <t:ExampleClass x:Key=\"bindingSource\" />\n" +
" </TextBox.Resources>\n" +
" <Binding Path=\"StringProp\" ConverterParameter=\"{StaticResource dummy}\" Source=\"{StaticResource bindingSource}\" />\n" +
"</TextBox>";
AssertCanvasDesignerOutput(expectedXaml, button.Context);
AssertLog("");
@ -667,6 +689,36 @@ namespace ICSharpCode.WpfDesign.Tests.Designer @@ -667,6 +689,36 @@ namespace ICSharpCode.WpfDesign.Tests.Designer
AssertLog("");
}
[Test]
public void AddMarkupExtensionWithoutWrapperToCollection()
{
DesignItem textBox = CreateCanvasContext("<TextBox/>");
DesignItem multiBindingItem = textBox.Context.Services.Component.RegisterComponentForDesigner(new System.Windows.Data.MultiBinding());
multiBindingItem.Properties["Converter"].SetValue(new ICSharpCode.WpfDesign.Tests.XamlDom.MyMultiConverter());
DesignItemProperty bindingsProp = multiBindingItem.ContentProperty;
// MyBindingExtension is a markup extension that will not use a wrapper.
DesignItem myBindingExtension = textBox.Context.Services.Component.RegisterComponentForDesigner(new ICSharpCode.WpfDesign.Tests.XamlDom.MyBindingExtension());
// Adding it to MultiBinding "Bindings" collection.
bindingsProp.CollectionElements.Add(myBindingExtension);
textBox.ContentProperty.SetValue(multiBindingItem);
const string expectedXaml = "<TextBox>\n" +
" <MultiBinding>\n" +
" <MultiBinding.Converter>\n" +
" <Controls0:MyMultiConverter />\n" +
" </MultiBinding.Converter>\n" +
" <Controls0:MyBindingExtension />\n" +
" </MultiBinding>\n" +
"</TextBox>";
AssertCanvasDesignerOutput(expectedXaml, textBox.Context, "xmlns:Controls0=\"" + ICSharpCode.WpfDesign.Tests.XamlDom.XamlTypeFinderTests.XamlDomTestsNamespace + "\"");
AssertLog("");
}
[Test]
public void AddBrushAsResource()
{

22
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/MarkupExtensionTests.cs

@ -133,6 +133,7 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -133,6 +133,7 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
<t:MyMultiConverter />
</MultiBinding.Converter>
<Binding Path=""SomeProperty"" />
<t:MyBindingExtension />
</MultiBinding>
</TextBox>
</Window>";
@ -157,7 +158,7 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -157,7 +158,7 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
var converter = expr.ParentMultiBinding.Converter as MyMultiConverter;
Assert.IsNotNull(converter);
Assert.AreEqual(expr.ParentMultiBinding.Bindings.Count, 1);
Assert.AreEqual(expr.ParentMultiBinding.Bindings.Count, 2);
}
[Test]
@ -267,4 +268,23 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -267,4 +268,23 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
#endregion
}
public class MyBindingExtension : MarkupExtension
{
readonly Binding binding = new Binding();
public MyBindingExtension()
{
var exampleClass = new ExampleClass();
exampleClass.StringProp = "Test";
binding.Source = exampleClass;
binding.Path = new PropertyPath("StringProp");
}
public override object ProvideValue(IServiceProvider serviceProvider)
{
return binding.ProvideValue(serviceProvider);
}
}
}

21
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SamplesTests.cs

@ -452,7 +452,6 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -452,7 +452,6 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
}
[Test]
[Ignore("Xaml writer creates different XAML")]
public void Style3()
{
TestLoading(@"<Window xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
@ -504,6 +503,26 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -504,6 +503,26 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
</Window>");
}
[Test]
public void Template2()
{
TestLoading(@"<Window xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"">
<Window.Resources>
<ResourceDictionary>
<SolidColorBrush Color=""Blue"" x:Key=""bb"" />
<ControlTemplate x:Key=""aa"" TargetType=""Button"">
<Grid HorizontalAlignment=""Left"">
<Rectangle Fill=""{StaticResource bb}"" />
</Grid>
</ControlTemplate>
</ResourceDictionary>
</Window.Resources>
</Window>");
}
[Test]
public void ListBox1()

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Tests/XamlDom/SimpleLoadTests.cs

@ -293,7 +293,6 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom @@ -293,7 +293,6 @@ namespace ICSharpCode.WpfDesign.Tests.XamlDom
}
[Test]
[Ignore("Own XamlParser should handle different namespaces pointing to same types, because builtin XamlReader does.")]
public void ResourceDictionaryExplicitNetfx2007()
{
// The reason this test case fails is because own XamlParser cannot always handle the case where multiple xmlns points to the same type.

27
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/DesignInstanceExtension.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Markup;
namespace ICSharpCode.WpfDesign.XamlDom
{
public class DesignInstanceExtension : MarkupExtension
{
public DesignInstanceExtension(Type type)
{
this.Type = type;
}
public Type Type { get; set; }
public bool IsDesignTimeCreatable { get; set; }
public bool CreateList { get; set; }
public override object ProvideValue(IServiceProvider serviceProvider)
{
return null;
}
}
}

4
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/MarkupExtensionPrinter.cs

@ -137,8 +137,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -137,8 +137,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
var xamlObject = value as XamlObject;
if (xamlObject == null || !xamlObject.IsMarkupExtension)
return false;
else
return CanPrint(xamlObject, true, nonMarkupExtensionParent);
else if (!CanPrint(xamlObject, true, nonMarkupExtensionParent))
return false;
}
}

82
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs

@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -24,6 +25,7 @@ using System.Reflection; @@ -24,6 +25,7 @@ using System.Reflection;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Markup;
using System.Xaml;
using System.Xml;
using System.Xml.XPath;
@ -31,8 +33,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -31,8 +33,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
public static class TemplateHelper
{
public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement)
public static FrameworkTemplate GetFrameworkTemplate(XmlElement xmlElement, XamlObject parentObject)
{
var nav = xmlElement.CreateNavigator();
var ns = new Dictionary<string, string>();
@ -48,15 +51,88 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -48,15 +51,88 @@ namespace ICSharpCode.WpfDesign.XamlDom
break;
}
foreach (var dictentry in ns)
xmlElement = (XmlElement)xmlElement.CloneNode(true);
foreach (var dictentry in ns.ToList())
{
xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value);
}
var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace);
if (string.IsNullOrEmpty(keyAttrib)) {
xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__");
}
var xaml = xmlElement.OuterXml;
xaml = "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/netfx/2007/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" + xaml + "</ResourceDictionary>";
StringReader stringReader = new StringReader(xaml);
XmlReader xmlReader = XmlReader.Create(stringReader);
return (FrameworkTemplate)XamlReader.Load(xmlReader);
var xamlReader = new XamlXmlReader(xmlReader, parentObject.ServiceProvider.SchemaContext);
var seti = new XamlObjectWriterSettings();
var resourceDictionary = new ResourceDictionary();
var obj = parentObject;
while (obj != null)
{
if (obj.Instance is ResourceDictionary)
{
var r = obj.Instance as ResourceDictionary;
foreach (var k in r.Keys)
{
if (!resourceDictionary.Contains(k))
resourceDictionary.Add(k, r[k]);
}
}
else if (obj.Instance is FrameworkElement)
{
var r = ((FrameworkElement)obj.Instance).Resources;
foreach (var k in r.Keys)
{
if (!resourceDictionary.Contains(k))
resourceDictionary.Add(k, r[k]);
}
}
obj = obj.ParentObject;
}
seti.BeforePropertiesHandler = (s, e) =>
{
if (seti.BeforePropertiesHandler != null)
{
var rr = e.Instance as ResourceDictionary;
rr.MergedDictionaries.Add(resourceDictionary);
seti.BeforePropertiesHandler = null;
}
};
var writer = new XamlObjectWriter(parentObject.ServiceProvider.SchemaContext, seti);
XamlServices.Transform(xamlReader, writer);
var result = (ResourceDictionary)writer.Result;
var enr = result.Keys.GetEnumerator();
enr.MoveNext();
var rdKey = enr.Current;
var template = result[rdKey] as FrameworkTemplate;
result.Remove(rdKey);
return template;
}
private static Stream GenerateStreamFromString(string s)
{
MemoryStream stream = new MemoryStream();
StreamWriter writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
}
}

1
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/WpfDesign.XamlDom.csproj

@ -69,6 +69,7 @@ @@ -69,6 +69,7 @@
<Compile Include="AssemblyInfo.cs" />
<Compile Include="CollectionElementsCollection.cs" />
<Compile Include="CollectionSupport.cs" />
<Compile Include="DesignInstanceExtension.cs" />
<Compile Include="DesignTimeProperties.cs" />
<Compile Include="IXamlErrorSink.cs" />
<Compile Include="MarkupCompatibilityProperties.cs" />

10
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlDocument.cs

@ -229,6 +229,16 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -229,6 +229,16 @@ namespace ICSharpCode.WpfDesign.XamlDom
return _typeFinder.GetXmlNamespaceFor(type.Assembly, type.Namespace, getClrNamespace);
}
internal List<string> GetNamespacesFor(Type type, bool getClrNamespace = false)
{
if (type == typeof (DesignTimeProperties))
return new List<string>(){XamlConstants.DesignTimeNamespace};
if (type == typeof (MarkupCompatibilityProperties))
return new List<string>(){XamlConstants.MarkupCompatibilityNamespace};
return _typeFinder.GetXmlNamespacesFor(type.Assembly, type.Namespace, getClrNamespace);
}
internal string GetPrefixForNamespace(string @namespace)
{
if (@namespace == XamlConstants.PresentationNamespace)

41
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObject.cs

@ -273,9 +273,22 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -273,9 +273,22 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
void UpdateChildMarkupExtensions(XamlObject obj)
{
foreach (XamlObject propXamlObject in obj.Properties.Where((prop) => prop.IsSet).Select((prop) => prop.PropertyValue).OfType<XamlObject>()) {
UpdateChildMarkupExtensions(propXamlObject);
}
if (obj.IsMarkupExtension && obj.ParentProperty != null) {
obj.ParentProperty.UpdateValueOnInstance();
}
}
void UpdateMarkupExtensionChain()
{
var obj = this;
UpdateChildMarkupExtensions(this);
var obj = this.ParentObject;
while (obj != null && obj.IsMarkupExtension && obj.ParentProperty != null) {
obj.ParentProperty.UpdateValueOnInstance();
obj = obj.ParentObject;
@ -426,11 +439,23 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -426,11 +439,23 @@ namespace ICSharpCode.WpfDesign.XamlDom
PropertyDescriptorCollection propertyDescriptors = TypeDescriptor.GetProperties(instance);
PropertyDescriptor propertyInfo = propertyDescriptors[propertyName];
XamlProperty newProperty;
if (propertyInfo == null) {
propertyDescriptors = TypeDescriptor.GetProperties(this.elementType);
propertyInfo = propertyDescriptors[propertyName];
}
if (propertyInfo != null) {
newProperty = new XamlProperty(this, new XamlNormalPropertyInfo(propertyInfo));
} else {
EventDescriptorCollection events = TypeDescriptor.GetEvents(instance);
EventDescriptor eventInfo = events[propertyName];
if (eventInfo == null) {
events = TypeDescriptor.GetEvents(this.elementType);
eventInfo = events[propertyName];
}
if (eventInfo != null) {
newProperty = new XamlProperty(this, new XamlEventPropertyInfo(eventInfo));
} else {
@ -503,7 +528,17 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -503,7 +528,17 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (value == null)
element.RemoveAttribute(name, XamlConstants.XamlNamespace);
else
element.SetAttribute(name, XamlConstants.XamlNamespace, value);
{
var prefix = element.GetPrefixOfNamespace(XamlConstants.XamlNamespace);
if (!string.IsNullOrEmpty(prefix))
{
var attribute = element.OwnerDocument.CreateAttribute(prefix, name, XamlConstants.XamlNamespace);
attribute.InnerText = value;
element.SetAttributeNode(attribute);
}
else
element.SetAttribute(name, XamlConstants.XamlNamespace, value);
}
if (isNameChange) {
bool nameChangedAlreadyRaised = false;
@ -548,7 +583,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -548,7 +583,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (wrapper != null) {
return wrapper.ProvideValue();
}
if (this.ParentObject.ElementType == typeof (Setter) && this.ElementType == typeof(DynamicResourceExtension))
if (this.ParentObject != null && this.ParentObject.ElementType == typeof (Setter) && this.ElementType == typeof(DynamicResourceExtension))
return Instance;
return (Instance as MarkupExtension).ProvideValue(ServiceProvider);
}

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlObjectServiceProvider.cs

@ -136,7 +136,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -136,7 +136,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
get
{
return iCsharpXamlSchemaContext = iCsharpXamlSchemaContext ?? new XamlSchemaContext();
return iCsharpXamlSchemaContext = iCsharpXamlSchemaContext ?? System.Windows.Markup.XamlReader.GetWpfSchemaContext(); // new XamlSchemaContext();
}
}

63
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlParser.cs

@ -28,6 +28,7 @@ using System.Windows; @@ -28,6 +28,7 @@ using System.Windows;
using System.Windows.Interop;
using System.Windows.Markup;
using System.Xml;
using System.Windows.Media;
namespace ICSharpCode.WpfDesign.XamlDom
{
@ -146,6 +147,8 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -146,6 +147,8 @@ namespace ICSharpCode.WpfDesign.XamlDom
static Type FindType(XamlTypeFinder typeFinder, string namespaceUri, string localName)
{
Type elementType = typeFinder.GetType(namespaceUri, localName);
if (elementType == null)
elementType = typeFinder.GetType(namespaceUri, localName+"Extension");
if (elementType == null)
throw new XamlLoadException("Cannot find type " + localName + " in " + namespaceUri);
return elementType;
@ -195,7 +198,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -195,7 +198,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (typeof (FrameworkTemplate).IsAssignableFrom(elementType))
{
var xamlObj = new XamlObject(document, element, elementType, TemplateHelper.GetFrameworkTemplate(element));
var xamlObj = new XamlObject(document, element, elementType, TemplateHelper.GetFrameworkTemplate(element, currentXamlObject));
xamlObj.ParentObject = currentXamlObject;
return xamlObj;
}
@ -323,8 +326,11 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -323,8 +326,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (defaultProperty == null && obj.Instance != null && CollectionSupport.IsCollectionType(obj.Instance.GetType())) {
XamlObject parentObj = obj.ParentObject;
var parentElement = element.ParentNode;
XamlPropertyInfo propertyInfo = GetPropertyInfo(settings.TypeFinder, parentObj.Instance, parentObj.ElementType, parentElement.NamespaceURI, parentElement.LocalName);
collectionProperty = FindExistingXamlProperty(parentObj, propertyInfo);
XamlPropertyInfo propertyInfo;
if (parentObj != null) {
propertyInfo = GetPropertyInfo(settings.TypeFinder, parentObj.Instance, parentObj.ElementType, parentElement.NamespaceURI, parentElement.LocalName);
collectionProperty = FindExistingXamlProperty(parentObj, propertyInfo);
}
collectionInstance = obj.Instance;
collectionType = obj.ElementType;
collectionPropertyElement = element;
@ -500,6 +506,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -500,6 +506,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
if (eventInfo != null) {
return new XamlEventPropertyInfo(eventInfo);
}
throw new XamlLoadException("property " + propertyName + " not found");
}
@ -507,7 +514,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -507,7 +514,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
MethodInfo getMethod = elementType.GetMethod("Get" + propertyName, BindingFlags.Public | BindingFlags.Static);
MethodInfo setMethod = elementType.GetMethod("Set" + propertyName, BindingFlags.Public | BindingFlags.Static);
if (getMethod != null && setMethod != null) {
if (getMethod != null || setMethod != null) {
FieldInfo field = elementType.GetField(propertyName + "Property", BindingFlags.Public | BindingFlags.Static);
if (field != null && field.FieldType == typeof(DependencyProperty)) {
return new XamlDependencyPropertyInfo((DependencyProperty)field.GetValue(null), true);
@ -521,9 +528,28 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -521,9 +528,28 @@ namespace ICSharpCode.WpfDesign.XamlDom
return null;
}
internal static XamlPropertyInfo TryFindAttachedEvent(Type elementType, string propertyName)
{
FieldInfo fieldEvent = elementType.GetField(propertyName + "Event", BindingFlags.Public | BindingFlags.Static);
if (fieldEvent != null && fieldEvent.FieldType == typeof(RoutedEvent))
{
return new XamlEventPropertyInfo(TypeDescriptor.GetEvents(elementType)[propertyName]);
}
if (elementType.BaseType != null)
{
return TryFindAttachedEvent(elementType.BaseType, propertyName);
}
return null;
}
static XamlPropertyInfo FindAttachedProperty(Type elementType, string propertyName)
{
XamlPropertyInfo pi = TryFindAttachedProperty(elementType, propertyName);
if (pi == null) {
pi = TryFindAttachedEvent(elementType, propertyName);
}
if (pi != null) {
return pi;
} else {
@ -555,8 +581,15 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -555,8 +581,15 @@ namespace ICSharpCode.WpfDesign.XamlDom
return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName);
} else if (attribute.LocalName == "IsLocked" && attribute.NamespaceURI == XamlConstants.DesignTimeNamespace) {
return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName);
} else if (attribute.LocalName == "LayoutOverrides" && attribute.NamespaceURI == XamlConstants.DesignTimeNamespace) {
return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName);
} else if (attribute.LocalName == "LayoutRounding" && attribute.NamespaceURI == XamlConstants.DesignTimeNamespace) {
return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName);
} else if (attribute.LocalName == "DataContext" && attribute.NamespaceURI == XamlConstants.DesignTimeNamespace) {
return FindAttachedProperty(typeof(DesignTimeProperties), attribute.LocalName);
}
return null;
}
@ -674,6 +707,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -674,6 +707,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
else {
collectionInstance = collectionProperty.propertyInfo.GetValue(obj.Instance);
collectionProperty.ParserSetPropertyElement(element);
collectionInstance = collectionInstance ?? Activator.CreateInstance(collectionProperty.propertyInfo.ReturnType);
}
}
@ -712,6 +746,13 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -712,6 +746,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
internal static object CreateObjectFromAttributeText(string valueText, XamlPropertyInfo targetProperty, XamlObject scope)
{
if (targetProperty.ReturnType == typeof(Uri)) {
return scope.OwnerDocument.TypeFinder.ConvertUriToLocalUri(new Uri(valueText, UriKind.RelativeOrAbsolute));
} else if (targetProperty.ReturnType == typeof(ImageSource)) {
var uri = scope.OwnerDocument.TypeFinder.ConvertUriToLocalUri(new Uri(valueText, UriKind.RelativeOrAbsolute));
return targetProperty.TypeConverter.ConvertFromString(scope.OwnerDocument.GetTypeDescriptorContext(scope), CultureInfo.InvariantCulture, uri.ToString());
}
return targetProperty.TypeConverter.ConvertFromString(
scope.OwnerDocument.GetTypeDescriptorContext(scope),
CultureInfo.InvariantCulture, valueText);
@ -768,6 +809,19 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -768,6 +809,19 @@ namespace ICSharpCode.WpfDesign.XamlDom
/// <param name="settings">Parser settings used by <see cref="XamlParser"/>.</param>
/// <returns>Returns the XamlObject of the parsed <paramref name="xaml"/>.</returns>
public static XamlObject ParseSnippet(XamlObject root, string xaml, XamlParserSettings settings)
{
return ParseSnippet(root, xaml, settings, null);
}
/// <summary>
/// Method use to parse a piece of Xaml.
/// </summary>
/// <param name="root">The Root XamlObject of the current document.</param>
/// <param name="xaml">The Xaml being parsed.</param>
/// <param name="settings">Parser settings used by <see cref="XamlParser"/>.</param>
/// <param name="parentObject">Parent Object, where the Parsed snippet will be inserted (Needed for Example for Bindings).</param>
/// <returns>Returns the XamlObject of the parsed <paramref name="xaml"/>.</returns>
public static XamlObject ParseSnippet(XamlObject root, string xaml, XamlParserSettings settings, XamlObject parentObject)
{
XmlTextReader reader = new XmlTextReader(new StringReader(xaml));
var element = root.OwnerDocument.XmlDocument.ReadNode(reader);
@ -785,6 +839,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -785,6 +839,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
parser.settings = settings;
parser.errorSink = (IXamlErrorSink)settings.ServiceProvider.GetService(typeof(IXamlErrorSink));
parser.document = root.OwnerDocument;
parser.currentXamlObject = parentObject;
var xamlObject = parser.ParseObject(element as XmlElement);
RemoveRootNamespacesFromNodeAndChildNodes(root, element);

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlProperty.cs

@ -356,19 +356,19 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -356,19 +356,19 @@ namespace ICSharpCode.WpfDesign.XamlDom
static XmlNode FindChildNode(XmlNode node, Type elementType, string propertyName, XamlDocument xamlDocument)
{
var localName = elementType.Name + "." + propertyName;
var namespaceURI = xamlDocument.GetNamespaceFor(elementType);
var namespacesURI = xamlDocument.GetNamespacesFor(elementType);
var clrNamespaceURI = xamlDocument.GetNamespaceFor(elementType, true);
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == localName && (childNode.NamespaceURI == namespaceURI || childNode.NamespaceURI == clrNamespaceURI))
if (childNode.LocalName == localName && (namespacesURI.Contains(childNode.NamespaceURI) || childNode.NamespaceURI == clrNamespaceURI))
{
return childNode;
}
}
var type = elementType.BaseType;
namespaceURI = xamlDocument.GetNamespaceFor(type);
namespacesURI = xamlDocument.GetNamespacesFor(type);
while (type != typeof(object))
{
@ -379,7 +379,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -379,7 +379,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
foreach (XmlNode childNode in node.ChildNodes)
{
if (childNode.LocalName == localName && childNode.NamespaceURI == namespaceURI)
if (childNode.LocalName == localName && namespacesURI.Contains(childNode.NamespaceURI))
{
return childNode;
}
@ -556,7 +556,13 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -556,7 +556,13 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
set {
propertyInfo.SetValue(parentObject.Instance, value);
var setValue = value;
if (propertyInfo.ReturnType == typeof(Uri))
{
setValue = this.ParentObject.OwnerDocument.TypeFinder.ConvertUriToLocalUri((Uri)value);
}
propertyInfo.SetValue(parentObject.Instance, setValue);
if (ValueOnInstanceChanged != null)
ValueOnInstanceChanged(this, EventArgs.Empty);
}

33
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/XamlTypeFinder.cs

@ -19,6 +19,7 @@ @@ -19,6 +19,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Windows.Markup;
using System.Xaml;
@ -82,6 +83,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -82,6 +83,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
Dictionary<string, XamlNamespace> namespaces = new Dictionary<string, XamlNamespace>();
Dictionary<AssemblyNamespaceMapping, string> reverseDict = new Dictionary<AssemblyNamespaceMapping, string>();
Dictionary<AssemblyNamespaceMapping, List<string>> reverseDictList = new Dictionary<AssemblyNamespaceMapping, List<string>>();
/// <summary>
/// Gets a type referenced in XAML.
@ -128,6 +130,20 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -128,6 +130,20 @@ namespace ICSharpCode.WpfDesign.XamlDom
}
}
/// <summary>
/// Gets the XML namespaces that can be used for the specified assembly/namespace combination.
/// </summary>
public List<string> GetXmlNamespacesFor(Assembly assembly, string @namespace, bool getClrNamespace = false)
{
AssemblyNamespaceMapping mapping = new AssemblyNamespaceMapping(assembly, @namespace);
List<string> xmlNamespaces;
if (!getClrNamespace && reverseDictList.TryGetValue(mapping, out xmlNamespaces)) {
return xmlNamespaces;
} else {
return new List<string>() { "clr-namespace:" + mapping.Namespace + ";assembly=" + mapping.Assembly.GetName().Name };
}
}
/// <summary>
/// Gets the prefix to use for the specified XML namespace,
/// or null if no suitable prefix could be found.
@ -178,6 +194,14 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -178,6 +194,14 @@ namespace ICSharpCode.WpfDesign.XamlDom
{
ns.ClrNamespaces.Add(mapping);
List<string> xmlNamespaceList;
if (reverseDictList.TryGetValue(mapping, out xmlNamespaceList)) {
if (!xmlNamespaceList.Contains(ns.XmlNamespace))
xmlNamespaceList.Add(ns.XmlNamespace);
}
else
reverseDictList.Add(mapping, new List<string>(){ ns.XmlNamespace });
string xmlNamespace;
if (reverseDict.TryGetValue(mapping, out xmlNamespace)) {
if (xmlNamespace == XamlConstants.PresentationNamespace) {
@ -262,6 +286,9 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -262,6 +286,9 @@ namespace ICSharpCode.WpfDesign.XamlDom
foreach (KeyValuePair<AssemblyNamespaceMapping, string> pair in source.reverseDict) {
this.reverseDict.Add(pair.Key, pair.Value);
}
foreach (KeyValuePair<AssemblyNamespaceMapping, List<string>> pair in source.reverseDictList) {
this.reverseDictList.Add(pair.Key, pair.Value.ToList());
}
}
object ICloneable.Clone()
@ -277,6 +304,11 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -277,6 +304,11 @@ namespace ICSharpCode.WpfDesign.XamlDom
return WpfTypeFinder.Instance.Clone();
}
public virtual Uri ConvertUriToLocalUri(Uri uri)
{
return uri;
}
static class WpfTypeFinder
{
internal static readonly XamlTypeFinder Instance;
@ -291,6 +323,7 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -291,6 +323,7 @@ namespace ICSharpCode.WpfDesign.XamlDom
Instance.RegisterAssembly(typeof(IAddChild).Assembly); // PresentationCore
Instance.RegisterAssembly(typeof(XamlReader).Assembly); // PresentationFramework
Instance.RegisterAssembly(typeof(XamlType).Assembly); // System.Xaml
Instance.RegisterAssembly(typeof(Type).Assembly); // mscorelib
}
}
}

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/DesignItem.cs

@ -161,6 +161,13 @@ namespace ICSharpCode.WpfDesign @@ -161,6 +161,13 @@ namespace ICSharpCode.WpfDesign
for (int i = 0; i < _extensionServers.Length; i++) {
if (_extensionServers[i] == server) {
bool shouldApply = server.ShouldApplyExtensions(this);
if (server.ShouldBeReApplied() && shouldApply && shouldApply == _extensionServerIsApplied[i])
{
_extensionServerIsApplied[i] = false;
ApplyUnapplyExtensionServer(extensionManager, false, server);
}
if (shouldApply != _extensionServerIsApplied[i]) {
_extensionServerIsApplied[i] = shouldApply;
ApplyUnapplyExtensionServer(extensionManager, shouldApply, server);

23
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/EventArgs.cs

@ -44,6 +44,29 @@ namespace ICSharpCode.WpfDesign @@ -44,6 +44,29 @@ namespace ICSharpCode.WpfDesign
}
}
/// <summary>
/// Event arguments specifying a component and property as parameter.
/// </summary>
public class DesignItemPropertyChangedEventArgs : DesignItemEventArgs
{
readonly DesignItemProperty _itemProperty;
/// <summary>
/// Creates a new ComponentEventArgs instance.
/// </summary>
public DesignItemPropertyChangedEventArgs(DesignItem item, DesignItemProperty itemProperty) : base(item)
{
_itemProperty = itemProperty;
}
/// <summary>
/// The property affected by the event.
/// </summary>
public DesignItemProperty ItemProperty {
get { return _itemProperty; }
}
}
/// <summary>
/// Event arguments specifying a component as parameter.
/// </summary>

15
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/Extension.cs

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
using System;
using System.Diagnostics;
using System.Windows;
namespace ICSharpCode.WpfDesign.Extensions
{
@ -32,5 +33,19 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -32,5 +33,19 @@ namespace ICSharpCode.WpfDesign.Extensions
/// </remarks>
public abstract class Extension
{
public static string GetDisabledExtensions(DependencyObject obj)
{
return (string)obj.GetValue(DisabledExtensionsProperty);
}
public static void SetDisabledExtensions(DependencyObject obj, string value)
{
obj.SetValue(DisabledExtensionsProperty, value);
}
public static readonly DependencyProperty DisabledExtensionsProperty =
DependencyProperty.RegisterAttached("DisabledExtensions", typeof(string), typeof(Extension), new PropertyMetadata(null));
}
}

17
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionManager.cs

@ -65,14 +65,14 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -65,14 +65,14 @@ namespace ICSharpCode.WpfDesign.Extensions
internal readonly Type ExtensionType;
internal readonly ExtensionServer Server;
internal readonly Type OverriddenExtensionType;
internal readonly int Order;
internal readonly int Order;
public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType, int Order)
public ExtensionEntry(Type extensionType, ExtensionServer server, Type overriddenExtensionType, int Order)
{
this.ExtensionType = extensionType;
this.Server = server;
this.OverriddenExtensionType = overriddenExtensionType;
this.Order = Order;
this.Order = Order;
}
}
@ -106,7 +106,7 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -106,7 +106,7 @@ namespace ICSharpCode.WpfDesign.Extensions
result.Add(entry);
}
}
return result.OrderBy(x => x.Order).ToList();
return result.OrderBy(x => x.Order).ToList();
}
/// <summary>
@ -151,7 +151,10 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -151,7 +151,10 @@ namespace ICSharpCode.WpfDesign.Extensions
foreach (ExtensionEntry entry in GetExtensionEntries(item)) {
if (entry.Server == server) {
yield return server.CreateExtension(entry.ExtensionType, item);
var disabledExtensions = Extension.GetDisabledExtensions(item.View);
if (disabledExtensions == null || !disabledExtensions.Split(';').Contains(entry.ExtensionType.Name))
yield return server.CreateExtension(entry.ExtensionType, item);
}
}
}
@ -186,8 +189,8 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -186,8 +189,8 @@ namespace ICSharpCode.WpfDesign.Extensions
foreach (ExtensionForAttribute designerFor in extensionForAttributes) {
ExtensionServer server = GetServerForExtension(type);
ExtensionAttribute extensionAttribute = type.GetCustomAttributes(typeof(ExtensionAttribute), false).FirstOrDefault() as ExtensionAttribute;
AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtension, extensionAttribute != null ? extensionAttribute.Order : 0));
ExtensionAttribute extensionAttribute = type.GetCustomAttributes(typeof(ExtensionAttribute), false).FirstOrDefault() as ExtensionAttribute;
AddExtensionEntry(designerFor.DesignedItemType, new ExtensionEntry(type, server, designerFor.OverrideExtension, extensionAttribute != null ? extensionAttribute.Order : 0));
}
}
}

8
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/ExtensionServer.cs

@ -74,6 +74,14 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -74,6 +74,14 @@ namespace ICSharpCode.WpfDesign.Extensions
/// </summary>
public abstract bool ShouldApplyExtensions(DesignItem extendedItem);
// <summary>
/// Set if the Extension Server should be reaplied (For multiple Selection extension Server for Example!)
/// </summary>
public virtual bool ShouldBeReApplied()
{
return false;
}
/// <summary>
/// Create an extension of the specified type.
/// Is called by the ExtensionManager.

5
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Extensions/SelectionExtensionServer.cs

@ -121,6 +121,11 @@ namespace ICSharpCode.WpfDesign.Extensions @@ -121,6 +121,11 @@ namespace ICSharpCode.WpfDesign.Extensions
ReapplyExtensions(this.Services.Selection.SelectedItems);
}
public override bool ShouldBeReApplied()
{
return true;
}
/// <summary>
/// Gets if the item is in the secondary selection.
/// </summary>

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PlacementBehavior.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.WpfDesign @@ -31,7 +31,7 @@ namespace ICSharpCode.WpfDesign
/// <summary>
/// Gets if the child element can be resized.
/// </summary>
bool CanPlace(ICollection<DesignItem> childItems, PlacementType type, PlacementAlignment position);
bool CanPlace(IEnumerable<DesignItem> childItems, PlacementType type, PlacementAlignment position);
/// <summary>
/// Starts placement mode for this container.

31
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/EditorManager.cs

@ -17,13 +17,10 @@ @@ -17,13 +17,10 @@
// DEALINGS IN THE SOFTWARE.
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Collections.Generic;
using System.Reflection;
using System.Windows;
using System.Windows.Input;
using ICSharpCode.WpfDesign.PropertyGrid.Editors;
using System.Windows.Controls;
namespace ICSharpCode.WpfDesign.PropertyGrid
{
@ -37,6 +34,10 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -37,6 +34,10 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
// property full name => editor type
static Dictionary<string, Type> propertyEditors = new Dictionary<string, Type>();
static Type defaultComboboxEditor;
static Type defaultTextboxEditor;
/// <summary>
/// Creates a property editor for the specified <paramref name="property"/>
/// </summary>
@ -61,14 +62,32 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -61,14 +62,32 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
if (editorType == null) {
var standardValues = Metadata.GetStandardValues(property.ReturnType);
if (standardValues != null) {
return new ComboBoxEditor() { ItemsSource = standardValues };
var itemsControl = (ItemsControl)Activator.CreateInstance(defaultComboboxEditor);
itemsControl.ItemsSource = standardValues;
return itemsControl;
}
return new TextBoxEditor();
return (FrameworkElement)Activator.CreateInstance(defaultTextboxEditor);
}
}
return (FrameworkElement)Activator.CreateInstance(editorType);
}
/// <summary>
/// Registers the Textbox Editor.
/// </summary>
public static void SetDefaultTextBoxEditorType(Type type)
{
defaultTextboxEditor = type;
}
/// <summary>
/// Registers the Combobox Editor.
/// </summary>
public static void SetDefaultComboBoxEditorType(Type type)
{
defaultComboboxEditor = type;
}
/// <summary>
/// Registers property editors defined in the specified assembly.
/// </summary>

33
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/PropertyGrid/TypeHelper.cs

@ -102,7 +102,6 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -102,7 +102,6 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
}
else
{
var l=TypeDescriptor.GetProperties(element);
foreach(PropertyDescriptor p in TypeDescriptor.GetProperties(element)){
if (!p.IsBrowsable) continue;
if (p.IsReadOnly && !typeof(ICollection).IsAssignableFrom(p.PropertyType)) continue;
@ -119,32 +118,14 @@ namespace ICSharpCode.WpfDesign.PropertyGrid @@ -119,32 +118,14 @@ namespace ICSharpCode.WpfDesign.PropertyGrid
/// <returns></returns>
public static IEnumerable<PropertyDescriptor> GetCommonAvailableProperties(IEnumerable<object> elements)
{
foreach (var pd1 in GetAvailableProperties(elements.First())) {
bool propertyOk = true;
foreach (var element in elements.Skip(1)) {
bool typeOk = false;
foreach (var pd2 in GetAvailableProperties(element)) {
if (pd1 == pd2) {
typeOk = true;
break;
}
/* Check if it is attached property.*/
if(pd1.Name.Contains(".") && pd2.Name.Contains(".")){
if(pd1.Name==pd2.Name){
typeOk=true;
break;
}
}
}
if (!typeOk) {
propertyOk = false;
break;
}
}
if (propertyOk) yield return pd1;
var properties = TypeDescriptor.GetProperties(elements.First()).Cast<PropertyDescriptor>();
foreach (var element in elements.Skip(1))
{
var currentProperties = TypeDescriptor.GetProperties(element).Cast<PropertyDescriptor>();
properties = Enumerable.Intersect(properties, currentProperties);
}
}
return properties;
}
}
}

3
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/Services.cs

@ -126,6 +126,9 @@ namespace ICSharpCode.WpfDesign @@ -126,6 +126,9 @@ namespace ICSharpCode.WpfDesign
/// <summary>Event raised whenever a component is registered</summary>
event EventHandler<DesignItemEventArgs> ComponentRegistered;
/// <summary>Property Changed</summary>
event EventHandler<DesignItemPropertyChangedEventArgs> PropertyChanged;
}
#endregion

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign/Project/WpfDesign.csproj

@ -103,12 +103,6 @@ @@ -103,12 +103,6 @@
<Compile Include="PlacementAlignment.cs" />
<Compile Include="PropertyGrid\Category.cs" />
<Compile Include="PropertyGrid\EditorManager.cs" />
<Compile Include="PropertyGrid\Editors\ComboBoxEditor.xaml.cs">
<DependentUpon>ComboBoxEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\Editors\TextBoxEditor.xaml.cs">
<DependentUpon>TextBoxEditor.xaml</DependentUpon>
</Compile>
<Compile Include="PropertyGrid\PropertyEditorAttribute.cs" />
<Compile Include="PropertyGrid\PropertyNode.cs" />
<Compile Include="PropertyGrid\SortedObservableCollection.cs" />
@ -120,16 +114,6 @@ @@ -120,16 +114,6 @@
<Compile Include="Services.cs" />
<Compile Include="Tools.cs" />
</ItemGroup>
<ItemGroup>
<Page Include="PropertyGrid\Editors\ComboBoxEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PropertyGrid\Editors\TextBoxEditor.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<CodeAnalysisDictionary Include="Configuration\CodeAnalysisDictionary.xml" />
</ItemGroup>

1
src/AddIns/Misc/PackageManagement/Project/PackageManagement.csproj

@ -224,6 +224,7 @@ @@ -224,6 +224,7 @@
<Compile Include="Src\IThreadSafePackageManagementEvents.cs" />
<Compile Include="Src\ManagePackagesUserPrompts.cs" />
<Compile Include="Src\ManagePackagesViewTitle.cs" />
<Compile Include="Src\MessageServiceExtensions.cs" />
<Compile Include="Src\MSBuildBasedProjectExtensions.cs" />
<Compile Include="Src\IPackageFromRepositoryExtensions.cs" />
<Compile Include="Src\NoPackageSourcesConfiguredException.cs" />

14
src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeFileSystem.cs

@ -59,7 +59,12 @@ namespace ICSharpCode.PackageManagement.Design @@ -59,7 +59,12 @@ namespace ICSharpCode.PackageManagement.Design
public string GetFullPath(string path)
{
return PathToReturnFromGetFullPath;
if (PathToReturnFromGetFullPath != null) {
return PathToReturnFromGetFullPath;
} else if (Root == null) {
return null;
}
return Path.Combine(Root, path);
}
public void DeleteFile(string path)
@ -70,9 +75,16 @@ namespace ICSharpCode.PackageManagement.Design @@ -70,9 +75,16 @@ namespace ICSharpCode.PackageManagement.Design
public bool FileExists(string path)
{
PathPassedToFileExists = path;
if (ExistingFiles.Contains(path)) {
return true;
}
return FileExistsReturnValue;
}
public List<string> ExistingFiles = new List<string>();
public bool DirectoryExists(string path)
{
PathPassedToDirectoryExists = path;

4
src/AddIns/Misc/PackageManagement/Project/Src/Design/FakePackageManagementProject.cs

@ -20,6 +20,7 @@ using System; @@ -20,6 +20,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Versioning;
using ICSharpCode.PackageManagement;
using ICSharpCode.PackageManagement.EnvDTE;
using NuGet;
@ -41,6 +42,7 @@ namespace ICSharpCode.PackageManagement.Design @@ -41,6 +42,7 @@ namespace ICSharpCode.PackageManagement.Design
this.Name = name;
ConstraintProvider = NullConstraintProvider.Instance;
TargetFramework = new FrameworkName(".NETFramework", new Version("4.0"));
}
private FakeInstallPackageAction FakeInstallPackageAction;
@ -283,5 +285,7 @@ namespace ICSharpCode.PackageManagement.Design @@ -283,5 +285,7 @@ namespace ICSharpCode.PackageManagement.Design
}
public IPackageConstraintProvider ConstraintProvider { get; set; }
public FrameworkName TargetFramework { get; set; }
}
}

14
src/AddIns/Misc/PackageManagement/Project/Src/Design/FakeSettings.cs

@ -100,14 +100,14 @@ namespace ICSharpCode.PackageManagement.Design @@ -100,14 +100,14 @@ namespace ICSharpCode.PackageManagement.Design
return SavedSectionValueLists[RegisteredPackageSourceSettings.PackageSourcesSectionName];
}
public bool DeleteValue(string section, string key)
public virtual bool DeleteValue(string section, string key)
{
throw new NotImplementedException();
}
public List<string> SectionsDeleted = new List<string>();
public bool DeleteSection(string section)
public virtual bool DeleteSection(string section)
{
SectionsDeleted.Add(section);
return true;
@ -159,10 +159,10 @@ namespace ICSharpCode.PackageManagement.Design @@ -159,10 +159,10 @@ namespace ICSharpCode.PackageManagement.Design
public IList<KeyValuePair<string, string>> GetNestedValues(string section, string key)
{
throw new NotImplementedException();
return new List<KeyValuePair<string, string>>();
}
public void SetNestedValues(string section, string key, IList<KeyValuePair<string, string>> values)
public virtual void SetNestedValues(string section, string key, IList<KeyValuePair<string, string>> values)
{
throw new NotImplementedException();
}
@ -184,7 +184,7 @@ namespace ICSharpCode.PackageManagement.Design @@ -184,7 +184,7 @@ namespace ICSharpCode.PackageManagement.Design
}
}
public void SetPackageRestoreSetting(bool enabled)
public virtual void SetPackageRestoreSetting(bool enabled)
{
var items = new List<KeyValuePair<string, string>>();
items.Add(new KeyValuePair<string, string>("enabled", enabled.ToString()));
@ -218,7 +218,9 @@ namespace ICSharpCode.PackageManagement.Design @@ -218,7 +218,9 @@ namespace ICSharpCode.PackageManagement.Design
public IList<SettingValue> GetSettingValues(string section, bool isPath)
{
throw new NotImplementedException();
return Sections[section]
.Select(item => new SettingValue(item.Key, item.Value, false))
.ToList();
}
public void SetRepositoryPathSetting(string fullPath)

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

Loading…
Cancel
Save