/// <summary> /// 默认初始化主菜单 /// </summary> private void initInstSCMenu() { LMenu_Border.Visibility = Visibility.Hidden; RMenu_Border.Visibility = Visibility.Hidden; TMenu_Border.Visibility = Visibility.Hidden; ItemType mainMenu = DseFunctions.GetMenu(Environment.CurrentDirectory, GlobalDefines.StaName, GlobalDefines.EquName); ItemType rootMenu = new ItemType(); ITEM_TYPE gooseInputItem = new ITEM_TYPE() { name = "GOOSE输入" }; ItemType gooseInput = new ItemType(gooseInputItem); ITEM_TYPE shortcutMenuItem = new ITEM_TYPE() { name = "快捷菜单" }; ItemType shortcutMenu = new ItemType(shortcutMenuItem); // GooseInput_TextBlock.DataContext = gooseInput; Shortcut_TextBlock.DataContext = shortcutMenu; mainMenu.Add(mainMenu); mainMenu.Add(gooseInput); RootMenu_ListBox.ItemsSource = mainMenu; RootMenu_ListBox.SelectedIndex = 0; this.Visibility = Visibility.Hidden; }
/// <summary> /// 获取装置菜单 /// </summary> /// <param name="menuPath">菜单路径</param> /// <param name="staName">站点名称</param> /// <param name="equName">装置名称</param> /// <returns></returns> public static ItemType GetMenu(string menuPath, string staName, string equName) { int iGet = 0; ITEM_TYPE root = new ITEM_TYPE(); ItemType menu = new ItemType(); int size = Marshal.SizeOf(typeof(ITEM_TYPE)); try { StringBuilder sbErr = new StringBuilder(); iGet = dse_get_ied_menu(menuPath, staName, equName, ref root, sbErr); if (sbErr.ToString() != "") { // MessageBox.Show("打开文件失败!"); return null; } menu = new MenuType(root); } catch (Exception) { } return menu; }
public static extern int dse_get_ied_menu(string path, string sta_name, string equ_name, ref ITEM_TYPE pItem, StringBuilder err);