Browse Source

Fixes in Template helper:

Remove Added Key and Namespaces...
pull/604/head
jogibear9988 12 years ago
parent
commit
0922851312
  1. 12
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/CanvasPlacementSupport.cs
  2. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Extensions/DefaultPlacementBehavior.cs
  3. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.XamlDom/Project/TemplateHelper.cs

12
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)) { if (IsPropertySet(child, Canvas.LeftProperty) || !IsPropertySet(child, Canvas.RightProperty)) {
x = GetCanvasProperty(child, Canvas.LeftProperty); x = GetCanvasProperty(child, Canvas.LeftProperty);
} else { } 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)) { if (IsPropertySet(child, Canvas.TopProperty) || !IsPropertySet(child, Canvas.BottomProperty)) {
y = GetCanvasProperty(child, Canvas.TopProperty); y = GetCanvasProperty(child, Canvas.TopProperty);
} else { } 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); var p = new Point(x, y);
//Fixes, Empty Image Resized to 0 //Fixes, Empty Image Resized to 0
//return new Rect(p, child.RenderSize); //return new Rect(p, child.RenderSize);
return new Rect(p, PlacementOperation.GetRealElementSize(item.View)); return new Rect(p, PlacementOperation.GetRealElementSize(item.View));
} }
public override void SetPosition(PlacementInformation info) public override void SetPosition(PlacementInformation info)
{ {

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

@ -81,9 +81,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
{ {
InfoTextEnterArea.Stop(ref infoTextEnterArea); InfoTextEnterArea.Stop(ref infoTextEnterArea);
this.ExtendedItem.Services.Selection.SetSelectedComponents(null); this.ExtendedItem.Services.Selection.SetSelectedComponents(null);
this.ExtendedItem.Services.Selection.SetSelectedComponents(operation.PlacedItems.Select(x => x.Item).ToList()); this.ExtendedItem.Services.Selection.SetSelectedComponents(operation.PlacedItems.Select(x => x.Item).ToList());
} }
public virtual Rect GetPosition(PlacementOperation operation, DesignItem item) public virtual Rect GetPosition(PlacementOperation operation, DesignItem item)
{ {
@ -91,7 +91,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
return Rect.Empty; return Rect.Empty;
var p = item.View.TranslatePoint(new Point(), operation.CurrentContainer.View); 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 void BeforeSetPosition(PlacementOperation operation)
@ -100,8 +100,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
public virtual void SetPosition(PlacementInformation info) public virtual void SetPosition(PlacementInformation info)
{ {
if (info.Operation.Type != PlacementType.Move) if (info.Operation.Type != PlacementType.Move)
ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height); ModelTools.Resize(info.Item, info.Bounds.Width, info.Bounds.Height);
} }
public virtual bool CanLeaveContainer(PlacementOperation operation) public virtual bool CanLeaveContainer(PlacementOperation operation)
@ -164,8 +164,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions
} }
} }
if (ExtendedItem.ContentProperty.ReturnType == typeof(string)) if (ExtendedItem.ContentProperty.ReturnType == typeof(string))
return false; return false;
if (!ExtendedItem.ContentProperty.IsSet) if (!ExtendedItem.ContentProperty.IsSet)
return true; return true;

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

@ -51,15 +51,21 @@ namespace ICSharpCode.WpfDesign.XamlDom
break; 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); 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&&§§%%__"); xmlElement.SetAttribute("Key", XamlConstants.XamlNamespace, "$$temp&&§§%%__");
}
var xaml = xmlElement.OuterXml; 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>"; xaml = "<ResourceDictionary xmlns=\"http://schemas.microsoft.com/netfx/2007/xaml/presentation\" xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\">" + xaml + "</ResourceDictionary>";
@ -111,11 +117,20 @@ namespace ICSharpCode.WpfDesign.XamlDom
var result = (ResourceDictionary)writer.Result; 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(); var enr = result.Keys.GetEnumerator();
enr.MoveNext(); enr.MoveNext();
var rdKey = enr.Current; var rdKey = enr.Current;
var template = result[rdKey] as FrameworkTemplate; var template = result[rdKey] as FrameworkTemplate;
result.Remove(rdKey); result.Remove(rdKey);
return template; return template;
} }

Loading…
Cancel
Save