private IEnumerable <FrameworkElement> GetRowMenuItems(XamContextMenu contextMenu) { var rowItems = new List <FrameworkElement>(); bool areThereSpecificContextItems = contextMenu.Items.Count > 0; var menuItem = new XamMenuItem { Header = "Export", Command = DefaultRadGridContextMenuCommands.ExportGridCommand, CommandParameter = AssociatedObject }; rowItems.Add(menuItem); if (areThereSpecificContextItems) { rowItems.Add(new XamMenuSeparator()); rowItems.AddRange(contextMenu.Items.Cast <FrameworkElement>()); } contextMenu.Items.Clear(); return(rowItems); }
void GetMenuItems() { string sql = ""; try { cnnMain.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (cnnMain != null && cnnMain.State == ConnectionState.Open) { if (this.Main_Menu.HasItems) { this.Main_Menu.Items.Clear(); } DataTable dtP = null; try { sql = @" select FEATURE_WBS as swbs, FEATURE_NAME as view_name from tracker_tb_features t where t.prj_no = '" + My.Application.Prj_No + "' and t.FEATURE_ENABLED=1 and FEATURE_PARENT is null order by FEATURE_ORDER"; dtP = MyDb.Common.sql2DT(sql, cnnMain); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (dtP != null && dtP.Rows.Count > 0) { foreach (DataRow drP in dtP.Rows) { string wbs = (string)(drP["SWBS"] + ""); XamMenuItem m = new XamMenuItem(); m.Tag = wbs; m.Header = wbs + " " + (string)drP["VIEW_NAME"]; // popupmenutool.SharedProps.Category = "Reports"; sql = @" select FEATURE_WBS as swbs, FEATURE_NAME as view_name from tracker_tb_features t where t.prj_no = '" + My.Application.Prj_No + "' and t.FEATURE_ENABLED=1 and FEATURE_PARENT ='" + wbs + "' order by FEATURE_ORDER"; DataTable dtC = null; try { dtC = MyDb.Common.sql2DT(sql, cnnMain); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (dtP != null && dtP.Rows.Count > 0) { foreach (DataRow drC in dtC.Rows) { XamMenuItem mm = new XamMenuItem(); mm.Tag = (string)drC["swbs"]; mm.IsEnabled = GetMenuEnabled(mm.Tag + ""); mm.Header = (string)drC["swbs"] + " " + (string)drC["view_name"]; mm.Click += new System.EventHandler(this.XamMenuItem_Click); m.Items.Add(mm); } } Main_Menu.Items.Add(m); } } } }
//Todo add check in security tables to see if user should not have access to open this void GetMenuItems_Reports() { cnnMain = new OracleConnection(My.Application.Csettings.cnnString); string sql = ""; try { cnnMain.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message); } if (cnnMain != null && cnnMain.State == ConnectionState.Open) { if (this.Main_Menu.HasItems) { this.Main_Menu.Items.Clear(); } DataTable dtP = null; try { sql = @"select swbs, view_name from TRACKER_tb_VIEWS t where t.prj_no = '" + My.Application.Prj_No + "' and t.view_enabled=1 and view_parent is null order by view_order"; dtP = MyDb.Oracle.sql2DT(sql, cnnMain); } catch (Exception ex) { Debug.WriteLine(ex.Message); } if (dtP != null && dtP.Rows.Count > 0) { foreach (DataRow drP in dtP.Rows) { string wbs = (string)(drP["SWBS"] + ""); XamMenuItem m = new XamMenuItem(); m.Tag = wbs; m.Header = wbs + " " + (string)drP["VIEW_NAME"]; // popupmenutool.SharedProps.Category = "Reports"; sql = "select swbs, view_name from TRACKER_tb_VIEWS t where t.prj_no = 'BPGOM' and t.view_enabled=1 and view_parent ='" + wbs + "' order by view_order"; DataTable dtC = null; try { dtC = MyDb.Oracle.sql2DT(sql, cnnMain); } catch (Exception ex) { Debug.WriteLine(ex.Message); } if (dtP != null && dtP.Rows.Count > 0) { foreach (DataRow drC in dtC.Rows) { XamMenuItem mm = new XamMenuItem(); mm.Tag = (string)drC["swbs"]; mm.Header = (string)drC["swbs"] + " " + (string)drC["view_name"]; mm.Click += new System.EventHandler(this.XamMenuItem_Click); m.Items.Add(mm); } } Main_Menu.Items.Add(m); } } } }
private IEnumerable <FrameworkElement> GetGenericHeaderMenuItems() { var lst = new List <FrameworkElement>(); if (ShowSaveSettings) { XamMenuItem saveSettings = new XamMenuItem { Tag = ForceKey, Header = "Save", Command = DefaultRadGridContextMenuCommands.SaveSettingsCommand, CommandParameter = AssociatedObject, }; lst.Add(saveSettings); XamMenuItem loadSettings = new XamMenuItem { Tag = ForceKey, Header = "Load", Command = DefaultRadGridContextMenuCommands.LoadSettingsCommand, CommandParameter = AssociatedObject, }; lst.Add(loadSettings); XamMenuItem setDefault = new XamMenuItem { Tag = ForceKey, Header = "Imposta come layout di default", Command = DefaultRadGridContextMenuCommands.SetDefaultCommand, CommandParameter = AssociatedObject, }; lst.Add(setDefault); XamMenuItem clearSettings = new XamMenuItem { Header = "Ripristina layout della griglia", Command = DefaultRadGridContextMenuCommands.ClearSettingsCommand, CommandParameter = AssociatedObject, }; lst.Add(clearSettings); lst.Add(new XamMenuSeparator()); } XamMenuItem sortAscItem = new XamMenuItem { Header = "Ordina A - Z per \"{0}\"", Command = DefaultRadGridContextMenuCommands.SortAscendingCommand }; lst.Add(sortAscItem); XamMenuItem sortDescItem = new XamMenuItem { Header = "Ordina Z - A per \"{0}\"", Command = DefaultRadGridContextMenuCommands.SortDescendingCommand }; lst.Add(sortDescItem); XamMenuItem clearSortItem = new XamMenuItem { Header = "Cancella ordinamento per \"{0}\"", Command = DefaultRadGridContextMenuCommands.SortClearingCommand }; lst.Add(new XamMenuSeparator()); lst.Add(clearSortItem); XamMenuItem groupItem = new XamMenuItem { Header = "Raggruppa per \"{0}\"", Command = DefaultRadGridContextMenuCommands.GroupByCommand }; lst.Add(groupItem); XamMenuItem ungroupItem = new XamMenuItem { Header = "Cancella reggruppamento per \"{0}\"", Command = DefaultRadGridContextMenuCommands.UnGroupByCommand }; lst.Add(ungroupItem); lst.Add(new XamMenuSeparator()); XamMenuItem colVisibleItem = new XamMenuItem { Header = "Colonne visibili : " }; lst.Add(colVisibleItem); XamDataGrid grid = AssociatedObject; foreach (Field column in grid.FieldLayouts[0].Fields) { XamMenuItem subMenu = new XamMenuItem { Header = column.Name, IsCheckable = true, IsChecked = true, StaysOpenOnClick = true }; Binding isCheckedBinding = new Binding("Visibility") { Mode = BindingMode.TwoWay, Source = column, Converter = new VisibilityToBooleanConverter() }; // bind IsChecked menu item property to IsVisible column property subMenu.SetBinding(XamMenuItem.IsCheckedProperty, isCheckedBinding); colVisibleItem.Items.Add(subMenu); } lst.Add(new XamMenuSeparator()); XamMenuItem colDelFilterItem = new XamMenuItem { Header = "Elimina filtri", Command = DefaultRadGridContextMenuCommands.DeleteFiltersCommand }; lst.Add(colDelFilterItem); if (ShowManageSettings) { var menuItem2 = new XamMenuItem { Header = "Gestione colori", Command = DefaultRadGridContextMenuCommands.ChangeColorCommand }; lst.Add(menuItem2); var menuItem1 = new XamMenuItem { Header = "Gestione font", Command = DefaultRadGridContextMenuCommands.ChangeFontCommand }; lst.Add(menuItem1); var menuItem3 = new XamMenuItem { Header = "Gestione proprietà", Command = DefaultRadGridContextMenuCommands.PropertiesCommand }; lst.Add(menuItem3); } return(lst); }
private void SaveLayout(string layoutName, Action CloseDialog) { try { if (!this._Layouts.Contains(layoutName)) { XamMenuItem item = new XamMenuItem(); item.Header = layoutName; item.Click += Layout_Click; this.layout.Items.Add(item); this._Layouts.Add(layoutName); } this._LayoutManager.SaveLayout(layoutName); CloseDialog(); MessageBox.Show("存储成功"); } catch (Exception ex) { Logger.TraceEvent(System.Diagnostics.TraceEventType.Error, "SaveLayout.\r\n{0}", ex.ToString()); } }
private void InitializeUI(LoginResult result) { FunctionTree functionTree = ConsoleClient.Instance.GetFunctionTree(); for (int i = 0; i < functionTree.Modules.Count; i++) { this.AuthorizedModules.Add(functionTree.Modules[i].Type, functionTree.Modules[i]); } // initialize layout try { this._Layouts = new ObservableCollection<string>(result.LayoutNames); foreach (string layoutName in result.LayoutNames) { XamMenuItem item = new XamMenuItem(); item.Header = layoutName; item.Click += Layout_Click; this.layout.Items.Add(item); } if (!string.IsNullOrEmpty(result.DockLayout)) { this._LayoutManager.LoadLayout(result.DockLayout, result.ContentLayout); } } catch (Exception exception) { Logger.AddEvent(TraceEventType.Error, "MainWindow.InitializeUI\r\n{0}", exception); } // initialize function tree Dictionary<ModuleCategoryType, TreeViewItem> typeTreeViewItems = new Dictionary<ModuleCategoryType, TreeViewItem>(); foreach (Module module in this.AuthorizedModules.Values) { TreeViewItem catalogNode; if (!typeTreeViewItems.TryGetValue(module.Category, out catalogNode)) { catalogNode = new TreeViewItem() { Header = functionTree.Categories.Single<Category>(c => c.CategoryType == module.Category).CategoryDescription }; this.FunctionTree.Items.Add(catalogNode); typeTreeViewItems.Add(module.Category, catalogNode); } string iconName = module.Type.ToString(); TreeViewItem functionNode; if (!this._FunctionTreeItems.TryGetValue(iconName, out functionNode)) { functionNode = new TreeViewItem() { Tag = module.Type }; if (this.Resources.Contains(iconName)) { StackPanel headerPanel; headerPanel = new StackPanel() { Orientation = Orientation.Horizontal }; headerPanel.Children.Add((UIElement)this.Resources[iconName]); headerPanel.Children.Add(new TextBlock() { Text = module.ModuleDescription, Margin = new Thickness(3, 0, 0, 0) }); functionNode.Header = headerPanel; } else { functionNode.Header = module.ModuleDescription; } this._FunctionTreeItems.Add(iconName, functionNode); } functionNode.MouseDoubleClick += treeViewItem_MouseDoubleClick; catalogNode.Items.Add(functionNode); } }