Browse Source

reactivate code that turns complex properties into markup extensions if possible

pull/252/head
Siegfried Pammer 15 years ago
parent
commit
72a1b71f82
  1. 52
      ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs
  2. 14
      ILSpy.BamlDecompiler/Tests/Cases/AvalonDockCommon.xaml

52
ILSpy.BamlDecompiler/Ricciolo.StylesExplorer.MarkupReflection/XmlBamlReader.cs

@ -870,8 +870,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -870,8 +870,7 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
short extensionIdentifier = (short)-(x & 0xfff);
string value = String.Empty;
switch (x)
{
switch (x) {
case 0x25a:
// StaticExtension
object resource = this.GetResourceName(valueIdentifier);
@ -1093,30 +1092,27 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -1093,30 +1092,27 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
CloseElement();
complexPropertyOpened--;
// // Valuto se contiene tutte extension
// int start = nodes.IndexOf(propertyElement) + 1;
// IEnumerator enumerator = nodes.GetEnumerator();
//
// int c = 0;
// while (c < start && enumerator.MoveNext())
// c++;
//
// if (IsExtension(enumerator))
// {
// start--;
// nodes.RemoveAt(start);
// nodes.RemoveLast();
//
// StringBuilder sb = new StringBuilder();
// FormatElementExtension((XmlBamlElement) nodes[start], sb);
//
// XmlBamlProperty property =
// new XmlBamlProperty(PropertyType.Complex, propertyElement.PropertyDeclaration);
// property.Value = sb.ToString();
// nodes.Add(property);
//
// return;
// }
// this property could be a markup extension
// try to convert it
int start = nodes.IndexOf(propertyElement) + 1;
IEnumerator enumerator = nodes.GetEnumerator();
// move enumerator to the start of this property value
for (int i = 0; i < start && enumerator.MoveNext(); i++) ;
if (IsExtension(enumerator)) {
start--;
nodes.RemoveAt(start);
nodes.RemoveLast();
StringBuilder sb = new StringBuilder();
FormatElementExtension((XmlBamlElement) nodes[start], sb);
XmlBamlProperty property =
new XmlBamlProperty(elements.Peek(), PropertyType.Complex, propertyElement.PropertyDeclaration);
property.Value = sb.ToString();
nodes.Add(property);
}
}
void FormatElementExtension(XmlBamlElement element, StringBuilder sb)
@ -1535,8 +1531,8 @@ namespace Ricciolo.StylesExplorer.MarkupReflection @@ -1535,8 +1531,8 @@ namespace Ricciolo.StylesExplorer.MarkupReflection
if (identifier < LastKey.StaticResources.Count)
return LastKey.StaticResources[(int)identifier];
return "???" + identifier +"???";
// throw new ArgumentException("Cannot find StaticResource", "identifier");
// return "???" + identifier +"???";
throw new ArgumentException("Cannot find StaticResource", "identifier");
}
void ReadTextWithConverter()

14
ILSpy.BamlDecompiler/Tests/Cases/AvalonDockCommon.xaml

@ -17,11 +17,11 @@ @@ -17,11 +17,11 @@
<MenuItem Command="ad:DocumentContentCommands.TabbedDocument" />
</ContextMenu>
<Style x:Key="{x:Type ad:Resizer}" TargetType="{x:Type ad:Resizer}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Background" Value="#00FFFFFF" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ad:Resizer}">
<Border Background="{TemplateBinding Background}" />
<Border Background="{TemplateBinding Control.Background}" />
</ControlTemplate>
</Setter.Value>
</Setter>
@ -30,14 +30,14 @@ @@ -30,14 +30,14 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border x:Name="PaneHeaderCommandIntBorder" Background="Transparent" BorderThickness="1" Margin="0" Opacity="0.8">
<Border Name="PaneHeaderCommandIntBorder" Background="#00FFFFFF" BorderThickness="1" Margin="0" Opacity="0.8">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" TargetName="PaneHeaderCommandIntBorder" Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.PaneHeaderCommandBorderBrush}}}" />
<Setter Property="Background" TargetName="PaneHeaderCommandIntBorder" Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.PaneHeaderCommandBackground}}}" />
<Setter Property="Opacity" TargetName="PaneHeaderCommandIntBorder" Value="1" />
<Setter TargetName="PaneHeaderCommandIntBorder" Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.PaneHeaderCommandBorderBrush}}}" Property="BorderBrush" />
<Setter TargetName="PaneHeaderCommandIntBorder" Value="{DynamicResource {ComponentResourceKey {x:Type ad:DockingManager}, {x:Static ad:AvalonDockBrushes.PaneHeaderCommandBackground}}}" Property="Background" />
<Setter TargetName="PaneHeaderCommandIntBorder" Property="Opacity" Value="1" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
</Setter>
</Style>
<Style x:Key="PaneHeaderContextMenuCommandStyle" TargetType="{x:Type Border}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Background" Value="#00FFFFFF" />
<Setter Property="BorderThickness" Value="1" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">

Loading…
Cancel
Save