private void buttonAddChild_Click(object sender, EventArgs e) { KryptonBreadCrumbItem item = (KryptonBreadCrumbItem)CreateInstance(typeof(KryptonBreadCrumbItem)); TreeNode newNode = new MenuTreeNode(item); TreeNode selectedNode = treeView1.SelectedNode; // If there is no selection then append to root if (selectedNode == null) { treeView1.Nodes.Add(newNode); } else { MenuTreeNode selectedMenu = (MenuTreeNode)selectedNode; selectedMenu.Item.Items.Add(item); selectedNode.Nodes.Add(newNode); } // Select the newly added node if (newNode != null) { treeView1.SelectedNode = newNode; treeView1.Focus(); } UpdateButtons(); UpdatePropertyGrid(); }
/// <summary> /// 树结构对象 /// </summary> /// <param name="parentId"></param> /// <param name="list"></param> /// <returns></returns> private static List <MenuTreeNode> GetChildreNodes(int parentId, List <int> list) { var nodes = new List <MenuTreeNode>(); //获取所有的菜单组 List <bjf_menu> groupmentList = MenuManager.GetInstance() .SelectList(m => m.isdelete == false && m.isuse == false && m.parentid == parentId); //循环菜单组找出子菜单 if (groupmentList.Any()) { foreach (var c in groupmentList) { bool ischecked = list.Count > 0 && list.Contains(c.id) ? true : false; var childList = GetChildreNodes(c.id, list); //菜单组下的子菜单 var node = new MenuTreeNode { id = c.id, name = c.menuname, isParent = childList.Any(), parentId = Convert.ToInt32(c.parentid), sortCode = c.sortcode, linkUrl = c.menuhref, open = false, Checked = ischecked, children = childList //子菜单下的孙子菜单 以此类推 }; nodes.Add(node); } } return(nodes); }
private void buttonDelete_Click(object sender, EventArgs e) { TreeNode node = treeView1.SelectedNode; // We should have a selected node! if (node != null) { MenuTreeNode treeNode = node as MenuTreeNode; // If at root level then remove from root, otherwise from the parent collection if (node.Parent == null) { treeView1.Nodes.Remove(node); } else { TreeNode parentNode = node.Parent; MenuTreeNode treeParentNode = parentNode as MenuTreeNode; treeParentNode.Item.Items.Remove(treeNode.Item); node.Parent.Nodes.Remove(node); } treeView1.Focus(); } UpdateButtons(); UpdatePropertyGrid(); }
private void UpdateButtons() { MenuTreeNode node = treeView1.SelectedNode as MenuTreeNode; buttonMoveUp.Enabled = (node != null) && (PreviousNode(node) != null); buttonMoveDown.Enabled = (node != null) && (NextNode(node) != null); buttonDelete.Enabled = (node != null); }
public MenuTreeNodeViewModel(MenuTreeNode Node) { _MenuNode = Node; foreach (var ChildNode in Node.Children) { _Children.Add(new MenuTreeNodeViewModel(ChildNode)); } _Children.CollectionChanged += Children_CollectionChanged; }
private void buttonMoveUp_Click(object sender, EventArgs e) { // If we have a selected node MenuTreeNode node = (MenuTreeNode)treeView1.SelectedNode; if (node != null) { // Find the previous node using the currently selected node MenuTreeNode previousNode = (MenuTreeNode)PreviousNode(node); if (previousNode != null) { // Is the current node contained inside the next node bool contained = ContainsNode(previousNode, node); // Remove cell from parent collection MenuTreeNode parentNode = (MenuTreeNode)node.Parent; TreeNodeCollection parentCollection = (node.Parent == null ? treeView1.Nodes : node.Parent.Nodes); parentNode?.Item.Items.Remove(node.Item); parentCollection.Remove(node); if (contained) { // Add cell to the parent of target node MenuTreeNode previousParent = (MenuTreeNode)previousNode.Parent; parentCollection = (previousNode.Parent == null ? treeView1.Nodes : previousNode.Parent.Nodes); int pageIndex = parentCollection.IndexOf(previousNode); // If the current and previous nodes are inside the same common node if (!contained && ((previousParent != null) && (previousParent != parentNode))) { // If the page is the last one in the collection then we need to insert afterwards if (pageIndex == (previousParent.Nodes.Count - 1)) { pageIndex++; } } previousParent?.Item.Items.Insert(pageIndex, node.Item); parentCollection.Insert(pageIndex, node); } else { parentNode = (MenuTreeNode)previousNode; parentNode.Item.Items.Insert(parentNode.Nodes.Count, node.Item); parentNode.Nodes.Insert(parentNode.Nodes.Count, node); } } } // Ensure the target node is still selected treeView1.SelectedNode = node; UpdateButtons(); UpdatePropertyGrid(); }
private void SystemMenuItem_Click(object sender, EventArgs e) { MenuTreeNode ClickedNode = null; MenuNodeDictionary.TryGetValue((System.Windows.Forms.ToolStripItem)sender, out ClickedNode); SystemMenuTreeNode SystemMenuNode = ClickedNode as SystemMenuTreeNode; if (SystemMenuNode != null) { SystemMenuNode.Execute(); } }
/// <summary> /// Add a Menu Tree Node if user in in the list of Authorized roles. /// Thanks to abain for fixing authorization bug. /// </summary> /// <param name="tabIndex">Index of the tab</param> /// <param name="myTab">Tab to add to the MenuTreeNodes collection</param> protected virtual void AddMenuTreeNode(int tabIndex, PageStripDetails myTab) //MH: { if (PortalSecurity.IsInRoles(myTab.AuthorizedRoles)) { MenuTreeNode mn = new MenuTreeNode(myTab.PageName); mn.Link = giveMeUrl(myTab.PageName, myTab.PageID); mn.Height = Height; mn.Width = Width; mn = RecourseMenu(tabIndex, myTab.Pages, mn); Childs.Add(mn); } }
/// <summary> /// Add the current tab as top menu item. /// </summary> private void AddRootNode() { var PortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; var tabItemsRoot = PortalSettings.ActivePage; using (var mn = new MenuTreeNode(tabItemsRoot.PageName)) { // change the link to stay on the same page and call a category product mn.Link = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, tabItemsRoot.PageID); mn.Width = this.Width; this.Childs.Add(mn); } }
/// <summary> /// Add the current tab as top menu item. /// </summary> private void AddRootNode() { PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; PageSettings tabItemsRoot = portalSettings.ActivePage; using (MenuTreeNode mn = new MenuTreeNode(tabItemsRoot.PageName)) { // change the link to stay on the same page and call a category product mn.Link = HttpUrlBuilder.BuildUrl("~/DesktopDefault.aspx", tabItemsRoot.PageID); mn.Width = Width; Childs.Add(mn); } }
/// <summary> /// Adds the shop home node. /// </summary> private void AddShopHomeNode() { PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; int tabIDShop = portalSettings.ActivePage.PageID; MenuTreeNode mn = new MenuTreeNode(General.GetString("PRODUCT_HOME", "Shop Home")); // change the link to stay on the same page and call a category product mn.Link = HttpUrlBuilder.BuildUrl(tabIDShop); mn.Width = Width; Childs.Add(mn); }
private IMenu BuildUltraMenuItem(MenuTreeNode node) { string menuName = UserControl.MutiLanguages.ParserString(Menu_Prefix + node.MenuWithUrl.MenuCode); if (menuName == string.Empty) { menuName = UserControl.MutiLanguages.ParserString(Module_Prefix + node.MenuWithUrl.ModuleCode); if (menuName == string.Empty) { menuName = node.MenuWithUrl.MenuCode; } } string strUrl = node.MenuWithUrl.FormUrl; string strKey = strUrl; if (strKey == string.Empty) { strKey = node.MenuWithUrl.MenuCode; } MenuCommand item = new MenuCommand(strKey, menuName, 0, new CommandOpenForm(strUrl)); TreeObjectNodeSet set = node.GetSubLevelChildrenNodes(); ArrayList listSubMenu = new ArrayList(); foreach (MenuTreeNode subNode in set) { if (subNode.MenuWithUrl.MenuType.ToUpper() == MenuType.MenuType_PDA.ToUpper()) { if (this.menuHT != null && this.menuHT.Contains(subNode.MenuWithUrl.ModuleCode)) { continue; } if (this.htUnVisibilityMenu != null && this.htUnVisibilityMenu.Contains(subNode.MenuWithUrl.MenuCode)) { continue; } listSubMenu.Add(BuildUltraMenuItem(subNode)); } } if (listSubMenu.Count > 0) { MenuCommand[] subMenu = new MenuCommand[listSubMenu.Count]; listSubMenu.CopyTo(subMenu); item.SubMenus = subMenu; } return(item); }
private DataMenuItem BuildUltraMenuItemRPTNew(MenuTreeNode node, ControlLibrary.Web.Language.LanguageComponent languageComponent, string reportViewMenuCode, DataMenuItem reportViewMenuItem) { DataMenuItem item = new DataMenuItem(); //item.Style.Width = new Unit(180); item.Target = "frmWorkSpace"; string menuName = languageComponent.GetString(Menu_Prefix + node.MenuWithUrl.MenuCode); if (menuName == string.Empty) { menuName = languageComponent.GetString(Module_Prefix + node.MenuWithUrl.ModuleCode); if (menuName == string.Empty) { menuName = node.MenuWithUrl.MenuCode; } } item.Text = menuName; item.NavigateUrl = node.MenuWithUrl.FormUrl; TreeObjectNodeSet set = node.GetSubLevelChildrenNodes(); foreach (MenuTreeNode subNode in set) { if (subNode.MenuWithUrl.MenuType.ToUpper() == MenuType.MenuType_RPT.ToUpper()) { if (this.menuHT != null && this.menuHT.Contains(subNode.MenuWithUrl.ModuleCode)) { continue; } if (this.htUnVisibilityMenu != null && this.htUnVisibilityMenu.Contains(subNode.MenuWithUrl.MenuCode)) { continue; } item.Items.Add(BuildUltraMenuItemRPTNew(subNode, languageComponent, reportViewMenuCode, reportViewMenuItem)); } } if (string.Compare(node.MenuWithUrl.MenuCode, reportViewMenuCode, true) == 0 && reportViewMenuItem != null) { foreach (DataMenuItem reportViewitem in reportViewMenuItem.Items) { item.Items.Add(reportViewitem); } } return(item); }
private void SystemButton_Click(object sender, RoutedEventArgs e) { this.Hide(); MenuTreeNode ClickedNode = null; System.Windows.Controls.Button ClickedButton = (System.Windows.Controls.Button)sender; MenuNodeDictionary.TryGetValue(ClickedButton, out ClickedNode); SystemMenuTreeNode SystemMenuNode = ClickedNode as SystemMenuTreeNode; if (SystemMenuNode != null) { SystemMenuNode.Execute(); } }
private System.Windows.Forms.ToolStripItem[] BuildContextMenuItem(MenuTreeNode Node) { if (!Node.IsVisible) { return(null); } List <System.Windows.Forms.ToolStripItem> NewItems = new List <System.Windows.Forms.ToolStripItem>(); if (Node.Type == MenuType.Category) { foreach (var Child in Node.Children) { var ChildItem = BuildContextMenuItem(Child); if (ChildItem != null) { NewItems.AddRange(ChildItem); } } System.Windows.Forms.ToolStripSeparator separator = new System.Windows.Forms.ToolStripSeparator(); NewItems.Add(separator); } else { System.Windows.Forms.ToolStripMenuItem NewItem = new System.Windows.Forms.ToolStripMenuItem(Node.Name); NewItems.Add(NewItem); LauncherCommandInfo Command = App.AppConfig.FindCommandInfo(Node.CommandInfoID); if (Command != null && Command.Type != CommandExecuteType.None) { NewItem.ToolTipText = Command.Description; NewItem.Click += MenuNode_Click; MenuNodeDictionary.Add(NewItem, Node); } foreach (var Child in Node.Children) { var ChildItem = BuildContextMenuItem(Child); if (ChildItem != null) { NewItem.DropDownItems.AddRange(ChildItem); } } bool LastChildIsSeparator = NewItem.DropDownItems.Count == 0 ? false : NewItem.DropDownItems[NewItem.DropDownItems.Count - 1] is System.Windows.Forms.ToolStripSeparator; if (LastChildIsSeparator) { NewItem.DropDownItems.RemoveAt(NewItem.DropDownItems.Count - 1); } } return(NewItems.ToArray()); }
private void MenuNode_Click(object sender, EventArgs e) { MenuTreeNode ClickedNode = null; MenuNodeDictionary.TryGetValue((System.Windows.Forms.ToolStripItem)sender, out ClickedNode); if (ClickedNode != null) { LauncherCommandInfo Command = App.AppConfig.FindCommandInfo(ClickedNode.CommandInfoID); if (Command != null) { App.Executer.Execute(Command); } } }
/// <summary> /// Add a Menu Tree Node if user in in the list of Authorized roles. /// Thanks to abain for fixing authorization bug. /// </summary> /// <param name="tabIndex"> /// Index of the tab /// </param> /// <param name="mytab"> /// Tab to add to the MenuTreeNodes collection /// </param> protected virtual void AddMenuTreeNode(int tabIndex, PageStripDetails mytab) { // MH: if (PortalSecurity.IsInRoles(mytab.AuthorizedRoles)) { var mn = new MenuTreeNode(mytab.PageName) { Link = this.GiveMeUrl(mytab.PageName, mytab.PageID), Height = this.Height, Width = this.Width }; mn = this.RecourseMenu(tabIndex, mytab.Pages, mn); this.Childs.Add(mn); } }
private void buttonMoveDown_Click(object sender, EventArgs e) { // If we have a selected node MenuTreeNode node = (MenuTreeNode)treeView1.SelectedNode; if (node != null) { // Find the next node using the currently selected node MenuTreeNode nextNode = (MenuTreeNode)NextNode(node); if (nextNode != null) { // Is the current node contained inside the next node bool contained = ContainsNode(nextNode, node); // Remove cell from parent collection MenuTreeNode parentNode = (MenuTreeNode)node.Parent; TreeNodeCollection parentCollection = (node.Parent == null ? treeView1.Nodes : node.Parent.Nodes); if (parentNode != null) { parentNode.Item.Items.Remove(node.Item); } parentCollection.Remove(node); if (contained) { // Add cell to the parent sequence of target cell MenuTreeNode previousParent = (MenuTreeNode)nextNode.Parent; parentCollection = (nextNode.Parent == null ? treeView1.Nodes : nextNode.Parent.Nodes); int pageIndex = parentCollection.IndexOf(nextNode); if (previousParent != null) { previousParent.Item.Items.Insert(pageIndex + 1, node.Item); } parentCollection.Insert(pageIndex + 1, node); } else { parentNode = (MenuTreeNode)nextNode; parentNode.Item.Items.Insert(0, node.Item); parentNode.Nodes.Insert(0, node); } } } // Ensure the target node is still selected treeView1.SelectedNode = node; UpdateButtons(); UpdatePropertyGrid(); }
/// <summary> /// Adds the shop home node. /// </summary> private void AddShopHomeNode() { var PortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; var tabIdShop = PortalSettings.ActivePage.PageID; var mn = new MenuTreeNode(General.GetString("PRODUCT_HOME", "Shop Home")) { // change the link to stay on the same page and call a category product Link = HttpUrlBuilder.BuildUrl(tabIdShop), Width = this.Width }; this.Childs.Add(mn); }
/// <summary> /// Shops the desktop navigation. /// </summary> /// <param name="myTab">My tab.</param> private void ShopDesktopNavigation(PageStripDetails myTab) { if (PortalSecurity.IsInRoles(myTab.AuthorizedRoles)) { MenuTreeNode mn = new MenuTreeNode(myTab.PageName); mn.Link = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, myTab.ParentPageID, "ItemID=" + myTab.PageID.ToString()); mn.Height = Height; mn.Width = Width; mn = RecourseMenuShop(0, myTab.Pages, mn, myTab.ParentPageID); Childs.Add(mn); } }
private void NewButton_Click(object sender, RoutedEventArgs e) { this.Hide(); MenuTreeNode ClickedNode = null; System.Windows.Controls.Button ClickedButton = (System.Windows.Controls.Button)sender; MenuNodeDictionary.TryGetValue(ClickedButton, out ClickedNode); if (ClickedNode != null) { LauncherCommandInfo Command = App.AppConfig.FindCommandInfo(ClickedNode.CommandInfoID); if (Command != null) { App.Executer.Execute(Command); } } }
private void Page_Load(object sender, System.EventArgs e) { PortalConfig configPortal = (PortalConfig)HttpContext.Current.Items["PortalConfig"]; int pagId; int paginaActual = configPortal.PagActiva.PagId;; if (configPortal.PagActiva.PagPadre == -1) { pagId = configPortal.PagActiva.PagId; } else { pagId = BuscarPadre(configPortal.PagActiva.PagId); } ArrayList PaginasAutorizadas = new ArrayList(); Menu.ClientScriptPath = Global.ObtenerRuta(Request) + "/Controles/DUEMETRI_UI_WebControls_HWMenu/1_0_0_0"; Menu.ImagesPath = Global.ObtenerRuta(Request) + "/Controles/DUEMETRI_UI_WebControls_HWMenu/1_0_0_0"; IDataReader Hijas = PaginasBD.ObtenerHijas(pagId); //int agregadas = 0; while (Hijas.Read()) { string GruposAutorizados = Hijas["GruposAutorizados"].ToString(); if (SeguridadPortal.EstaEnGrupos(GruposAutorizados)) { string Nombre = Hijas["PagNombre"].ToString(); MenuTreeNode elementoMenu = new MenuTreeNode(Nombre); elementoMenu.Link = Global.ObtenerRuta(Request) + "/Default.aspx?pagid=" + Hijas["PagId"].ToString(); elementoMenu.Width = Menu.Width; elementoMenu.Font.Name = "Tahoma"; elementoMenu.Font.Bold = false; elementoMenu.Font.Size = 11; elementoMenu = CreaSubMenu(elementoMenu, (int)Hijas["PagId"]); Menu.Childs.Add(elementoMenu); } } Hijas.Close(); }
private Infragistics.WebUI.UltraWebNavigator.Item BuildUltraMenuItemRPT(MenuTreeNode node, ControlLibrary.Web.Language.LanguageComponent languageComponent) { Infragistics.WebUI.UltraWebNavigator.Item item = new Infragistics.WebUI.UltraWebNavigator.Item(); //item.Style.Width = new Unit(180); item.TargetFrame = "frmWorkSpace"; string menuName = languageComponent.GetString(Menu_Prefix + node.MenuWithUrl.MenuCode); if (menuName == string.Empty) { menuName = languageComponent.GetString(Module_Prefix + node.MenuWithUrl.ModuleCode); if (menuName == string.Empty) { menuName = node.MenuWithUrl.MenuCode; } } item.Text = menuName; item.TargetUrl = node.MenuWithUrl.FormUrl; TreeObjectNodeSet set = node.GetSubLevelChildrenNodes(); foreach (MenuTreeNode subNode in set) { if (subNode.MenuWithUrl.MenuType.ToUpper() == MenuType.MenuType_RPT.ToUpper()) { if (this.menuHT != null && this.menuHT.Contains(subNode.MenuWithUrl.ModuleCode)) { continue; } if (this.htUnVisibilityMenu != null && this.htUnVisibilityMenu.Contains(subNode.MenuWithUrl.MenuCode)) { continue; } item.Items.Add(BuildUltraMenuItemRPT(subNode, languageComponent)); } } return(item); }
/// <summary> /// Add a Menu Tree Node if user in in the list of Authorized roles. /// Thanks to abain for fixing authorization bug. /// </summary> /// <param name="tabIndex">Index of the tab</param> /// <param name="myTab">Tab to add to the MenuTreeNodes collection</param> private void AddMenuTreeNode(int tabIndex, PageStripDetails myTab) { if (PortalSecurity.IsInRoles(myTab.AuthorizedRoles)) { // get index and id from this page and transmit them // Obtain PortalSettings from Current Context PortalSettings portalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; int tabIDShop = portalSettings.ActivePage.PageID; MenuTreeNode mn = new MenuTreeNode(myTab.PageName); // change the link to stay on the same page and call a category product mn.Link = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, tabIDShop, "ItemID=" + myTab.PageID); mn.Width = Width; mn = RecourseMenu(tabIDShop, myTab.Pages, mn); Childs.Add(mn); } }
private void AddMenuTreeNode(KryptonBreadCrumbItem item, MenuTreeNode parent) { // Create a node to match the item MenuTreeNode node = new MenuTreeNode(item); // Add to either root or parent node if (parent != null) { parent.Nodes.Add(node); } else { treeView1.Nodes.Add(node); } // Add children of an items collection foreach (KryptonBreadCrumbItem child in item.Items) { AddMenuTreeNode(child, node); } }
// modified to transmit the PageID and TabIndex for the shop page /// <summary> /// Recourses the menu. /// </summary> /// <param name="tabIDShop">The tab ID shop.</param> /// <param name="t">The t.</param> /// <param name="mn">The mn.</param> /// <returns></returns> private MenuTreeNode RecourseMenu(int tabIDShop, PagesBox t, MenuTreeNode mn) { if (t.Count > 0) { for (int c = 0; c < t.Count; c++) { PageStripDetails mySubTab = (PageStripDetails)t[c]; if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles)) { MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName); // change PageID into ItemID for the product module on the same page mnc.Link = HttpUrlBuilder.BuildUrl("~/" + HttpUrlBuilder.DefaultPage, tabIDShop, "ItemID=" + mySubTab.PageID); mnc.Width = mn.Width; mnc = RecourseMenu(tabIDShop, mySubTab.Pages, mnc); mn.Childs.Add(mnc); } } } return(mn); }
private void AddNewMenuTreeNode(object obj) { var treeView = (TreeView)obj; var selectedTreeItem = treeView.SelectedItem as IMenuTreeNode; var newMenuTreeNode = new MenuTreeNode(); if (selectedTreeItem == null) { HostOperationsMenuTree.Add(newMenuTreeNode); } else if (selectedTreeItem is MenuTreeNode) { (selectedTreeItem as MenuTreeNode).Children.Add(newMenuTreeNode); } else if (selectedTreeItem is HostCommandNode) { var hostCommandNodeCollection = FindHostCommandNodeCollection(selectedTreeItem, HostOperationsMenuTree); hostCommandNodeCollection.Add(newMenuTreeNode); } treeView.SetSelectedItem(newMenuTreeNode); }
/// <summary> /// Recourses the menu. /// </summary> /// <param name="tabIndex">Index of the tab.</param> /// <param name="t">The t.</param> /// <param name="mn">The mn.</param> /// <returns></returns> protected virtual MenuTreeNode RecourseMenu(int tabIndex, PagesBox t, MenuTreeNode mn) //mh: { if (t.Count > 0) { for (int c = 0; c < t.Count; c++) { PageStripDetails mySubTab = t[c]; if (PortalSecurity.IsInRoles(mySubTab.AuthorizedRoles)) { MenuTreeNode mnc = new MenuTreeNode(mySubTab.PageName); mnc.Link = giveMeUrl(mySubTab.PageName, mySubTab.PageID); mnc.Width = mn.Width; mnc = RecourseMenu(tabIndex, mySubTab.Pages, mnc); mn.Childs.Add(mnc); } } } return(mn); }
/// <summary> /// Add a Menu Tree Node if user in in the list of Authorized roles. /// Thanks to abain for fixing authorization bug. /// </summary> /// <param name="mytab"> /// Tab to add to the MenuTreeNodes collection /// </param> private void AddMenuTreeNode(PageStripDetails mytab) { if (PortalSecurity.IsInRoles(mytab.AuthorizedRoles)) { // get index and id from this page and transmit them // Obtain PortalSettings from Current Context var PortalSettings = (PortalSettings)HttpContext.Current.Items["PortalSettings"]; var tabIdShop = PortalSettings.ActivePage.PageID; var mn = new MenuTreeNode(mytab.PageName) { // change the link to stay on the same page and call a category product Link = HttpUrlBuilder.BuildUrl( "~/" + HttpUrlBuilder.DefaultPage, tabIdShop, "ItemID=" + mytab.PageID), Width = this.Width }; mn = this.RecourseMenu(tabIdShop, mytab.Pages, mn); this.Childs.Add(mn); } }
MenuTreeNode CreaSubMenu(MenuTreeNode elementoMenu, int pagId) { IDataReader Hijas = PaginasBD.ObtenerHijas(pagId); while (Hijas.Read()) { string GruposAutorizados = Hijas["GruposAutorizados"].ToString(); if (SeguridadPortal.EstaEnGrupos(GruposAutorizados)) { string Nombre = Hijas["PagNombre"].ToString(); MenuTreeNode subMenu = new MenuTreeNode(Nombre); subMenu.Link = Global.ObtenerRuta(Request) + "/Default.aspx?pagid=" + Hijas["PagId"].ToString(); subMenu.Width = elementoMenu.Width; subMenu = CreaSubMenu(subMenu, (int)Hijas["PagId"]); elementoMenu.Childs.Add(subMenu); } } Hijas.Close(); return(elementoMenu); }
public bool CheckIsValid(MenuTreeNode node){ if (node == null) return false; if (node.filePath != null && node.filePath.Contains ("ENTER")) return false; if (node.info != null && node.info.DialogTitle != null && node.info.DialogTitle.Contains ("ENTER")) return false; // here, depending on the node type, see if there is enough info to use this node return node.valid; }
StringMap editStrmap = new StringMap(); // this persistent value lets us edit a stringmap public static MenuTreeNode BuildMenu( string fileName ) // pass in the relative path { MenuTreeNode returnNode = new MenuTreeNode(); returnNode.filePath = fileName; Serializer<ObjectInteractionInfo> serializer = new Serializer<ObjectInteractionInfo>(); // ObjectInteractionInfo info; returnNode.info = serializer.Load(fileName); // if this load fails, then we should probably create a default empty file returnNode.children = new List<MenuTreeNode>(); // read in the ObjectInteractionInfo at this level. // If a DialogItem begins with XML, if (returnNode.info == null) return null; foreach (InteractionMap map in returnNode.info.ItemResponse) { if (map.item.Contains("XML:")) { // remove XML: string newXML = map.item.Remove(0, 4); // load this new one // info = serializer.Load("XML/Interactions/" + newXML); // parse new one and add it as a child MenuTreeNode newNode = BuildMenu("XML/Interactions/" + newXML); if (newNode != null){ newNode.parent = returnNode; returnNode.children.Add(newNode); } } else { // it's a terminal node, an interaction MenuTreeNode newNode = new MenuTreeNode(); newNode.map = map; newNode.parent = returnNode; returnNode.children.Add(newNode); } } return returnNode; }
int AddScripts(MenuTreeNode node,ScriptedObject SO, int index){ if (node.map != null){ InteractionScript IS = BuildScriptFromInteraction(node.map); SO.scripts[index] = IS; // build the unity hierachy IS.gameObject.transform.parent = SO.gameObject.transform; index++; } else { foreach (MenuTreeNode n in node.children) index = AddScripts(n,SO,index); } return index; }
void OnWizardOtherButton(){ menuTree = MenuTreeNode.BuildMenu(XMLName); // assuming that worked, we'll build a script of character tasks for every node that is an interaction. string[] parts = XMLName.Split('/'); GameObject scriptedObjectGO = new GameObject(parts[parts.Length-1]+"Scripts"); SO = scriptedObjectGO.AddComponent<ScriptedObject>(); int numScripts = CountScripts(menuTree); SO.scripts = new InteractionScript[numScripts]; // now traverse the menutree, and as we encounter maps, build them into scripts currentScript = 0; // this is a global AddScripts(menuTree, SO, currentScript); SO.prettyname = parts[parts.Length-1]+" Scripts"; SO.XMLName = XMLName+" "+DateTime.Now.ToString(); // we really don't need this value, but it shows where we came from SO.moveToParentOnDrop = true; }
public void RemoveChild(MenuTreeNode child){ // find a child node, which might be a whole submenu, or just a single interaction, // and remove it from our info's DialogItems, and from our list of children // this child node is a submenu or an interactionMap if (child.map == null){ // remove submenu XML: thinkg from our dialog items } else { // remove the interaction item from our dialog items info.DialogItems.Remove (child.map.item); // and save our objectInteractionInfo out to it's filepath. Serializer<ObjectInteractionInfo> serializer = new Serializer<ObjectInteractionInfo>(); serializer.Save("Assets/Resources/"+filePath+".xml",info); // updates this level of menu with the new child // then remove the child from our children list children.Remove(child); } }
// this method recursively displays the menu tree for the Editor inspector, and can call methods to add and save public void ShowInspectorGUI(int level){ EditorGUILayout.Space (); if (level == -1) GUILayout.Label("============ CREATING NEW ITEM ============="); else if (level == 0){ GUILayout.Label ("VVV >> FOR TESTING ONLY, STILL WORK IN PROGRESS << VVV"); GUILayout.Label("============ INTERACTION MENUS ============="); } string indent = ""; string xp = expanded?"V ":"> "; for (int i=0;i<level;i++) indent += "__"; // just a string to add space on the left if (map == null){ // this is a submenu GUILayout.BeginHorizontal (); GUILayout.Label (indent+info.Name+" DialogTitle:",GUILayout.Width(125)); info.DialogTitle = GUILayout.TextField (info.DialogTitle,GUILayout.Width(175)); bool clicked = GUILayout.Button (xp+info.DialogTitle,GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); if (clicked) expanded = !expanded; if (expanded){ Color topColor = GUI.color; Color nextColor = topColor; nextColor.r = 0.75f; nextColor.g = 0.9f; GUI.color = nextColor; GUILayout.BeginHorizontal(); GUILayout.Label ("Loads From:"); filePath = GUILayout.TextField(filePath); GUILayout.EndHorizontal(); foreach (MenuTreeNode n in children) n.ShowInspectorGUI(level+1); GUILayout.BeginHorizontal(); GUILayout.Label (info.DialogTitle+":"); if (newNode == null){ if (GUILayout.Button("Add Submenu",GUILayout.ExpandWidth(false))) { //lets add a submenu! newNode = new MenuTreeNode(); newNode.expanded = true; // makes more sense for editing newNode.info = new ObjectInteractionInfo(); newNode.info.DialogTitle = "ENTER Submenu Title"; newNode.filePath = "ENTER Path relative to XML/Interactions/"; newNode.children = new List<MenuTreeNode>(); //newNode.valid = false; } if (GUILayout.Button ("Add Interaction",GUILayout.ExpandWidth(false))) { // lets add an interaction! newNode = new MenuTreeNode(); newNode.expanded = true; // makes more sense for editing newNode.map = new InteractionMap(); // this tells the dialog we are adding an interaction newNode.map.item = "TASK:NEW:THING"; //newNode.valid = false; } } if (newNode == null && CheckIsValid(this)) // we don't have work in progress if (GUILayout.Button ("Save Changes!",GUILayout.ExpandWidth(false))) { // save the xml stuff, and reload ourselves // if we are a submenu thing, serialize our } GUILayout.EndHorizontal(); if (newNode != null) ShowAddNodeGUI(); GUI.color = topColor; } } else { // this is a terminal node, an interaction, so show it for editing Color prevColor = GUI.color; GUI.color = new Color(.75f,1,1,1); GUILayout.BeginHorizontal(); bool clicked = GUILayout.Button("Interaction"+indent+xp+StringMgr.GetInstance().Get(map.item)); if (clicked) expanded = !expanded; if (DeleteButton()){// delete this interaction! that means the whole menu node at this level! parent.RemoveChild(this); } GUILayout.EndHorizontal(); if (expanded) { GUILayout.BeginHorizontal(); GUILayout.Label (indent+"item:",GUILayout.Width(125)); map.item = GUILayout.TextField(map.item); GUILayout.EndHorizontal (); map.item = EditMappedString(indent+"item:", map.item, map); map.response = EditMappedString(indent+"response:", map.response, map); map.response_title = EditMappedString(indent+"response_title:", map.response_title, map); map.tooltip = EditMappedString(indent+"tooltip:", map.tooltip, map); map.note = EditMappedString(indent+"note:", map.note, map); if (map.sound != null){ GUILayout.Label (indent+"sound:"+map.sound); // AudioClip sound = SoundMgr.GetInstance().Get(map.sound); // EditorGUILayout.PropertyField(sound); } GUILayout.BeginHorizontal(); GUILayout.Label(indent+"task:",GUILayout.Width(125)); if (map.task == null){ if (GUILayout.Button ("No Task, CLICK TO ADD")) map.task = "TASK:"; } else map.task = GUILayout.TextField(map.task); // textfiled doesn't like a null argument GUILayout.EndHorizontal (); if (map.task != null){ if (TaskMaster.GetInstance().GetTask(map.task) != null){ Color taskColor = GUI.color; GUI.color = new Color(.95f,1,1,1); GUILayout.Label(indent+"-----------------Taskdata: ---------------"); foreach (CharacterTask ct in TaskMaster.GetInstance().GetTask(map.task).data.characterTasks){ GUILayout.Label (indent+"CT characterName:"+ct.characterName); GUILayout.Label (indent+"CT nodeName:"+ct.nodeName); if (ct.posture != null) GUILayout.Label (indent+"CT posture:"+ct.posture); if (ct.lookAt != null) GUILayout.Label (indent+"CT lookAt:"+ct.lookAt); if (ct.animatedInteraction != null) GUILayout.Label (indent+"CT animatedInteraction:"+ct.animatedInteraction); GUILayout.Label (indent+"CT delay:"+ct.delay); GUILayout.Label ("---------------------------------------------"); } GUI.color = taskColor; }else{ GUILayout.Label("*WARNING* NO TASK FOUND for ["+map.task+"] !!!!"); } } string xl = expandList?"V ":"> "; GUILayout.BeginHorizontal (); GUILayout.Label (indent+"list:",GUILayout.ExpandWidth(false)); if (GUILayout.Button(xl+map.list,GUILayout.ExpandWidth(false))) expandList = ! expandList; GUILayout.EndHorizontal(); // some assumptions made about the way things are being used here, we should generalize. // we have a list of interactions, which point back to maps, which could have further lists or single tasks // here, we have assumed a single task, and that lets us open it for editing. // we could add a data field to the task, map, or interaction, that lets us flag it for editing, then // make these methods self contained and part of the each class. // for now, lets just assume lists of interactions point to maps with single tasks, and move forward... if (expandList && map.list != null){ foreach (Interaction intr in InteractionMgr.GetInstance ().GetList(map.list).Interactions){ EditorGUILayout.Space (); GUILayout.Label (indent+" InteractionName:"+intr.Name); // GUILayout.Label (" Map:"+intr.Map.item); // these 3 are the same as the intr name // GUILayout.Label (" Task:"+intr.Map.task); // GUILayout.Label (" TaskData:"+TaskMaster.GetInstance().GetTask(intr.Map.task).data.name); // if no task is open for edit, then allow opening this one if (intr.Map.task == null){ // there's no task for this, either add one or bail GUILayout.Label (indent+" InteractionName:"+intr.Name+" has no task set yet. Bail for now."); } else { // there is a map with a taskname. // is this the one opened task for this menuitem ? if (editingTaskKey == ""){ // then we can open this one if (GUILayout.Button ("Edit "+intr.Map.task)) editingTaskKey = intr.Map.task; } if (editingTaskKey == intr.Map.task){ Color listColor = GUI.color; GUI.color = new Color(1,.7f,.7f,1); GUILayout.BeginHorizontal(); intr.Map.task = EditorGUILayout.TextField ("task",intr.Map.task); if (GUILayout.Button ("SAVE",GUILayout.ExpandWidth(false))){ //We have to save the task and task data, and maybe the interaction and its map as well! } if (GUILayout.Button ("CANCEL",GUILayout.ExpandWidth(false))){editingTaskKey = "";} GUILayout.EndHorizontal(); intr.Name = EditorGUILayout.TextField ("Name",intr.Name); intr.Character = EditorGUILayout.TextField ("Character",intr.Character); EditorGUILayout.LabelField ("WaitTime: "+intr.WaitTime); EditorGUILayout.LabelField ("WaitTask: "+intr.WaitTask); if (TaskMaster.GetInstance().GetTask(intr.Map.task) != null){ foreach (CharacterTask ct in TaskMaster.GetInstance().GetTask(intr.Map.task).data.characterTasks){ GUILayout.Label ("-------Character Task-----------------------"); ct.characterName = EditorGUILayout.TextField("characterName",ct.characterName); ct.nodeName = EditorGUILayout.TextField("nodeName",ct.nodeName); ct.posture = EditorGUILayout.TextField("posture",ct.posture); ct.lookAt = EditorGUILayout.TextField("lookAt",ct.lookAt); ct.animatedInteraction = EditorGUILayout.TextField("animatedInteraction",ct.animatedInteraction); GUILayout.Label (indent+"CT delay:"+ct.delay); } }else{ GUILayout.Label("*WARNING* NO TASK FOUND for ["+intr.Map.task+"] !!!!"); } GUI.color = listColor; } } } } GUILayout.Label (indent+"time:"+map.time); GUILayout.Label (indent+"log:"+map.log); GUILayout.Label (indent+"max:"+map.max); GUILayout.Label (indent+"prereq:"); if (map.prereq != null){ foreach (string tag in map.prereq){ GUILayout.Label (indent+"prereq: "+tag); } } } GUI.color = prevColor; } }
int CountScripts(MenuTreeNode node){ // we use this just to dimension the SO.scripts array int count = 0; if (node.map != null) count = 1; else { foreach (MenuTreeNode n in node.children) count += CountScripts(n); } return count; }
/// <summary> /// Checks recursively for URL or content ID matches in the menu /// </summary> /// <param name="startNode">The starting node to check from</param> /// <returns>Whether or not a match was found</returns> private bool DoesMenuHaveMatch(MenuTreeNode startNode) { if (!string.IsNullOrEmpty(startNode.NavigateUrl) && startNode.NavigateUrl != "/") { // Check for URL match if (Page.Request.RawUrl.ToLower().Contains(startNode.NavigateUrl.ToLower())) { return true; } } if (this.ContentId > 0 && !string.IsNullOrEmpty(startNode.ItemId)) { // Check for content ID match if (this.ContentId.ToString() == startNode.ItemId) { return true; } } foreach (MenuTreeNode childNode in startNode.Items) { if (this.DoesMenuHaveMatch(childNode)) { return true; } } return false; }
public void ShowAddNodeGUI(){ EditorGUILayout.Space(); GUILayout.BeginHorizontal(); if (newNode.map == null) { GUILayout.Label ("Add Submenu BELOW to "+info.DialogTitle+" Menu"); // Not much needed here, } else { GUILayout.Label ("Add Interaction BELOW to "+info.DialogTitle+" Menu"); // gotta have an interaction map with a ... } if (GUILayout.Button ("CANCEL")) { newNode = null; // relies on garbage collection... } if (CheckIsValid(newNode)) if (GUILayout.Button ("SAVE")){ if (newNode.map == null){ // we've made a new submenu for our current //if its a submenu, add the XML our dialog items info.DialogItems.Add ("XML:"+newNode.filePath); // this is not exactly right. at all. Serializer<ObjectInteractionInfo> serializer = new Serializer<ObjectInteractionInfo>(); serializer.Save("Assets/Resources/"+filePath+".xml",info); // updates this level of menu with the new child serializer.Save("Assets/Resources/XML/Interactions/"+newNode.filePath+".xml",newNode.info); // at some point, we need to create the new XML file at the specified path by serilaizing the ObjectInteractionInfo of the new node. // that should probably be done when we hit the SAVE CHANGES button, but we might do it here } else { //we've added an interaction to an our current menu level, so update that with the item name info.DialogItems.Add (newNode.map.item); Serializer<ObjectInteractionInfo> serializer = new Serializer<ObjectInteractionInfo>(); serializer.Save("Assets/Resources/"+filePath+".xml",info); // we need to add the newNode.map to the interaction Manager and save out Interactions.xml // unless it's one that was already in there. // check to see if it exists if (InteractionMgr.GetInstance().Get(newNode.map.item)== null){ // TODO make this a routine cause we need to do it elsewhere // and if not, add it, then serialize the interactions! InteractionMgr.GetInstance().Add(newNode.map); InteractionMgr.GetInstance().SaveXML("Assets/Resources/XML/Interactions/Interactions.xml"); } } newNode.expanded = false; //looks better in the editor if itar closes when added children.Add(newNode); newNode = null; } GUILayout.EndHorizontal(); EditorGUILayout.Space(); if (newNode != null) newNode.ShowInspectorGUI (-1); // assuming this is sufficient for filling out the fields }