DotNet 4.8.1 build of DotNetBar
This commit is contained in:
@@ -0,0 +1,257 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides designer for MetroAppButton.
|
||||
/// </summary>
|
||||
public class MetroAppButtonDesigner : BaseItemDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
protected override DesignerVerb[] GetVerbs()
|
||||
{
|
||||
DesignerVerb[] baseVerbs = base.GetVerbs();
|
||||
int verbsCount = baseVerbs.Length + 1;
|
||||
if (IsBackstageSet) verbsCount = 1;
|
||||
|
||||
bool includeClearSubItems = false;
|
||||
MetroAppButton appButton = this.Component as MetroAppButton;
|
||||
if (appButton != null && appButton.BackstageTab != null && appButton.SubItems.Count > 0)
|
||||
{
|
||||
includeClearSubItems = true;
|
||||
verbsCount++;
|
||||
}
|
||||
|
||||
int verbsOffset = 1;
|
||||
DesignerVerb[] verbs = new DesignerVerb[verbsCount];
|
||||
verbs[0] = new DesignerVerb((IsBackstageSet ? "Remove Backstage" : "Set Backstage"), new EventHandler(CreateBackstageTab));
|
||||
|
||||
if (includeClearSubItems)
|
||||
{
|
||||
verbs[1] = new DesignerVerb("Clear Sub-items", new EventHandler(ClearSubItems));
|
||||
verbsOffset++;
|
||||
}
|
||||
|
||||
if (!IsBackstageSet)
|
||||
{
|
||||
for (int i = 0; i < baseVerbs.Length; i++)
|
||||
{
|
||||
verbs[i + verbsOffset] = baseVerbs[i];
|
||||
}
|
||||
}
|
||||
|
||||
return verbs;
|
||||
}
|
||||
|
||||
private void ClearSubItems(object sender, EventArgs e)
|
||||
{
|
||||
if (MessageBox.Show("Are you sure you want to delete all sub-items?", "DotNetBar Application Button", MessageBoxButtons.YesNo) == DialogResult.No) return;
|
||||
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (dh == null) return;
|
||||
MetroAppButton appButton = (MetroAppButton)this.Component;
|
||||
if (appButton.SubItems.Count == 0) return;
|
||||
|
||||
DesignerTransaction trans = dh.CreateTransaction("Clearing Application Button SubItems");
|
||||
try
|
||||
{
|
||||
cc.OnComponentChanging(appButton, TypeDescriptor.GetProperties(appButton)["SubItems"]);
|
||||
BaseItem[] items = new BaseItem[appButton.SubItems.Count];
|
||||
appButton.SubItems.CopyTo(items, 0);
|
||||
foreach (BaseItem item in items)
|
||||
{
|
||||
appButton.SubItems.Remove(item);
|
||||
dh.DestroyComponent(item);
|
||||
}
|
||||
cc.OnComponentChanged(appButton, TypeDescriptor.GetProperties(appButton)["SubItems"], null, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsBackstageSet
|
||||
{
|
||||
get
|
||||
{
|
||||
MetroAppButton appButton = (MetroAppButton)this.Component;
|
||||
if (appButton != null && appButton.BackstageTab != null) return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateBackstageTab()
|
||||
{
|
||||
IDesignerHost dh = GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (dh == null) return;
|
||||
|
||||
MetroAppButton appButton = (MetroAppButton)this.Component;
|
||||
if (appButton.BackstageTab != null)
|
||||
{
|
||||
DesignerTransaction trans1 = dh.CreateTransaction("Removing Backstage tab");
|
||||
try
|
||||
{
|
||||
SuperTabControl backstageTab = appButton.BackstageTab;
|
||||
SetProperty(appButton, "BackstageTab", null);
|
||||
backstageTab.Visible = true;
|
||||
SetProperty(backstageTab, "Location", new System.Drawing.Point(0, 150));
|
||||
SetProperty(backstageTab, "Size", new System.Drawing.Size(250, 350));
|
||||
ISelectionService selection = (ISelectionService)GetService(typeof(ISelectionService));
|
||||
if (selection != null) selection.SetSelectedComponents(new Control[] { backstageTab }, SelectionTypes.Primary);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans1.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans1.Canceled)
|
||||
trans1.Commit();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
DesignerTransaction trans = dh.CreateTransaction("Create Backstage");
|
||||
try
|
||||
{
|
||||
|
||||
if (appButton.Expanded) appButton.Expanded = false;
|
||||
SuperTabControl backstageTab = (SuperTabControl)dh.CreateComponent(typeof(SuperTabControl));
|
||||
SetProperty(appButton, "BackstageTab", backstageTab);
|
||||
|
||||
Control root = dh.RootComponent as Control;
|
||||
if (root != null)
|
||||
{
|
||||
cc.OnComponentChanging(root, TypeDescriptor.GetProperties(root)["Controls"]);
|
||||
root.Controls.Add(backstageTab);
|
||||
cc.OnComponentChanged(root, TypeDescriptor.GetProperties(root)["Controls"], null, null);
|
||||
}
|
||||
SetupBackstageTab(backstageTab, dh);
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
}
|
||||
}
|
||||
private void CreateBackstageTab(object sender, EventArgs e)
|
||||
{
|
||||
CreateBackstageTab();
|
||||
}
|
||||
|
||||
private void SetupBackstageTab(SuperTabControl backstageTab, IDesignerHost dh)
|
||||
{
|
||||
backstageTab.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
backstageTab.ControlBox.Visible = false;
|
||||
backstageTab.ItemPadding.Left = 6;
|
||||
backstageTab.ItemPadding.Right = 4;
|
||||
backstageTab.ItemPadding.Top = 4;
|
||||
backstageTab.ReorderTabsEnabled = false;
|
||||
try
|
||||
{
|
||||
backstageTab.SelectedTabFont = new System.Drawing.Font("Segoe UI", 9.75F);
|
||||
}
|
||||
catch { }
|
||||
backstageTab.SelectedTabIndex = 0;
|
||||
backstageTab.Size = new System.Drawing.Size(614, 315);
|
||||
backstageTab.TabAlignment = DevComponents.DotNetBar.eTabStripAlignment.Left;
|
||||
try
|
||||
{
|
||||
backstageTab.TabFont = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch { }
|
||||
backstageTab.TabHorizontalSpacing = 16;
|
||||
backstageTab.TabStyle = DevComponents.DotNetBar.eSuperTabStyle.Office2010BackstageBlue;
|
||||
backstageTab.TabVerticalSpacing = 8;
|
||||
|
||||
SuperTabControlDesigner tabDesigner = dh.GetDesigner(backstageTab) as SuperTabControlDesigner;
|
||||
if (tabDesigner != null)
|
||||
{
|
||||
ButtonItem button;
|
||||
// Save button
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Save");
|
||||
SetProperty(button, "KeyTips", "S");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Save16.png"));
|
||||
|
||||
// Open
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Open");
|
||||
SetProperty(button, "KeyTips", "O");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Open.png"));
|
||||
|
||||
// Close
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Close");
|
||||
SetProperty(button, "KeyTips", "C");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Close16.png"));
|
||||
|
||||
SuperTabItem tab;
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "Recent");
|
||||
SetProperty(tab, "KeyTips", "R");
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "New");
|
||||
SetProperty(tab, "KeyTips", "N");
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "Print");
|
||||
SetProperty(tab, "KeyTips", "P");
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
//SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
tab = tabDesigner.CreateNewTab();
|
||||
SetProperty(tab, "Text", "Help");
|
||||
SetProperty(tab, "KeyTips", "H");
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImage", RibbonControlDesigner.LoadImage("BlueBackstageBgImage.png"));
|
||||
SetProperty((SuperTabControlPanel)tab.AttachedControl, "BackgroundImagePosition", DevComponents.DotNetBar.eStyleBackgroundImage.BottomRight);
|
||||
|
||||
// Options
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Options");
|
||||
SetProperty(button, "KeyTips", "T");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Options2.png"));
|
||||
|
||||
// Exit
|
||||
button = tabDesigner.CreateButton();
|
||||
SetProperty(button, "Text", "Exit");
|
||||
SetProperty(button, "KeyTips", "X");
|
||||
SetProperty(button, "Image", RibbonControlDesigner.LoadImage("Exit2.png"));
|
||||
}
|
||||
}
|
||||
|
||||
private void SetProperty(object targetObject, string propertyName, object propertyValue)
|
||||
{
|
||||
TypeDescriptor.GetProperties(targetObject)[propertyName].SetValue(targetObject, propertyValue);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Windows.Forms.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Design;
|
||||
using DevComponents.DotNetBar.Metro.ColorTables;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design.Metro
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class MetroColorThemeEditor : System.Drawing.Design.UITypeEditor
|
||||
{
|
||||
private IWindowsFormsEditorService edSvc = null;
|
||||
public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
|
||||
{
|
||||
if (context != null
|
||||
&& context.Instance != null
|
||||
&& provider != null)
|
||||
{
|
||||
edSvc = provider.GetService(typeof(IWindowsFormsEditorService)) as IWindowsFormsEditorService;
|
||||
|
||||
if (edSvc != null)
|
||||
{
|
||||
ListBox lb = new ListBox();
|
||||
lb.SelectedIndexChanged += new EventHandler(this.SelectedChanged);
|
||||
MetroColorGeneratorParameters currentParams = (MetroColorGeneratorParameters)value;
|
||||
MetroColorGeneratorParameters[] metroThemes = MetroColorGeneratorParameters.GetAllPredefinedThemes();
|
||||
string selectedTheme = null;
|
||||
foreach (MetroColorGeneratorParameters mt in metroThemes)
|
||||
{
|
||||
lb.Items.Add(mt.ThemeName);
|
||||
if (currentParams.BaseColor == mt.BaseColor && currentParams.CanvasColor == mt.CanvasColor)
|
||||
{
|
||||
lb.SelectedItem = mt.ThemeName;
|
||||
selectedTheme = mt.ThemeName;
|
||||
}
|
||||
}
|
||||
|
||||
edSvc.DropDownControl(lb);
|
||||
if (lb.SelectedItem != null && selectedTheme != (string)lb.SelectedItem)
|
||||
{
|
||||
return metroThemes[lb.SelectedIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
private void SelectedChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (edSvc != null)
|
||||
edSvc.CloseDropDown();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the editor style used by the EditValue method.
|
||||
/// </summary>
|
||||
/// <param name="context">An ITypeDescriptorContext that can be used to gain additional context information.</param>
|
||||
/// <returns>A UITypeEditorEditStyle value that indicates the style of editor used by EditValue. If the UITypeEditor does not support this method, then GetEditStyle will return None</returns>
|
||||
public override UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext context)
|
||||
{
|
||||
if (context != null && context.Instance != null)
|
||||
{
|
||||
return UITypeEditorEditStyle.DropDown;
|
||||
}
|
||||
return base.GetEditStyle(context);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,725 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
// <summary>
|
||||
/// Represents Windows Forms designer for MetroTab control.
|
||||
/// </summary>
|
||||
public class MetroShellDesigner : BarBaseControlDesigner
|
||||
{
|
||||
#region Private Variables
|
||||
private bool m_QuickAccessToolbarSelected = false;
|
||||
#endregion
|
||||
|
||||
#region Internal Implementation
|
||||
|
||||
public MetroShellDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop = true;
|
||||
this.AcceptExternalControls = false;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (!component.Site.DesignMode)
|
||||
return;
|
||||
MetroShell c = component as MetroShell;
|
||||
if (c != null)
|
||||
{
|
||||
c.SetDesignMode();
|
||||
//this.Expanded = c.Expanded;
|
||||
}
|
||||
this.EnableDragDrop(false);
|
||||
}
|
||||
|
||||
public override bool CanParent(Control control)
|
||||
{
|
||||
if (control is MetroTabPanel && !this.Control.Controls.Contains(control))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Create Tab", new EventHandler(CreateMetroTab)),
|
||||
new DesignerVerb("Create Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Create Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Create Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Create Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Create Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Create Switch Button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Create Rating Item", new EventHandler(CreateRatingItem)),};
|
||||
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private BaseItem GetNewItemContainer()
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (m_QuickAccessToolbarSelected)
|
||||
return r.MetroTabStrip.CaptionContainerItem;
|
||||
else
|
||||
return r.MetroTabStrip.StripContainerItem;
|
||||
}
|
||||
|
||||
protected override void CreateButton(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateButton(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateTextBox(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateTextBox(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateComboBox(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateComboBox(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateLabel(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateLabel(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateColorPicker(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateColorPicker(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateProgressBar(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateProgressBar(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateRatingItem(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateRatingItem(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void CreateSwitch(object sender, EventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
CreateSwitch(GetNewItemContainer());
|
||||
}
|
||||
}
|
||||
|
||||
protected override void ComponentChangeComponentAdded(object sender, ComponentEventArgs e)
|
||||
{
|
||||
if (m_AddingItem)
|
||||
{
|
||||
m_AddingItem = false;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(this.Control, null);
|
||||
this.GetNewItemContainer().SubItems.Add(e.Component as BaseItem);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(this.Control, null, null, null);
|
||||
m_InsertItemTransaction.Commit();
|
||||
m_InsertItemTransaction = null;
|
||||
this.RecalcLayout();
|
||||
}
|
||||
}
|
||||
|
||||
protected override ArrayList GetAllAssociatedComponents()
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
AddSubItems(r.MetroTabStrip.StripContainerItem, c);
|
||||
AddSubItems(r.MetroTabStrip.CaptionContainerItem, c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList c = new ArrayList(this.BaseAssociatedComponents);
|
||||
MetroShell rc = this.Control as MetroShell;
|
||||
if (rc != null)
|
||||
{
|
||||
foreach (BaseItem item in rc.QuickToolbarItems)
|
||||
{
|
||||
if (!item.SystemItem)
|
||||
c.Add(item);
|
||||
}
|
||||
foreach (BaseItem item in rc.Items)
|
||||
{
|
||||
if (!item.SystemItem)
|
||||
c.Add(item);
|
||||
}
|
||||
}
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private StyleManager CreateStyleManager()
|
||||
{
|
||||
StyleManager manager = null;
|
||||
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh != null)
|
||||
{
|
||||
DesignerTransaction trans = dh.CreateTransaction("Create Style Manager");
|
||||
try
|
||||
{
|
||||
manager = dh.CreateComponent(typeof(StyleManager)) as StyleManager;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled) trans.Commit();
|
||||
}
|
||||
}
|
||||
|
||||
return manager;
|
||||
}
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
CreateMetroTab("&HOME");
|
||||
CreateMetroTab("&VIEW");
|
||||
StyleManager manager = CreateStyleManager();
|
||||
MetroShell c = this.Control as MetroShell;
|
||||
if (c != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
c.KeyTipsFont = new Font("Tahoma", 7);
|
||||
c.TabStripFont = new System.Drawing.Font("Segoe UI", 10.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
//this.Style = eDotNetBarStyle.StyleManagerControlled;
|
||||
this.CanCustomize = true;
|
||||
c.Size = new Size(200, 154);
|
||||
c.Dock = DockStyle.Top;
|
||||
this.CaptionVisible = true;
|
||||
|
||||
if (manager != null)
|
||||
manager.ManagerStyle = eStyle.Metro;
|
||||
}
|
||||
|
||||
protected override BaseItem GetItemContainer()
|
||||
{
|
||||
MetroShell tab = this.Control as MetroShell;
|
||||
if (tab != null)
|
||||
return tab.MetroTabStrip.GetBaseItemContainer();
|
||||
return null;
|
||||
}
|
||||
|
||||
protected override System.Windows.Forms.Control GetItemContainerControl()
|
||||
{
|
||||
MetroShell tab = this.Control as MetroShell;
|
||||
if (tab != null)
|
||||
return tab.MetroTabStrip;
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Support for popup menu closing.
|
||||
/// </summary>
|
||||
protected override void DesignTimeSelectionChanged(ISelectionService ss)
|
||||
{
|
||||
if (ss == null)
|
||||
return;
|
||||
if (this.Control == null || this.Control.IsDisposed)
|
||||
return;
|
||||
|
||||
if (IsApplicationButtonBackstageControl(ss.PrimarySelection))
|
||||
return;
|
||||
|
||||
base.DesignTimeSelectionChanged(ss);
|
||||
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r == null) return;
|
||||
|
||||
BaseItem container = r.MetroTabStrip.StripContainerItem;
|
||||
if (container == null) return;
|
||||
|
||||
if (ss.PrimarySelection is MetroTabItem)
|
||||
{
|
||||
MetroTabItem item = ss.PrimarySelection as MetroTabItem;
|
||||
if (container.SubItems.Contains(item))
|
||||
{
|
||||
TypeDescriptor.GetProperties(item)["Checked"].SetValue(item, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsApplicationButtonBackstageControl(object primarySelection)
|
||||
{
|
||||
MetroShell tab = this.Control as MetroShell;
|
||||
if (tab == null || !(tab.GetApplicationButton() is MetroAppButton)) return false;
|
||||
MetroAppButton appButton = tab.GetApplicationButton() as MetroAppButton;
|
||||
if (appButton.BackstageTab == null) return false;
|
||||
|
||||
SuperTabControl backstageTab = appButton.BackstageTab;
|
||||
if (primarySelection is BaseItem)
|
||||
{
|
||||
BaseItem item = (BaseItem)primarySelection;
|
||||
if (backstageTab.Tabs.Contains(item)) return true;
|
||||
while (item.Parent != null) item = item.Parent;
|
||||
Control parentControl = item.ContainerControl as Control;
|
||||
if (parentControl == null) return false;
|
||||
return ContainsControl(backstageTab, parentControl);
|
||||
}
|
||||
else if (primarySelection is Control)
|
||||
return ContainsControl(backstageTab, (Control)primarySelection);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool ContainsControl(Control container, Control childControl)
|
||||
{
|
||||
Control parent = childControl;
|
||||
while (parent != null)
|
||||
{
|
||||
if (parent == container) return true;
|
||||
parent = parent.Parent;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when some other component on the form is removed.
|
||||
/// </summary>
|
||||
protected override void OtherComponentRemoving(object sender, ComponentEventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r != null)
|
||||
{
|
||||
BaseItem container = r.MetroTabStrip.StripContainerItem;
|
||||
|
||||
if (e.Component is MetroTabItem && container != null && container.SubItems != null &&
|
||||
container.SubItems.Contains(((MetroTabItem)e.Component)))
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.DestroyComponent(((MetroTabItem)e.Component).Panel);
|
||||
}
|
||||
}
|
||||
base.OtherComponentRemoving(sender, e);
|
||||
}
|
||||
|
||||
protected override void ComponentRemoved(object sender, ComponentEventArgs e)
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (e.Component is BaseItem && r != null)
|
||||
{
|
||||
BaseItem item = e.Component as BaseItem;
|
||||
if (r.Items.Contains(item))
|
||||
r.Items.Remove(item);
|
||||
else if (r.QuickToolbarItems.Contains(item))
|
||||
r.QuickToolbarItems.Remove(item);
|
||||
DestroySubItems(item);
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(ref Message m, MouseButtons button)
|
||||
{
|
||||
m_QuickAccessToolbarSelected = false;
|
||||
|
||||
System.Windows.Forms.Control ctrl = this.GetItemContainerControl();
|
||||
MetroTabStrip strip = ctrl as MetroTabStrip;
|
||||
|
||||
if (strip == null)
|
||||
return base.OnMouseDown(ref m, button);
|
||||
|
||||
Point pos = strip.PointToClient(System.Windows.Forms.Control.MousePosition);
|
||||
if (!strip.ClientRectangle.Contains(pos))
|
||||
return base.OnMouseDown(ref m, button);
|
||||
|
||||
if (button == MouseButtons.Right)
|
||||
{
|
||||
if (strip.QuickToolbarBounds.Contains(pos))
|
||||
m_QuickAccessToolbarSelected = true;
|
||||
return base.OnMouseDown(ref m, button);
|
||||
}
|
||||
|
||||
bool callBase = true;
|
||||
|
||||
if (callBase)
|
||||
return base.OnMouseDown(ref m, button);
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Design-Time Item Creation
|
||||
protected virtual void CreateMetroTab(object sender, EventArgs e)
|
||||
{
|
||||
CreateMetroTab(string.Empty);
|
||||
}
|
||||
|
||||
private void CreateMetroTab(string text)
|
||||
{
|
||||
m_QuickAccessToolbarSelected = false;
|
||||
IDesignerHost dh = (IDesignerHost)GetService(typeof(IDesignerHost));
|
||||
if (dh != null)
|
||||
{
|
||||
DesignerTransaction trans = dh.CreateTransaction("Creating Metro Tab");
|
||||
IComponentChangeService cc = (IComponentChangeService)GetService(typeof(IComponentChangeService));
|
||||
MetroShell tab = this.Control as MetroShell;
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
OnSubItemsChanging();
|
||||
MetroTabItem item = dh.CreateComponent(typeof(MetroTabItem)) as MetroTabItem;
|
||||
if (string.IsNullOrEmpty(text))
|
||||
TypeDescriptor.GetProperties(item)["Text"].SetValue(item, item.Name);
|
||||
else
|
||||
TypeDescriptor.GetProperties(item)["Text"].SetValue(item, text);
|
||||
|
||||
MetroTabPanel panel = dh.CreateComponent(typeof(MetroTabPanel)) as MetroTabPanel;
|
||||
TypeDescriptor.GetProperties(panel)["Dock"].SetValue(panel, DockStyle.Fill);
|
||||
//TypeDescriptor.GetProperties(panel)["ColorSchemeStyle"].SetValue(panel, tab.Style);
|
||||
tab.SetTabPanelStyle(panel);
|
||||
|
||||
//panel.Style.BorderBottom = eStyleBorderType.Solid;
|
||||
//TypeDescriptor.GetProperties(panel.Style)["BorderBottom"].SetValue(panel.Style, eStyleBorderType.Solid);
|
||||
|
||||
cc.OnComponentChanging(this.Control, TypeDescriptor.GetProperties(typeof(Control))["Controls"]);
|
||||
this.Control.Controls.Add(panel);
|
||||
panel.SendToBack();
|
||||
cc.OnComponentChanged(this.Control, TypeDescriptor.GetProperties(typeof(Control))["Controls"], null, null);
|
||||
|
||||
TypeDescriptor.GetProperties(item)["Panel"].SetValue(item, panel);
|
||||
|
||||
SimpleItemContainer cont = tab.MetroTabStrip.StripContainerItem;
|
||||
cc.OnComponentChanging(cont, TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"]);
|
||||
cont.SubItems.Add(item);
|
||||
cc.OnComponentChanged(cont, TypeDescriptor.GetProperties(typeof(BaseItem))["SubItems"], null, null);
|
||||
if (cont.SubItems.Count == 1)
|
||||
TypeDescriptor.GetProperties(item)["Checked"].SetValue(item, true);
|
||||
|
||||
this.RecalcLayout();
|
||||
OnSubItemsChanged();
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
throw;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled)
|
||||
trans.Commit();
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Shadowing
|
||||
/// <summary>
|
||||
/// Gets or sets whether custom caption and quick access toolbar provided by the control is visible. Default value is false.
|
||||
/// This property should be set to true when control is used on MetroForm.
|
||||
/// </summary>
|
||||
[Browsable(true), DefaultValue(false), Category("Appearance"), Description("Indicates whether custom caption and quick access toolbar provided by the control is visible.")]
|
||||
public bool CaptionVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
return r.CaptionVisible;
|
||||
}
|
||||
set
|
||||
{
|
||||
MetroShell r = this.Control as MetroShell;
|
||||
if (r.CaptionVisible == value) return;
|
||||
r.CaptionVisible = value;
|
||||
|
||||
if (r.CaptionVisible && (
|
||||
r.QuickToolbarItems.Count == 6 && r.QuickToolbarItems[0] is SystemCaptionItem && r.QuickToolbarItems[5] is SystemCaptionItem))
|
||||
{
|
||||
// Add custom items to the toolbar
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (dh != null && !dh.Loading && cc != null && dh.TransactionDescription != "Paste components")
|
||||
{
|
||||
DesignerTransaction trans = dh.CreateTransaction();
|
||||
try
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
MetroAppButton sb = dh.CreateComponent(typeof(MetroAppButton)) as MetroAppButton;
|
||||
sb.Text = "&File";
|
||||
sb.ShowSubItems = false;
|
||||
sb.CanCustomize = false;
|
||||
sb.AutoExpandOnClick = true;
|
||||
cc.OnComponentChanging(r, TypeDescriptor.GetProperties(r)["QuickToolbarItems"]);
|
||||
sb.ImageFixedSize = new Size(16, 16);
|
||||
r.Items.Insert(0, sb);
|
||||
cc.OnComponentChanged(r, TypeDescriptor.GetProperties(r)["QuickToolbarItems"], null, null);
|
||||
ButtonItem buttonStart = sb;
|
||||
|
||||
ButtonItem b = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
|
||||
b.Text = b.Name;
|
||||
cc.OnComponentChanging(r, TypeDescriptor.GetProperties(r)["QuickToolbarItems"]);
|
||||
r.QuickToolbarItems.Add(b, 2);
|
||||
cc.OnComponentChanged(r, TypeDescriptor.GetProperties(r)["QuickToolbarItems"], null, null);
|
||||
|
||||
|
||||
}
|
||||
catch
|
||||
{
|
||||
trans.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!trans.Canceled) trans.Commit();
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ButtonItem CreateFileButton(IDesignerHost dh, string text, Image image)
|
||||
{
|
||||
ButtonItem button = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
|
||||
button.ButtonStyle = DevComponents.DotNetBar.eButtonStyle.ImageAndText;
|
||||
button.Image = image;
|
||||
button.SubItemsExpandWidth = 24;
|
||||
button.Text = text;
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
private ButtonItem CreateMRUButton(IDesignerHost dh, string text)
|
||||
{
|
||||
ButtonItem button = dh.CreateComponent(typeof(ButtonItem)) as ButtonItem;
|
||||
button.Text = text;
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
|
||||
internal static Bitmap LoadImage(string imageName)
|
||||
{
|
||||
string imagesFolder = GetImagesFolder();
|
||||
if (imagesFolder != "")
|
||||
{
|
||||
if (File.Exists(imagesFolder + imageName))
|
||||
return new Bitmap(imagesFolder + imageName);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static string GetImagesFolder()
|
||||
{
|
||||
try
|
||||
{
|
||||
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.LocalMachine;
|
||||
string path = "";
|
||||
try
|
||||
{
|
||||
if (key != null)
|
||||
key = key.OpenSubKey("Software\\DevComponents\\DotNetBar");
|
||||
if (key != null)
|
||||
path = key.GetValue("InstallationFolder", "").ToString();
|
||||
}
|
||||
finally { if (key != null) key.Close(); }
|
||||
|
||||
if (path != "")
|
||||
{
|
||||
if (path.Substring(path.Length - 1, 1) != "\\")
|
||||
path += "\\";
|
||||
path += "Images\\";
|
||||
return path;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether control can be customized and items added by end-user using context menu to the quick access toolbar.
|
||||
/// Caption of the control must be visible for customization to be enabled. Default value is true.
|
||||
/// </summary>
|
||||
[DefaultValue(true), Browsable(true), Category("Quick Access Toolbar"), Description("Indicates whether control can be customized. Caption must be visible for customization to be fully enabled.")]
|
||||
public bool CanCustomize
|
||||
{
|
||||
get
|
||||
{
|
||||
MetroShell rc = this.Control as MetroShell;
|
||||
return rc.CanCustomize;
|
||||
}
|
||||
set
|
||||
{
|
||||
MetroShell rc = this.Control as MetroShell;
|
||||
rc.CanCustomize = value;
|
||||
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null && !dh.Loading)
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
// Make sure that QatCustomizeItem exists
|
||||
QatCustomizeItem qatCustom = GetQatCustomizeItem(rc);
|
||||
if (qatCustom == null)
|
||||
{
|
||||
DesignerTransaction dt = dh.CreateTransaction("Creating the QAT");
|
||||
try
|
||||
{
|
||||
// Create QatCustomItem...
|
||||
m_CreatingItem = true;
|
||||
qatCustom = dh.CreateComponent(typeof(QatCustomizeItem)) as QatCustomizeItem;
|
||||
qatCustom.BeginGroup = true;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(rc, TypeDescriptor.GetProperties(rc)["QuickToolbarItems"]);
|
||||
rc.QuickToolbarItems.Add(qatCustom);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(rc, TypeDescriptor.GetProperties(rc)["QuickToolbarItems"], null, null);
|
||||
m_CreatingItem = false;
|
||||
this.RecalcLayout();
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
QatCustomizeItem qatCustom = GetQatCustomizeItem(rc);
|
||||
if (qatCustom != null)
|
||||
{
|
||||
DesignerTransaction dt = dh.CreateTransaction("Removing the QAT");
|
||||
try
|
||||
{
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanging(rc, TypeDescriptor.GetProperties(rc)["QuickToolbarItems"]);
|
||||
rc.QuickToolbarItems.Remove(qatCustom);
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(rc, TypeDescriptor.GetProperties(rc)["QuickToolbarItems"], null, null);
|
||||
dh.DestroyComponent(qatCustom);
|
||||
}
|
||||
catch
|
||||
{
|
||||
dt.Cancel();
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (!dt.Canceled) dt.Commit();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private QatCustomizeItem GetQatCustomizeItem(MetroShell rc)
|
||||
{
|
||||
QatCustomizeItem qatCustom = null;
|
||||
// Remove QatCustomizeItem if it exists
|
||||
foreach (BaseItem item in rc.QuickToolbarItems)
|
||||
{
|
||||
if (item is QatCustomizeItem)
|
||||
{
|
||||
qatCustom = item as QatCustomizeItem;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return qatCustom;
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
|
||||
properties["CaptionVisible"] = TypeDescriptor.CreateProperty(typeof(MetroShellDesigner), (PropertyDescriptor)properties["CaptionVisible"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(false),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Appearance"),
|
||||
new DescriptionAttribute("Indicates whether custom caption and quick access toolbar provided by the control is visible.")});
|
||||
|
||||
properties["CanCustomize"] = TypeDescriptor.CreateProperty(typeof(MetroShellDesigner), (PropertyDescriptor)properties["CanCustomize"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(true),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Quick Access Toolbar"),
|
||||
new DescriptionAttribute("Indicates whether control can be customized. Caption must be visible for customization to be fully enabled")});
|
||||
|
||||
//DesignTime.RemoveProperties(properties, new string[] { "AccessibleDescription"
|
||||
// ,"AccessibleName","AccessibleRole","AutoScroll", "AutoScrollMargin", "AutoScrollMinSize",
|
||||
// "BackColor", "BackgroundImage", "BackgroundImageLayout", "DisplayRectangle", "ForeColor",
|
||||
// "MaximumSize", "MinimumSize", "Site","Text","UseWaitCursor", "Cursor","ContextMenuStrip"});
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,144 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MetroStatusBarDesigner : BarBaseControlDesigner
|
||||
{
|
||||
public MetroStatusBarDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop=true;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (component == null || component.Site == null || !component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
#if !TRIAL
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
MetroStatusBar bar = this.Control as MetroStatusBar;
|
||||
bar.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
try
|
||||
{
|
||||
bar.Font = new System.Drawing.Font("Segoe UI", 10.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
bar.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
Bar bar = this.Control as Bar;
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Add Horizontal Container", new EventHandler(CreateHorizontalContainer)),
|
||||
new DesignerVerb("Add Vertical Container", new EventHandler(CreateVerticalContainer)),
|
||||
new DesignerVerb("Add Slider", new EventHandler(CreateSliderItem)),
|
||||
new DesignerVerb("Add Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Add Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Add Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Add Color Picker", new EventHandler(CreateColorPicker)),
|
||||
new DesignerVerb("Add Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Add Switch Button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Add Progress bar", new EventHandler(CreateProgressBar)),
|
||||
new DesignerVerb("Add Check box", new EventHandler(CreateCheckBox)),
|
||||
new DesignerVerb("Add WinForms Control Container", new EventHandler(CreateControlContainer))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateVerticalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Vertical);
|
||||
}
|
||||
|
||||
private void CreateHorizontalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
}
|
||||
|
||||
private void CreateContainer(BaseItem parent, eOrientation orientation)
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
try
|
||||
{
|
||||
DesignerSupport.CreateItemContainer(this, parent, orientation);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
#region Licensing Stuff
|
||||
#if !TRIAL
|
||||
private string GetLicenseKey()
|
||||
{
|
||||
string key = "";
|
||||
Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.LocalMachine;
|
||||
regkey = regkey.OpenSubKey("Software\\DevComponents\\Licenses", false);
|
||||
if (regkey != null)
|
||||
{
|
||||
object keyValue = regkey.GetValue("DevComponents.DotNetBar.DotNetBarManager2");
|
||||
if (keyValue != null)
|
||||
key = keyValue.ToString();
|
||||
}
|
||||
return key;
|
||||
}
|
||||
private void dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
string key = GetLicenseKey();
|
||||
MetroStatusBar bar = this.Control as MetroStatusBar;
|
||||
if (key != "" && bar != null && bar.LicenseKey == "" && bar.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(bar)["LicenseKey"].SetValue(bar, key);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Windows Forms designer for MetroTabItem
|
||||
/// </summary>
|
||||
public class MetroTabItemDesigner : BaseItemDesigner
|
||||
{
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
using System.Windows.Forms.Design;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MetroTabPanelDesigner : PanelControlDesigner
|
||||
{
|
||||
#region Internal Implementation
|
||||
public override SelectionRules SelectionRules
|
||||
{
|
||||
get { return (SelectionRules.Locked | SelectionRules.Visible); }
|
||||
}
|
||||
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
// RibbonPanel p = this.Control as RibbonPanel;
|
||||
//#if FRAMEWORK20
|
||||
// p.Padding = new System.Windows.Forms.Padding(3, 0, 3, 3);
|
||||
//#else
|
||||
// p.DockPadding.Left = 3;
|
||||
// p.DockPadding.Right = 3;
|
||||
// p.DockPadding.Bottom = 3;
|
||||
//#endif
|
||||
}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
return new DesignerVerbCollection();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws design-time border around the panel when panel does not have one.
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
protected override void DrawBorder(Graphics g)
|
||||
{
|
||||
MetroTabPanel panel = this.Control as MetroTabPanel;
|
||||
if (panel == null) return;
|
||||
Rectangle r = panel.ClientRectangle;
|
||||
using (Pen pen = new Pen(Color.WhiteSmoke, 1))
|
||||
{
|
||||
pen.DashStyle = System.Drawing.Drawing2D.DashStyle.Dash;
|
||||
r.Width--;
|
||||
r.Height--;
|
||||
g.DrawRectangle(pen, r);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using System.Collections;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MetroTileFrameDesigner : ComponentDesigner
|
||||
{
|
||||
private static bool SetGenerateMemberProperty(
|
||||
IExtenderListService service,
|
||||
IComponent component,
|
||||
bool value)
|
||||
{
|
||||
IExtenderProvider provider = null;
|
||||
IExtenderProvider[] providers = service.GetExtenderProviders();
|
||||
foreach (IExtenderProvider item in providers)
|
||||
{
|
||||
if (item.GetType().FullName ==
|
||||
"System.ComponentModel.Design.Serialization.CodeDomDesignerLoader+ModifiersExtenderProvider")
|
||||
{
|
||||
provider = item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (provider == null) return false;
|
||||
|
||||
MethodInfo methodInfo =
|
||||
provider.GetType().GetMethod(
|
||||
"SetGenerateMember", BindingFlags.Public |
|
||||
BindingFlags.Instance);
|
||||
|
||||
if (methodInfo != null)
|
||||
{
|
||||
methodInfo.Invoke(
|
||||
provider, new object[]
|
||||
{
|
||||
component,
|
||||
value
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
// no reason to create a member since container has no use aside from logical grouping at design time
|
||||
SetGenerateMemberProperty(
|
||||
(IExtenderListService)GetService(typeof(IExtenderListService)),
|
||||
this.Component,
|
||||
false);
|
||||
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.ComponentModel.Design;
|
||||
using DevComponents.DotNetBar.Rendering;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
public class MetroTilePanelDesigner : ItemPanelDesigner
|
||||
{
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
Bar bar = this.Control as Bar;
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Metro Tile", new EventHandler(CreateMetroTile)),
|
||||
new DesignerVerb("Add Tile Group", new EventHandler(CreateHorizontalContainer))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void SetDesignTimeDefaults()
|
||||
{
|
||||
ItemPanel panel = this.Control as ItemPanel;
|
||||
panel.BackgroundStyle.Class = ElementStyleClassKeys.MetroTilePanelKey;
|
||||
|
||||
ItemContainer container = CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
container.TitleStyle.Class = ElementStyleClassKeys.MetroTileGroupTitleKey;
|
||||
container.TitleText = "First";
|
||||
//LabelItem label = CreateLabel(container);
|
||||
////label.Width = 530;
|
||||
//label.ContainerNewLineAfter = true;
|
||||
//label.Font = new System.Drawing.Font("Segoe UI Semibold", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
//label.Text = "First";
|
||||
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
|
||||
container = CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
container.TitleStyle.Class = ElementStyleClassKeys.MetroTileGroupTitleKey;
|
||||
container.TitleText = "Second";
|
||||
//label = CreateLabel(container);
|
||||
////label.Width = 530;
|
||||
//label.ContainerNewLineAfter = true;
|
||||
//label.Font = new System.Drawing.Font("Segoe UI Semibold", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
//label.Text = "Second";
|
||||
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
CreateMetroTile(container);
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
panel.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
protected override ItemContainer CreateContainer(BaseItem parent, eOrientation orientation)
|
||||
{
|
||||
ItemContainer container = base.CreateContainer(parent, orientation);
|
||||
if (container != null)
|
||||
TypeDescriptor.GetProperties(container)["MultiLine"].SetValue(container, true);
|
||||
return container;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,258 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using DevComponents.DotNetBar.Metro;
|
||||
using System.ComponentModel;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DevComponents.DotNetBar.Design
|
||||
{
|
||||
class MetroToolbarDesigner : BarBaseControlDesigner
|
||||
{
|
||||
public MetroToolbarDesigner()
|
||||
{
|
||||
this.EnableItemDragDrop=true;
|
||||
this.ShadowProperties["Expanded"] = false;
|
||||
}
|
||||
|
||||
public override void Initialize(IComponent component)
|
||||
{
|
||||
base.Initialize(component);
|
||||
if (component == null || component.Site == null || !component.Site.DesignMode)
|
||||
return;
|
||||
|
||||
#if !TRIAL
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete += new EventHandler(dh_LoadComplete);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if FRAMEWORK20
|
||||
public override void InitializeNewComponent(IDictionary defaultValues)
|
||||
{
|
||||
base.InitializeNewComponent(defaultValues);
|
||||
SetDesignTimeDefaults();
|
||||
}
|
||||
#else
|
||||
public override void OnSetComponentDefaults()
|
||||
{
|
||||
SetDesignTimeDefaults();
|
||||
base.OnSetComponentDefaults();
|
||||
}
|
||||
#endif
|
||||
|
||||
private void SetDesignTimeDefaults()
|
||||
{
|
||||
MetroToolbar bar = this.Control as MetroToolbar;
|
||||
try
|
||||
{
|
||||
bar.Font = new System.Drawing.Font("Segoe UI", 10.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
#if !TRIAL
|
||||
string key = GetLicenseKey();
|
||||
bar.LicenseKey = key;
|
||||
#endif
|
||||
}
|
||||
|
||||
//protected override BaseItem GetItemContainer()
|
||||
//{
|
||||
// MetroToolbar bar = this.Control as MetroToolbar;
|
||||
// return ((MetroToolbarContainer)bar.GetBaseItemContainer()).MainItemsContainer;
|
||||
//}
|
||||
|
||||
public override DesignerVerbCollection Verbs
|
||||
{
|
||||
get
|
||||
{
|
||||
Bar bar = this.Control as Bar;
|
||||
DesignerVerb[] verbs = null;
|
||||
verbs = new DesignerVerb[]
|
||||
{
|
||||
new DesignerVerb("Add Button", new EventHandler(CreateButton)),
|
||||
new DesignerVerb("Add Horizontal Container", new EventHandler(CreateHorizontalContainer)),
|
||||
new DesignerVerb("Add Vertical Container", new EventHandler(CreateVerticalContainer)),
|
||||
new DesignerVerb("Add Text Box", new EventHandler(CreateTextBox)),
|
||||
new DesignerVerb("Add Combo Box", new EventHandler(CreateComboBox)),
|
||||
new DesignerVerb("Add Label", new EventHandler(CreateLabel)),
|
||||
new DesignerVerb("Add Color Picker", new EventHandler(CreateColorPicker)),
|
||||
new DesignerVerb("Add Micro-Chart", new EventHandler(CreateMicroChart)),
|
||||
new DesignerVerb("Add Switch Button", new EventHandler(CreateSwitch)),
|
||||
new DesignerVerb("Add Progress bar", new EventHandler(CreateProgressBar)),
|
||||
new DesignerVerb("Add Check box", new EventHandler(CreateCheckBox)),
|
||||
new DesignerVerb("Add WinForms Control Container", new EventHandler(CreateControlContainer))
|
||||
};
|
||||
return new DesignerVerbCollection(verbs);
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateVerticalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Vertical);
|
||||
}
|
||||
|
||||
private void CreateHorizontalContainer(object sender, EventArgs e)
|
||||
{
|
||||
CreateContainer(this.GetItemContainer(), eOrientation.Horizontal);
|
||||
}
|
||||
|
||||
private void CreateContainer(BaseItem parent, eOrientation orientation)
|
||||
{
|
||||
m_CreatingItem = true;
|
||||
try
|
||||
{
|
||||
DesignerSupport.CreateItemContainer(this, parent, orientation);
|
||||
}
|
||||
finally
|
||||
{
|
||||
m_CreatingItem = false;
|
||||
}
|
||||
this.RecalcLayout();
|
||||
}
|
||||
|
||||
protected override void OnIsSelectedChanged(bool oldValue, bool newValue)
|
||||
{
|
||||
if (newValue)
|
||||
{
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
if (!this.Expanded && bar.ExpandButtonVisible)
|
||||
{
|
||||
bar.Expanded = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!this.Expanded)
|
||||
{
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
bar.Expanded = false;
|
||||
IComponentChangeService cc = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
|
||||
if (cc != null)
|
||||
cc.OnComponentChanged(bar, TypeDescriptor.GetProperties(cc)["Location"], null, null);
|
||||
}
|
||||
}
|
||||
base.OnIsSelectedChanged(oldValue, newValue);
|
||||
}
|
||||
|
||||
protected override void PreFilterProperties(IDictionary properties)
|
||||
{
|
||||
base.PreFilterProperties(properties);
|
||||
properties["Expanded"] = TypeDescriptor.CreateProperty(typeof(MetroToolbarDesigner), (PropertyDescriptor)properties["Expanded"], new Attribute[]
|
||||
{
|
||||
new DefaultValueAttribute(false),
|
||||
new BrowsableAttribute(true),
|
||||
new CategoryAttribute("Layout"),
|
||||
new DescriptionAttribute("Indicates whether control is expanded or not. When control is expanded both main and extra toolbar items are visible.")});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether control is expanded or not. When control is expanded both main and extra toolbar items are visible. When collapsed
|
||||
/// only main items are visible. Default value is false.
|
||||
/// </summary>
|
||||
[DefaultValue(false), Browsable(true), Category("Layout"), Description("Indicates whether control is expanded or not. When control is expanded both main and extra toolbar items are visible.")]
|
||||
public bool Expanded
|
||||
{
|
||||
get { return (bool)ShadowProperties["Expanded"]; }
|
||||
set
|
||||
{
|
||||
// this value is not passed to the actual control at design-time
|
||||
this.ShadowProperties["Expanded"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public override System.Collections.ICollection AssociatedComponents
|
||||
{
|
||||
get
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
foreach (BaseItem item in bar.Items)
|
||||
{
|
||||
if (item.DesignMode)
|
||||
c.Add(item);
|
||||
}
|
||||
foreach (BaseItem item in bar.ExtraItems)
|
||||
{
|
||||
if (item.DesignMode)
|
||||
c.Add(item);
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
}
|
||||
|
||||
protected override ArrayList GetAllAssociatedComponents()
|
||||
{
|
||||
ArrayList c = new ArrayList(base.AssociatedComponents);
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
BaseItem container = ((MetroToolbarContainer)bar.GetBaseItemContainer()).MainItemsContainer;
|
||||
if (container != null)
|
||||
{
|
||||
AddSubItems(container, c);
|
||||
}
|
||||
container = ((MetroToolbarContainer)bar.GetBaseItemContainer()).ExtraItemsContainer;
|
||||
if (container != null)
|
||||
{
|
||||
AddSubItems(container, c);
|
||||
}
|
||||
return c;
|
||||
}
|
||||
|
||||
protected override BaseItem GetControlItem(System.Windows.Forms.Control control)
|
||||
{
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
BaseItem parent = ((MetroToolbarContainer)bar.GetBaseItemContainer()).MainItemsContainer;
|
||||
if (parent == null)
|
||||
return null;
|
||||
BaseItem item = GetControlItem(control, parent);
|
||||
if (item != null) return item;
|
||||
|
||||
parent = ((MetroToolbarContainer)bar.GetBaseItemContainer()).ExtraItemsContainer;
|
||||
if (parent == null)
|
||||
return null;
|
||||
item = GetControlItem(control, parent);
|
||||
return item;
|
||||
}
|
||||
|
||||
protected override BaseItem GetDefaultNewItemContainer()
|
||||
{
|
||||
MetroToolbar bar = (MetroToolbar)this.Control;
|
||||
return ((MetroToolbarContainer)bar.GetBaseItemContainer()).MainItemsContainer;
|
||||
}
|
||||
|
||||
#region Licensing Stuff
|
||||
#if !TRIAL
|
||||
private string GetLicenseKey()
|
||||
{
|
||||
string key = "";
|
||||
Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.LocalMachine;
|
||||
regkey = regkey.OpenSubKey("Software\\DevComponents\\Licenses", false);
|
||||
if (regkey != null)
|
||||
{
|
||||
object keyValue = regkey.GetValue("DevComponents.DotNetBar.DotNetBarManager2");
|
||||
if (keyValue != null)
|
||||
key = keyValue.ToString();
|
||||
}
|
||||
return key;
|
||||
}
|
||||
private void dh_LoadComplete(object sender, EventArgs e)
|
||||
{
|
||||
IDesignerHost dh = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
|
||||
if (dh != null)
|
||||
dh.LoadComplete -= new EventHandler(dh_LoadComplete);
|
||||
|
||||
string key = GetLicenseKey();
|
||||
MetroToolbar bar = this.Control as MetroToolbar;
|
||||
if (key != "" && bar != null && bar.LicenseKey == "" && bar.LicenseKey != key)
|
||||
TypeDescriptor.GetProperties(bar)["LicenseKey"].SetValue(bar, key);
|
||||
}
|
||||
#endif
|
||||
#endregion
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user