Browse Source

Use "EnableAppXamlParsing" Setting, but default should be "true"

pull/630/head
jkuehner 11 years ago
parent
commit
8951f3a2f9
  1. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/Options/WpfEditorOptions.cs
  2. 36
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/Options/WpfEditorOptions.cs

@ -30,7 +30,7 @@ namespace ICSharpCode.WpfDesign.AddIn.Options
public static bool EnableAppXamlParsing { public static bool EnableAppXamlParsing {
get { get {
return SD.PropertyService.Get(EnableAppXamlParsingOptionName, false); return SD.PropertyService.Get(EnableAppXamlParsingOptionName, true);
} }
set { set {
SD.PropertyService.Set(EnableAppXamlParsingOptionName, value); SD.PropertyService.Set(EnableAppXamlParsingOptionName, value);

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

@ -49,6 +49,7 @@ using ICSharpCode.WpfDesign.Designer.PropertyGrid;
using ICSharpCode.WpfDesign.Designer.Services; using ICSharpCode.WpfDesign.Designer.Services;
using ICSharpCode.WpfDesign.Designer.Xaml; using ICSharpCode.WpfDesign.Designer.Xaml;
using ICSharpCode.WpfDesign.XamlDom; using ICSharpCode.WpfDesign.XamlDom;
using ICSharpCode.WpfDesign.AddIn.Options;
namespace ICSharpCode.WpfDesign.AddIn namespace ICSharpCode.WpfDesign.AddIn
{ {
@ -155,26 +156,27 @@ namespace ICSharpCode.WpfDesign.AddIn
} }
try{ try{
var appXaml = SD.ProjectService.CurrentProject.Items.FirstOrDefault(x=>x.FileName.GetFileName().ToLower() == ("app.xaml")); if (WpfEditorOptions.EnableAppXamlParsing) {
if (appXaml!=null){ var appXaml = SD.ProjectService.CurrentProject.Items.FirstOrDefault(x=>x.FileName.GetFileName().ToLower() == ("app.xaml"));
var f=appXaml as FileProjectItem; if (appXaml!=null){
OpenedFile a = SD.FileService.GetOrCreateOpenedFile(f.FileName); var f=appXaml as FileProjectItem;
OpenedFile a = SD.FileService.GetOrCreateOpenedFile(f.FileName);
var xml = XmlReader.Create(a.OpenRead()); var xml = XmlReader.Create(a.OpenRead());
var doc=new XmlDocument(); var doc=new XmlDocument();
doc.Load(xml); doc.Load(xml);
var node = doc.FirstChild.ChildNodes.Cast<XmlNode>().FirstOrDefault(x=>x.Name=="Application.Resources"); var node = doc.FirstChild.ChildNodes.Cast<XmlNode>().FirstOrDefault(x=>x.Name=="Application.Resources");
foreach (XmlAttribute att in doc.FirstChild.Attributes.Cast<XmlAttribute>().ToList()) foreach (XmlAttribute att in doc.FirstChild.Attributes.Cast<XmlAttribute>().ToList()) {
{ if (att.Name.StartsWith("xmlns"))
if (att.Name.StartsWith("xmlns")) node.Attributes.Append(att);
node.Attributes.Append(att); }
}
var appXamlXml = XmlReader.Create(new StringReader(node.InnerXml)); var appXamlXml = XmlReader.Create(new StringReader(node.InnerXml));
var parsed = XamlParser.Parse(appXamlXml, ((XamlDesignContext) designer.DesignContext).ParserSettings); var parsed = XamlParser.Parse(appXamlXml, ((XamlDesignContext) designer.DesignContext).ParserSettings);
var dict = (ResourceDictionary)parsed.RootInstance; var dict = (ResourceDictionary)parsed.RootInstance;
designer.DesignPanel.Resources.MergedDictionaries.Add(dict); designer.DesignPanel.Resources.MergedDictionaries.Add(dict);
}
} }
} catch (Exception ex) { } catch (Exception ex) {
LoggingService.Error("Error in loading app.xaml", ex); LoggingService.Error("Error in loading app.xaml", ex);

Loading…
Cancel
Save