public BookmarksTreeView(BookmarksFilter bookmarksFilter, BookmarksModel bookmarksModel, Configuration.ConfigBookmarksList bookmarksListSettings, WebBrowserTreeNodeToolTip webBrowserToolTip, IQueryParser queryParser, ICacheFileSystem cacheFileSystem, SearchHandler searchHandler) { InitializeComponent(); BookmarksFilter = bookmarksFilter; BookmarksModel = bookmarksModel; BookmarksListSettings = bookmarksListSettings; WebBrowserToolTip = webBrowserToolTip; QueryParser = queryParser; CacheFileSystem = cacheFileSystem; SearchHandler = searchHandler; treeView = new TreeViewEx(); treeViewContextMenu = new ContextMenu(); treeViewNodeSorter = new BookmarksTreeViewNodeSorter(); SuspendLayout(); // // // treeViewContextMenu.Tag = treeView; treeViewContextMenu.Popup += TreeViewContextMenu_Popup; // // // treeView.HideSelection = false; treeView.HotTracking = true; treeView.Dock = DockStyle.Fill; //treeView.TreeViewNodeSorter = new TreeViewNodeSorter(); treeView.Sorted = true; treeView.ContextMenu = treeViewContextMenu; treeView.NodeActivated += TreeView_NodeActivated; treeView.NodeSelected += TreeView_NodeSelected; treeView.AfterExpand += TreeView_AfterExpand; treeView.AfterCollapse += TreeView_AfterCollapse; treeView.ItemDrag += TreeView_ItemDrag; treeView.DragDrop += TreeView_DragDrop; treeView.DragOver += TreeView_DragOver; treeView.DragEnter += TreeView_DragEnter; treeView.AllowDrop = true; // // this // Controls.Add(treeView); BookmarksModel.FolderAdded += BookmarksModel_FolderAdded; bookmarksFilter.TextChanged += BookmarksFilter_TextChanged; ResumeLayout(false); }
static void SelectedItemProperty_Changed(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs e) { TreeViewEx targetObject = dependencyObject as TreeViewEx; if (targetObject != null) { TreeViewItem tvi = targetObject.FindItemNode(targetObject.SelectedItem) as TreeViewItem; if (tvi != null) { tvi.IsSelected = true; } } }
IRawElementProviderSimple[] ISelectionProvider.GetSelection() { List <IRawElementProviderSimple> list = new List <IRawElementProviderSimple>(); TreeViewEx treeView = (TreeViewEx)Owner; foreach (var item in treeView.GetTreeViewItemsFor(treeView.SelectedItems)) { list.Add(new TreeViewExItemAutomationPeer(item, this)); } return(list.ToArray()); }
private bool HasAnyCheckedNodes(TreeViewEx treeView) { int checkedCount = 0; IterateTreeNodes(treeView, (o, node) => { if (node.Checked) { checkedCount++; } }); return(checkedCount > 0); }
internal void Invalidate() { if (treeView == null || !treeView.IsHandleCreated) { return; } RectangleF bounds = Bounds; if (bounds != Rectangle.Empty) { // Include the focus rectangle. bounds = new Rectangle(0, (int)bounds.Y - 1, (int)bounds.Right + 2, (int)bounds.Height + 2); treeView.Invalidate(TreeViewEx.RectIFromRectF(bounds)); } }
// Be sure to call the base class constructor. public DragAdorner(TreeViewEx treeViewEx, DragContent content) : base(treeViewEx) { layer = AdornerLayer.GetAdornerLayer(treeViewEx); layer.Add(this); contentPresenter = new ContentPresenter(); contentPresenter.Content = content; Binding b = new Binding("DragTemplate"); b.Source = treeViewEx; b.Mode = BindingMode.OneWay; contentPresenter.SetBinding(ContentPresenter.ContentTemplateProperty, b); }
// UnCheck All... protected void OnUnCheckAllClick(object sender, EventArgs e) { if (this.UnCheckAllEvent == null) { TreeNodeEx treeNode = this.TreeNode; TreeViewEx treeView = treeNode.TreeView; treeView.BeginUpdate(); TreeViewHelpers.CheckBoxes.UnCheckAll(treeNode); treeView.EndUpdate(); } else { this.UnCheckAllEvent(this, new ContextMenuEventArgs <TreeNodeEx>(this.TreeNode)); } }
public BrowsingTreeView(BrowsingFilter browsingFilter, BrowsingModel browsingModel, Configuration.ConfigBrowsingList browsingListSettings, SearchHandler searchHandler, ISessionManager sessionManager, IQueryParser queryParser) { InitializeComponent(); BrowsingFilter = browsingFilter; BrowsingModel = browsingModel; BrowsingListSettings = browsingListSettings; SearchHandler = searchHandler; SessionManager = sessionManager; QueryParser = queryParser; treeView = new TreeViewEx(); treeViewContextMenu = new ContextMenu(); SuspendLayout(); // // // treeViewContextMenu.Tag = treeView; treeViewContextMenu.Popup += TreeViewContextMenu_Popup; // // // treeView.ContextMenu = treeViewContextMenu; treeView.HideSelection = false; treeView.HotTracking = true; treeView.Dock = DockStyle.Fill; treeView.TreeViewNodeSorter = new BrowsingTreeViewNodeSorter(BrowsingSortType.LastAccessTime, SortOrder.Descending); treeView.NodeActivated += TreeView_NodeActivated; treeView.NodeSelected += TreeView_NodeSelected; treeView.AfterExpand += TreeView_AfterExpand; treeView.AfterCollapse += TreeView_AfterCollapse; // // // Controls.Add(treeView); BrowsingFilter.SortTypeChanged += BrowsingFilter_SortTypeChanged; BrowsingFilter.SortOrderChanged += BrowsingFilter_SortOrderChanged; BrowsingFilter.TextChanged += BrowsingFilter_TextChanged; ResumeLayout(false); }
/// <summary> /// 设置TreeView选中节点 /// </summary> /// <param name="treeView"></param> /// <param name="selectStrName">选中节点name</param> public static void SelectTreeView(TreeViewEx treeView, string selectStrName) { treeView.Focus(); for (int i = 0; i < treeView.Nodes.Count; i++) { for (int j = 0; j < treeView.Nodes[i].Nodes.Count; j++) { if (treeView.Nodes[i].Nodes[j].Name == selectStrName) { treeView.SelectedNode = treeView.Nodes[i].Nodes[j];//选中 //treeView.Nodes[i].Nodes[j].Checked = true; treeView.Nodes[i].Expand();//展开父级 return; } } } }
// Collapse All... protected void OnCollapseAllClick(object sender, EventArgs e) { if (this.CollapseAllEvent == null) { TreeNodeEx treeNode = this.TreeNode; TreeViewEx treeView = treeNode.TreeView; treeView.BeginUpdate(); treeNode.Collapse(); treeView.SelectedNode = treeNode; treeNode.EnsureVisible(); treeView.EndUpdate(); } else { this.CollapseAllEvent(this, new ContextMenuEventArgs <TreeNodeEx>(this.TreeNode)); } }
protected override List <AutomationPeer> GetChildrenCore() { List <AutomationPeer> children = new List <AutomationPeer>(); TreeViewEx treeView = (TreeViewEx)Owner; for (int i = 0; i < treeView.Items.Count; i++) { TreeViewExItem child = treeView.ItemContainerGenerator.ContainerFromIndex(i) as TreeViewExItem; if (child == null) { continue; } children.Add(new TreeViewExItemAutomationPeer(child, this)); } return(children); }
/// <summary> /// 设置TreeView选中节点 /// </summary> /// <param name="treeView"></param> /// <param name="selectStrName">选中节点name</param> public static void SelectTreeView(TreeViewEx treeView, string selectStrName) { treeView.Focus(); for (int i = 0; i < treeView.Nodes.Count; i++) { for (int j = 0; j < treeView.Nodes[i].Nodes.Count; j++) { if (treeView.Nodes[i].Nodes[j].Name == selectStrName) { treeView.SelectedNode = treeView.Nodes[i].Nodes[j]; //选中 //treeView.Nodes[i].Nodes[j].Checked = true; treeView.Nodes[i].Expand(); //展开父级 return; } } } }
static public void UnCheckAll(TreeNodeEx treeNode) { lock (m_syncRoot) { TreeViewEx treeView = (TreeViewEx)treeNode.TreeView; if (treeView != null) { treeView.SuspendCheckEvents(); } CheckBoxes.UnCheckAll((TreeNode)treeNode); if (treeView != null) { treeView.InvokeTreeViewExNodesChecked(); treeView.ResumeCheckEvents(); } } }
private List <TreeNode> GetFlatList(TreeViewEx treeView) { List <TreeNode> flatList = new List <TreeNode>(); var treeIterator = new GenericTreeIterator <TreeNode>( treeNode => treeNode.Nodes.OfType <TreeNode>(), () => treeView.Nodes.OfType <TreeNode>()); treeIterator.IterateTree(false, null, delegate(GenericTreeIterationArgs <TreeNode> args) { if (!flatList.Contains(args.Current)) { flatList.Add(args.Current); } }); return(flatList); }
public LibraryTreeView(LibraryFilter libraryFilter, LibraryModel libraryModel, List <IArchiveWriter> archiveWriters, WebBrowserTreeNodeToolTip webBrowserToolTip, SearchHandler searchHandler, ICacheFileSystem cacheFileSystem) { InitializeComponent(); LibraryFilter = libraryFilter; LibraryModel = libraryModel; ArchiveWriters = archiveWriters; SearchHandler = searchHandler; CacheFileSystem = cacheFileSystem as CacheFileSystem; // lazy hack. WebBrowserToolTip = webBrowserToolTip; treeView = new TreeViewEx(); SuspendLayout(); // // // treeView.HideSelection = false; treeView.HotTracking = true; treeView.Dock = DockStyle.Fill; treeView.Sorted = true; treeView.TreeViewNodeSorter = new LibraryTreeViewNodeSorter(LibrarySortType.CreationTime, SortOrder.Descending); treeView.AfterSelect += TreeView_AfterSelect; treeView.NodeActivated += TreeView_NodeActivated; treeView.NodeContextMenuRequested += TreeView_NodeContextMenuRequested; // TODO: add this once I have sorting options //treeViewContextMenu = new ContextMenu(); //treeViewContextMenu.Popup += TreeViewContextMenu_Popup; //treeView.ContextMenu = treeViewContextMenu; // // this // Controls.Add(treeView); LibraryFilter.SortTypeChanged += LibraryFilter_SortTypeChanged; LibraryFilter.SortOrderChanged += LibraryFilter_SortOrderChanged; LibraryFilter.TextChanged += LibraryFilter_TextChanged; LibraryModel.Poll += LibraryModel_Poll; ResumeLayout(false); }
private void RemoveRecurse() { // Remove children. // FIXME: why? /*for (int i = 0; i < childCount; i++) { children[i].RemoveRecurse(); }*/ // Remove out of parent's children. for (int i = index; i < parent.childCount - 1; i++) { TreeNodeEx node = parent.children[i + 1]; node.index = i; parent.children[i] = node; } parent.childCount--; parent = null; treeView = null; }
private void PopulateFileTreeView(TreeViewEx fileView, List <Model.FileInfo> listOfFiles, char pathSeparator = '\\') { string subPathAgg; foreach (Model.FileInfo fileInfo in listOfFiles) { TreeNode lastNode = null; subPathAgg = string.Empty; var subPath = fileInfo.RelativePath.Split(pathSeparator); for (int index = 0; index < subPath.Length; index++) { subPathAgg += subPath[index] + pathSeparator; TreeNode foundNode; var isNodeFound = fileView.KeyNodes.TryGetValue(subPathAgg, out foundNode); if (isNodeFound == false) { if (lastNode == null) { lastNode = fileView.Nodes.Add(subPathAgg, subPath[index]); fileView.KeyNodes.Add(subPathAgg, lastNode); if (index == subPath.Length - 1) { lastNode.Tag = fileInfo; } } else { lastNode = lastNode.Nodes.Add(subPathAgg, subPath[index]); fileView.KeyNodes.Add(subPathAgg, lastNode); if (index == subPath.Length - 1) { lastNode.Tag = fileInfo; } } } else { lastNode = foundNode; } } } }
/// <summary> 当鼠标拖拽某节点时(两个控件的该事件都指向这个方法) /// </summary> void tvex_ItemDrag(object sender, ItemDragEventArgs e) { if (e.Item is TreeNode && e.Button == System.Windows.Forms.MouseButtons.Left && e.Item != null && sender is TreeViewEx) { //TreeView trv = sender as TreeView; //TreeNode node = e.Item as TreeNode; //if (node.Parent != null && trv.Tag != null) //{ // int value = Convert.ToInt32(trv.Tag); // MoveTo = (MoveTreeView)value; // DragNode = node; // NodeSource = trv; // trv.DoDragDrop(node, DragDropEffects.Move); //} TreeViewEx tv = sender as TreeViewEx; tv.DoDragDrop(e.Item, DragDropEffects.Copy); } }
public Selection(TreeViewEx treeView, ClassStatus status) { SelFiles = treeView.SelectedNodes.Select(s => s.Tag.ToString()).ToArray(); // Move files into different buckets based on what function needs to be done on them foreach (var s in SelFiles) { if (Opclass.ContainsKey(status.Ycode(s))) { Opclass[status.Ycode(s)].Add(s); } else { Opclass[status.Ycode(s)] = new List <string> { s } }; } } }
//将MenuStrip中的项按照层次加到TreeNode中 public void GetMenu(MenuStrip menuS)//public static void GetMenu(TreeView treeV, MenuStrip menuS) { int i = 0; //遍历menuStrip中的一级菜单项 foreach (ToolStripDropDownItem m1 in menuS.Items) { //循环添加一级菜单 treeView[i] = new TreeViewEx(); treeView[i].BorderStyle = System.Windows.Forms.BorderStyle.None; treeView[i].Dock = System.Windows.Forms.DockStyle.Fill; treeView[i].Name = "treeView1"; treeView[i].Size = new System.Drawing.Size(292, 266); treeView[i].TabIndex = 0; treeView[i].ImageList = imageList1;//sx treeView[i].ImageIndex = 0; treeView[i].SelectedImageIndex = 0; treeView[i].ShowLines = false; treeView[i].ShowNodeToolTips = true; treeView[i].FullRowSelect = true; treeView[i].HotTracking = true; treeView[i].ShowPlusMinus = false; // treeView[i].DoubleClick += new EventHandler(treeView1_DoubleClick);//双击 treeView[i].NodeMouseClick += new TreeNodeMouseClickEventHandler(treeView1_NodeMouseClick); if (m1.Enabled == true) { TreeNode node1 = treeView[i].Nodes.Add(m1.Name, m1.Text); //node1.Checked = true; node1.Text = ""; //隐藏根结点 node1.Tag = ""; node1.ImageIndex = 3; //根节点图标 node1.SelectedImageIndex = 3; //根节点图标 GetMenu(node1, m1); i++; } treeView[i - 1].ExpandAll(); } }
internal static void RemoveGroup(TreeViewEx tree, string group) { try { Rwl.AcquireWriterLock(5000); try { if (!tree.Nodes.ContainsKey(group)) { return; } var tngroup = tree.Nodes[group]; tree.BeginUpdate(); for (int i = tngroup.Nodes.Count - 1; i >= 0; i--) { var tn = tngroup.Nodes[i]; var contact = (Contact)tn.Tag; tn.Remove(); if (AppVars.Profile.Contacts.ContainsKey(contact.Name.ToLower())) { AppVars.Profile.Contacts.Remove(contact.Name.ToLower()); } } tngroup.Remove(); tree.EndUpdate(); AppVars.Profile.Save(); } finally { Rwl.ReleaseWriterLock(); } } catch (ApplicationException) { } }
private void PopulateRegTreeView(TreeViewEx regView, List <Model.RegInfo> listOfRegistryValues, char pathSeparator = '\\') { string subPathAgg; foreach (Model.RegInfo regItem in listOfRegistryValues) { TreeNode lastNode = null; subPathAgg = string.Empty; var tempKeyNodes = regItem.Key.Split(pathSeparator); for (int index = 0; index < tempKeyNodes.Length; index++) { subPathAgg += tempKeyNodes[index] + pathSeparator; TreeNode foundNode; var isNodeFound = regView.KeyNodes.TryGetValue(subPathAgg, out foundNode); if (isNodeFound == false) { if (lastNode == null) { lastNode = regView.Nodes.Add(subPathAgg, tempKeyNodes[index]); regView.KeyNodes.Add(subPathAgg, lastNode); } else { lastNode = lastNode.Nodes.Add(subPathAgg, tempKeyNodes[index]); regView.KeyNodes.Add(subPathAgg, lastNode); } } else { lastNode = foundNode; } } if (lastNode != null && subPathAgg != string.Empty) { var tempNode = lastNode.Nodes.Add(subPathAgg, string.Format("{0}={1}:{2}", regItem.ValueName, regItem.Kind, regItem.Value)); tempNode.Tag = regItem; } } }
public void PopulateSourceTreeView(TreeViewEx fileView, TreeViewEx regView) { if (_fileValues != null) { PopulateFileTreeView(fileView, _fileValues); if (fileView.Nodes.Count == 0) { fileView.Nodes.Add("Empty"); } } if (_regValues != null) { PopulateRegTreeView(regView, _regValues); if (regView.Nodes.Count == 0) { regView.Nodes.Add("Empty"); } } }
private void FrmDifferentList_Load(object sender, EventArgs e) { Core.LoadDBTable(this.gBoxSource, Data.SourceConnectionString, Data.SourceDataBase, Data.SourceTable); Core.LoadDBTable(this.gBoxDest, Data.DestConnectionString, Data.DestDataBase, Data.DestTable); Core.LoadTableField(Data.SourceConnectionString, Data.SourceTable, pBarSource); Core.LoadTableField(Data.DestConnectionString, Data.DestTable, pBarDest); #region 创建TreeView TvSource = new TreeViewEx(); TvSource.Name = "TvSource"; TvDestination = new TreeViewEx(); TvDestination.Name = "TvDestination"; this.gBoxSource.Controls.Add(TvSource); this.gBoxDest.Controls.Add(TvDestination); this.TvSource.Dock = DockStyle.Fill; this.TvDestination.Dock = DockStyle.Fill; this.TvSource.AfterExpand += new TreeViewEventHandler(TreeView_AfterExpand); this.TvDestination.AfterExpand += new TreeViewEventHandler(TreeView_AfterExpand); this.TvSource.AfterCollapse += new TreeViewEventHandler(TreeView_AfterCollapse); this.TvDestination.AfterCollapse += new TreeViewEventHandler(TreeView_AfterCollapse); this.TvSource.BeforeSelect += new TreeViewCancelEventHandler(TreeView_BeforeSelect); this.TvDestination.BeforeSelect += new TreeViewCancelEventHandler(TreeView_BeforeSelect); this.TvSource.AfterSelect += new TreeViewEventHandler(TreeView_AfterSelect); this.TvDestination.AfterSelect += new TreeViewEventHandler(TreeView_AfterSelect); this.TvSource.NodeMouseClick += new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick); this.TvDestination.NodeMouseClick += new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick); TvSource.ContextMenuStrip = this.MenuStrip; TvDestination.ContextMenuStrip = this.MenuStrip; #endregion Core.DataBaseCompare(this.pBarSource, this.pBarDest); }
/// <summary> /// 设置TreeView选中节点 /// </summary> /// <param name="treeView"></param> /// <param name="selectStrName">选中节点name</param> public static void SelectTreeView(TreeViewEx treeView, string selectStrName) { treeView.Focus(); TreeNode[] selectnode = treeView.Nodes.Find(IsNullToString(selectStrName), true); if (selectnode != null && selectnode.Length > 0) { treeView.SelectedNode = selectnode[0];//选中 if (selectnode[0].Parent != null) selectnode[0].Parent.Expand();//展开父级 } //for (int i = 0; i < treeView.Nodes.Count; i++) //{ // for (int j = 0; j < treeView.Nodes[i].Nodes.Count; j++) // { // if (treeView.Nodes[i].Nodes[j].Name == selectStrName) // { // treeView.SelectedNode = treeView.Nodes[i].Nodes[j];//选中 // //treeView.Nodes[i].Nodes[j].Checked = true; // treeView.Nodes[i].Expand();//展开父级 // return; // } // } //} }
public TreeNodeCollectionEx(TreeViewEx treeView) { this.treeView = treeView; }
/// <summary>添加菜单控件 /// </summary> /// <param name="LeftMemuName">菜单名称</param> /// <param name="STR_CS_LEFT_MEMU_NAME">fun_id</param> /// <param name="childList">二级菜单列表</param> /// <param name="next_top">下一个坐标top</param> /// <param name="pHeight">二级菜单高度-展开的</param> /// <param name="tHeight">菜单列表高度-展开的高度 三级菜单</param> /// <param name="SecondMenu">二级菜单DataRow</param> private void LeftMenu(string LeftMemuName, string STR_CS_LEFT_MEMU_NAME, DataTable childList, int next_top, int pHeight, int tHeight, DataRow SecondMenu) { PanelEx Pleft_panel_tiem = new PanelEx(); //二级菜单Panel Pleft_panel_tiem.Name = STR_CS_LEFT_MEMU_NAME; Pleft_panel_tiem.BackColor = Color.FromArgb(219, 236, 246);//.White;//.Silver; //Pleft_panel_tiem.Location = new Point(0, 0); Pleft_panel_tiem.Width = LeftWidth; Pleft_panel_tiem.Height = pHeight; Pleft_panel_tiem.BorderStyle = BorderStyle.FixedSingle; Pleft_panel_tiem.BorderWidth = 0; Pleft_panel_tiem.Top = next_top; Pleft_panel_tiem.Left = 0; //plecd.Anchor = AnchorStyles.Left; this.Controls.Add(Pleft_panel_tiem); PanelEx Pleft_panel_tiem_top = new PanelEx(); Pleft_panel_tiem_top.Name = "top_" + STR_CS_LEFT_MEMU_NAME; Pleft_panel_tiem_top.BackColor = Color.FromArgb(233, 243, 253);// Color.LightSkyBlue; Pleft_panel_tiem_top.BorderWidth = 1; Pleft_panel_tiem_top.BorderColor = Color.FromArgb(190, 213, 243); Pleft_panel_tiem_top.Location = new Point(0, 0); Pleft_panel_tiem_top.Width = LeftWidth; Pleft_panel_tiem_top.Height = item_top_height; Pleft_panel_tiem_top.Tag = SecondMenu; Pleft_panel_tiem_top.BorderStyle = BorderStyle.FixedSingle; if (childList != null && childList.Rows.Count == 0) { Pleft_panel_tiem_top.Click += new EventHandler(Pleft_panel_tiem_top_Click); } Pleft_panel_tiem.Controls.Add(Pleft_panel_tiem_top); var image = new PictureBox(); image.Location = new Point(4,6); image.Image = SkinAssistant.GetResourcesImage(STR_CS_LEFT_MEMU_NAME, true); image.SizeMode = PictureBoxSizeMode.AutoSize; Pleft_panel_tiem_top.Controls.Add(image); Label lbl = new Label(); //菜单名称 lbl.Name = "lbl_" + STR_CS_LEFT_MEMU_NAME; lbl.ForeColor = Color.FromArgb(20, 129, 194); lbl.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); lbl.Cursor = Cursors.Default; lbl.BackColor = Color.Transparent; lbl.AutoSize = true; lbl.Left = 16; lbl.Top = 6; lbl.Text = LeftMemuName; //菜单名 lbl.Tag = SecondMenu; ; if (childList != null && childList.Rows.Count == 0) { lbl.Click += new EventHandler(lbl_Click); } Pleft_panel_tiem_top.Controls.Add(lbl); if (childList != null && childList.Rows.Count == 0) { PictureBox pb = new PictureBox(); pb.Name = "pb_" + STR_CS_LEFT_MEMU_NAME; pb.Width = 24; pb.Height = 24; pb.Left = LeftWidth - pb.Width - 2; pb.Top = 3; if (STR_CS_LEFT_MEMU_NAME == str_Curr_Item) { pb.Image = null; } else { pb.Image = null; } Pleft_panel_tiem_top.Controls.Add(pb); } else if (childList != null && childList.Rows.Count > 0) { ServiceStationClient.ComponentUI.ImageButton ibtn = new ImageButton(); //展开折叠 ibtn.Name = "ibtn_" + STR_CS_LEFT_MEMU_NAME; ibtn.Cursor = Cursors.Hand; ibtn.Width = 24; ibtn.Height = 24; ibtn.Left = LeftWidth - ibtn.Width - 2; ibtn.Top = 3; if (STR_CS_LEFT_MEMU_NAME == str_Curr_Item) { ibtn.Tag = "1"; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_delete; } else { ibtn.Tag = "0"; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_add; } ibtn.Click += new EventHandler(ibtn_Click); Pleft_panel_tiem_top.Controls.Add(ibtn); TreeViewEx tvex = new TreeViewEx(); tvex.Name = "tv_" + STR_CS_LEFT_MEMU_NAME; tvex.ForeColor = Color.FromArgb(20, 129, 194); tvex.Indent = 8; tvex.ItemHeight = 21; tvex.Location = new Point(0, Pleft_panel_tiem_top.Height); tvex.Width = LeftWidth; tvex.Height = tHeight; tvex.BorderStyle = BorderStyle.None; tvex.Scrollable = true; tvex.ShowLines = false; tvex.Cursor = System.Windows.Forms.Cursors.Hand; tvex.ImageList = treeImage; Pleft_panel_tiem.Controls.Add(tvex); if (childList != null && childList.Rows.Count > 0) { #region modify by kord //foreach (DataRow fun in childList.Rows) //{ // TreeNode node = new TreeNode(); // node.Tag = fun; // node.Text = fun["fun_name"].ToString(); // node.Name = fun["fun_id"].ToString(); // if (fun["fun_img"] != DBNull.Value && fun["fun_img"].ToString().Trim() != "") // { // treeImage.Images.Add(fun["fun_img"].ToString(), (Image)ServiceStationClient.Skin.Properties.Resources.ResourceManager.GetObject(fun["fun_img"].ToString())); // node.ImageKey = fun["fun_img"].ToString(); // node.SelectedImageKey = fun["fun_img"].ToString(); // } // tvex.Nodes.Add(node); //} foreach (DataRow fun in childList.Rows) { TreeNode node = new TreeNode(); node.Tag = fun; node.Text = fun["fun_name"].ToString(); node.Name = fun["fun_id"].ToString(); if (fun["fun_img"] != DBNull.Value && fun["fun_img"].ToString().Trim() != "") { treeImage.Images.Add(fun["fun_img"].ToString(), ServiceStationClient.Skin.SkinAssistant.GetResourcesImage(fun["fun_img"], true)); node.ImageKey = fun["fun_img"].ToString(); node.SelectedImageKey = fun["fun_img"].ToString(); } tvex.Nodes.Add(node); } #endregion } //tvex.ItemDrag += new ItemDragEventHandler(tvex_ItemDrag); tvex.NodeMouseClick += new TreeNodeMouseClickEventHandler(tvex_NodeMouseClick); } }
public TreeViewExAutomationPeer(TreeViewEx owner) : base(owner) { }
/// <summary> /// 左侧菜单状态 折叠 展开 选中 未选 /// </summary> /// <param name="pname">展开的功能名称name(二级菜单)</param> /// <param name="threeMenu">三级菜单</param> public void LeftMenuState(string pname, string threeMenu) { int Pleft_panelHeight = panel_MainHeight; //panel的高度 if (this.Controls.Count > 0) { int Pleft_panel_count = this.Controls.Count; // -1; //二级菜单个数 int Pleft_panel_item_height = Pleft_panelHeight - (Pleft_panel_count * item_top_height) + item_top_height; //二级菜单高度-展开的 int tvex_height = Pleft_panel_item_height - item_top_height; //菜单列表高度-展开的 int next_top = 0; int i = 0; foreach (PanelEx ctl in this.Controls) { PanelEx ctl_top = ctl.Controls.Find("top_" + ctl.Name, true)[0] as PanelEx; ctl.Width = LeftWidth; ctl_top.Width = LeftWidth; //ctl_top.Height=item_top_height; if (ctl.Controls.Find("ibtn_" + ctl.Name, true).Count() > 0) { ImageButton ibtn = ctl_top.Controls.Find("ibtn_" + ctl.Name, true)[0] as ImageButton; TreeViewEx tvex = ctl.Controls.Find("tv_" + ctl.Name, true)[0] as TreeViewEx; ibtn.Left = LeftWidth - ibtn.Width - 1; tvex.Width = LeftWidth; if (ctl.Name == pname) { ctl.Height = Pleft_panel_item_height; tvex.Visible = true; tvex.Height = tvex_height; if (tvex.GetNodeCount(true) > 0) { for (int j = 0; j < tvex.Nodes.Count; j++) { if (tvex.Nodes[j].Name == threeMenu) { tvex.Focus(); //tvex.Nodes[j].BackColor = Color.FromArgb(51, 153, 255); tvex.SelectedNode = tvex.Nodes[j]; //选中 break; } //else //{ // //未选中 // tvex.Nodes[j].BackColor = Color.White; //} } } ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_delete; ibtn.Tag = "1"; } else { if (pname == "" && i == 0) { ctl.Height = Pleft_panel_item_height; tvex.Visible = true; tvex.Height = tvex_height; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_delete; ibtn.Tag = "1"; } else { ctl.Height = item_top_height; tvex.Visible = true; tvex.Height = 0; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_add; ibtn.Tag = "0"; } } } else { ctl.Height = item_top_height; PictureBox pb = ctl_top.Controls.Find("pb_" + ctl.Name, true)[0] as PictureBox; pb.Left = LeftWidth - pb.Width - 1; if (ctl.Name == pname) { pb.Image = null; //ctl_top.BackColor = Color.FromArgb(255, 255, 0, 0); } else if (ctl.Name == threeMenu) { pb.Image = null; //ctl_top.BackColor = Color.FromArgb(255, 255, 0, 0); } else { pb.Image = null; //ctl_top.BackColor = Color.FromArgb(233, 243, 253); } ctl_top.Refresh(); } ctl.Top = next_top; next_top += ctl.Height; i++; } } }
/// <summary> 左侧菜单状态 折叠 展开 选中 未选 点击一级菜单使用此函数 /// </summary> /// <param name="pname">展开的功能名称name(二级菜单)</param> /// <param name="threeMenu">三级菜单</param> /// <param name="oldThreeMenu">原三级菜单</param> public void LeftMenuState(string pname, string threeMenu, string oldThreeMenu) { if (oldThreeMenu == "") { LeftMenuState(pname, threeMenu); } else { if (IsSameMenu(oldThreeMenu, SYSModel.clsSysConfig.STR_CURR_MAINMEMU)) { LeftMenuState(pname, threeMenu); } else { int Pleft_panelHeight = panel_MainHeight; //panel的高度 if (this.Controls.Count > 0) { int Pleft_panel_count = this.Controls.Count; // -1; //二级菜单个数 int Pleft_panel_item_height = Pleft_panelHeight - (Pleft_panel_count * item_top_height) + item_top_height; //二级菜单高度-展开的 int tvex_height = Pleft_panel_item_height - item_top_height; //菜单列表高度-展开的 int next_top = 0; int i = 0; foreach (PanelEx ctl in this.Controls) { PanelEx ctl_top = ctl.Controls.Find("top_" + ctl.Name, true)[0] as PanelEx; ctl.Width = LeftWidth; ctl_top.Width = LeftWidth; //ctl_top.Height = item_top_height; if (ctl.Controls.Find("ibtn_" + ctl.Name, true).Count() > 0) { ImageButton ibtn = ctl_top.Controls.Find("ibtn_" + ctl.Name, true)[0] as ImageButton; TreeViewEx tvex = ctl.Controls.Find("tv_" + ctl.Name, true)[0] as TreeViewEx; ibtn.Left = LeftWidth - ibtn.Width - 1; tvex.Width = LeftWidth; if (i == 0) { ctl.Height = Pleft_panel_item_height; tvex.Visible = true; tvex.Height = tvex_height; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_delete; ibtn.Tag = "1"; } else { ctl.Height = item_top_height; tvex.Visible = true; tvex.Height = 0; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_add; ibtn.Tag = "0"; } } else { //ctl_top.BackColor = Color.FromArgb(233, 243, 253); PictureBox pb = ctl_top.Controls.Find("pb_" + ctl.Name, true)[0] as PictureBox; pb.Left = LeftWidth - pb.Width - 1; ctl_top.Refresh(); } ctl.Top = next_top; next_top += ctl.Height; i++; } } } } }
/// <summary>添加菜单控件 /// </summary> /// <param name="LeftMemuName">菜单名称</param> /// <param name="STR_CS_LEFT_MEMU_NAME">fun_id</param> /// <param name="childList">二级菜单列表</param> /// <param name="next_top">下一个坐标top</param> /// <param name="pHeight">二级菜单高度-展开的</param> /// <param name="tHeight">菜单列表高度-展开的高度 三级菜单</param> /// <param name="SecondMenu">二级菜单DataRow</param> private void LeftMenu(string LeftMemuName, string STR_CS_LEFT_MEMU_NAME, DataTable childList, int next_top, int pHeight, int tHeight, DataRow SecondMenu) { PanelEx Pleft_panel_tiem = new PanelEx(); //二级菜单Panel Pleft_panel_tiem.Name = STR_CS_LEFT_MEMU_NAME; Pleft_panel_tiem.BackColor = Color.FromArgb(219, 236, 246); //.White;//.Silver; //Pleft_panel_tiem.Location = new Point(0, 0); Pleft_panel_tiem.Width = LeftWidth; Pleft_panel_tiem.Height = pHeight; Pleft_panel_tiem.BorderStyle = BorderStyle.FixedSingle; Pleft_panel_tiem.BorderWidth = 0; Pleft_panel_tiem.Top = next_top; Pleft_panel_tiem.Left = 0; //plecd.Anchor = AnchorStyles.Left; this.Controls.Add(Pleft_panel_tiem); PanelEx Pleft_panel_tiem_top = new PanelEx(); Pleft_panel_tiem_top.Name = "top_" + STR_CS_LEFT_MEMU_NAME; Pleft_panel_tiem_top.BackColor = Color.FromArgb(233, 243, 253); // Color.LightSkyBlue; Pleft_panel_tiem_top.BorderWidth = 1; Pleft_panel_tiem_top.BorderColor = Color.FromArgb(190, 213, 243); Pleft_panel_tiem_top.Location = new Point(0, 0); Pleft_panel_tiem_top.Width = LeftWidth; Pleft_panel_tiem_top.Height = item_top_height; Pleft_panel_tiem_top.Tag = SecondMenu; Pleft_panel_tiem_top.BorderStyle = BorderStyle.FixedSingle; if (childList != null && childList.Rows.Count == 0) { Pleft_panel_tiem_top.Click += new EventHandler(Pleft_panel_tiem_top_Click); } Pleft_panel_tiem.Controls.Add(Pleft_panel_tiem_top); var image = new PictureBox(); image.Location = new Point(4, 6); image.Image = SkinAssistant.GetResourcesImage(STR_CS_LEFT_MEMU_NAME, true); image.SizeMode = PictureBoxSizeMode.AutoSize; Pleft_panel_tiem_top.Controls.Add(image); Label lbl = new Label(); //菜单名称 lbl.Name = "lbl_" + STR_CS_LEFT_MEMU_NAME; lbl.ForeColor = Color.FromArgb(20, 129, 194); lbl.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); lbl.Cursor = Cursors.Default; lbl.BackColor = Color.Transparent; lbl.AutoSize = true; lbl.Left = 16; lbl.Top = 6; lbl.Text = LeftMemuName; //菜单名 lbl.Tag = SecondMenu;; if (childList != null && childList.Rows.Count == 0) { lbl.Click += new EventHandler(lbl_Click); } Pleft_panel_tiem_top.Controls.Add(lbl); if (childList != null && childList.Rows.Count == 0) { PictureBox pb = new PictureBox(); pb.Name = "pb_" + STR_CS_LEFT_MEMU_NAME; pb.Width = 24; pb.Height = 24; pb.Left = LeftWidth - pb.Width - 2; pb.Top = 3; if (STR_CS_LEFT_MEMU_NAME == str_Curr_Item) { pb.Image = null; } else { pb.Image = null; } Pleft_panel_tiem_top.Controls.Add(pb); } else if (childList != null && childList.Rows.Count > 0) { ServiceStationClient.ComponentUI.ImageButton ibtn = new ImageButton(); //展开折叠 ibtn.Name = "ibtn_" + STR_CS_LEFT_MEMU_NAME; ibtn.Cursor = Cursors.Hand; ibtn.Width = 24; ibtn.Height = 24; ibtn.Left = LeftWidth - ibtn.Width - 2; ibtn.Top = 3; if (STR_CS_LEFT_MEMU_NAME == str_Curr_Item) { ibtn.Tag = "1"; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_delete; } else { ibtn.Tag = "0"; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.ico_add; } ibtn.Click += new EventHandler(ibtn_Click); Pleft_panel_tiem_top.Controls.Add(ibtn); TreeViewEx tvex = new TreeViewEx(); tvex.Name = "tv_" + STR_CS_LEFT_MEMU_NAME; tvex.ForeColor = Color.FromArgb(20, 129, 194); tvex.Indent = 8; tvex.ItemHeight = 21; tvex.Location = new Point(0, Pleft_panel_tiem_top.Height); tvex.Width = LeftWidth; tvex.Height = tHeight; tvex.BorderStyle = BorderStyle.None; tvex.Scrollable = true; tvex.ShowLines = false; tvex.Cursor = System.Windows.Forms.Cursors.Hand; tvex.ImageList = treeImage; Pleft_panel_tiem.Controls.Add(tvex); if (childList != null && childList.Rows.Count > 0) { #region modify by kord //foreach (DataRow fun in childList.Rows) //{ // TreeNode node = new TreeNode(); // node.Tag = fun; // node.Text = fun["fun_name"].ToString(); // node.Name = fun["fun_id"].ToString(); // if (fun["fun_img"] != DBNull.Value && fun["fun_img"].ToString().Trim() != "") // { // treeImage.Images.Add(fun["fun_img"].ToString(), (Image)ServiceStationClient.Skin.Properties.Resources.ResourceManager.GetObject(fun["fun_img"].ToString())); // node.ImageKey = fun["fun_img"].ToString(); // node.SelectedImageKey = fun["fun_img"].ToString(); // } // tvex.Nodes.Add(node); //} foreach (DataRow fun in childList.Rows) { TreeNode node = new TreeNode(); node.Tag = fun; node.Text = fun["fun_name"].ToString(); node.Name = fun["fun_id"].ToString(); if (fun["fun_img"] != DBNull.Value && fun["fun_img"].ToString().Trim() != "") { treeImage.Images.Add(fun["fun_img"].ToString(), ServiceStationClient.Skin.SkinAssistant.GetResourcesImage(fun["fun_img"], true)); node.ImageKey = fun["fun_img"].ToString(); node.SelectedImageKey = fun["fun_img"].ToString(); } tvex.Nodes.Add(node); } #endregion } //tvex.ItemDrag += new ItemDragEventHandler(tvex_ItemDrag); tvex.NodeMouseClick += new TreeNodeMouseClickEventHandler(tvex_NodeMouseClick); } }
public DefaultTreeViewExContextMenuStripProvider(TreeViewEx treeView) { this.treeView = treeView; }
/// <summary> Assign new TreeView for the statements to the mission</summary> public void AssignStatementTreeView(TreeViewEx value = null) { if (TreeViewStatements != null) { TreeViewStatements.NodesClear(); TreeViewStatements.IsFolder_Reset(); TreeViewStatements.IsAllowedToHaveRelation_Reset(); TreeViewStatements.NodeMoved -= _E_statementTV_NodeMoved; TreeViewStatements.AfterSelect -= _E_statementTV_AfterSelect; TreeViewStatements.KeyDown -= _E_statementTV_KeyDown; TreeViewStatements.MouseDoubleClick -= _E_statementTV_MouseDoubleClick; } TreeViewStatements = null; if (value == null) return; TreeViewStatements = value; TreeViewStatements.IsFolder = (TreeNode ii) => (ii.Tag is string); TreeViewStatements.IsAllowedToHaveRelation = TreeViewStatements_IsAllowedToHaveRelation; TreeViewStatements.NodeMoved += _E_statementTV_NodeMoved; TreeViewStatements.AfterSelect += _E_statementTV_AfterSelect; TreeViewStatements.KeyDown += _E_statementTV_KeyDown; TreeViewStatements.MouseDoubleClick += _E_statementTV_MouseDoubleClick; }
/// <summary> Assign new TreeView for the nodes to the mission</summary> public void AssignNodeTreeView(TreeViewEx value = null) { if (TreeViewNodes != null) { TreeViewNodes.NodesClear(); TreeViewNodes.IsFolder_Reset(); TreeViewNodes.IsAllowedToHaveRelation_Reset(); TreeViewNodes.NodeMoved -= _E_nodeTV_NodeMoved; TreeViewNodes.AfterLabelEdit -= _E_nodeTV_AfterLabelEdit; TreeViewNodes.AfterSelect -= _E_nodeTV_AfterSelect; TreeViewNodes.KeyDown -= _E_nodeTV_KeyDown; TreeViewNodes.AfterExpand -= _E_nodeTV_AfterExpand; TreeViewNodes.AfterCollapse -= _E_nodeTV_AfterCollapse; } TreeViewNodes = null; if (value == null) return; TreeViewNodes = value; TreeViewNodes.IsFolder = (TreeNode ii) => ii.Tag != null && ii.Tag.GetType() == typeof(MissionNode_Folder); TreeViewNodes.IsAllowedToHaveRelation = TreeViewNodes_IsAllowedToHaveRelation; TreeViewNodes.NodeMoved += _E_nodeTV_NodeMoved; TreeViewNodes.AfterLabelEdit += _E_nodeTV_AfterLabelEdit; TreeViewNodes.AfterSelect += _E_nodeTV_AfterSelect; TreeViewNodes.KeyDown += _E_nodeTV_KeyDown; TreeViewNodes.AfterExpand += _E_nodeTV_AfterExpand; TreeViewNodes.AfterCollapse += _E_nodeTV_AfterCollapse; }
/// <summary> /// 添加菜单控件 /// </summary> /// <param name="LeftMemuName">菜单名称</param> /// <param name="STR_CS_LEFT_MEMU_NAME">fun_id</param> /// <param name="childList">二级菜单列表</param> /// <param name="next_top">下一个坐标top</param> /// <param name="pHeight">二级菜单高度-展开的</param> /// <param name="tHeight">菜单列表高度-展开的高度 三级菜单</param> /// <param name="SecondMenu">二级菜单DataRow</param> private void LeftMenu(string LeftMemuName, string STR_CS_LEFT_MEMU_NAME, DataTable childList, int next_top, int pHeight, int tHeight, DataRow SecondMenu) { Panel Pleft_panel_tiem = new Panel(); //二级菜单Panel Pleft_panel_tiem.Name = STR_CS_LEFT_MEMU_NAME; Pleft_panel_tiem.BackColor = Color.FromArgb(219, 236, 246);//.White;//.Silver; Pleft_panel_tiem.Cursor = Cursors.Default; Pleft_panel_tiem.Width = LeftWidth + 3; Pleft_panel_tiem.Height = pHeight; Pleft_panel_tiem.Location = new Point(0, next_top); this.Controls.Add(Pleft_panel_tiem); PanelEx Pleft_panel_tiem_top = new PanelEx(); Pleft_panel_tiem_top.Name = "top_" + STR_CS_LEFT_MEMU_NAME; Pleft_panel_tiem_top.BackColor = _normalColor; Pleft_panel_tiem_top.BorderWidth = 1; Pleft_panel_tiem_top.BorderColor = Color.FromArgb(190, 213, 243); if (next_top < 0) { Pleft_panel_tiem_top.Location = new Point(-1, -1); } else { Pleft_panel_tiem_top.Location = new Point(-1, 0); } Pleft_panel_tiem_top.Height = item_top_height; Pleft_panel_tiem_top.Width = LeftWidth + 3; Pleft_panel_tiem_top.Tag = SecondMenu; Pleft_panel_tiem_top.BorderStyle = BorderStyle.FixedSingle; if (childList != null && childList.Rows.Count == 0) { Pleft_panel_tiem_top.Click += new EventHandler(Pleft_panel_tiem_top_Click); } else { Pleft_panel_tiem_top.Click += new EventHandler(ibtn_Click); } Pleft_panel_tiem.Controls.Add(Pleft_panel_tiem_top); Label lbl = new Label(); //菜单名称 lbl.Name = "lbl_" + STR_CS_LEFT_MEMU_NAME; lbl.ForeColor = Color.FromArgb(20, 129, 194); lbl.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); lbl.Cursor = Cursors.Default; lbl.BackColor = Color.Transparent; lbl.AutoSize = true; lbl.Left = 16; lbl.Top = 7; lbl.Text = LeftMemuName; //菜单名 lbl.Tag = SecondMenu;; if (childList != null && childList.Rows.Count == 0) { lbl.Click += new EventHandler(lbl_Click); } else { lbl.Click += new EventHandler(ibtn_Click); } Pleft_panel_tiem_top.Controls.Add(lbl); if (childList != null && childList.Rows.Count == 0) { //PictureBox pb = new PictureBox(); //pb.Name = "pb_" + STR_CS_LEFT_MEMU_NAME; //pb.Width = 10; //pb.Height = 10; //pb.Left = LeftWidth - pb.Width - 5; //pb.Top = 10; //pb.BackColor = Color.Transparent; //if (STR_CS_LEFT_MEMU_NAME == str_Curr_Item) //{ // pb.Image = iChecked; //} //else //{ // pb.Image = iNoChecked; //} //Pleft_panel_tiem_top.Controls.Add(pb); } else if (childList != null && childList.Rows.Count > 0) { ServiceStationClient.ComponentUI.ImageButton ibtn = new ImageButton(); //展开折叠 ibtn.Name = "ibtn_" + STR_CS_LEFT_MEMU_NAME; ibtn.Cursor = Cursors.Hand; ibtn.Width = 10; ibtn.Height = 10; ibtn.BackColor = Color.Transparent; //ibtn.Left = LeftWidth - ibtn.Width - 125; ibtn.Left = LeftWidth - ibtn.Width - 5; ibtn.Top = 10; if (STR_CS_LEFT_MEMU_NAME == str_Curr_Item) { Pleft_panel_tiem_top.Tag = "1"; lbl.Tag = "1"; ibtn.Tag = "1"; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Collapse_V; } else { Pleft_panel_tiem_top.Tag = "0"; lbl.Tag = "0"; ibtn.Tag = "0"; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Expand_V; } ibtn.Click += new EventHandler(ibtn_Click); Pleft_panel_tiem_top.Controls.Add(ibtn); TreeViewEx tvex = new TreeViewEx(); tvex.Name = "tv_" + STR_CS_LEFT_MEMU_NAME; tvex.ForeColor = Color.FromArgb(20, 129, 194); tvex.Indent = 8; tvex.ItemHeight = 25; tvex.Location = new Point(0, Pleft_panel_tiem_top.Height); tvex.Width = LeftWidth + 3; tvex.Height = tHeight; tvex.BorderStyle = BorderStyle.None; tvex.Scrollable = true; tvex.ShowLines = false; tvex.Cursor = System.Windows.Forms.Cursors.Hand; tvex.ImageList = treeImage; Pleft_panel_tiem.Controls.Add(tvex); if (childList != null && childList.Rows.Count > 0) { foreach (DataRow fun in childList.Rows) { TreeNode node = new TreeNode(); node.Tag = fun; node.Text = fun["fun_name"].ToString(); node.Name = fun["fun_id"].ToString(); if (fun["fun_img"] != DBNull.Value && fun["fun_img"].ToString().Trim() != "") { treeImage.Images.Add(fun["fun_img"].ToString(), ServiceStationClient.Skin.SkinAssistant.GetResourcesImage(fun["fun_img"], true)); node.ImageKey = fun["fun_img"].ToString(); node.SelectedImageKey = fun["fun_img"].ToString(); } tvex.Nodes.Add(node); } } tvex.ItemDrag += new ItemDragEventHandler(tvex_ItemDrag); tvex.NodeMouseClick += new TreeNodeMouseClickEventHandler(tvex_NodeMouseClick); } }
public Mission() { TreeViewNodes = null; TreeViewStatements = null; FlowLayoutPanelMain = null; FormMain = null; LabelMain = null; StatusStripMain = null; ToolStripObjectsTotal = null; ContextMenuStripForLabels = null; AssignFlowPanel(); AssignNodeTreeView(); AssignStatementTreeView(); AssignForm(); AssignLabel(); AssignStatusToolStrip(); AssignContextMenuStripForLabels(); Dependencies = new DependencyGraph(); AmountOfMissionEndStatements = 0; AmountOfCreatePlayerStatements = 0; VariableSetNames = new List<string>(); VariableCheckNames = new List<string>(); VariableCheckLocations = new Dictionary<string, List<MissionNode>>(); TimerSetNames = new List<string>(); TimerCheckNames = new List<string>(); AllCreatedObjectNames = new List<string>(); VariableNames = new List<string>(); VariableNameHeaders = new List<string>(); TimerNames = new List<string>(); TimerNameHeaders = new List<string>(); NamedObjectNames = new Dictionary<string,List<string>>(); NamedObjectNames.Add("anomaly", new List<string>()); NamedObjectNames.Add("blackHole", new List<string>()); NamedObjectNames.Add("enemy", new List<string>()); NamedObjectNames.Add("neutral", new List<string>()); NamedObjectNames.Add("genericMesh", new List<string>()); NamedObjectNames.Add("player", new List<string>()); NamedObjectNames.Add("station", new List<string>()); NamedObjectNames.Add("monster", new List<string>()); NamedObjectNames.Add("whale", new List<string>()); UndoStack = new Stack<MissionSavedState>(); RedoStack = new Stack<MissionSavedState>(); EventCount = 0; SuppressSelectionEvents = false; SupressSelectionEvents = false; SupressExpandCollapseEvents = false; UpdateSemaphoreCounter = 0; }
/// <summary> /// 添加菜单控件 /// </summary> /// <param name="LeftMemuName">菜单名称</param> /// <param name="STR_CS_LEFT_MEMU_NAME">fun_id</param> /// <param name="childList">二级菜单列表</param> /// <param name="next_top">下一个坐标top</param> /// <param name="pHeight">二级菜单高度-展开的</param> /// <param name="tHeight">菜单列表高度-展开的高度 三级菜单</param> /// <param name="SecondMenu">二级菜单DataRow</param> private void LeftMenu(string LeftMemuName, string STR_CS_LEFT_MEMU_NAME, DataTable childList, int next_top, int pHeight, int tHeight, DataRow SecondMenu) { Panel Pleft_panel_tiem = new Panel(); //二级菜单Panel Pleft_panel_tiem.Name = STR_CS_LEFT_MEMU_NAME; Pleft_panel_tiem.BackColor = Color.FromArgb(219, 236, 246);//.White;//.Silver; Pleft_panel_tiem.Cursor = Cursors.Default; Pleft_panel_tiem.Width = LeftWidth + 3; Pleft_panel_tiem.Height = pHeight; Pleft_panel_tiem.Location = new Point(0, next_top); this.Controls.Add(Pleft_panel_tiem); PanelEx Pleft_panel_tiem_top = new PanelEx(); Pleft_panel_tiem_top.Name = "top_" + STR_CS_LEFT_MEMU_NAME; Pleft_panel_tiem_top.BackColor = _normalColor; Pleft_panel_tiem_top.BorderWidth = 1; Pleft_panel_tiem_top.BorderColor = Color.FromArgb(190, 213, 243); if (next_top < 0) { Pleft_panel_tiem_top.Location = new Point(-1, -1); } else { Pleft_panel_tiem_top.Location = new Point(-1, 0); } Pleft_panel_tiem_top.Height = item_top_height; Pleft_panel_tiem_top.Width = LeftWidth + 3; Pleft_panel_tiem_top.Tag = SecondMenu; Pleft_panel_tiem_top.BorderStyle = BorderStyle.FixedSingle; if (childList != null && childList.Rows.Count == 0) { Pleft_panel_tiem_top.Click += new EventHandler(Pleft_panel_tiem_top_Click); } else { Pleft_panel_tiem_top.Click += new EventHandler(ibtn_Click); } Pleft_panel_tiem.Controls.Add(Pleft_panel_tiem_top); Label lbl = new Label(); //菜单名称 lbl.Name = "lbl_" + STR_CS_LEFT_MEMU_NAME; lbl.ForeColor = Color.FromArgb(20, 129, 194); lbl.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134))); lbl.Cursor = Cursors.Default; lbl.BackColor = Color.Transparent; lbl.AutoSize = true; lbl.Left = 16; lbl.Top = 7; lbl.Text = LeftMemuName; //菜单名 lbl.Tag = SecondMenu;; if (childList != null && childList.Rows.Count == 0) { lbl.Click += new EventHandler(lbl_Click); } else { lbl.Click += new EventHandler(ibtn_Click); } Pleft_panel_tiem_top.Controls.Add(lbl); if (childList != null && childList.Rows.Count == 0) { //PictureBox pb = new PictureBox(); //pb.Name = "pb_" + STR_CS_LEFT_MEMU_NAME; //pb.Width = 10; //pb.Height = 10; //pb.Left = LeftWidth - pb.Width - 5; //pb.Top = 10; //pb.BackColor = Color.Transparent; //if (STR_CS_LEFT_MEMU_NAME == str_Curr_Item) //{ // pb.Image = iChecked; //} //else //{ // pb.Image = iNoChecked; //} //Pleft_panel_tiem_top.Controls.Add(pb); } else if (childList != null && childList.Rows.Count > 0) { ServiceStationClient.ComponentUI.ImageButton ibtn = new ImageButton(); //展开折叠 ibtn.Name = "ibtn_" + STR_CS_LEFT_MEMU_NAME; ibtn.Cursor = Cursors.Hand; ibtn.Width = 10; ibtn.Height = 10; ibtn.BackColor = Color.Transparent; //ibtn.Left = LeftWidth - ibtn.Width - 125; ibtn.Left = LeftWidth - ibtn.Width - 5; ibtn.Top = 10; if (STR_CS_LEFT_MEMU_NAME == str_Curr_Item) { Pleft_panel_tiem_top.Tag = "1"; lbl.Tag = "1"; ibtn.Tag = "1"; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Collapse_V; } else { Pleft_panel_tiem_top.Tag = "0"; lbl.Tag = "0"; ibtn.Tag = "0"; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Expand_V; } ibtn.Click += new EventHandler(ibtn_Click); Pleft_panel_tiem_top.Controls.Add(ibtn); TreeViewEx tvex = new TreeViewEx(); tvex.Name = "tv_" + STR_CS_LEFT_MEMU_NAME; tvex.ForeColor = Color.FromArgb(20, 129, 194); tvex.Indent = 8; tvex.ItemHeight = 25; tvex.Location = new Point(0, Pleft_panel_tiem_top.Height); tvex.Width = LeftWidth + 3; tvex.Height = tHeight; tvex.BorderStyle = BorderStyle.None; tvex.Scrollable = true; tvex.ShowLines = false; tvex.Cursor = System.Windows.Forms.Cursors.Hand; tvex.ImageList = treeImage; Pleft_panel_tiem.Controls.Add(tvex); if (childList != null && childList.Rows.Count > 0) { foreach (DataRow fun in childList.Rows) { TreeNode node = new TreeNode(); node.Tag = fun; node.Text = fun["fun_name"].ToString(); node.Name = fun["fun_id"].ToString(); if (fun["fun_img"] != DBNull.Value && fun["fun_img"].ToString().Trim() != "") { treeImage.Images.Add(fun["fun_img"].ToString(), SkinAssistant.GetResourcesImage(fun["fun_img"], true)); node.ImageKey = fun["fun_img"].ToString(); node.SelectedImageKey = fun["fun_img"].ToString(); } tvex.Nodes.Add(node); } } tvex.ItemDrag += new ItemDragEventHandler(tvex_ItemDrag); tvex.NodeMouseClick += new TreeNodeMouseClickEventHandler(tvex_NodeMouseClick); } }
/// <summary> /// 左侧菜单状态 折叠 展开 选中 未选 /// </summary> /// <param name="pname">展开的功能名称name(二级菜单)</param> /// <param name="threeMenu">三级菜单</param> public void LeftMenuState(string pname, string threeMenu) { int Pleft_panelHeight = panel_MainHeight;//panel的高度 if (this.Controls.Count > 0) { int Pleft_panel_count = this.Controls.Count; // -1; //二级菜单个数 int Pleft_panel_item_height = Pleft_panelHeight - (Pleft_panel_count * item_top_height) + item_top_height; //二级菜单高度-展开的 int tvex_height = Pleft_panel_item_height - item_top_height; //菜单列表高度-展开的 int next_top = 0; int i = 0; foreach (Panel ctl in this.Controls) { PanelEx ctl_top = ctl.Controls.Find("top_" + ctl.Name, false)[0] as PanelEx; ctl.Width = LeftWidth + 3; ctl_top.Width = LeftWidth + 3; if (ctl_top.Controls.ContainsKey("ibtn_" + ctl.Name)) { ImageButton ibtn = ctl_top.Controls.Find("ibtn_" + ctl.Name, false)[0] as ImageButton; TreeViewEx tvex = ctl.Controls.Find("tv_" + ctl.Name, false)[0] as TreeViewEx; ibtn.Left = LeftWidth - ibtn.Width - 5; tvex.Width = LeftWidth + 3; if (ctl.Name == pname) { ctl.Height = Pleft_panel_item_height; tvex.Visible = true; tvex.Height = tvex_height; if (tvex.GetNodeCount(true) > 0) { for (int j = 0; j < tvex.Nodes.Count; j++) { if (tvex.Nodes[j].Name == threeMenu) { tvex.Focus(); //tvex.Nodes[j].BackColor = Color.FromArgb(51, 153, 255); tvex.SelectedNode = tvex.Nodes[j];//选中 break; } } } ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Collapse_V; ibtn.Tag = "1"; } else { ctl_top.BackColor = _normalColor; if (pname == "" && i == 0) { ctl.Height = Pleft_panel_item_height; tvex.Visible = true; tvex.Height = tvex_height; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Collapse_V; ibtn.Tag = "1"; } else { ctl.Height = item_top_height; tvex.Visible = true; tvex.Height = 0; ibtn.BackgroundImage = ServiceStationClient.Skin.Properties.Resources.Menu_Expand_V; ibtn.Tag = "0"; } } } else { ctl.Height = item_top_height; if (ctl.Name != pname) { ctl_top.BackColor = _normalColor; } } ctl.Top = next_top; next_top += ctl.Height; i++; } } }