Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2577 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
17 changed files with 284 additions and 45 deletions
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Windows.Markup; |
||||
|
||||
using ICSharpCode.SharpDevelop; |
||||
|
||||
namespace ICSharpCode.WpfDesign.AddIn |
||||
{ |
||||
/// <summary>
|
||||
/// Used to support loading Image.ImageSource.
|
||||
/// </summary>
|
||||
public class FileUriContext : IUriContext |
||||
{ |
||||
OpenedFile file; |
||||
|
||||
public FileUriContext(OpenedFile file) |
||||
{ |
||||
if (file == null) |
||||
throw new ArgumentNullException("file"); |
||||
this.file = file; |
||||
} |
||||
|
||||
public Uri BaseUri { |
||||
get { |
||||
return new Uri(file.FileName); |
||||
} |
||||
set { |
||||
throw new NotSupportedException(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,62 @@
@@ -0,0 +1,62 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Reflection; |
||||
using ICSharpCode.WpfDesign.XamlDom; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using TypeResolutionService = ICSharpCode.FormsDesigner.Services.TypeResolutionService; |
||||
|
||||
namespace ICSharpCode.WpfDesign.AddIn |
||||
{ |
||||
public class MyTypeFinder : XamlTypeFinder |
||||
{ |
||||
OpenedFile file; |
||||
|
||||
public static MyTypeFinder Create(OpenedFile file) |
||||
{ |
||||
MyTypeFinder f = new MyTypeFinder(); |
||||
f.file = file; |
||||
f.ImportFrom(CreateWpfTypeFinder()); |
||||
return f; |
||||
} |
||||
|
||||
public override Assembly LoadAssembly(string name) |
||||
{ |
||||
if (string.IsNullOrEmpty(name)) { |
||||
IProjectContent pc = GetProjectContent(file); |
||||
if (pc != null) { |
||||
return TypeResolutionService.LoadAssembly(pc); |
||||
} |
||||
return null; |
||||
} else { |
||||
return base.LoadAssembly(name); |
||||
} |
||||
} |
||||
|
||||
public override XamlTypeFinder Clone() |
||||
{ |
||||
MyTypeFinder copy = new MyTypeFinder(); |
||||
copy.file = this.file; |
||||
copy.ImportFrom(this); |
||||
return copy; |
||||
} |
||||
|
||||
internal static IProjectContent GetProjectContent(OpenedFile file) |
||||
{ |
||||
if (ProjectService.OpenSolution != null && file != null) { |
||||
IProject p = ProjectService.OpenSolution.FindProjectContainingFile(file.FileName); |
||||
if (p != null) { |
||||
return ParserService.GetProjectContent(p); |
||||
} |
||||
} |
||||
return ParserService.DefaultProjectContent; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Reflection; |
||||
using ICSharpCode.WpfDesign.XamlDom; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer.Xaml |
||||
{ |
||||
/// <summary>
|
||||
/// Settings used to load a XAML document.
|
||||
/// </summary>
|
||||
public sealed class XamlLoadSettings |
||||
{ |
||||
public readonly ICollection<Assembly> DesignerAssemblies = new List<Assembly>(); |
||||
public readonly List<Action<XamlDesignContext>> CustomServiceRegisterFunctions = new List<Action<XamlDesignContext>>(); |
||||
XamlTypeFinder typeFinder = XamlTypeFinder.CreateWpfTypeFinder(); |
||||
|
||||
public XamlTypeFinder TypeFinder { |
||||
get { return typeFinder; } |
||||
set { |
||||
if (value == null) |
||||
throw new ArgumentNullException("value"); |
||||
typeFinder = value; |
||||
} |
||||
} |
||||
|
||||
public XamlLoadSettings() |
||||
{ |
||||
DesignerAssemblies.Add(typeof(XamlDesignContext).Assembly); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue