|
|
|
@ -36,8 +36,6 @@ using ICSharpCode.Core.Presentation;
@@ -36,8 +36,6 @@ using ICSharpCode.Core.Presentation;
|
|
|
|
|
using ICSharpCode.NRefactory.TypeSystem; |
|
|
|
|
using ICSharpCode.SharpDevelop; |
|
|
|
|
using ICSharpCode.SharpDevelop.Designer; |
|
|
|
|
using ICSharpCode.SharpDevelop.Dom; |
|
|
|
|
using ICSharpCode.SharpDevelop.Editor; |
|
|
|
|
using ICSharpCode.SharpDevelop.Gui; |
|
|
|
|
using ICSharpCode.SharpDevelop.Parser; |
|
|
|
|
using ICSharpCode.SharpDevelop.Project; |
|
|
|
@ -48,7 +46,6 @@ using ICSharpCode.WpfDesign.Designer.OutlineView;
@@ -48,7 +46,6 @@ using ICSharpCode.WpfDesign.Designer.OutlineView;
|
|
|
|
|
using ICSharpCode.WpfDesign.Designer.PropertyGrid; |
|
|
|
|
using ICSharpCode.WpfDesign.Designer.Services; |
|
|
|
|
using ICSharpCode.WpfDesign.Designer.Xaml; |
|
|
|
|
using ICSharpCode.WpfDesign.XamlDom; |
|
|
|
|
using ICSharpCode.WpfDesign.AddIn.Options; |
|
|
|
|
|
|
|
|
|
namespace ICSharpCode.WpfDesign.AddIn |
|
|
|
@ -125,7 +122,48 @@ namespace ICSharpCode.WpfDesign.AddIn
@@ -125,7 +122,48 @@ namespace ICSharpCode.WpfDesign.AddIn
|
|
|
|
|
context.Services.AddService(typeof(ChooseClassServiceBase), new IdeChooseClassService()); |
|
|
|
|
}); |
|
|
|
|
settings.TypeFinder = MyTypeFinder.Create(this.PrimaryFile); |
|
|
|
|
try { |
|
|
|
|
settings.CurrentProjectAssemblyName = SD.ProjectService.CurrentProject.AssemblyName; |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
if (WpfEditorOptions.EnableAppXamlParsing) |
|
|
|
|
{ |
|
|
|
|
var appXaml = SD.ProjectService.CurrentProject.Items.FirstOrDefault(x => x.FileName.GetFileName().ToLower() == ("app.xaml")); |
|
|
|
|
if (appXaml != null) |
|
|
|
|
{ |
|
|
|
|
var f = appXaml as FileProjectItem; |
|
|
|
|
OpenedFile a = SD.FileService.GetOrCreateOpenedFile(f.FileName); |
|
|
|
|
|
|
|
|
|
var xml = XmlReader.Create(a.OpenRead()); |
|
|
|
|
var doc = new XmlDocument(); |
|
|
|
|
doc.Load(xml); |
|
|
|
|
var node = doc.FirstChild.ChildNodes.Cast<XmlNode>().FirstOrDefault(x => x.Name == "Application.Resources"); |
|
|
|
|
|
|
|
|
|
foreach (XmlAttribute att in doc.FirstChild.Attributes.Cast<XmlAttribute>().ToList()) |
|
|
|
|
{ |
|
|
|
|
if (att.Name.StartsWith("xmlns")) { |
|
|
|
|
foreach (var childNode in node.ChildNodes.OfType<XmlNode>()) { |
|
|
|
|
childNode.Attributes.Append(att); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var appXamlXml = XmlReader.Create(new StringReader(node.InnerXml)); |
|
|
|
|
var appxamlContext = new XamlDesignContext(appXamlXml, settings); |
|
|
|
|
|
|
|
|
|
//var parsed = XamlParser.Parse(appXamlXml, appxamlContext.ParserSettings);
|
|
|
|
|
var dict = (ResourceDictionary) appxamlContext.RootItem.Component;// parsed.RootInstance;
|
|
|
|
|
designer.DesignPanel.Resources.MergedDictionaries.Add(dict); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
LoggingService.Error("Error in loading app.xaml", ex); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
settings.ReportErrors = UpdateTasks; |
|
|
|
|
designer.LoadDesigner(r, settings); |
|
|
|
|
|
|
|
|
@ -154,33 +192,6 @@ namespace ICSharpCode.WpfDesign.AddIn
@@ -154,33 +192,6 @@ namespace ICSharpCode.WpfDesign.AddIn
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
this.UserContent = new WpfDocumentError(e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
try{ |
|
|
|
|
if (WpfEditorOptions.EnableAppXamlParsing) { |
|
|
|
|
var appXaml = SD.ProjectService.CurrentProject.Items.FirstOrDefault(x=>x.FileName.GetFileName().ToLower() == ("app.xaml")); |
|
|
|
|
if (appXaml!=null){ |
|
|
|
|
var f=appXaml as FileProjectItem; |
|
|
|
|
OpenedFile a = SD.FileService.GetOrCreateOpenedFile(f.FileName); |
|
|
|
|
|
|
|
|
|
var xml = XmlReader.Create(a.OpenRead()); |
|
|
|
|
var doc=new XmlDocument(); |
|
|
|
|
doc.Load(xml); |
|
|
|
|
var node = doc.FirstChild.ChildNodes.Cast<XmlNode>().FirstOrDefault(x=>x.Name=="Application.Resources"); |
|
|
|
|
|
|
|
|
|
foreach (XmlAttribute att in doc.FirstChild.Attributes.Cast<XmlAttribute>().ToList()) { |
|
|
|
|
if (att.Name.StartsWith("xmlns")) |
|
|
|
|
node.Attributes.Append(att); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var appXamlXml = XmlReader.Create(new StringReader(node.InnerXml)); |
|
|
|
|
var parsed = XamlParser.Parse(appXamlXml, ((XamlDesignContext) designer.DesignContext).ParserSettings); |
|
|
|
|
var dict = (ResourceDictionary)parsed.RootInstance; |
|
|
|
|
designer.DesignPanel.Resources.MergedDictionaries.Add(dict); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} catch (Exception ex) { |
|
|
|
|
LoggingService.Error("Error in loading app.xaml", ex); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|