private void CreateRibbon() { { RibbonButtonTab tab = new RibbonButtonTab(); tab.Name = "Start"; tab.DropDown = new RibbonDropDownMenu(this.Ribbon) { Menu = CreateStartMenu() }; this.Ribbon.Tabs.Add(tab); } { RibbonTab tab = new RibbonTab(); tab.Name = "Home"; this.Ribbon.Tabs.Add(tab); { RibbonControlGroup group = new RibbonControlGroup(); group.Name = "Script"; tab.TabPanel.Groups.Add(group); { RibbonControlGroupPanel panel = new RibbonControlGroupPanel(); panel.Policy = RibbonControlSizingPolicy.Big; group.Panels.Add(panel); { RibbonButton button = new RibbonButton(); button.BigImage = TurtleIdeRibbon.New; button.SmallImage = TurtleIdeRibbon.New; button.Name = "New"; button.Executed += (s, e) => this.content.OperationNew(); panel.ControlItems.Add(button); } } { RibbonControlGroupPanel panel = new RibbonControlGroupPanel(); panel.Policy = RibbonControlSizingPolicy.BigSmall; group.Panels.Add(panel); { RibbonButton button = new RibbonButton(); button.ButtonStyle = RibbonButtonStyle.SplitButton; button.BigImage = TurtleIdeRibbon.Open; button.SmallImage = TurtleIdeRibbon.Open; button.Name = "Open"; button.DropDown = CreateOpenMenu(this.Ribbon); button.Executed += (s, e) => this.content.OperationOpen(); panel.ControlItems.Add(button); } { RibbonButton button = new RibbonButton(); button.BigImage = TurtleIdeRibbon.Save; button.SmallImage = TurtleIdeRibbon.Save; button.Name = "Save"; button.Executed += (s, e) => this.content.OperationSave(); panel.ControlItems.Add(button); } { RibbonButton button = new RibbonButton(); button.BigImage = TurtleIdeRibbon.SaveAs; button.SmallImage = TurtleIdeRibbon.SaveAs; button.Name = "Save As"; button.Executed += (s, e) => this.content.OperationSaveAs(); panel.ControlItems.Add(button); } } } { RibbonControlGroup group = new RibbonControlGroup(); group.Name = "Clipboard"; tab.TabPanel.Groups.Add(group); { RibbonControlGroupPanel panel = new RibbonControlGroupPanel(); panel.Policy = RibbonControlSizingPolicy.BigSmall; group.Panels.Add(panel); { RibbonButton button = this.buttonCut = new RibbonButton(); button.BigImage = TurtleIdeRibbon.Cut; button.SmallImage = TurtleIdeRibbon.Cut; button.Name = "Cut"; button.Executed += (s, e) => this.content.OperationCut(); panel.ControlItems.Add(button); } { RibbonButton button = this.buttonCopy = new RibbonButton(); button.BigImage = TurtleIdeRibbon.Copy; button.SmallImage = TurtleIdeRibbon.Copy; button.Name = "Copy"; button.Executed += (s, e) => this.content.OperationCopy(); panel.ControlItems.Add(button); } { RibbonButton button = this.buttonPaste = new RibbonButton(); button.BigImage = TurtleIdeRibbon.Paste; button.SmallImage = TurtleIdeRibbon.Paste; button.Name = "Paste"; button.Executed += (s, e) => this.content.OperationPaste(); panel.ControlItems.Add(button); } } } { RibbonButtonGroup group = new RibbonButtonGroup(); group.Name = "Edit"; tab.TabPanel.Groups.Add(group); { RibbonButton button = this.buttonUndo = new RibbonButton(); button.BigImage = TurtleIdeRibbon.Undo; button.Name = "Undo"; button.Executed += (s, e) => this.content.OperationUndo(); group.BigItems.Add(button); } { RibbonButton button = this.buttonRedo = new RibbonButton(); button.BigImage = TurtleIdeRibbon.Redo; button.Name = "Redo"; button.Executed += (s, e) => this.content.OperationRedo(); group.BigItems.Add(button); } } { RibbonButtonGroup group = new RibbonButtonGroup(); group.Name = "Debug"; tab.TabPanel.Groups.Add(group); { RibbonButton button = this.buttonRun = new RibbonButton(); button.BigImage = TurtleIdeRibbon.Run; button.Name = "Run"; button.Executed += (s, e) => this.content.OperationRun(); group.BigItems.Add(button); } { RibbonButton button = this.buttonStop = new RibbonButton(); button.BigImage = TurtleIdeRibbon.Stop; button.Name = "Stop"; button.Executed += (s, e) => this.content.OperationStop(); group.BigItems.Add(button); } } } UpdateRibbon(false); }
private void CreateRibbon() { { RibbonButtonTab tab = new RibbonButtonTab(); tab.Name = "开始"; tab.DropDown = new RibbonDropDownMenu(this.Ribbon) { Menu = CreateStartMenu() }; this.Ribbon.Tabs.Add(tab); } { RibbonTab tab = new RibbonTab(); tab.Name = "主页"; this.Ribbon.Tabs.Add(tab); { RibbonButtonGroup group = new RibbonButtonGroup(); group.Name = "剪贴板"; tab.TabPanel.Groups.Add(group); { RibbonButton button = new RibbonButton(); button.BigImage = ButtonImages.Paste; button.Name = "粘帖1"; group.BigItems.Add(button); } { RibbonButton button = new RibbonButton(); button.BigImage = ButtonImages.Paste; button.Name = "粘帖2"; button.Enabled = false; group.BigItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ButtonImages.CutHS; button.Name = "剪切"; group.SmallItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ButtonImages.CopyHS; button.Name = "复制"; button.ButtonStyle = RibbonButtonStyle.SplitButton; group.SmallItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ButtonImages.Color_linecolor; button.Name = "格式刷"; button.ButtonStyle = RibbonButtonStyle.DropDownButton; group.SmallItems.Add(button); } } { RibbonButtonGroup group = new RibbonButtonGroup(); group.Name = "字体"; tab.TabPanel.Groups.Add(group); { RibbonButton button = new RibbonButton(); button.BigImage = ButtonImages.Paste; button.Name = "粘帖3"; button.ButtonStyle = RibbonButtonStyle.DropDownButton; group.BigItems.Add(button); } { RibbonButton button = new RibbonButton(); button.BigImage = ButtonImages.Paste; button.Name = "粘帖4"; button.ButtonStyle = RibbonButtonStyle.SplitButton; group.BigItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ButtonImages.Window1; button.Name = "一个窗口"; button.ButtonStyle = RibbonButtonStyle.GroupedToggleButton; button.ToggleGroup = 0; button.Toggled = true; group.SmallItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ButtonImages.Window2; button.Name = "两个窗口"; button.ButtonStyle = RibbonButtonStyle.GroupedToggleButton; button.ToggleGroup = 0; group.SmallItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ButtonImages.Window3; button.Name = "三个窗口"; button.ButtonStyle = RibbonButtonStyle.GroupedToggleButton; button.ToggleGroup = 0; button.Enabled = false; group.SmallItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ButtonImages.Arrow1; button.Name = "第一箭头"; button.ButtonStyle = RibbonButtonStyle.ToggleButton; group.SmallItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ButtonImages.Arrow2; button.Name = "第二箭头"; button.ButtonStyle = RibbonButtonStyle.ToggleButton; group.SmallItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ButtonImages.Arrow3; button.Name = "第三箭头"; button.ButtonStyle = RibbonButtonStyle.ToggleButton; group.SmallItems.Add(button); } } { RibbonToolStripGroup group = new RibbonToolStripGroup(); group.Name = "段落"; tab.TabPanel.Groups.Add(group); { RibbonToolStrip tool = new RibbonToolStrip(); tool.NormalLine = 0; tool.CompactLine = 0; group.ToolStrips.Add(tool); { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.ItemNumber; tool.ToolItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.ItemDot; button.ButtonStyle = RibbonButtonStyle.DropDownButton; button.Enabled = false; tool.ToolItems.Add(button); } } { RibbonToolStrip tool = new RibbonToolStrip(); tool.NormalLine = 0; tool.CompactLine = 0; group.ToolStrips.Add(tool); { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.TabIn; tool.ToolItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.TabOut; tool.ToolItems.Add(button); } } { RibbonToolStrip tool = new RibbonToolStrip(); tool.NormalLine = 1; tool.CompactLine = 1; group.ToolStrips.Add(tool); { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.AlignLeft; button.Toggled = true; button.ToggleGroup = 0; button.ButtonStyle = RibbonButtonStyle.GroupedToggleButton; tool.ToolItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.AlignCenter; button.ToggleGroup = 0; button.ButtonStyle = RibbonButtonStyle.GroupedToggleButton; tool.ToolItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.AlignRight; button.ToggleGroup = 0; button.ButtonStyle = RibbonButtonStyle.GroupedToggleButton; tool.ToolItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.AlignFull; button.ToggleGroup = 0; button.ButtonStyle = RibbonButtonStyle.GroupedToggleButton; tool.ToolItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.AlignExpand; button.ToggleGroup = 0; button.ButtonStyle = RibbonButtonStyle.GroupedToggleButton; button.Enabled = false; tool.ToolItems.Add(button); } } { RibbonToolStrip tool = new RibbonToolStrip(); tool.NormalLine = 1; tool.CompactLine = 1; group.ToolStrips.Add(tool); { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.LinePadding; tool.ToolItems.Add(button); } } { RibbonToolStrip tool = new RibbonToolStrip(); tool.NormalLine = 0; tool.CompactLine = 2; group.ToolStrips.Add(tool); { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.TableBorder; button.ButtonStyle = RibbonButtonStyle.DropDownButton; button.DropDown = new RibbonDropDownMenu(this.Ribbon) { Menu = CreateTableMenu() }; tool.ToolItems.Add(button); } { RibbonButton button = new RibbonButton(); button.SmallImage = ToolImages.SortAscending; button.ButtonStyle = RibbonButtonStyle.SplitButton; tool.ToolItems.Add(button); } } } } { RibbonTab tab = new RibbonTab(); tab.Name = "插入"; this.Ribbon.Tabs.Add(tab); { RibbonControlGroup group = new RibbonControlGroup(); group.Name = "好复杂啊"; tab.TabPanel.Groups.Add(group); RibbonControlSizingPolicy[] policies = new RibbonControlSizingPolicy[] { RibbonControlSizingPolicy.Big, RibbonControlSizingPolicy.BigSmall, RibbonControlSizingPolicy.BigCompact, RibbonControlSizingPolicy.Small, RibbonControlSizingPolicy.SmallCompact, RibbonControlSizingPolicy.Compact }; Image[] smalls = new Image[] { ControlImages.a1, ControlImages.b1, ControlImages.c1, ControlImages.d1, ControlImages.e1, ControlImages.f1 }; Image[] bigs = new Image[] { ControlImages.a2, ControlImages.b2, ControlImages.c2, ControlImages.d2, ControlImages.e2, ControlImages.f2 }; RibbonButtonStyle[] styles = new RibbonButtonStyle[] { RibbonButtonStyle.PushButton, RibbonButtonStyle.DropDownButton, RibbonButtonStyle.SplitButton }; for (int i = 0; i < 6; i++) { RibbonControlGroupPanel panel = new RibbonControlGroupPanel(); panel.Policy = policies[i]; group.Panels.Add(panel); for (int j = 0; j < 3; j++) { RibbonButton button = new RibbonButton(); button.SmallImage = smalls[i]; button.BigImage = bigs[i]; button.ButtonStyle = styles[j]; button.Name = panel.Policy.ToString() + " " + (i + 1).ToString(); panel.ControlItems.Add(button); } } } { RibbonControlGroup group = new RibbonControlGroup(); group.Name = "好复杂啊"; RibbonControlSizingPolicy[] policies = new RibbonControlSizingPolicy[] { RibbonControlSizingPolicy.Big, RibbonControlSizingPolicy.BigSmall, RibbonControlSizingPolicy.BigCompact, RibbonControlSizingPolicy.Small, RibbonControlSizingPolicy.SmallCompact, RibbonControlSizingPolicy.Compact }; Image[] smalls = new Image[] { ControlImages.a1, ControlImages.b1, ControlImages.c1, ControlImages.d1, ControlImages.e1, ControlImages.f1 }; Image[] bigs = new Image[] { ControlImages.a2, ControlImages.b2, ControlImages.c2, ControlImages.d2, ControlImages.e2, ControlImages.f2 }; RibbonButtonStyle[] styles = new RibbonButtonStyle[] { RibbonButtonStyle.PushButton, RibbonButtonStyle.DropDownButton, RibbonButtonStyle.SplitButton }; for (int i = 0; i < 6; i++) { RibbonControlGroupPanel panel = new RibbonControlGroupPanel(); panel.Policy = policies[i]; group.Panels.Add(panel); for (int j = 0; j < 3; j++) { RibbonButton button = new RibbonButton(); button.SmallImage = smalls[i]; button.BigImage = bigs[i]; button.ButtonStyle = styles[j]; button.Name = panel.Policy.ToString() + " " + (i + 1).ToString(); panel.ControlItems.Add(button); } } ((tab.TabPanel.Groups[0] as RibbonControlGroup).Panels[0].ControlItems[1] as RibbonButton).DropDown = new RibbonDropDownGroup(this.Ribbon) { Group = group }; } } { RibbonTab tab = new RibbonTab(); tab.Name = "页面布局"; this.Ribbon.Tabs.Add(tab); } { RibbonTab tab = new RibbonTab(); tab.Name = "引用"; this.Ribbon.Tabs.Add(tab); } { RibbonTab tab = new RibbonTab(); tab.Name = "设计"; this.Ribbon.Tabs.Add(tab); } { RibbonTab tab = new RibbonTab(); tab.Name = "布局"; this.Ribbon.Tabs.Add(tab); } { RibbonTabGroup group = new RibbonTabGroup(); group.Name = "表格工具"; group.FirstIndex = 5; group.LastIndex = 6; this.Ribbon.TabGroups.Add(group); } UpdateRibbon(false); }