void InitRecentItems() { BackstageView.Items.Insert(4, new BackstageViewItemSeparator()); int itemCount = Math.Min(MRUFileList.Count, (int)spinEdit1.Value); for (int i = 0; i < itemCount; i++) { BackstageViewButtonItem item = new BackstageViewButtonItem(); item.Caption = Path.GetFileName((string)MRUFileList[i]); item.Glyph = imageCollection3.Images[2]; item.Tag = (string)MRUFileList[i]; item.ItemClick += new BackstageViewItemEventHandler(OnRecentItemClick); BackstageView.Items.Insert(5 + i, item); } }
void ClearRecentItems() { if (BackstageView == null) { return; } for (int i = 0; i < BackstageView.Items.Count;) { BackstageViewButtonItem item = BackstageView.Items[i] as BackstageViewButtonItem; if ((item != null && item.Tag != null) || BackstageView.Items[i] is BackstageViewItemSeparator) { if (item != null) { item.ItemClick -= new BackstageViewItemEventHandler(OnRecentItemClick); } BackstageView.Items.RemoveAt(i); } else { i++; } } }
private void CreateRecentItem() { { //// WinForms Controls > DevExpress.XtraBars.Ribbon > BackstageViewTabItem > SelectedChanged //// To get a selected tab item or select a tab item, use: //BackstageViewTabItem oo = this.backstageViewControl1.SelectedTab; //int oo = this.backstageViewControl1.SelectedTabIndex; //// BackstageViewTabItem.Selected - Allows you to select a specific tab item by using this Boolean property. //this.backstageViewControl1.SelectedTabChanged += this.BackstageViewControl1_SelectedTabChanged; { BackstageViewButtonItem o = new BackstageViewButtonItem() { Caption = "New", Glyph = ImageResourceCache.Default.GetImage("office2013/actions/new_32x32.png") }; this.backstageViewControl1.Items.Add(o); } this.backstageViewControl1.Items.Add(new BackstageViewItemSeparator()); { BackstageViewButtonItem o = new BackstageViewButtonItem() { Caption = "Open", // Glyph = ImageResourceCache.Default.GetImage("office2013/actions/open_32x32.png"), }; this.backstageViewControl1.Items.Add(o); } { this.rofBackstageViewTabItem = new BackstageViewTabItem() { Caption = "Open Recent", Name = "Open Recent", //Glyph = ImageResourceCache.Default.GetImage( "office2013/actions/open_32x32.png" ) }; this.backstageViewControl1.Items.Add(this.rofBackstageViewTabItem); OpenRecentXuc xuc = new OpenRecentXuc(this.appCfg, this.backstageViewControl1) { Dock = DockStyle.Fill }; this.rofBackstageViewTabItem.ContentControl.Controls.Add(xuc); xuc.ReOpenFile += this.OpenRecentXuc_ReOpenFile; } this.backstageViewControl1.Items.Add(new BackstageViewItemSeparator()); { BackstageViewButtonItem o = new BackstageViewButtonItem() { Caption = "Save", //Glyph = ImageResourceCache.Default.GetImage("office2013/save/save_32x32.png") }; this.backstageViewControl1.Items.Add(o); } { BackstageViewTabItem o = new BackstageViewTabItem() { Caption = "Save As...", //Glyph = ImageResourceCache.Default.GetImage("office2013/save/saveas_32x32.png") }; this.backstageViewControl1.Items.Add(o); } this.backstageViewControl1.Items.Add(new BackstageViewItemSeparator()); { BackstageViewButtonItem o = new BackstageViewButtonItem() { Caption = nameof(Close), //Glyph = ImageResourceCache.Default.GetImage( "office2013/actions/close_32x32.png" ) }; this.backstageViewControl1.Items.Add(o); } this.backstageViewControl1.Items.Add(new BackstageViewItemSeparator()); { BackstageViewButtonItem o = new BackstageViewButtonItem() { Caption = "Exit", //Glyph = ImageResourceCache.Default.GetImage( "office2013/actions/close_32x32.png" ) }; this.backstageViewControl1.Items.Add(o); } this.backstageViewControl1.Items.Add(new BackstageViewItemSeparator()); { BackstageViewTabItem o = new BackstageViewTabItem(); o.Caption = "Export"; SimpleButton btn = new SimpleButton(); btn.Text = "Export"; btn.Location = new Point(10, 10); o.ContentControl.Controls.Add(btn); this.backstageViewControl1.Items.Add(o); } this.backstageViewControl1.Items.Insert(1, new BackstageViewItemSeparator()); } }
private void InitBackstageViewTabItemAndCommand(DisplayMode displayMode) { backstageViewControl.Items.Clear(); if (this.BackstageViewTabItems != null) { var list = BackstageViewTabItems.Where(p => p.Value.DisplayMode.In(displayMode, DisplayMode.All)).OrderBy(p => p.Value.Index); foreach (var item in list) { item.Value.Init(); if (item.Value.BeginGroup) { BackstageViewItemSeparator sp = new BackstageViewItemSeparator(); backstageViewControl.Items.Add(sp); } BackstageViewTabItem tab = new BackstageViewTabItem(); tab.Caption = item.Value.Caption; tab.ContentControl.Controls.Add(item.Value.View); item.Value.View.Dock = DockStyle.Fill; backstageViewControl.Items.Add(tab); tab.Selected = item.Value.IsSelected; tab.SelectedChanged += (sender, args) => { item.Value.RefreshUI(); }; } } if (this.BackstageViewCommands != null) { var list = BackstageViewCommands.Where(p => p.Value.DisplayMode.In(displayMode, DisplayMode.All)).OrderBy(p => p.Value.Index); foreach (var item in list) { if (item.Value.BeginGroup) { BackstageViewItemSeparator sp = new BackstageViewItemSeparator(); backstageViewControl.Items.Add(sp); } BackstageViewButtonItem btn = new BackstageViewButtonItem(); btn.Caption = item.Value.Caption; btn.Glyph = item.Value.m_Glyph; btn.ItemClick += item.Value.ItemClick; backstageViewControl.Items.Add(btn); } } }