public RibbonComboBox() { _dropDownItems = new RibbonItemCollection(); _dropDownVisible = true; AllowTextEdit = true; _iconsBar = true; }
private void RefreshMdiWindowList() { RibbonItemCollection items = switchWindowsToggleGroup.Items; for (int i = 0; i < items.Count; i++) { items[i].Dispose(); } items.Clear(); Form[] forms = MdiChildren; Form activeChild = ActiveMdiChild; for (int i = 0; i < forms.Length; i++) { frmList f = forms[i] as frmList; if (f != null && !f.BeingDisposed) { RibbonToggleButton tb = new RibbonToggleButton(); tb.Pressed = object.ReferenceEquals(f, activeChild); tb.Text = f.Text; tb.Tag = f; items.Add(tb); } } switchWindowsMenu.Enabled = items.Count > 0; }
RibbonListItem AppendListItem(RibbonItemCollection ribbonItems, int num, string path) { var rli = new C1.Win.Ribbon.RibbonListItem(); var sb = new StringBuilder(); if (num < 10) { sb.Append('&').Append(num).Append(" "); } else { sb.Append(num).Append(' '); } sb.Append(Path.GetFileNameWithoutExtension(path)); rli.Items.Add(new RibbonLabel(sb.ToString())); var delButton = new C1.Win.Ribbon.RibbonButton(); if (num < 10) { delButton.KeyTip = "Y" + num.ToString(); } delButton.SelectableInListItem = true; delButton.SmallImage = Properties.Resources.Delete16x16; delButton.ToolTip = "Remove from list"; delButton.Click += new System.EventHandler(this.DelButton_Click); rli.Items.Add(delButton); ribbonItems.Add(rli); rli.ToolTip = path; rli.Click += RibbonListItem_Click; return(rli); }
public virtual void CreateItem(Ribbon ribbon, RibbonItemCollection collection, Type t) { var host = GetService(typeof(IDesignerHost)) as IDesignerHost; if (host != null && collection != null && ribbon != null) { var transaction = host.CreateTransaction("AddRibbonItem_" + Component.Site.Name); MemberDescriptor member = TypeDescriptor.GetProperties(Component)["Items"]; base.RaiseComponentChanging(member); var 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(); } }
/// <summary> /// /// </summary> /// <param name="items"></param> private void TranslateRibbonItems(RibbonItemCollection items) { if (items == null || items.Count <= 0) { return; } foreach (RibbonItem item in items) { item.Text = I18N._(item.Text); item.ToolTip = I18N._(item.ToolTip); item.ToolTipTitle = I18N._(item.ToolTipTitle); if (item.GetType().ToString().EndsWith("RibbonButton", StringComparison.CurrentCultureIgnoreCase)) { var btn = item as RibbonButton; if (btn.Style != RibbonButtonStyle.Normal) { TranslateRibbonItems(btn.DropDownItems); } } else if (item.GetType().ToString().EndsWith("RibbonButtonList", StringComparison.CurrentCultureIgnoreCase)) { TranslateRibbonItems(item as RibbonButtonList); } else if (item.GetType().ToString().EndsWith("RibbonButtonCollection", StringComparison.CurrentCultureIgnoreCase)) { //TranslateRibbonItems( (RibbonItemCollection) item. ); } } }
private void CreateOrbItem(string collectionName, RibbonItemCollection collection, Type t) { if (Ribbon == null) { return; } var host = GetService(typeof(IDesignerHost)) as IDesignerHost; var transaction = host.CreateTransaction("AddRibbonOrbItem_" + Component.Site.Name); MemberDescriptor member = TypeDescriptor.GetProperties(Ribbon.OrbDropDown)[collectionName]; RaiseComponentChanging(member); var item = host.CreateComponent(t) as RibbonItem; if (!(item is RibbonSeparator)) { item.Text = item.Site.Name; } collection.Add(item); Ribbon.OrbDropDown.OnRegionsChanged(); RaiseComponentChanged(member, null, null); transaction.Commit(); Ribbon.OrbDropDown.SelectOnDesigner(item); Ribbon.OrbDropDown.WrappedDropDown.Size = Ribbon.OrbDropDown.Size; }
public RecentDocumentList( RibbonItemCollection rightPaneItems, StringCollection files, LoadDocumentDelegate loadDocument) { this.rightPaneItems = rightPaneItems; this.files = files; this.loadDocument = loadDocument; // first create a header and make sure it's not selectable RibbonListItem listItem = new RibbonListItem(new RibbonLabel("Recent Documents")); listItem.AllowSelection = false; rightPaneItems.Add(listItem); rightPaneItems.Add(new RibbonListItem(new RibbonSeparator())); this.listTopIndex = rightPaneItems.Count; // create the recently used document list foreach (string document in this.files) { RecentDocumentItem item = new RecentDocumentItem(document, false, loadDocument); rightPaneItems.Add(item); string d = document; } }
public static RibbonButton AddButton(this RibbonItemCollection items, AcCommand command) { RibbonButton btn = new RibbonButton(); items.AddItem(btn, command); return(btn); }
internal RibbonOrbDropDown(Ribbon ribbon) : base() { DoubleBuffered = true; _ribbon = ribbon; _menuItems = new RibbonItemCollection(); _recentItems = new RibbonItemCollection(); _optionItems = new RibbonItemCollection(); _menuItems.SetOwner(Ribbon); _recentItems.SetOwner(Ribbon); _optionItems.SetOwner(Ribbon); _optionsPadding = 6; Size = new System.Drawing.Size(527, 447); BorderRoundness = 8; AutoSizeContentButtons = DefaultAutoSizeContentButtons; ContentButtonsMinWidth = DefaultContentButtonsMinWidth; ContentRecentItemsMinWidth = DefaultContentRecentItemsMinWidth; //if (!(Site != null && Site.DesignMode)) //{ // _keyboardHook = new GlobalHook(GlobalHook.HookTypes.Keyboard); // _keyboardHook.KeyUp += new KeyEventHandler(_keyboardHook_KeyUp); //} }
public RibbonComboBox() { _dropDownItems = new RibbonItemCollection(); _dropDownVisible = true; AllowTextEdit = true; _iconsBar = true; _dropDownMaxHeight = 0; }
/// <summary> /// Creates a new button /// </summary> /// <param name="image">Image of the button (32 x 32 suggested)</param> /// <param name="smallImage">Image of the button when in medium of compact mode (16 x 16 suggested)</param> /// <param name="style">Style of the button</param> /// <param name="text">Text of the button</param> public RibbonButton() { _dropDownItems = new RibbonItemCollection(); _dropDownArrowSize = new Size(5, 3); _dropDownMargin = new Padding(6); Image = CreateImage(32); SmallImage = CreateImage(16); }
public static RibbonSplitButton AddSplitButton(this RibbonItemCollection panelSrc, string text, ICommand command, Bitmap image) { RibbonSplitButton splitBtn = new RibbonSplitButton(); panelSrc.AddItem(splitBtn, text, command, image, image); splitBtn.IsSplit = false; return(splitBtn); }
/// <summary> /// Creates a new button /// </summary> /// <param name="image">Image of the button (32 x 32 suggested)</param> /// <param name="smallImage">Image of the button when in medium of compact mode (16 x 16 suggested)</param> /// <param name="style">Style of the button</param> /// <param name="text">Text of the button</param> public RibbonButton() { _dropDownItems = new RibbonItemCollection(); _dropDownArrowSize = new Size(5, 3); _dropDownMargin = new Padding(6); Image = CreateImage(32); SmallImage = CreateImage(16); _iconsBar = true; }
public RibbonComboBox() { _dropDownItems = new RibbonItemCollection(); _dropDownItems.SetOwnerItem(this); _dropDownVisible = false; AllowTextEdit = true; _iconsBar = true; _dropDownMaxHeight = 0; _disableTextboxCursor = true; }
/// <summary> /// Creates a new RibbonPanel /// </summary> public RibbonPanel() { _items = new RibbonItemCollection(); _sizeMode = RibbonElementSizeMode.None; _flowsTo = RibbonPanelFlowDirection.Bottom; _buttonMoreEnabled = true; _buttonMoreVisible = true; _items.SetOwnerPanel(this); _enabled = true; }
void AddThemeColor(RibbonItemCollection items, ThemeColor themeColor) { RibbonToggleButton tb = new RibbonToggleButton(); tb.Text = themeColor.ToString(); tb.Tag = themeColor; tb.ToggleGroupName = "Theme"; tb.CanDepress = false; items.Add(tb); }
public RibbonButtonList() { _buttons = new RibbonButtonCollection(this); _dropDownItems = new RibbonItemCollection(); _controlButtonsWidth = 16; _itemsInLargeMode = 7; _itemsInMediumMode = 3; _ItemsInDropwDownMode = new Size(7, 5); _buttonsSizeMode = RibbonElementSizeMode.Large; }
/// <summary> /// Creates a new RibbonPanel /// </summary> public RibbonPanel() { IsLastPanel = false; IsFirstPanel = false; _items = new RibbonItemCollection(); _sizeMode = RibbonElementSizeMode.None; _flowsTo = RibbonPanelFlowDirection.Bottom; _buttonMoreEnabled = true; _buttonMoreVisible = true; _items.SetOwnerPanel(this); _enabled = true; }
public RibbonButtonList() { _buttons = new RibbonButtonCollection(this); _dropDownItems = new RibbonItemCollection(); _controlButtonsWidth = 16; _itemsInLargeMode = 7; _itemsInMediumMode = 3; _ItemsInDropwDownMode = new Size(7, 5); _buttonsSizeMode = RibbonElementSizeMode.Large; _scrollType = ListScrollType.UpDownButtons; }
internal RibbonOrbDropDown(Controls.Ribbon.Ribbon ribbon) { DoubleBuffered = true; _ribbon = ribbon; _menuItems = new RibbonItemCollection(); _recentItems = new RibbonItemCollection(); _optionItems = new RibbonItemCollection(); _menuItems.SetOwner(Ribbon); _recentItems.SetOwner(Ribbon); _optionItems.SetOwner(Ribbon); OptionItemsPadding = 6; Size = new Size(527, 447); }
public void UpdateRecentPackFiles() { RibbonItemCollection collection = mRibbon.OrbDropDown.RecentItems; collection.Clear(); for (int i = 0; i < Settings.RecentPackFiles.Count; i++) { RibbonButton item = new RibbonButton(); item.Text = PathShortener(Settings.RecentPackFiles[i], 40); item.Tag = Settings.RecentPackFiles[i]; item.Click += new EventHandler(recentItem_Click); collection.Add(item); } }
internal RibbonOrbDropDown(Ribbon ribbon) : base() { DoubleBuffered = true; _ribbon = ribbon; _menuItems = new RibbonItemCollection(); _recentItems = new RibbonItemCollection(); _optionItems = new RibbonItemCollection(); _menuItems.SetOwner(Ribbon); _recentItems.SetOwner(Ribbon); _optionItems.SetOwner(Ribbon); _optionsPadding = 6; Size = new System.Drawing.Size(527, 447); BorderRoundness = 8; }
private void BorderWidthSetup() { const string Sample = "Hairline"; // should be not smaller than the biggest text const int PadX = 4; const int PadY = 3; const int Gap = 8; // gap between text and line const int LineLength = 64; RibbonItemCollection items = rcmbBorderWidth.Items; items.BeginUpdate(); foreach (BordersForm.BorderWidthItem bwi in BordersForm.s_borderWidths) { RibbonButton item = new RibbonButton(bwi.Width.ToString()); item.OwnerDraw = true; item.MeasureItem += (ss, ee) => { SizeF s = ee.Graphics.MeasureString(Sample, this.Font, PointF.Empty, StringFormat.GenericDefault); ee.ItemHeight = (int)Math.Round(s.Height + PadY * 2); ee.ItemWidth = (int)Math.Round(s.Width + LineLength + PadX * 2 + Gap); }; item.DrawItem += (ss, ee) => { ee.DrawBackground(); using (Pen p = new Pen(ee.ForeColor, ((float)bwi.Width / 1440f) * ee.Graphics.DpiY)) using (SolidBrush b = new SolidBrush(ee.ForeColor)) using (var sf = new StringFormat(StringFormat.GenericDefault)) { var offset = ee.Graphics.MeasureString(Sample, this.Font, PointF.Empty, StringFormat.GenericDefault).Width + PadX + Gap / 2; sf.Alignment = StringAlignment.Far; sf.LineAlignment = StringAlignment.Center; ee.Graphics.DrawString(bwi.Text, this.Font, b, ee.Bounds.Left + offset - Gap / 2, ee.Bounds.Top + ee.Bounds.Height / 2, sf); if (bwi.Width > 0) { ee.Graphics.DrawLine(p, ee.Bounds.Left + offset + Gap / 2, ee.Bounds.Top + ee.Bounds.Height / 2, ee.Bounds.Right - PadX, ee.Bounds.Top + ee.Bounds.Height / 2); } } }; items.Add(item); } items.EndUpdate(); }
private void ApplyMaskedString(RibbonItemCollection ribbonItems, dynamic data) { // flatten data object in of an array if (data.GetType() == typeof(JArray)) { data = data[0]; } // loop through all ribbon items in the "insert merge fields" menu foreach (Control ribbonButton in ribbonItems) { // in case, the item is a drop-down, call ApplyMaskedString // recursively with a new data object if (ribbonButton is RibbonMenuButton) { ApplyMaskedString( ((RibbonMenuButton)ribbonButton).DropDownItems, data[ribbonButton.Text]); } // in case it is a merge field insert button else if (ribbonButton is RibbonButton) { // and it is not a separator or title if (!ribbonButton.Name.StartsWith("TXITEM_")) { // get the data from the first data row var dataValue = data[ribbonButton.Text]; if (dataValue == null) { continue; } if (dataValue.GetType() == typeof(JValue)) { // change the actual text ribbonButton.Text = dataValue.Value; } } } } }
public static void AddItem(this RibbonItemCollection items, RibbonCommandItem item, string text, ICommand command, Bitmap smallImage, Bitmap largeImage) { item.Text = text; item.ShowText = true; item.ShowImage = false; if ((smallImage != null) || (largeImage != null)) { item.ShowImage = true; if (largeImage == null) { largeImage = smallImage; } item.Image = GetImage(smallImage); item.LargeImage = GetImage(largeImage); } item.Size = RibbonItemSize.Standard; item.CommandHandler = command; items.Add(item); }
// initialize main menu void InitApplicationMenu() { // initialize menu RibbonApplicationMenu menu = this.ApplicationMenu; menu.DropDownWidth = 370; menu.AllowImageScaling = false; menu.SmallImage = Resources.AppMenuArrow; menu.Appearance = AppMenuAppearance.WholeForm; menu.DropDown += Menu_DropDown; // left menu items RibbonItemCollection items = menu.LeftPaneItems; items.ClearAndDisposeItems(); items.Add(CreateButton("New")); items.Add(CreateTab("OpenTab")); ((AppMenuTabs.OpenTab)((RibbonAppMenuTab)items["OpenTab"]).Control).RibbonApplicationMenu = menu; items.Add(CreateButton("Save")); items["Save"].SmallImage = null; items.Add(CreateTab("SaveAsTab")); ((AppMenuTabs.SaveAsTab)((RibbonAppMenuTab)items["SaveAsTab"]).Control).RibbonApplicationMenu = menu; items.Add(new RibbonSeparator()); items.Add(CreateTab("PrintTab")); _printTab = (AppMenuTabs.PrintTab)((RibbonAppMenuTab)items["PrintTab"]).Control; _printTab.Ribbon = this; _printTab.VisibleChanged += _printTab_VisibleChanged; //items.Add(CreateSplitButton("Print", // CreateHeaderLabel("PreviewAndPrint"), // CreateButton("Print"), // CreateButton("QuickPrint"), // CreateButton("PrintPreview"))); items.Add(CreateButton("ExportPdf")); items.Add(new RibbonSeparator()); items.Add(CreateButton("Exit")); _mruOpened = new RecentDocumentList(Settings.Default.OpenedFiles); _mruSaved = new RecentDocumentList(Settings.Default.SavedFiles); }
protected virtual void CreateItem(Controls.Ribbon.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(); } }
private void UpdateRecentLocations(string address) { // Get the collection of recent locations (right pane) RibbonItemCollection mru = c1Ribbon.ApplicationMenu.RightPaneItems; // Add the specified address if not already present if (address.Length > 0 && !mru.Contains(address)) { // Create a list item containing a label RibbonLabel label = new RibbonLabel(address); RibbonListItem item = new RibbonListItem(label); // Add a handler for the Click event item.Click += new EventHandler(recentLocation_Click); // Must set the ID for subsequent calls to mru.Contains(address) item.ID = address; // Add the new item to the collection mru.Add(item); } }
internal RibbonOrbDropDown(Ribbon ribbon) { DoubleBuffered = true; _ribbon = ribbon; _menuItems = new RibbonItemCollection(); _recentItems = new RibbonItemCollection(); _optionItems = new RibbonItemCollection(); _menuItems.SetOwner(Ribbon); _recentItems.SetOwner(Ribbon); _optionItems.SetOwner(Ribbon); OptionItemsPadding = 6; Size = new Size(527, 447); BorderRoundness = 8; //if (!(Site != null && Site.DesignMode)) //{ // _keyboardHook = new GlobalHook(GlobalHook.HookTypes.Keyboard); // _keyboardHook.KeyUp += new KeyEventHandler(_keyboardHook_KeyUp); //} }
// adds a list of items to a RibbonItemCollection. // items must be strings or RibbonItem objects. static void AddSubItems(RibbonItemCollection ric, object[] items) { foreach (object item in items) { // convert text into buttons string text = item as string; if (text != null) { ric.Add(CreateButton(text)); continue; } // paste items RibbonItem ribbonItem = item as RibbonItem; if (ribbonItem != null) { ric.Add(ribbonItem); continue; } // oops Debug.Assert(false, "AddSubItems expected string or RibbonItem"); } }
public static void AddItem(this RibbonItemCollection items, RibbonCommandItem item, AcCommand command) { item.Description = command.Description; AddItem(items, item, command.DisplayName, command, command.SmallImage, command.LargeImage); }
public static void AddRowBreak(this RibbonItemCollection items) { items.Add(new RibbonRowBreak()); }
public RibbonSplitButtonViewModel() { Items = new RibbonItemCollection <RibbonControlViewModel>(); }
public RibbonSplitButtonViewModel(ActionViewModel action) : base(action) { Items = new RibbonItemCollection <RibbonControlViewModel>(); }
private RibbonButton AddButton(RibbonItemCollection collection, RibbonButtonStyle style, string label, string msoImageName, string msoCommandName, RibbonElementSizeMode maxSizeMode = RibbonElementSizeMode.None, Action customAction = null) { RibbonButton button = new RibbonButton(); button.Style = style; button.MaxSizeMode = maxSizeMode; button.Text = label; AssignImage(button, msoImageName); if (customAction == null) { AssignAction(button, msoCommandName); } else { EventHandler handler = new EventHandler(delegate(object sender, EventArgs ea) { RunCommand(customAction); }); button.Click += handler; button.DoubleClick += handler; } collection.Add(button); return button; }
private void CreateOrbItem(string collectionName, RibbonItemCollection collection, Type t) { if (Ribbon == null) return; IDesignerHost host = GetService(typeof(IDesignerHost)) as IDesignerHost; DesignerTransaction transaction = host.CreateTransaction("AddRibbonOrbItem_" + Component.Site.Name); MemberDescriptor member = TypeDescriptor.GetProperties(Ribbon.OrbDropDown)[collectionName]; RaiseComponentChanging(member); RibbonItem item = host.CreateComponent(t) as RibbonItem; if (!(item is RibbonSeparator)) item.Text = item.Site.Name; collection.Add(item); Ribbon.OrbDropDown.OnRegionsChanged(); RaiseComponentChanged(member, null, null); transaction.Commit(); Ribbon.OrbDropDown.SelectOnDesigner(item); Ribbon.OrbDropDown.WrappedDropDown.Size = Ribbon.OrbDropDown.Size; }
public static void AddSeparator(this RibbonItemCollection items) { items.Add(new RibbonSeparator()); }
private RibbonUpDown AddUpDown(RibbonItemCollection collection, string label, string msoImageName, DocumentEventHandler getValue, string suffix, decimal increment, decimal min = 0, decimal max = 100, EventHandler changed = null) { RibbonUpDown updown = new RibbonUpDown(); updown.Text = label; updown.LabelWidth = 50; AssignImage(updown, msoImageName); decimal currentValue = 0; updown.TextBoxText = currentValue + suffix; updown.AllowTextEdit = true; updown.Enabled = true; updown.UpButtonClicked += new MouseEventHandler(delegate(object sender, MouseEventArgs e) { currentValue = Math.Min(currentValue + increment, max); updown.TextBoxText = currentValue + suffix; }); updown.DownButtonClicked += new MouseEventHandler(delegate(object sender, MouseEventArgs e) { currentValue = Math.Max(currentValue - increment, min); updown.TextBoxText = currentValue + suffix; }); m_WordInstance.Application.WindowActivate += new Word.ApplicationEvents4_WindowActivateEventHandler(delegate(Word.Document doc, Word.Window win) { currentValue = Math.Min(max, Math.Max(min, getValue(doc))); updown.TextBoxText = currentValue + suffix; }); // TODO: Uncommenting this causes serious issues. Figure out later if necessary. //updown.TextBoxTextChanged += changed; collection.Add(updown); return updown; }
private RibbonSeparator AddSeparator(RibbonItemCollection collection) { RibbonSeparator separator = new RibbonSeparator(); collection.Add(separator); return separator; }
private RibbonCheckBox AddCheckBox(RibbonItemCollection collection, string text, string msoCommandName) { RibbonCheckBox checkbox = new RibbonCheckBox(); checkbox.Text = text; collection.Add(checkbox); AssignAction(checkbox, msoCommandName); return checkbox; }
private RibbonLabel AddLabel(RibbonItemCollection collection, string text) { RibbonLabel label = new RibbonLabel(); label.Text = text; collection.Add(label); return label; }
public RibbonButtonPanelViewModel() { Items = new RibbonItemCollection <RibbonControlViewModel>(); }
/// <summary> /// Creates a new button /// </summary> /// <param name="image">Image of the button (32 x 32 suggested)</param> /// <param name="smallImage">Image of the button when in medium of compact mode (16 x 16 suggested)</param> /// <param name="style">Style of the button</param> /// <param name="text">Text of the button</param> public RibbonButton() { _dropDownItems = new RibbonItemCollection(); _dropDownItems.SetOwnerItem(this); _dropDownArrowSize = new Size(5, 3); _dropDownMargin = new Padding(6); Image = CreateImage(32); SmallImage = CreateImage(16); _iconsBar = true; }
public RibbonComboBoxViewModel() { Items = new RibbonItemCollection <RibbonControlViewModel>(); }