diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs index e1e6b469ec..0f45fd9f4c 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs @@ -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) { diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs index f894e939d2..363e8a5894 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs @@ -81,17 +81,17 @@ 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) { if (item.View == null) 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) @@ -100,8 +100,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions 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) @@ -129,7 +129,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions if (canEnter && !shouldAlwaysEnter && !Keyboard.IsKeyDown(Key.LeftAlt) && !Keyboard.IsKeyDown(Key.RightAlt)) { var b = new Rect(0, 0, ((FrameworkElement)this.ExtendedItem.View).ActualWidth, ((FrameworkElement)this.ExtendedItem.View).ActualHeight); - InfoTextEnterArea.Start(ref infoTextEnterArea, this.Services, this.ExtendedItem.View, b, Translations.Instance.PressAltText); + InfoTextEnterArea.Start(ref infoTextEnterArea, this.Services, this.ExtendedItem.View, b, Translations.Instance.PressAltText); return false; } @@ -139,7 +139,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions private bool internalCanEnterContainer(PlacementOperation operation) { - InfoTextEnterArea.Stop(ref infoTextEnterArea); + InfoTextEnterArea.Stop(ref infoTextEnterArea); if (ExtendedItem.Component is Expander) { @@ -164,8 +164,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions } } - if (ExtendedItem.ContentProperty.ReturnType == typeof(string)) - return false; + if (ExtendedItem.ContentProperty.ReturnType == typeof(string)) + return false; if (!ExtendedItem.ContentProperty.IsSet) return true; @@ -188,7 +188,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions foreach (var info in operation.PlacedItems) { SetPosition(info); } - } + } } } } diff --git a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs index 69ff8f8958..8c105ace8d 100644 --- a/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs +++ b/src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs @@ -51,15 +51,21 @@ namespace ICSharpCode.WpfDesign.XamlDom break; } - foreach (var dictentry in ns) + foreach (var dictentry in ns.ToList()) { - xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); + if (xmlElement.HasAttribute("xmlns:" + dictentry.Key)) + ns.Remove(dictentry.Key); + else + xmlElement.SetAttribute("xmlns:" + dictentry.Key, dictentry.Value); } var keyAttrib = xmlElement.GetAttribute("Key", XamlConstants.XamlNamespace); - if (string.IsNullOrEmpty(keyAttrib)) + bool keySet = false; + if (string.IsNullOrEmpty(keyAttrib)) { + keySet = true; xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&ยงยง%%__"); + } var xaml = xmlElement.OuterXml; xaml = "" + xaml + ""; @@ -111,11 +117,20 @@ namespace ICSharpCode.WpfDesign.XamlDom var result = (ResourceDictionary)writer.Result; + if (keySet) + xmlElement.RemoveAttribute("Key", XamlConstants.XamlNamespace); + + foreach (var dictentry in ns) + { + xmlElement.RemoveAttribute("xmlns:" + dictentry.Key); + } + var enr = result.Keys.GetEnumerator(); enr.MoveNext(); var rdKey = enr.Current; var template = result[rdKey] as FrameworkTemplate; + result.Remove(rdKey); return template; }