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 @@ -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)
{

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

@ -81,9 +81,9 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -81,9 +81,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,7 +91,7 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -91,7 +91,7 @@ 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)
@ -100,8 +100,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -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)
@ -164,8 +164,8 @@ namespace ICSharpCode.WpfDesign.Designer.Extensions @@ -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;

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

@ -51,15 +51,21 @@ namespace ICSharpCode.WpfDesign.XamlDom @@ -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 = "<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 @@ -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;
}

Loading…
Cancel
Save