Browse Source

Add more controls to toolbox, support editing properties of type "Cursor" and "bool?".

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2671 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
9567c3e210
  1. 67
      data/templates/project/CSharp/WPFApplication.xpt
  2. 77
      data/templates/project/CSharp/WPFNavigationApplication.xpt
  3. 11
      src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Toolbox.cs
  4. 7
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfToolbox.cs
  5. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs
  6. 11
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/ContentEditor.cs
  7. 25
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/CursorEditor.cs
  8. 51
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/NullableBoolEditor.cs
  9. 32
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs
  10. 2
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

67
data/templates/project/CSharp/WPFApplication.xpt

@ -37,13 +37,9 @@
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
</PropertyGroup> </PropertyGroup>
<Imports failureMessage="Please ensure the .NET Framework 3.0 is installed on your machine!">
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
</Imports>
<Files> <Files>
<File name="App.xaml" buildAction="ApplicationDefinition" language="XML"><![CDATA[<Application x:Class="${StandardNamespace}.App" <File name="App.xaml" buildAction="ApplicationDefinition" language="XML"><![CDATA[<Application x:Class="${StandardNamespace}.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml" StartupUri="Window1.xaml"
> >
@ -59,28 +55,25 @@ using System.Configuration;
namespace ${StandardNamespace} namespace ${StandardNamespace}
{ {
/// <summary> /// <summary>
/// Interaction logic for App.xaml /// Interaction logic for App.xaml
/// </summary> /// </summary>
public partial class App : Application
public partial class App : Application {
{ public App()
{
public App() InitializeComponent();
{ }
InitializeComponent(); }
}
}
}]]></File> }]]></File>
<File name="Window1.xaml" buildAction="Page" language="XML"><![CDATA[<Window x:Class="${StandardNamespace}.Window1" <File name="Window1.xaml" buildAction="Page" language="XML"><![CDATA[<Window x:Class="${StandardNamespace}.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="${StandardNamespace}" Height="300" Width="300" Title="${StandardNamespace}" Height="300" Width="300"
> >
<Grid> <Grid>
</Grid> </Grid>
</Window>]]></File> </Window>]]></File>
<File name="Window1.xaml.cs" SubType="Code" DependentUpon="Window1.xaml"><![CDATA[using System; <File name="Window1.xaml.cs" SubType="Code" DependentUpon="Window1.xaml"><![CDATA[using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -94,22 +87,18 @@ using System.Windows.Media;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
namespace ${StandardNamespace} namespace ${StandardNamespace}
{ {
/// <summary> /// <summary>
/// Interaction logic for Window1.xaml /// Interaction logic for Window1.xaml
/// </summary> /// </summary>
public partial class Window1 : Window
public partial class Window1 : Window {
{ public Window1()
{
public Window1() InitializeComponent();
{ }
InitializeComponent(); }
}
}
}]]></File> }]]></File>
<File name="AssemblyInfo.cs" src="WPFAssemblyInfo.cs" /> <File name="AssemblyInfo.cs" src="WPFAssemblyInfo.cs" />
</Files> </Files>

77
data/templates/project/CSharp/WPFNavigationApplication.xpt

@ -36,20 +36,16 @@
<PropertyGroup> <PropertyGroup>
<OutputType>WinExe</OutputType> <OutputType>WinExe</OutputType>
</PropertyGroup> </PropertyGroup>
<Imports failureMessage="Please ensure the .NET Framework 3.0 is installed on your machine!">
<Import Project="$(MSBuildBinPath)\Microsoft.WinFX.targets" />
</Imports>
<Files> <Files>
<File name="App.xaml" buildAction="ApplicationDefinition" language="XML"><![CDATA[<Application x:Class="${StandardNamespace}.App" <File name="App.xaml" buildAction="ApplicationDefinition" language="XML"><![CDATA[<Application x:Class="${StandardNamespace}.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Page1.xaml" StartupUri="Page1.xaml"
> >
<Application.Resources> <Application.Resources>
</Application.Resources> </Application.Resources>
</Application>]]></File> </Application>]]></File>
<File name="App.xaml.cs" SubType="Code" DependentUpon="App.xaml"><![CDATA[using System; <File name="App.xaml.cs" SubType="Code" DependentUpon="App.xaml"><![CDATA[using System;
using System.Windows; using System.Windows;
@ -59,28 +55,25 @@ using System.Configuration;
namespace ${StandardNamespace} namespace ${StandardNamespace}
{ {
/// <summary> /// <summary>
/// Interaction logic for App.xaml /// Interaction logic for App.xaml
/// </summary> /// </summary>
public partial class App : Application
public partial class App : Application {
{ public App()
{
public App() InitializeComponent();
{ }
InitializeComponent(); }
}
}
}]]></File> }]]></File>
<File name="Page1.xaml" language="XML" buildAction="Page"><![CDATA[<Page x:Class="${StandardNamespace}.Page1" <File name="Page1.xaml" language="XML" buildAction="Page"><![CDATA[<Page x:Class="${StandardNamespace}.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/netfx/2007/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1" Title="Page1"
> >
<StackPanel> <Grid>
</StackPanel> </Grid>
</Page>]]></File> </Page>]]></File>
<File name="Page1.xaml.cs" language="C#" DependentUpon="Page1.xaml" SubType="Code"><![CDATA[using System; <File name="Page1.xaml.cs" language="C#" DependentUpon="Page1.xaml" SubType="Code"><![CDATA[using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -97,18 +90,16 @@ using System.Windows.Shapes;
namespace ${StandardNamespace} namespace ${StandardNamespace}
{ {
/// <summary> /// <summary>
/// Interaction logic for Page1.xaml /// Interaction logic for Page1.xaml
/// </summary> /// </summary>
public partial class Page1 : Page
public partial class Page1 : Page {
{ public Page1()
public Page1() {
{ InitializeComponent();
InitializeComponent(); }
} }
}
}]]></File> }]]></File>
<File name="AssemblyInfo.cs" src="WPFAssemblyInfo.cs" /> <File name="AssemblyInfo.cs" src="WPFAssemblyInfo.cs" />
</Files> </Files>

11
src/AddIns/DisplayBindings/WpfDesign/StandaloneDesigner/Toolbox.cs

@ -12,6 +12,7 @@ using System.Windows.Media.Imaging;
using System.Windows.Navigation; using System.Windows.Navigation;
using System.Windows.Shapes; using System.Windows.Shapes;
using ICSharpCode.WpfDesign; using ICSharpCode.WpfDesign;
using ICSharpCode.WpfDesign.Designer;
using ICSharpCode.WpfDesign.Designer.Services; using ICSharpCode.WpfDesign.Designer.Services;
namespace StandaloneDesigner namespace StandaloneDesigner
@ -35,12 +36,10 @@ namespace StandaloneDesigner
this.Items.Clear(); this.Items.Clear();
if (toolService != null) { if (toolService != null) {
AddTool("Pointer", toolService.PointerTool); AddTool("Pointer", toolService.PointerTool);
AddTool(typeof(Button));
AddTool(typeof(TextBox)); foreach (Type t in DesignSurface.SupportedToolboxControls)
AddTool(typeof(CheckBox)); AddTool(t);
AddTool(typeof(Label));
AddTool(typeof(Canvas));
AddTool(typeof(Grid));
toolService.CurrentToolChanged += OnCurrentToolChanged; toolService.CurrentToolChanged += OnCurrentToolChanged;
OnCurrentToolChanged(null, null); OnCurrentToolChanged(null, null);
} }

7
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfToolbox.cs

@ -45,11 +45,8 @@ namespace ICSharpCode.WpfDesign.AddIn
sideTab.ChoosedItemChanged += OnChoosedItemChanged; sideTab.ChoosedItemChanged += OnChoosedItemChanged;
sideTab.Items.Add(new WpfSideTabItem()); sideTab.Items.Add(new WpfSideTabItem());
sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.Button))); foreach (Type t in Designer.DesignSurface.SupportedToolboxControls)
sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.CheckBox))); sideTab.Items.Add(new WpfSideTabItem(t));
sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.TextBox)));
sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.Grid)));
sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.Canvas)));
sideBar.Tabs.Add(sideTab); sideBar.Tabs.Add(sideTab);
sideBar.ActiveTab = sideTab; sideBar.ActiveTab = sideTab;

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

@ -24,7 +24,7 @@ using ICSharpCode.WpfDesign.PropertyEditor;
namespace ICSharpCode.WpfDesign.AddIn namespace ICSharpCode.WpfDesign.AddIn
{ {
/// <summary> /// <summary>
/// Description of WpfViewContent. /// IViewContent implementation that hosts the WPF designer.
/// </summary> /// </summary>
public class WpfViewContent : AbstractViewContentHandlingLoadErrors, IHasPropertyContainer, IToolsHost public class WpfViewContent : AbstractViewContentHandlingLoadErrors, IHasPropertyContainer, IToolsHost
{ {

11
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/ContentEditor.cs

@ -109,7 +109,6 @@ namespace ICSharpCode.WpfDesign.Designer.Controls.TypeEditors
{ {
} }
EventHandler valueChangedListeners;
internal bool preventSetValue; internal bool preventSetValue;
public override object Value { public override object Value {
@ -121,10 +120,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls.TypeEditors
} }
} }
public override event EventHandler ValueChanged { // don't forward add/remove calls to the underlying property, but register them here
add { valueChangedListeners += value; } public override event EventHandler ValueChanged;
remove { valueChangedListeners -= value; }
}
public override System.ComponentModel.TypeConverter TypeConverter { public override System.ComponentModel.TypeConverter TypeConverter {
get { return System.ComponentModel.TypeDescriptor.GetConverter(typeof(string)); } get { return System.ComponentModel.TypeDescriptor.GetConverter(typeof(string)); }
@ -132,8 +129,8 @@ namespace ICSharpCode.WpfDesign.Designer.Controls.TypeEditors
internal void RaiseValueChanged() internal void RaiseValueChanged()
{ {
if (valueChangedListeners != null) { if (ValueChanged != null) {
valueChangedListeners(this, EventArgs.Empty); ValueChanged(this, EventArgs.Empty);
} }
} }
} }

25
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/CursorEditor.cs

@ -0,0 +1,25 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.PropertyEditor;
namespace ICSharpCode.WpfDesign.Designer.Controls.TypeEditors
{
[TypeEditor(typeof(System.Windows.Input.Cursor))]
public class CursorEditor : ComboBox
{
public CursorEditor(IPropertyEditorDataProperty property)
{
foreach (object o in property.TypeConverter.GetStandardValues()) {
this.Items.Add(o);
}
SetBinding(ComboBox.SelectedItemProperty, PropertyEditorBindingHelper.CreateBinding(this, property));
}
}
}

51
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/Controls/TypeEditors/NullableBoolEditor.cs

@ -0,0 +1,51 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Windows.Controls;
using ICSharpCode.WpfDesign.PropertyEditor;
namespace ICSharpCode.WpfDesign.Designer.Controls.TypeEditors
{
[TypeEditor(typeof(bool?))]
public class NullableBoolEditor : ComboBox
{
readonly static Entry[] entries = {
new Entry(SharedInstances.BoxedTrue, bool.TrueString),
new Entry(SharedInstances.BoxedFalse, bool.FalseString),
new Entry(null, "Null")
};
public NullableBoolEditor(IPropertyEditorDataProperty property)
{
this.SelectedValuePath = "Value";
this.ItemsSource = entries;
SetBinding(ComboBox.SelectedValueProperty, PropertyEditorBindingHelper.CreateBinding(this, property));
}
sealed class Entry
{
object val;
string description;
public object Value {
get { return val; }
}
public Entry(object val, string description)
{
this.val = val;
this.description = description;
}
public override string ToString()
{
return description;
}
}
}
}

32
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/DesignSurface.cs

@ -23,6 +23,38 @@ namespace ICSharpCode.WpfDesign.Designer
/// </summary> /// </summary>
public sealed class DesignSurface : SingleVisualChildElement public sealed class DesignSurface : SingleVisualChildElement
{ {
public static Type[] SupportedToolboxControls = {
typeof(Button),
typeof(CheckBox),
typeof(ComboBox),
typeof(Label),
typeof(TextBox),
typeof(RadioButton),
typeof(Canvas),
typeof(Grid),
typeof(Border),
typeof(DockPanel),
typeof(Expander),
typeof(GroupBox),
typeof(Image),
typeof(InkCanvas),
typeof(ListBox),
typeof(ListView),
typeof(Menu),
typeof(PasswordBox),
typeof(ProgressBar),
typeof(RichTextBox),
typeof(ScrollViewer),
typeof(Slider),
typeof(StackPanel),
typeof(TabControl),
typeof(ToolBar),
typeof(TreeView),
typeof(Viewbox),
typeof(Viewport3D),
typeof(WrapPanel)
};
readonly ScrollViewer _scrollViewer; readonly ScrollViewer _scrollViewer;
readonly DesignPanel _designPanel; readonly DesignPanel _designPanel;
DesignContext _designContext; DesignContext _designContext;

2
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.Designer/Project/WpfDesign.Designer.csproj

@ -73,6 +73,8 @@
<Compile Include="Controls\SingleVisualChildElement.cs" /> <Compile Include="Controls\SingleVisualChildElement.cs" />
<Compile Include="Controls\TypeEditors\BrushEditor.cs" /> <Compile Include="Controls\TypeEditors\BrushEditor.cs" />
<Compile Include="Controls\TypeEditors\ContentEditor.cs" /> <Compile Include="Controls\TypeEditors\ContentEditor.cs" />
<Compile Include="Controls\TypeEditors\CursorEditor.cs" />
<Compile Include="Controls\TypeEditors\NullableBoolEditor.cs" />
<Compile Include="Controls\WindowClone.cs" /> <Compile Include="Controls\WindowClone.cs" />
<Compile Include="DesignPanel.cs" /> <Compile Include="DesignPanel.cs" />
<Compile Include="DragDropExceptionHandler.cs" /> <Compile Include="DragDropExceptionHandler.cs" />

Loading…
Cancel
Save