private NGTreeNode[] SelectedNodes(Altaxo.Gui.Common.MultiSelectTreeView tree) { var result = tree.SelectedItems.OfType <NGTreeNode>().ToArray(); NGTreeNode.SortByOrder(result); return(result); }
private void EhTreeNodeMouseDoubleClick(NGTreeNode node) { if (null != node && (node.Tag is System.Data.DataColumn)) { AddField(node.Tag); } }
private void Controller_AvailableLists_Initialize() { _availableListsRootNode = new NGTreeNode(); var levelDict = new Dictionary <ItemDefinitionLevel, NGTreeNode>(); var allListsWithLevel = _manager.GetEntryValues().ToArray(); Array.Sort(allListsWithLevel, (x, y) => { int result = Comparer <ItemDefinitionLevel> .Default.Compare(x.Level, y.Level); return(result != 0 ? result : string.Compare(x.List.Name, y.List.Name)); } ); var dict = new Dictionary <string, NGTreeNode>(); foreach (var listAndLevel in allListsWithLevel) { if (!levelDict.TryGetValue(listAndLevel.Level, out var levelNode)) { levelNode = new NGTreeNode(Enum.GetName(typeof(ItemDefinitionLevel), listAndLevel.Level)); levelDict.Add(listAndLevel.Level, levelNode); _availableListsRootNode.Nodes.Add(levelNode); } levelNode.Nodes.Add(new NGTreeNode(listAndLevel.List.Name) { Tag = listAndLevel.List, IsSelected = object.ReferenceEquals(listAndLevel.List, _doc) }); } }
private void EhHideTableChosen(NGTreeNode node) { if (null != node && node.Tag is System.Data.DataTable) { node.Remove(); } }
public void SelectNode(NGTreeNode node) { var guiNode = (TreeNode)node.GuiTag; guiNode.EnsureVisible(); this._tvColumns.SelectedNode = guiNode; }
/// <summary> /// Mirrors a Non-Gui-TreeNode to a gui dependent tree node - including all childs and including the parent relation (the parent node has to be already mirrored. /// </summary> /// <param name="orgNode"></param> /// <returns></returns> public static TreeNode MirrorTreeNodeAdded(NGTreeNode orgNode) { // Do not change the order of the creation - it is essential for recursive operation // First create the GuiNode itself TreeNode guiNode = new TreeNode(orgNode.Text); guiNode.Tag = orgNode; orgNode.GuiTag = guiNode; // second - create the relation to the parent node if (null != orgNode.Parent && null == guiNode.Parent && (orgNode.Parent.GuiTag is TreeNode)) { (orgNode.Parent.GuiTag as TreeNode).Nodes.Add(guiNode); } // third - create the children - they will already see the created parent if (orgNode.HasChilds) { foreach (var childNode in orgNode.Nodes) { MirrorTreeNodeAdded(childNode); } } return(guiNode); }
// update table tree to reflect new connection string private void UpdateTableTree() { // initialize table tree NGTreeNode rootNode = new NGTreeNodeWithImageIndex(); var ndTables = new NGTreeNodeWithImageIndex { Text = Current.ResourceService.GetString("Gui.DataConnection.Tables"), ImageIndex = 0, SelectedImageIndex = 0 }; var ndViews = new NGTreeNodeWithImageIndex { Text = Current.ResourceService.GetString("Gui.DataConnection.Views"), ImageIndex = 1, SelectedImageIndex = 1 }; // populate using current schema if (Schema != null) { // populate the tree foreach (System.Data.DataTable dt in Schema.Tables) { // create new node, save table in tag property var node = new NGTreeNodeWithImageIndex { Text = dt.TableName }; node.Tag = dt; // add new node to appropriate parent switch (OleDbSchema.GetTableType(dt)) { case TableType.Table: ndTables.Nodes.Add(node); node.ImageIndex = node.SelectedImageIndex = 0; AddDataColumns(node, dt); break; case TableType.View: ndViews.Nodes.Add(node); node.ImageIndex = node.SelectedImageIndex = 1; AddDataColumns(node, dt); break; } } // add non-empty nodes to tree foreach (NGTreeNode nd in new NGTreeNode[] { ndTables, ndViews }) { if (nd.Nodes.Count > 0) { nd.Text = string.Format("{0} ({1})", nd.Text, nd.Nodes.Count); rootNode.Nodes.Add(nd); } } // expand tables node ndTables.IsExpanded = true; _treeTableNodes = rootNode; if (null != _view) { _view.SetTableTreeDataSource(_treeTableNodes); } } }
private void EhRelatedTablesRequired(NGTreeNode nd, List <string> resultingList) { resultingList.Clear(); System.Data.DataTable dt = nd == null ? null : nd.Tag as System.Data.DataTable; if (null == dt) { return; } var list = new List <string>(); foreach (System.Data.DataRelation dr in _builder.Schema.Relations) { if (dr.ParentTable == dt && !list.Contains(dr.ChildTable.TableName)) { list.Add(dr.ChildTable.TableName); } else if (dr.ChildTable == dt && !list.Contains(dr.ParentTable.TableName)) { list.Add(dr.ParentTable.TableName); } } list.Sort(); foreach (string tableName in list) { if (FindNode(tableName) != null) { resultingList.Add(tableName); } } }
public FileSystemTreeController() { // Sorted = true; _rootNode = new NGTreeNode(); Nodes = _rootNode.Nodes; Initialize(true); }
/// <summary> /// Mirrors an array of Non-Gui-TreeNode to a gui dependent tree node - including all childs and including the parent relation (the parent node has to be already mirrored. /// </summary> /// <param name="orgNodes">Array of Non-Gui-TreeNodes.</param> /// <returns>Array of Gui-TreeNodes</returns> public static TreeNode[] MirrorTreeNodesAdded(NGTreeNode[] orgNodes) { TreeNode[] guiNodes = new TreeNode[orgNodes.Length]; for (int i = 0; i < guiNodes.Length; i++) guiNodes[i] = MirrorTreeNodeAdded(orgNodes[i]); return guiNodes; }
TreeNode NewNode(NGTreeNode node) { TreeNode tnode = new TreeNode(); tnode.Text = node.Text; tnode.Tag = node; node.GuiTag = tnode; return(tnode); }
protected NGTreeNode GetRootNode(NGTreeNode node) { while (node.ParentNode != null) { node = node.ParentNode; } return(node); }
private void EhView_FolderTreeNodeSelected(NGTreeNode obj) { var node = obj as TreeNode; string path = node == null ? null : node.FullPath; if (null != SelectedPathChanged && path != null) { SelectedPathChanged(path); } }
public void ContentsListBox_MoveUpDown(int iDelta, NGTreeNode[] selNodes) { if (NGTreeNode.HaveSameParent(selNodes)) { NGTreeNode.MoveUpDown(iDelta, selNodes); TransferTreeToDoc(_plotItemsRootNode, _doc); View.Contents_SetItems(this._plotItemsTree); SetDirty(); } }
public void EhView_AfterSelectNode(NGTreeNode node) { if (node.Tag is DataColumn) { _selectedColumn = (DataColumn)node.Tag; } else { _selectedColumn = null; } }
/// <summary> /// Updates/fills the data nodes used for the TreeView content. /// </summary> protected virtual void UpdateTreeViewTreeNodes() { var builtIn = new NGTreeNode() { Text = "Builtin", Tag = Altaxo.Main.ItemDefinitionLevel.Builtin }; var app = new NGTreeNode() { Text = "Application", Tag = Altaxo.Main.ItemDefinitionLevel.Application }; var user = new NGTreeNode() { Text = "User", Tag = Altaxo.Main.ItemDefinitionLevel.UserDefined }; var proj = new NGTreeNode() { Text = "Project", Tag = Altaxo.Main.ItemDefinitionLevel.Project }; bool showPlotColorsOnly = ShowPlotColorsOnly; foreach (var set in _colorSetManager.GetEntryValues()) { if (showPlotColorsOnly && !set.IsPlotColorSet) { continue; } switch (set.Level) { case Altaxo.Main.ItemDefinitionLevel.Builtin: builtIn.Nodes.Add(new NGTreeNodeForColorSet(set.List)); break; case Altaxo.Main.ItemDefinitionLevel.Application: app.Nodes.Add(new NGTreeNodeForColorSet(set.List)); break; case Altaxo.Main.ItemDefinitionLevel.UserDefined: user.Nodes.Add(new NGTreeNodeForColorSet(set.List)); break; case Altaxo.Main.ItemDefinitionLevel.Project: proj.Nodes.Add(new NGTreeNodeForColorSet(set.List)); break; } } _treeRootNode.Nodes.Clear(); _treeRootNode.Nodes.Add(builtIn); _treeRootNode.Nodes.Add(app); _treeRootNode.Nodes.Add(user); _treeRootNode.Nodes.Add(proj); }
public void EhSelectionChanged(NGTreeNode node) { if (node.Tag is DataTable) { _selectedTable = (DataTable)node.Tag; } else { _selectedTable = null; } }
private void AddTopic(IOptionPanelDescriptor desc, NGTreeNodeCollection nodecoll) { var newNode = new NGTreeNode(desc.Label); newNode.Tag = desc; if (null != desc.ChildOptionPanelDescriptors) { foreach (var child in desc.ChildOptionPanelDescriptors) AddTopic(child, newNode.Nodes); } nodecoll.Add(newNode); }
public void Initialize(bool initData) { if (initData) { if (_doc.Environment is Altaxo.Gui.Graph.Gdi.Viewing.IGraphController) { NGTreeNode node = null; node = new NGTreeNode(true) { Text = "Graph", Tag = _doc.Environment }; _rootNode.Nodes.Add(node); } var tableCollectionNode = new NGTreeNode(true) { Text = "Tables", Tag = Current.Project.DataTableCollection }; _rootNode.Nodes.Add(tableCollectionNode); AddAllTableNodes(tableCollectionNode); DataTable selectedTable = null; if (_doc.SelectedColumn != null) { selectedTable = DataTable.GetParentDataTableOf(_doc.SelectedColumn); } if (null != selectedTable) { var selTableNode = FindTableNode(tableCollectionNode, selectedTable); if (selTableNode != null) { selTableNode.IsExpanded = true; } if (null != selTableNode && null != _doc.SelectedColumn) { var selColumnNode = FindColumnNode(selTableNode, _doc.SelectedColumn); if (null != selColumnNode) { selColumnNode.IsSelected = true; } } } } if (_view != null) { _view.Initialize(_rootNode.Nodes); } }
private void EhDataAvailable_BeforeExpand(object sender, System.Windows.Forms.TreeViewCancelEventArgs e) { if (null != Controller) { this.m_Content_tvDataAvail.BeginUpdate(); NGTreeNode ngnode = (NGTreeNode)e.Node.Tag; Controller.EhView_DataAvailableBeforeExpand(ngnode); e.Node.Nodes.Clear(); Update(this.m_Content_tvDataAvail, e.Node.Nodes, ngnode.Nodes, null); this.m_Content_tvDataAvail.EndUpdate(); } }
private void AddDataColumns(NGTreeNode node, System.Data.DataTable dt) { foreach (System.Data.DataColumn col in dt.Columns) { var field = new NGTreeNodeWithImageIndex { Text = col.ColumnName }; field.Tag = col; field.ImageIndex = 3; field.SelectedImageIndex = 3; node.Nodes.Add(field); } }
protected virtual void Controller_AvailableItems_Initialize() { _availableItemsRootNode = new NGTreeNode(); var availableItems = Altaxo.Main.Services.ReflectionService.GetNonAbstractSubclassesOf(typeof(TItem)); foreach (var item in availableItems) { _availableItemsRootNode.Nodes.Add(new NGTreeNode(ToDisplayName(item)) { Tag = item, IsSelected = false }); } }
public void EhView_DataAvailableBeforeExpand(NGTreeNode node) { Data.DataTable dt = Current.Project.DataTableCollection[node.Text]; if (null != dt) { node.Nodes.Clear(); NGTreeNode[] toadd = new NGTreeNode[dt.DataColumns.ColumnCount]; for (int i = 0; i < toadd.Length; i++) { toadd[i] = new NGTreeNode(dt[i].Name); } node.Nodes.AddRange(toadd); } }
private void TransferTreeToDoc(NGTreeNode rootnode, PlotItemCollection picoll) { picoll.Clear(); foreach (NGTreeNode node in rootnode.Nodes) { IGPlotItem item = (IGPlotItem)node.Tag; if (item is PlotItemCollection) // if this is a plot item collection { TransferTreeToDoc(node, (PlotItemCollection)item); } picoll.Add(item); } }
/// <summary> /// Add a <see cref="NGTreeNode"/>s corresponding to the folder name recursively for all parts of the folder name so that a hierarchy of those nodes is built-up. /// If the folder name is already represented by a tree node (i.e. is present in the folderDictionary), this node is returned. /// If not, the node is created and added to the folder dictionary as well as to the nodes collection of the parent tree node. /// If the parent tree node is not found in the folderDictionary, this function is called recursively to add the parent tree node. /// </summary> /// <param name="folderName">The folder name to add.</param> /// <param name="folderDictionary">Dictionary that relates the full folder name to the already built-up tree nodes. At least the root node (key is the <see cref="Main.ProjectFolder.RootFolderName"/> has to be present in the dictionary. The newly created folder nodes are also added to this dictionary.</param> /// <returns>The tree node corresponding to the provided folder name.</returns> public static NGTreeNode AddFolderNodeRecursively(string folderName, Dictionary <string, NGTreeNode> folderDictionary) { if (!folderDictionary.TryGetValue(folderName, out var folderNode)) { var parentNode = AddFolderNodeRecursively(Main.ProjectFolder.GetFoldersParentFolder(folderName), folderDictionary); folderNode = new NGTreeNode { Text = Main.ProjectFolder.ConvertFolderNameToDisplayFolderName(Main.ProjectFolder.GetFoldersLastFolderPart(folderName)), Tag = folderName }; folderDictionary.Add(folderName, folderNode); parentNode.Nodes.Add(folderNode); } return(folderNode); }
public static void AddAllTableNodes(NGTreeNode tableCollectionNode) { // Create a dictionary of folders to TreeNodes relation var folderDict = new Dictionary <string, NGTreeNode> { { Altaxo.Main.ProjectFolder.RootFolderName, tableCollectionNode } // add the root folder node to the dictionary }; tableCollectionNode.Nodes.Clear(); foreach (var table in Current.Project.DataTableCollection) { var parentNode = Altaxo.Main.ProjectFolders.AddFolderNodeRecursively <FolderNode>(table.FolderName, folderDict); } }
public void EhSelectionChanged(NGTreeNode node) { if (node.Tag is ProjectFolder) { _selectedFolder = (ProjectFolder)node.Tag; } else if (node.Tag is string) { _selectedFolder = new ProjectFolder((string)node.Tag); } else { _selectedFolder = null; } }
NGTreeNode[] SelectedNodes(MWControlSuite.MWTreeView tree) { Hashtable hash = tree.SelNodes; NGTreeNode[] result = new NGTreeNode[hash.Count]; int i = 0; foreach (DictionaryEntry dict in hash) { result[i++] = ((MWControlSuite.MWTreeNodeWrapper)dict.Value).Node.Tag as NGTreeNode; } NGTreeNode.SortByOrder(result); return(result); }
private void AddTopic(IOptionPanelDescriptor desc, NGTreeNodeCollection nodecoll) { var newNode = new NGTreeNode(desc.Label) { Tag = desc }; if (null != desc.ChildOptionPanelDescriptors) { foreach (var child in desc.ChildOptionPanelDescriptors) { AddTopic(child, newNode.Nodes); } } nodecoll.Add(newNode); }
public static void MirrorTreeNodeRemoved(NGTreeNode orgNode) { if (orgNode.HasChilds) { foreach (NGTreeNode child in orgNode.Nodes) MirrorTreeNodeRemoved(child); } var guiNode = (orgNode.GuiTag as TreeNode); if (null != guiNode) { orgNode.GuiTag = null; guiNode.Tag = null; guiNode.Remove(); } }
private void Initialize(bool initData) { if (initData) { var items = ICSharpCode.Core.AddInTree.GetTreeNode("/Altaxo/Dialogs/SettingsDialog").BuildChildItems<IOptionPanelDescriptor>(null); _topics = new NGTreeNode(); foreach (var item in items) AddTopic(item, _topics.Nodes); } if (null != _view) { _view.InitializeTopics(_topics.Nodes); EhTopicSelectionChanged(_topics); } }
/// <summary> /// Updates/fills the data nodes used for the TreeView content. /// </summary> protected virtual void UpdateTreeViewTreeNodes() { var builtIn = new NGTreeNode() { Text = "Builtin", Tag = Altaxo.Main.ItemDefinitionLevel.Builtin }; var app = new NGTreeNode() { Text = "Application", Tag = Altaxo.Main.ItemDefinitionLevel.Application }; var user = new NGTreeNode() { Text = "User", Tag = Altaxo.Main.ItemDefinitionLevel.UserDefined }; var proj = new NGTreeNode() { Text = "Project", Tag = Altaxo.Main.ItemDefinitionLevel.Project }; foreach (var set in _styleListManager.GetEntryValues()) { switch (set.Level) { case Altaxo.Main.ItemDefinitionLevel.Builtin: builtIn.Nodes.Add(new NGTreeNodeForTList(this, set.List)); break; case Altaxo.Main.ItemDefinitionLevel.Application: app.Nodes.Add(new NGTreeNodeForTList(this, set.List)); break; case Altaxo.Main.ItemDefinitionLevel.UserDefined: user.Nodes.Add(new NGTreeNodeForTList(this, set.List)); break; case Altaxo.Main.ItemDefinitionLevel.Project: proj.Nodes.Add(new NGTreeNodeForTList(this, set.List)); break; } } _treeRootNode.Nodes.Clear(); _treeRootNode.Nodes.Add(builtIn); _treeRootNode.Nodes.Add(app); _treeRootNode.Nodes.Add(user); _treeRootNode.Nodes.Add(proj); }
public void EhView_ContentsDoubleClick(NGTreeNode selNode) { IGPlotItem pi = selNode.Tag as IGPlotItem; if (null != pi) { if (pi is PlotItemCollection) { // show not the dialog for PlotItemCollection, but only those for the group styles into that collection Current.Gui.ShowDialog(new object[] { ((PlotItemCollection)pi).GroupStyles }, pi.Name); } else { Current.Gui.ShowDialog(new object[] { pi }, pi.GetName(2), true); } } }
private void CreateDirectoryNode(string dir, NGTreeNode node) { var subfolders = Current.Project.Folders.GetSubfoldersAsStringList(dir, false); subfolders.Sort(); foreach (var subfolder in subfolders) { var subnode = new NGTreeNode(ProjectFolder.ConvertFolderNameToDisplayFolderLastPart(subfolder)) { Tag = subfolder, IsExpanded = true }; node.Nodes.Add(subnode); CreateDirectoryNode(subfolder, subnode); } }
private void EhTopicSelectionChanged(NGTreeNode obj) { // if this node has a own control, use it, otherwise use the next child var node = GetFirstNodeWithControl(obj); string title = string.Empty; object view = null; if (node != null) { var desc = (IOptionPanelDescriptor)node.Tag; var ctrl = desc.OptionPanel; title = desc.Label; view = ctrl.ViewObject; _currentNode = node; } _view.InitializeTopicView(title, view); _view.InitializeTopicViewDirtyIndicator(_dirtyTopics.Contains(_currentNode) ? 1 : 0); }
/// <summary> /// Mirrors a Non-Gui-TreeNode to a gui dependent tree node - including all childs and including the parent relation (the parent node has to be already mirrored. /// </summary> /// <param name="orgNode"></param> /// <returns></returns> public static TreeNode MirrorTreeNodeAdded(NGTreeNode orgNode) { // Do not change the order of the creation - it is essential for recursive operation // First create the GuiNode itself TreeNode guiNode = new TreeNode(orgNode.Text); guiNode.Tag = orgNode; orgNode.GuiTag = guiNode; // second - create the relation to the parent node if (null != orgNode.Parent && null == guiNode.Parent && (orgNode.Parent.GuiTag is TreeNode)) (orgNode.Parent.GuiTag as TreeNode).Nodes.Add(guiNode); // third - create the children - they will already see the created parent if (orgNode.HasChilds) { foreach (var childNode in orgNode.Nodes) MirrorTreeNodeAdded(childNode); } return guiNode; }
/// <summary> /// Puts the selected data columns into the plot content. /// </summary> /// <param name="selNodes"></param> public void EhView_PutData(NGTreeNode[] selNodes) { // first, put the selected node into the list, even if it is not checked foreach (NGTreeNode sn in selNodes) { if(null!=sn.Parent) { IGPlotItem newItem = this.CreatePlotItem(sn.Parent.Text,sn.Text); _doc.Add(newItem); NGTreeNode newNode = new NGTreeNode(); newNode.Text = newItem.GetName(2); newNode.Tag = newItem; _plotItemsTree.Add(newNode); } } View.Contents_SetItems(_plotItemsTree); View.DataAvailable_ClearSelection(); SetDirty(); }
public void SetElements(bool bInit) { if (_doc == null) throw new ApplicationException("Doc was not set before!"); // Available Items if(null!=View) { int nTables = Current.Project.DataTableCollection.Count; NGTreeNode no = new NGTreeNode(); foreach(Data.DataTable dt in Current.Project.DataTableCollection) { no.Nodes.Add( new NGTreeNode(dt.Name,new NGTreeNode[1]{new NGTreeNode()})); } View.DataAvailable_Initialize(no.Nodes); } // now fill the tree view with all plot associations currently inside if(bInit) { _plotItemsTree.Clear(); AddToNGTreeNode(_plotItemsRootNode, _doc); } if(null!=View) View.Contents_SetItems(_plotItemsTree); // if initializing set dirty to false if(bInit) m_bDirty = false; }
public void SetTreeSource(NGTreeNode rootNode) { _treeTables.ItemsSource = rootNode.Nodes; }
public void ContentsListBox_MoveUpDown(int iDelta, NGTreeNode[] selNodes) { if (NGTreeNode.HaveSameParent(selNodes)) { NGTreeNode.MoveUpDown(iDelta, selNodes); TransferTreeToDoc(_plotItemsRootNode, _doc); View.Contents_SetItems(this._plotItemsTree); SetDirty(); } }
public bool Apply(bool disposeController) { // we have to call apply for all dirty topics foreach (var node in _dirtyTopics) { var desc = (IOptionPanelDescriptor)node.Tag; var ctrl = desc.OptionPanel; if (null != ctrl && !ctrl.Apply()) { _currentNode = node; _view.SetSelectedNode(_currentNode); _view.InitializeTopicView(desc.Label, ctrl.ViewObject); _view.InitializeTopicViewDirtyIndicator(2); return false; } } return true; }
protected NGTreeNode GetRootNode(NGTreeNode node) { while (node.ParentNode != null) node = node.ParentNode; return node; }
public void SetLayerStructure(NGTreeNode value, int[] currentLayerNumber) { _layerToolBar.Children.Clear(); foreach (var node in value.TakeFromHereToFirstLeaves()) { var newbutton = new ToggleButton() { Content = node.Text, Tag = node.Tag }; newbutton.Margin = new Thickness(node.Level * 8, 2, 1, 0); newbutton.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; newbutton.Click += new RoutedEventHandler(EhLayerButton_Click); newbutton.ContextMenuOpening += new ContextMenuEventHandler(EhLayerButton_ContextMenuOpening); newbutton.IsChecked = System.Linq.Enumerable.SequenceEqual((int[])(node.Tag), currentLayerNumber); _layerToolBar.Children.Add(newbutton); } }
public void Initialize(bool initData) { if (initData) { if (_doc.Environment is Altaxo.Gui.Graph.Gdi.Viewing.IGraphController) { NGTreeNode node = null; node = new NGTreeNode(true) { Text = "Graph", Tag = _doc.Environment }; _rootNode.Nodes.Add(node); } var tableCollectionNode = new NGTreeNode(true) { Text = "Tables", Tag = Current.Project.DataTableCollection }; _rootNode.Nodes.Add(tableCollectionNode); AddAllTableNodes(tableCollectionNode); DataTable selectedTable = null; if (_doc.SelectedColumn != null) selectedTable = DataTable.GetParentDataTableOf(_doc.SelectedColumn); if (null != selectedTable) { var selTableNode = FindTableNode(tableCollectionNode, selectedTable); if (selTableNode != null) selTableNode.IsExpanded = true; if (null != selTableNode && null != _doc.SelectedColumn) { var selColumnNode = FindColumnNode(selTableNode, _doc.SelectedColumn); if (null != selColumnNode) selColumnNode.IsSelected = true; } } } if (_view != null) { _view.Initialize(_rootNode.Nodes); } }
private NGTreeNode FindTableNode(NGTreeNode tableCollectionNode, DataTable table) { NGTreeNode result = null; foreach (NGTreeNode node in tableCollectionNode.Nodes) if (object.ReferenceEquals(node.Tag, table)) { result = node; return result; } foreach (NGTreeNode node in tableCollectionNode.Nodes) { result = FindTableNode(node, table); if (null != result) return result; } return result; }
public void EhView_ListSelUpClick(NGTreeNode[] selNodes) { // move the selected items upwards in the list ContentsListBox_MoveUpDown(-1,selNodes); SetDirty(); }
public void EhView_PullDataClick(NGTreeNode[] selNodes) { View.Contents_RemoveItems(selNodes); foreach (NGTreeNode node in selNodes) node.Remove(); TransferTreeToDoc(_plotItemsRootNode, _doc); View.Contents_SetItems(_plotItemsTree); SetDirty(); }
public void EhView_PlotAssociationsClick(NGTreeNode[] selNodes) { if (selNodes.Length == 1) EhView_ContentsDoubleClick(selNodes[0]); }
public void EhView_EditRangeClick(NGTreeNode[] selNodes) { if (selNodes.Length == 1 && selNodes[0].Tag is IGPlotItem) EhView_ContentsDoubleClick(selNodes[0]); }
public void EhView_ContentsDoubleClick(NGTreeNode selNode) { IGPlotItem pi = selNode.Tag as IGPlotItem; if (null != pi) { if (pi is PlotItemCollection) { // show not the dialog for PlotItemCollection, but only those for the group styles into that collection Current.Gui.ShowDialog(new object[] { ((PlotItemCollection)pi).GroupStyles }, pi.Name); } else { Current.Gui.ShowDialog(new object[] { pi }, pi.GetName(2),true); } } }
public void EhView_UngroupClick(NGTreeNode[] selNodes) { // retrieve the selected items if(selNodes.Length<1) return; // we cannot ungroup anything if nothing selected selNodes = NGTreeNode.FilterIndependentNodes(selNodes); for(int i=0;i<selNodes.Length;i++) { if (selNodes[i].Nodes.Count==0 && selNodes[i].Parent!=null && selNodes[i].Parent.Parent!=null) { NGTreeNode parent = selNodes[i].Parent; NGTreeNode grandParent = parent.Parent; selNodes[i].Remove(); grandParent.Nodes.Add(selNodes[i]); if (parent.Nodes.Count == 0) parent.Remove(); } else if (selNodes[i].Nodes.Count > 0 && selNodes[i].Parent != null) { NGTreeNode parent = selNodes[i].Parent; while(selNodes[i].Nodes.Count>0) { NGTreeNode no = selNodes[i].Nodes[0]; no.Remove(); parent.Nodes.Add(no); } selNodes[i].Remove(); } } // end for TransferTreeToDoc(_plotItemsRootNode, _doc); View.Contents_SetItems(_plotItemsTree); SetDirty(); }
/// <summary> /// Group the selected nodes. /// </summary> /// <param name="selNodes"></param> public void EhView_GroupClick(NGTreeNode[] selNodes) { // retrieve the selected items if(selNodes.Length<2) return; // we cannot group anything if no or only one item is selected // look, if one of the selected items is a plot group // if found, use this group and add the remaining items to this int foundindex=-1; for(int i=0;i<selNodes.Length;i++) { if(selNodes[i].Tag is PlotItemCollection) { foundindex = i; break; } } // if a group was found use this to add the remaining items if (foundindex >= 0) { for (int i = 0; i < selNodes.Length; i++) if (i != foundindex) { selNodes[i].Remove(); selNodes[foundindex].Nodes.Add(selNodes[i]); } } else // if we found no group to add to, we have to create a new group { NGTreeNode newNode = new NGTreeNode(); newNode.Tag = new PlotItemCollection(); newNode.Text = "PlotGroup"; // now add the remaining selected items to the found group for (int i = 0; i < selNodes.Length; i++) { NGTreeNode node = selNodes[i]; if (node.Nodes.Count > 0) // if it is a group, add the members of the group to avoid more than one recursion { while(node.Nodes.Count>0) { NGTreeNode addnode = node.Nodes[0]; addnode.Remove(); newNode.Nodes.Add(addnode); } } else // item to add is not a group { node.Remove(); newNode.Nodes.Add(node); } } // end for _plotItemsRootNode.Nodes.Add(newNode); } // now all items are in the new group TransferTreeToDoc(_plotItemsRootNode, _doc); // so update the list box: View.Contents_SetItems(this._plotItemsTree); SetDirty(); }
public static void AddAllTableNodes(NGTreeNode tableCollectionNode) { // Create a dictionary of folders to TreeNodes relation var folderDict = new Dictionary<string, NGTreeNode>(); folderDict.Add(ProjectFolder.RootFolderName, tableCollectionNode); // add the root folder node to the dictionary tableCollectionNode.Nodes.Clear(); foreach (var table in Current.Project.DataTableCollection) { var parentNode = ProjectFolders.AddFolderNodeRecursively(table.FolderName, folderDict); var node = new TableNode(table); parentNode.Nodes.Add(node); } }
private void TransferTreeToDoc(NGTreeNode rootnode, PlotItemCollection picoll) { picoll.Clear(); foreach (NGTreeNode node in rootnode.Nodes) { IGPlotItem item = (IGPlotItem)node.Tag; if (item is PlotItemCollection) // if this is a plot item collection TransferTreeToDoc(node, (PlotItemCollection)item); picoll.Add(item); } }
private NGTreeNode FindColumnNode(NGTreeNode tableNode, DataColumn column) { NGTreeNode result = null; foreach (NGTreeNode node in tableNode.Nodes) { if (object.ReferenceEquals(node.Tag, column)) { return node; } else if (node.HasChilds) { result = FindColumnNode(node, column); if (null != result) return result; } } return null; }
private void AddToNGTreeNode(NGTreeNode node, PlotItemCollection picoll) { foreach (IGPlotItem pa in picoll) { if (pa is PlotItemCollection) // if this is a plot item collection { // add only one item to the list box, namely a PLCon group item with // all the members of that group NGTreeNode grpNode = new NGTreeNode(); grpNode.Text = "PlotGroup"; grpNode.Tag = pa; node.Nodes.Add(grpNode); // add all the items in the group also to the list of added items AddToNGTreeNode(grpNode, (PlotItemCollection)pa); } else // else if the item is not in a plot group { NGTreeNode toAdd = new NGTreeNode(); toAdd.Text = pa.GetName(2); toAdd.Tag = pa; node.Nodes.Add(toAdd); } } }
public void EhView_AfterSelectNode(NGTreeNode node) { if (node.Tag is DataColumn) _selectedColumn = (DataColumn)node.Tag; else _selectedColumn = null; }
private NGTreeNode GetFirstNodeWithControl(NGTreeNode obj) { // if this node has a own control, use it, otherwise use the next child var desc = (IOptionPanelDescriptor)obj.Tag; if (desc != null && desc.OptionPanel != null) return obj; if (obj.HasChilds) { foreach (var child in obj.Nodes) { var result = GetFirstNodeWithControl(child); if (null != result) return result; } } return null; // nothing found }
public void EhView_DataAvailableBeforeExpand(NGTreeNode node) { Data.DataTable dt = Current.Project.DataTableCollection[node.Text]; if(null!=dt) { node.Nodes.Clear(); NGTreeNode[] toadd = new NGTreeNode[dt.DataColumns.ColumnCount]; for(int i=0;i<toadd.Length;i++) { toadd[i] = new NGTreeNode(dt[i].Name); } node.Nodes.AddRange(toadd); } }
public void EhView_SelDownClick(NGTreeNode[] selNodes) { // move the selected items downwards in the list ContentsListBox_MoveUpDown(1,selNodes); SetDirty(); }