- ribbondemo0.4.zip
- RibbonDemo.exe
- System.Windows.Forms.Ribbon.dll
- ribbonsource0.4.zip
- System.Windows.Forms.Ribbon
- RibbonDemo
- BlackForm.cs
- BlackForm.Designer.cs
- BlackForm.resx
- MainForm.cs
- MainForm.Designer.cs
- MainForm.resx
- Program.cs
- Properties
- Resources
- addons32.png
- bold16.png
- borderbottom16.png
- casing16.png
- close32.png
- copy16.png
- copyformat16.png
- cut16.png
- eraseformat16.png
- exit16.png
- fill16.png
- find32.png
- fontcolor16.png
- fontsizedecrease16.png
- fontsizeincrease16.png
- goto16.png
- hilight16.png
- indentdecrease16.png
- indentdecrease161.png
- indentincrease16.png
- invisiblechars16.png
- italic16.png
- multilevellist16.png
- newdocument32.png
- open16.png
- open32.png
- options16.png
- orderedlist16.png
- pageblank16.png
- paragraphspacing16.png
- paste16.png
- paste32.png
- paste321.png
- pastelink16.png
- pastespecial16.png
- prepare32.png
- print32.png
- print321.png
- printpreview32.png
- printquick16.png
- printquick32.png
- publish32.png
- replace16.png
- save16.png
- save32.png
- saveas32.png
- saveas321.png
- select16.png
- send32.png
- sort16.png
- strikethru16.png
- style16.png
- stylechange32.png
- styleset16.png
- subindex16.png
- superindex16.png
- textaligncenter16.png
- textalignjustify16.png
- textalignleft16.png
- textalignright16.png
- themefont.png
- underline16.png
- undo16.png
- unorderedlist16.png
- word2003doc32.png
- worddocument32.png
- wordtemplate32.png
- RibbonDemo.csproj
- System.Windows.Forms.Ribbon.sln
- System.Windows.Forms.Ribbon.suo
- System.Windows.Forms.Ribbon
- ribbondemo_0.2.zip
- RibbonDemo.exe
- System.Windows.Forms.Ribbon.dll
- ribbonsource_0.3.zip
- bin
- RibbonDemo_0.3.zip
- RibbonDemo.exe
- System.Windows.Forms.Ribbon.dll
- RibbonDemo.zip
- RibbonDemo.exe
- System.Windows.Forms.Ribbon.dll
- ribbonsource_0.2.zip
|
/*
2008 Jos� Manuel Men�ndez Poo
*
* Please give me credit if you use this code. It's all I ask.
*
* Contact me for more info: menendezpoo@gmail.com
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.ComponentModel.Design;
using System.ComponentModel;
namespace System.Windows.Forms
{
internal abstract class RibbonElementWithItemCollectionDesigner
: ComponentDesigner
{
#region Props
public abstract Ribbon Ribbon { get; }
public abstract RibbonItemCollection Collection { get; }
public override DesignerVerbCollection Verbs
{
get
{
return new DesignerVerbCollection(new DesignerVerb[] {
new DesignerVerb("Add Button", new EventHandler(AddButton)),
new DesignerVerb("Add ButtonList", new EventHandler(AddButtonList)),
new DesignerVerb("Add ItemGroup", new EventHandler(AddItemGroup)),
new DesignerVerb("Add Separator", new EventHandler(AddSeparator)),
new DesignerVerb("Add TextBox", new EventHandler(AddTextBox)),
new DesignerVerb("Add ComboBox", new EventHandler(AddComboBox)),
new DesignerVerb("Add ColorChooser", new EventHandler(AddColorChooser))
});
}
}
#endregion
#region Methods
private void CreateItem(Type t)
{
CreateItem(Ribbon, Collection, t);
}
protected virtual void CreateItem(Ribbon ribbon, RibbonItemCollection collection, Type t)
{
IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost;
if (host != null && collection != null && ribbon != null)
{
DesignerTransaction transaction = host.CreateTransaction("AddRibbonItem_" + Component.Site.Name);
MemberDescriptor member = TypeDescriptor.GetProperties(Component)["Items"];
base.RaiseComponentChanging(member);
RibbonItem item = host.CreateComponent(t) as RibbonItem;
if (!(item is RibbonSeparator)) item.Text = item.Site.Name;
collection.Add(item);
ribbon.OnRegionsChanged();
base.RaiseComponentChanged(member, null, null);
transaction.Commit();
}
}
protected virtual void AddButton(object sender, EventArgs e)
{
CreateItem(typeof(RibbonButton));
}
protected virtual void AddButtonList(object sender, EventArgs e)
{
CreateItem(typeof(RibbonButtonList));
}
protected virtual void AddItemGroup(object sender, EventArgs e)
{
CreateItem(typeof(RibbonItemGroup));
}
protected virtual void AddSeparator(object sender, EventArgs e)
{
CreateItem(typeof(RibbonSeparator));
}
protected virtual void AddTextBox(object sender, EventArgs e)
{
CreateItem(typeof(RibbonTextBox));
}
protected virtual void AddComboBox(object sender, EventArgs e)
{
CreateItem(typeof(RibbonComboBox));
}
protected virtual void AddColorChooser(object sender, EventArgs e)
{
CreateItem(typeof(RibbonColorChooser));
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
- I've been programming Windows and Web apps since 1997.
- My greatest concern nowadays is product, user interface, and usability.
- TypeScript / React expert
@geeksplainer