private void CreateToolbarMenu() { mnuContext = new ContextMenuBar(); mnuContextRoot = new ButtonItem(); mnuContext.Items.Add(mnuContextRoot); foreach (IDesignerPlugin plugin in Plugins) { if (plugin is ToolbarBase) { ButtonItem menuItem = new ButtonItem(); menuItem.Text = (plugin as ToolbarBase).Text; menuItem.Tag = plugin; menuItem.Click += new EventHandler(toolbar_Click); mnuContextRoot.SubItems.Add(menuItem); } } mnuContextRoot.PopupOpen += new DotNetBarManager.PopupOpenEventHandler(mnuContextRoot_PopupOpen); mnuContext.SetContextMenuEx(DotNetBarManager.ToolbarTopDockSite, mnuContextRoot); }
/// <summary> /// Initializes a new instance of the <see cref="DictionaryWindow"/> class with default settings. /// </summary> /// <param name="designer">The report designer.</param> public DictionaryWindow(Designer designer) : base(designer) { Name = "DictionaryWindow"; Image = Res.GetImage(72); FToolbar = new Bar(); FToolbar.Dock = DockStyle.Top; FToolbar.Font = DrawUtils.DefaultFont; FToolbar.RoundCorners = false; btnActions = new ButtonItem(); btnActions.AutoExpandOnClick = true; btnEdit = AddButton(Res.GetImage(68), miEdit_Click); btnDelete = AddButton(Res.GetImage(51), miDelete_Click); btnView = AddButton(Res.GetImage(54), miView_Click); FToolbar.Items.AddRange(new ButtonItem[] { btnActions, btnEdit, btnDelete, btnView }); miNew = AddButton(Res.GetImage(0), miNew_Click); miOpen = AddButton(Res.GetImage(1), miOpen_Click); miMerge = AddButton(null, miMerge_Click); miSave = AddButton(Res.GetImage(2), miSave_Click); miChooseData = AddButton(null, Designer.cmdChooseData.Invoke); miChooseData.BeginGroup = true; miNewDataSource = AddButton(Res.GetImage(137), Designer.cmdAddData.Invoke); miNewDataSource.BeginGroup = true; miNewRelation = AddButton(Res.GetImage(139), miNewRelation_Click); miNewCalculatedColumn = AddButton(Res.GetImage(55), miNewCalculatedColumn_Click); miNewParameter = AddButton(Res.GetImage(56), miNewParameter_Click); miNewTotal = AddButton(Res.GetImage(65), miNewTotal_Click); btnActions.SubItems.AddRange(new ButtonItem[] { miNew, miOpen, miMerge, miSave, miChooseData, miNewDataSource, miNewRelation, miNewCalculatedColumn, miNewParameter, miNewTotal }); btnActions.PopupOpen += btnActions_PopupOpen; mnuContext = new ContextMenuBar(); mnuContextRoot = new ButtonItem(); mnuContext.Items.Add(mnuContextRoot); miRename = AddButton(null, miRename_Click); miRename.Shortcuts.Add(eShortcut.F2); miEdit = AddButton(Res.GetImage(68), miEdit_Click); miDelete = AddButton(Res.GetImage(51), miDelete_Click); miDeleteAlias = AddButton(null, miDeleteAlias_Click); miView = AddButton(Res.GetImage(54), miView_Click); mnuContextRoot.SubItems.AddRange(new ButtonItem[] { miRename, miEdit, miDelete, miDeleteAlias, miView }); mnuContextRoot.PopupOpen += mnuContextRoot_PopupOpen; FTree = new TreeView(); FTree.Dock = DockStyle.Fill; FTree.BorderStyle = BorderStyle.None; FTree.ImageList = Res.GetImages(); FTree.LabelEdit = true; FTree.HideSelection = false; FTree.AllowDrop = true; FTree.MouseDown += FTree_MouseDown; FTree.BeforeLabelEdit += FTree_BeforeLabelEdit; FTree.AfterLabelEdit += FTree_AfterLabelEdit; FTree.KeyDown += FTree_KeyDown; FTree.AfterSelect += FTree_AfterSelect; FTree.DoubleClick += miEdit_Click; FTree.ItemDrag += FTree_ItemDrag; FTree.DragOver += FTree_DragOver; FTree.DragDrop += FTree_DragDrop; mnuContext.SetContextMenuEx(FTree, mnuContextRoot); FSplitter = new Splitter(); FSplitter.Dock = DockStyle.Bottom; FSplitter.Visible = false; lblDescription = new DescriptionControl(); lblDescription.Dock = DockStyle.Bottom; lblDescription.Height = 70; lblDescription.Visible = false; ParentControl.Controls.AddRange(new Control[] { FTree, FSplitter, lblDescription, FToolbar }); FExpandedNodes = new List <string>(); Localize(); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); Control tabControl = this.GetType().BaseType.GetField("tabControl", BindingFlags.Instance | BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.ExactBinding) .GetValue(this) as Control; barMain = new ContextMenuBar(); itemRoot = new ButtonItem("Root"); item1 = new ComboBoxItem("item1"); item1.Text = "显示比例"; ButtonItem btn1 = new ButtonItem("b1", "标准"); ButtonItem btn2 = new ButtonItem("b2", "适应"); ButtonItem btn3 = new ButtonItem("b3", "页面宽度"); item1.Items.AddRange(new BaseItem[] { btn1, btn2, btn3 }); item1.ComboWidth = 80; item1.DropDownStyle = ComboBoxStyle.DropDownList; item1.SelectedIndex = 0; item1.Click += (obj, args) => { switch (item1.SelectedIndex) { case 0: this.Zoom = 1f; break; case 1: this.ZoomWholePage(); break; case 2: this.ZoomPageWidth(); break; default: break; } }; item2 = new ComboBoxItem("item2"); item2.Text = "页面位置"; ButtonItem btn4 = new ButtonItem("b4", "前一页"); ButtonItem btn5 = new ButtonItem("b5", "后一页"); ButtonItem btn6 = new ButtonItem("b7", "首页"); ButtonItem btn7 = new ButtonItem("b8", "尾页"); item2.Items.AddRange(new BaseItem[] { btn4, btn5, btn6, btn7 }); item2.ComboWidth = 80; item2.DropDownStyle = ComboBoxStyle.DropDownList; item2.SelectedIndex = 0; item2.Click += (obj, args) => { switch (item2.SelectedIndex) { case 0: this.Prior(); break; case 1: this.Next(); break; case 2: this.First(); break; case 3: this.Last(); break; default: break; } }; item3 = new ButtonItem("item3"); item3.BeginGroup = true; item3.Text = "打印"; item3.Image = Res.GetImage(195); item3.Click += (obj, args) => { this.Print(); }; item4 = new ButtonItem("item4"); item4.Text = "打印当前页"; item4.Click += (obj, args) => { this.Report.PrintSettings.PageNumbers = this.PageNo.ToString(); this.Report.PrintSettings.PageRange = FastReport.PageRange.PageNumbers; this.Report.Print(); this.Report.PrintSettings.PageNumbers = ""; this.Report.PrintSettings.PageRange = FastReport.PageRange.All; }; item5 = new TextBoxItem("item5"); item5.Text = "页码范围"; item5.Click += (obj, args) => { try { this.Report.PrintSettings.PageNumbers = item5.ControlText; this.Report.PrintSettings.PageRange = FastReport.PageRange.PageNumbers; this.Report.Print(); this.Report.PrintSettings.PageNumbers = ""; this.Report.PrintSettings.PageRange = FastReport.PageRange.All; } catch { MessageBoxEx.Show("输入的页码范围无效,请核对后重试", "提示"); } }; itemRoot.SubItems.AddRange(new BaseItem[] { item1, item2, item3, item4, item5 }); barMain.SetContextMenuEx(tabControl, itemRoot); this.Controls.Add(barMain); tabControl.Controls[0].MouseDown += (obj, args) => { itemRoot.ClosePopup(); }; //tabControl.Controls[0].LostFocus += (obj, args) => //{ // itemRoot.ClosePopup(); //}; }