private void AddSubMenuItems(System.Windows.Forms.TreeNodeCollection parentCollection, MenuItem parent) { /* foreach (TreeNode item in parentCollection) * { * ToolMenuItemProperty menuItemProperty = (ToolMenuItemProperty)item.Tag; * ToolSubMenuItem newSubMenuItem = new ToolSubMenuItem(); * newSubMenuItem.ID = menuItemProperty.UniqueID; * newSubMenuItem.Text = menuItemProperty.Text; * newSubMenuItem.Align = menuItemProperty.Align; * * parent.SubMenu.ID = Utils.GetUniqueID("AME_"); * parent.SubMenu.SubMenuItems.Add(newSubMenuItem); * * if (item.Nodes.Count > 0) * AddSubMenuItems(item.Nodes, newSubMenuItem); * }*/ foreach (System.Windows.Forms.TreeNode item in parentCollection) { MenuItemProperty menuItemProperty = (MenuItemProperty)item.Tag; MenuItem newMenuItem = new MenuItem(); newMenuItem.ID = menuItemProperty.UniqueID; newMenuItem.Text = menuItemProperty.Text; newMenuItem.Align = menuItemProperty.Align; parent.SubMenu.ID = Utils.GetUniqueID("AME_"); parent.SubMenu.Items.Add(newMenuItem); if (item.Nodes.Count > 0) { AddSubMenuItems(item.Nodes, newMenuItem); } } }
private void _bAddChild_Click(object sender, System.EventArgs e) { string defaultNodeName = GetNextDefaultNodeName(); if (_tvMenu.SelectedNode != null) { System.Windows.Forms.TreeNode newNode = new System.Windows.Forms.TreeNode(defaultNodeName); MenuItemProperty menuItemProperty = new MenuItemProperty(); menuItemProperty.UniqueID = Utils.GetUniqueID("AME_"); menuItemProperty.Text = defaultNodeName; newNode.Tag = menuItemProperty; _tvMenu.SelectedNode.Nodes.Add(newNode); _tvMenu.SelectedNode.Expand(); _tvMenu.SelectedNode = _tvMenu.SelectedNode.LastNode; _tvMenu.Focus(); } if (_bRemoveNode.Enabled == false) { _bRemoveNode.Enabled = true; } }
private void AddMenuItems(System.Windows.Forms.TreeNodeCollection parentCollection) { foreach (System.Windows.Forms.TreeNode child in parentCollection) { MenuItemProperty menuItemProperty = (MenuItemProperty)child.Tag; MenuItem newMenuItem = new MenuItem(); newMenuItem.ID = menuItemProperty.UniqueID; newMenuItem.Text = menuItemProperty.Text; if (menuItemProperty.Align != HorizontalAlign.NotSet) { newMenuItem.Align = menuItemProperty.Align; } if (menuItemProperty.Height.Value > 0) { newMenuItem.Height = menuItemProperty.Height; } if (menuItemProperty.Width.Value > 0) { newMenuItem.Width = menuItemProperty.Width; } newMenuItem.SubMenu.ID = Utils.GetUniqueID("AME_"); if (menuItemProperty.Image != string.Empty) { newMenuItem.Image = menuItemProperty.Image; } if (menuItemProperty.ImageOver != string.Empty) { newMenuItem.ImageOver = menuItemProperty.ImageOver; } if (menuItemProperty.NavigateURL != string.Empty) { newMenuItem.NavigateURL = menuItemProperty.NavigateURL; } if (menuItemProperty.Target != string.Empty) { newMenuItem.Target = menuItemProperty.Target; } if (menuItemProperty.OnClickClient != string.Empty) { newMenuItem.OnClickClient = menuItemProperty.OnClickClient; } _menu.MenuItems.Add(newMenuItem); if (child.Nodes.Count > 0) { AddSubMenu(child.Nodes, newMenuItem); } } }
private MenuItemProperty ConvertToItemProperty(MenuItem source) { MenuItemProperty item = new MenuItemProperty(); item.Text = source.Text; item.UniqueID = source.ClientID; item.Align = source.Align; item.Width = source.Width; item.Height = source.Height; item.Image = source.Image; item.ImageOver = source.ImageOver; item.NavigateURL = source.NavigateURL; item.Target = source.Target; item.OnClickClient = source.OnClickClient; return(item); }
private void AddSubMenu(System.Windows.Forms.TreeNodeCollection parentCollection, MenuItem parent) { /*foreach (System.Windows.Forms.TreeNode item in parentCollection) * { * ToolMenuItemProperty menuItemProperty = (ToolMenuItemProperty)item.Tag; * ToolSubMenuItem newSubMenuItem = new ToolSubMenuItem(); * * if (menuItemProperty.Align != HorizontalAlign.NotSet) * newSubMenuItem.Align = menuItemProperty.Align; * if (menuItemProperty.Height.Value > 0) * newSubMenuItem.Height = menuItemProperty.Height; * if (menuItemProperty.Width.Value > 0) * newSubMenuItem.Width = menuItemProperty.Width; * if (menuItemProperty.Image != string.Empty) * newSubMenuItem.Image = menuItemProperty.Image; * if (menuItemProperty.ImageOver != string.Empty) * newSubMenuItem.ImageOver = menuItemProperty.ImageOver; * if (menuItemProperty.NavigateURL != string.Empty) * newSubMenuItem.NavigateURL = menuItemProperty.NavigateURL; * if (menuItemProperty.Target != string.Empty) * newSubMenuItem.Target = menuItemProperty.Target; * if (menuItemProperty.OnClick != string.Empty) * newSubMenuItem.OnClick = menuItemProperty.OnClick; * * newSubMenuItem.ID = menuItemProperty.UniqueID; * * newSubMenuItem.Text = menuItemProperty.Text; * newSubMenuItem.Align = menuItemProperty.Align; * * parent.SubMenu.ID = Utils.GetUniqueID("AME_"); * parent.SubMenu.SubMenuItems.Add(newSubMenuItem); * * if (item.Nodes.Count > 0) * AddSubMenuItems(item.Nodes, newSubMenuItem); * } */ foreach (System.Windows.Forms.TreeNode item in parentCollection) { MenuItemProperty menuItemProperty = (MenuItemProperty)item.Tag; MenuItem newMenuItem = new MenuItem(); if (menuItemProperty.Align != HorizontalAlign.NotSet) { newMenuItem.Align = menuItemProperty.Align; } if (menuItemProperty.Height.Value > 0) { newMenuItem.Height = menuItemProperty.Height; } if (menuItemProperty.Width.Value > 0) { newMenuItem.Width = menuItemProperty.Width; } if (menuItemProperty.Image != string.Empty) { newMenuItem.Image = menuItemProperty.Image; } if (menuItemProperty.ImageOver != string.Empty) { newMenuItem.ImageOver = menuItemProperty.ImageOver; } if (menuItemProperty.NavigateURL != string.Empty) { newMenuItem.NavigateURL = menuItemProperty.NavigateURL; } if (menuItemProperty.Target != string.Empty) { newMenuItem.Target = menuItemProperty.Target; } if (menuItemProperty.OnClickClient != string.Empty) { newMenuItem.OnClickClient = menuItemProperty.OnClickClient; } newMenuItem.ID = menuItemProperty.UniqueID; newMenuItem.Text = menuItemProperty.Text; newMenuItem.Align = menuItemProperty.Align; parent.SubMenu.ID = Utils.GetUniqueID("AME_"); parent.SubMenu.Items.Add(newMenuItem); if (item.Nodes.Count > 0) { AddSubMenuItems(item.Nodes, newMenuItem); } } }