public Item GetMenu(string db, string language, string path) { string menuXMLPath = $@"wwwroot{Path.DirectorySeparatorChar}db{Path.DirectorySeparatorChar}{DatabaseId}{Path.DirectorySeparatorChar}menu.xml"; XDocument doc = XDocument.Load(menuXMLPath); XmlMenu menu = new XmlMenu(doc, language, m => { m.AlterItemBeforeStorage = item => { item.ID.Selection = System.IO.Path.GetFileName(item.ID.Selection); }; }); ItemSelection cid = string.IsNullOrEmpty(path) ? new ItemSelection() : new ItemSelection(System.IO.Path.GetDirectoryName(db + Path.DirectorySeparatorChar + path), System.IO.Path.GetFileName(path)); menu.SetCurrentItemBySelection(cid.Menu, cid.Selection); // Check if menu level has been found or not if (cid.Menu != "START" && cid.Selection != "START") { if (menu.CurrentItem.ID.Menu == "" && menu.CurrentItem.ID.Selection == db) { //Menu level has not been found in database return(new PxMenuItem(null)); } else if (((path.ToLower().Contains(".px")) && (!path.Contains(Path.DirectorySeparatorChar.ToString()))) && ((menu.CurrentItem.ID.Menu.Contains(Path.DirectorySeparatorChar.ToString()) && menu.CurrentItem.ID.Selection == path))) { // 1. We have a .PX-file with no path (no \) specified in nodeID // 2. SetCurrentItemBySelection however has found the path to the table and put this in CurrentItem.ID.Selection // We need to return an empty PxMenuItem in this case and instead find the table via the search functionality. // If we do not do this we will get an error in BuildForPresentation later on because of we do not have the cotrrect path to the table... return(new PxMenuItem(null)); } } return(menu.CurrentItem); }
private static PxMenuBase GetPxMenuAndItem(string dbid, string nodeId, string lang, out PCAxis.Menu.Item currentItem) { //Get menu-file DatabaseInfo currentdb = PXWeb.Settings.Current.General.Databases.GetPxDatabase(dbid); if (currentdb != null) { StringBuilder sb = new StringBuilder(PXWeb.Settings.Current.General.Paths.PxDatabasesPath); sb.Append("/"); sb.Append(currentdb.Id); sb.Append("/"); sb.Append(PXWeb.Settings.Current.General.Databases.PxDatabaseFilename); //string _xmlFile = HttpContext.Current.Server.MapPath(sb.ToString()); string _xmlFile = System.Web.Hosting.HostingEnvironment.MapPath(sb.ToString()); XmlMenu menu = new XmlMenu(XDocument.Load(_xmlFile), lang, m => { m.Restriction = item => { return(true); }; }); ItemSelection cid = PathHandlerFactory.Create(PCAxis.Web.Core.Enums.DatabaseType.PX).GetSelection(nodeId); menu.SetCurrentItemBySelection(cid.Menu, cid.Selection); currentItem = menu.CurrentItem; return(menu); } currentItem = null; return(null); }
/// <summary> /// Gets the PC-Axis file based menu object /// </summary> /// <returns>A PX file Menu object</returns> private static Item GetPxMenu(string db, string language, string nodeId) { string menuXMLPath = System.IO.Path.Combine(ExposedDatabases.DatabaseConfigurations[language][db].RootPath, "menu.xml"); XDocument doc = XDocument.Load(menuXMLPath); XmlMenu menu = new XmlMenu(doc, language, m => { m.AlterItemBeforeStorage = item => { item.ID.Selection = System.IO.Path.GetFileName(item.ID.Selection); }; }); ItemSelection cid = string.IsNullOrEmpty(nodeId) ? new ItemSelection() : new ItemSelection(System.IO.Path.GetDirectoryName(db + "\\" + nodeId), System.IO.Path.GetFileName(nodeId)); menu.SetCurrentItemBySelection(cid.Menu, cid.Selection); // Check if menu level has been found or not if (cid.Menu != "START" && cid.Selection != "START") { if (menu.CurrentItem.ID.Menu == "" && menu.CurrentItem.ID.Selection == db) { //Menu level has not been found in database return(new PxMenuItem(null)); } else if (((nodeId.ToLower().Contains(".px")) && (!nodeId.Contains(@"\"))) && ((menu.CurrentItem.ID.Menu.Contains(@"\") && menu.CurrentItem.ID.Selection == nodeId))) { // 1. We have a .PX-file with no path (no \) specified in nodeID // 2. SetCurrentItemBySelection however has found the path to the table and put this in CurrentItem.ID.Selection // We need to return an empty PxMenuItem in this case and instead find the table via the search functionality. // If we do not do this we will get an error in BuildForPresentation later on because of we do not have the cotrrect path to the table... return(new PxMenuItem(null)); } } return(menu.CurrentItem); }
private void ARen_Load(object sender, EventArgs e) { _UserModel = new UserModel(); _UserModel.Init(); GvFile.AutoGenerateColumns = false; _FileList = new List<TRen>(); _Renamer = new Renamer(); GvInfo.AutoGenerateColumns = false; LlInfo.Text = "一些文件名中的禁用字符(:|*?\"<>\\/)在命名表达式中的用法:"; DataTable dt = new DataTable(); dt.Columns.Add("KeyCode", typeof(string)); dt.Columns.Add("KeyInfo", typeof(string)); dt.Rows.Add(":", "数字表达式:从数值1逐步累加"); dt.Rows.Add(":<a,b,c,d>", "数字表达式:起始值a,步增量b,结果按定长c显示,不足时填充字符d"); dt.Rows.Add("|", "字符表达式:大写英文字母循环累加"); dt.Rows.Add("|<abc>", "字符表达式:表示循环计算abc等字符"); dt.Rows.Add("|<ab:c:def>", "字符表达式:表示循环计算ab、c、def等单词"); dt.Rows.Add("*", "文件名表达式:引用原文件名"); dt.Rows.Add("*<ab:c>", "文件名表达式:将文件名中的ab替换为c"); dt.Rows.Add("?", "扩展名表达式:引用原扩展名"); dt.Rows.Add("?<ab:c>", "扩展名表达式:将扩展名中的ab替换为c"); //dt.Rows.Add("\"", "字符表达式:对应位置的单个原有字符"); dt.Rows.Add("<>", "区间表达式:用于限制以上特殊含义字符的取值空间"); dt.Rows.Add("/", "正向转义字符,不能单独使用"); dt.Rows.Add("/:", "转义:使用文件修改时间,默认格式为 yyyyMMddHHmmss"); dt.Rows.Add("/:<yyyy-MM-dd HH.mm.ss>", "转义:使用文件修改时间,使用指定格式"); dt.Rows.Add("/|<1,4>", "转义:字符裁剪,从第1个字符开始裁剪掉后续4个字符"); dt.Rows.Add("/*", "转义:将文件名转换为小写"); dt.Rows.Add("/?", "转义:将扩展名转换为小写"); //dt.Rows.Add("/\"", "转义:将原有字符转换为小写"); dt.Rows.Add("\\", "反向转义字符,不能单独使用"); dt.Rows.Add("\\:", "转义:使用文件创建时间,默认时间格式为 yyyyMMddHHmmss"); dt.Rows.Add("\\:<yyyy-MM-dd HH.mm.ss>", "转义:使用文件创建时间,使用指定格式"); dt.Rows.Add("\\|<1,4>", "转义:字符截取,从第1个字符开始仅保留后续4个字符"); dt.Rows.Add("\\*", "转义:将文件名转换为大写"); dt.Rows.Add("\\?", "转义:将扩展名转换为大写"); //dt.Rows.Add("\\\"", "转义:将原有字符转换为大写"); GvInfo.DataSource = dt; foreach (MRen ren in _UserModel.LoadRules()) { LbRule.Items.Add(ren); } #region 系统选单 _XmlMenu = new XmlMenu<ARen>(this, null); if (_XmlMenu.Load(Path.Combine(_UserModel.DatHome, ERen.XML_MENU))) { _XmlMenu.GetStrokes("ARen", this); _XmlMenu.GetPopMenu("ARen", PmMenu); _XmlMenu.GetPopMenu("ARule", PmRule); _XmlMenu.GetPopMenu("AFile", PmFile); } #endregion }
public void Init() { _ViewModel = new ViewModel(_UserModel); _ViewModel.LoadLayout(); #region 系统选单 _XmlMenu = new XmlMenu<WPcs>(this, _ViewModel); if (_XmlMenu.Load(Path.Combine(_UserModel.DatHome, CPcs.XML_MENU))) { _XmlMenu.GetMenuBar("WPcs", MbMenu); _XmlMenu.GetToolBar("WPcs", TbTool); PopupMenu = new ContextMenuStrip(); _XmlMenu.GetPopMenu("WPcs", PopupMenu); _XmlMenu.GetStrokes("WPcs", this); } #endregion string path = Path.Combine(_UserModel.SysHome, "Pcs"); if (Directory.Exists(path)) { string key; foreach (string file in Directory.GetFiles(path, "*16.png")) { key = Path.GetFileNameWithoutExtension(file); key = key.Substring(0, key.Length - 2); IlPcsList.Images.Add(key, Image.FromFile(file)); } } _DefPage = new TabPage(); _DefPage.Text = "首页"; _DefPage.ImageKey = "main"; //_DefPage.Location = new System.Drawing.Point(4, 23); //_DefPage.Padding = new System.Windows.Forms.Padding(3); //_DefPage.Size = new System.Drawing.Size(604, 300); _PcsList = new PcsList(this, _UserModel, _DataModel); _PcsList.Init(); _PcsList.Dock = DockStyle.Fill; _DefPage.Controls.Add(_PcsList); TcMeta.TabPages.Add(_DefPage); _Threads = new List<TaskInfo>(); _Viewers = new List<ITaskViewer>(); }
public void Init() { if (_Inited) { return; } _Inited = true; #region 数据模型 _SafeModel = new SafeModel(_UserModel); _SafeModel.Init(); _DataModel = new DataModel(_UserModel, _Main); _DataModel.Init(); _ViewModel = new ViewModel(_UserModel); _ViewModel.Init(); _ViewModel.LoadLayout(); #endregion _KeyList = new KeyList(this, _DataModel, _ViewModel); _KeyList.Control.Dock = DockStyle.Fill; //_KeyList.Control.Location = new System.Drawing.Point(0, 0); _KeyList.Control.Name = "KeyList"; //_KeyList.Control.Size = new System.Drawing.Size(374, 29); //_KeyList.Control.TabIndex = 0; _CatTree = new CatTree(this, _DataModel); _CatTree.Control.Dock = DockStyle.Fill; _CatTree.KeyList = _KeyList; UcFind.KeyList = _KeyList; #region 系统选单 _XmlMenu = new XmlMenu<WPwd>(this, _ViewModel); if (_XmlMenu.Load(Path.Combine(_UserModel.DatHome, CPwd.XML_MENU))) { _XmlMenu.GetMenuBar(CPwd.APP_KEY, MbMenu); _XmlMenu.GetToolBar(CPwd.APP_KEY, TbTool); ContextMenuStrip CmCat = new ContextMenuStrip(); _XmlMenu.GetPopMenu("WCat", CmCat); _CatTree.PopupMenu = CmCat; ContextMenuStrip CmKey = new ContextMenuStrip(); _XmlMenu.GetPopMenu("WKey", CmKey); _KeyList.PopupMenu = CmKey; _AttMenu = new ContextMenuStrip(); _XmlMenu.GetPopMenu("WAtt", _AttMenu); _XmlMenu.GetStrokes(CPwd.APP_KEY, this); if (_XmlMenu.GetHotkeys(CPwd.APP_KEY, this)) { foreach (var hotkey in _XmlMenu.Hotkeys) { User32.RegisterHotKey(this.Handle, hotkey.Id, (int)hotkey.Modifiers, (int)hotkey.Code); } } } #endregion LoadLayout(); ShowInfo(); _CatTree.Init(null); // 当前时间 UcTimer.Start(); _DataModel.Start(); _DataModel.AppendHandler(new AmonHandler<string>(ShowEcho)); }
private void WIco_Load(object sender, EventArgs e) { _MIcon = new MultiIcon(); _XmlMenu = new XmlMenu<WIco>(this, null); if (_XmlMenu.Load(Path.Combine(_UserModel.DatHome, EIco.XML_MENU))) { _XmlMenu.GetStrokes("WIco", this); _XmlMenu.GetPopMenu("WIco", CmMenu); _XmlMenu.GetPopMenu("Icl", CmIcl); _XmlMenu.GetPopMenu("Ico", CmIco); } }
private void ASql_Load(object sender, EventArgs e) { KeyPreview = true; _XmlMenu = new XmlMenu<ASql>(this, null); if (_XmlMenu.Load(Path.Combine(_UserModel.Home, ESql.XML_MENU))) { _XmlMenu.GetStrokes("ASql"); _XmlMenu.GetPopMenu("ASql", CmMenu); } //string path = Path.Combine(_UserModel.Home, ESql.DDL_FILE); //if (!File.Exists(path)) //{ // return; //} //StreamReader reader = File.OpenText(path); //XmlDocument doc = new XmlDocument(); //doc.Load(reader); //reader.Close(); //LoadLib(doc); //_Drives = new List<Rdbms>(); //foreach (XmlNode node in doc.SelectNodes("/Amon/RDBMS")) //{ // Rdbms dbms = new Rdbms(); // dbms.FromXml(node); // _Drives.Add(dbms); //} ChangeDdl(null); }