Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2573 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
15 changed files with 336 additions and 31 deletions
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
// <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.Drawing; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.WpfDesign.Designer.Services; |
||||
|
||||
namespace ICSharpCode.WpfDesign.AddIn |
||||
{ |
||||
/// <summary>
|
||||
/// Description of WpfSideTabItem.
|
||||
/// </summary>
|
||||
public class WpfSideTabItem : SharpDevelopSideTabItem |
||||
{ |
||||
public WpfSideTabItem(Type componentType) : base(componentType.Name, new CreateComponentTool(componentType)) |
||||
{ |
||||
CanBeRenamed = false; |
||||
// this.Icon = tag.Bitmap;
|
||||
} |
||||
|
||||
///<summary>create a default tabitem : a pointer icon with an empty toolboxitem</summary>
|
||||
public WpfSideTabItem() : base("Pointer") |
||||
{ |
||||
CanBeRenamed = false; |
||||
CanBeDeleted = false; |
||||
Bitmap pointerBitmap = new Bitmap(IconService.GetBitmap("Icons.16x16.FormsDesigner.PointerIcon"), 16, 16); |
||||
this.Icon = pointerBitmap; |
||||
this.Tag = null; |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,110 @@
@@ -0,0 +1,110 @@
|
||||
// <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.Diagnostics; |
||||
using System.Windows.Forms; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Widgets.SideBar; |
||||
using WPF = System.Windows.Controls; |
||||
|
||||
namespace ICSharpCode.WpfDesign.AddIn |
||||
{ |
||||
/// <summary>
|
||||
/// Manages the WpfToolbox.
|
||||
/// </summary>
|
||||
public class WpfToolbox |
||||
{ |
||||
static WpfToolbox instance; |
||||
|
||||
public static WpfToolbox Instance { |
||||
get { |
||||
Debug.Assert(WorkbenchSingleton.InvokeRequired == false); |
||||
if (instance == null) { |
||||
instance = new WpfToolbox(); |
||||
} |
||||
return instance; |
||||
} |
||||
} |
||||
|
||||
IToolService toolService; |
||||
WpfSideBar sideBar; |
||||
|
||||
public WpfToolbox() |
||||
{ |
||||
sideBar = new WpfSideBar(); |
||||
SideTab sideTab = new SideTab(sideBar, "Windows Presentation Foundation"); |
||||
sideTab.DisplayName = StringParser.Parse(sideTab.Name); |
||||
sideTab.CanBeDeleted = false; |
||||
sideTab.ChoosedItemChanged += OnChoosedItemChanged; |
||||
|
||||
sideTab.Items.Add(new WpfSideTabItem()); |
||||
sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.Button))); |
||||
sideTab.Items.Add(new WpfSideTabItem(typeof(WPF.CheckBox))); |
||||
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.ActiveTab = sideTab; |
||||
} |
||||
|
||||
void OnChoosedItemChanged(object sender, EventArgs e) |
||||
{ |
||||
if (toolService != null) { |
||||
ITool newTool = null; |
||||
if (sideBar.ActiveTab != null && sideBar.ActiveTab.ChoosedItem != null) { |
||||
newTool = sideBar.ActiveTab.ChoosedItem.Tag as ITool; |
||||
} |
||||
toolService.CurrentTool = newTool ?? toolService.PointerTool; |
||||
} |
||||
} |
||||
|
||||
public Control ToolboxControl { |
||||
get { return sideBar; } |
||||
} |
||||
|
||||
public IToolService ToolService { |
||||
get { return toolService; } |
||||
set { |
||||
if (toolService != null) { |
||||
toolService.CurrentToolChanged -= OnCurrentToolChanged; |
||||
} |
||||
toolService = value; |
||||
if (toolService != null) { |
||||
toolService.CurrentToolChanged += OnCurrentToolChanged; |
||||
OnCurrentToolChanged(null, null); |
||||
} |
||||
} |
||||
} |
||||
|
||||
void OnCurrentToolChanged(object sender, EventArgs e) |
||||
{ |
||||
Debug.WriteLine("WpfToolbox.OnCurrentToolChanged"); |
||||
// for (int i = 0; i < this.Items.Count; i++) {
|
||||
// if (((ListBoxItem)this.Items[i]).Tag == toolService.CurrentTool) {
|
||||
// this.SelectedIndex = i;
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// this.SelectedIndex = -1;
|
||||
} |
||||
|
||||
sealed class WpfSideBar : SharpDevelopSideBar |
||||
{ |
||||
protected override object StartItemDrag(SideTabItem draggedItem) |
||||
{ |
||||
if (this.ActiveTab.ChoosedItem != draggedItem && this.ActiveTab.Items.Contains(draggedItem)) { |
||||
this.ActiveTab.ChoosedItem = draggedItem; |
||||
} |
||||
return new System.Windows.DataObject(draggedItem.Tag); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
@ -0,0 +1,24 @@
@@ -0,0 +1,24 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <author name="Daniel Grunwald"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
|
||||
namespace ICSharpCode.WpfDesign.Designer |
||||
{ |
||||
/// <summary>
|
||||
/// When the designer is hosted in a Windows.Forms application, exceptions in
|
||||
/// drag'n'drop handlers are silently ignored.
|
||||
/// Applications hosting the designer should specify a delegate to their own exception handling
|
||||
/// method. The default is Environment.FailFast.
|
||||
/// </summary>
|
||||
public static class DragDropExceptionHandler |
||||
{ |
||||
public static Action<Exception> HandleException = delegate(Exception ex) { |
||||
Environment.FailFast(ex.ToString()); |
||||
}; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue