Browse Source

XAML Designer Demo Project -> Add the Posibility to Add Controls from other Assemblys to the ToolBox

(needed for further testing)
pull/52/head
jkuehner 13 years ago
parent
commit
3a2ec306e5
  1. 7
      samples/XamlDesigner/Toolbox.cs
  2. 5
      samples/XamlDesigner/ToolboxView.xaml
  3. 17
      samples/XamlDesigner/ToolboxView.xaml.cs

7
samples/XamlDesigner/Toolbox.cs

@ -35,7 +35,7 @@ namespace ICSharpCode.XamlDesigner @@ -35,7 +35,7 @@ namespace ICSharpCode.XamlDesigner
node.Assembly = assembly;
node.Path = path;
foreach (var t in assembly.GetExportedTypes()) {
if (IsControl(t) && Metadata.IsPopularControl(t)) {
if (IsControl(t) /* && Metadata.IsPopularControl(t) */) {
node.Controls.Add(new ControlNode() { Type = t });
}
}
@ -64,8 +64,13 @@ namespace ICSharpCode.XamlDesigner @@ -64,8 +64,13 @@ namespace ICSharpCode.XamlDesigner
{
if (Settings.Default.AssemblyList != null) {
foreach (var path in Settings.Default.AssemblyList) {
try
{
AddAssembly(Environment.ExpandEnvironmentVariables(path), false);
}
catch (Exception ex)
{ }
}
}
}

5
samples/XamlDesigner/ToolboxView.xaml

@ -3,6 +3,11 @@ @@ -3,6 +3,11 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Outline="clr-namespace:ICSharpCode.WpfDesign.Designer.OutlineView;assembly=ICSharpCode.WpfDesign.Designer"
xmlns:Default="clr-namespace:ICSharpCode.XamlDesigner">
<UserControl.ContextMenu>
<ContextMenu>
<MenuItem Header="Browse..." Click="BrowseForAssemblies_OnClick"></MenuItem>
</ContextMenu>
</UserControl.ContextMenu>
<UserControl.Resources>
<HierarchicalDataTemplate DataType="{x:Type Default:AssemblyNode}"

17
samples/XamlDesigner/ToolboxView.xaml.cs

@ -1,3 +1,4 @@ @@ -1,3 +1,4 @@
using System.IO;
using ICSharpCode.WpfDesign.Designer.OutlineView;
using System;
using System.Collections.Generic;
@ -16,6 +17,7 @@ using System.Windows.Media.Imaging; @@ -16,6 +17,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ICSharpCode.WpfDesign.Designer.Services;
using Microsoft.Win32;
namespace ICSharpCode.XamlDesigner
{
@ -73,5 +75,20 @@ namespace ICSharpCode.XamlDesigner @@ -73,5 +75,20 @@ namespace ICSharpCode.XamlDesigner
Toolbox.Instance.Remove(node);
}
}
private void BrowseForAssemblies_OnClick(object sender, RoutedEventArgs e)
{
var dlg = new OpenFileDialog();
dlg.Filter = "Assemblies (*.dll)|*.dll";
dlg.Multiselect = true;
dlg.CheckFileExists = true;
if (dlg.ShowDialog().Value)
{
foreach (var fileName in dlg.FileNames)
{
Toolbox.Instance.AddAssembly(fileName);
}
}
}
}
}

Loading…
Cancel
Save