private void AddFitFunctionList(RootNode rootNode, Altaxo.Main.Services.IFitFunctionInformation[] info, FitFunctionContextMenuStyle menustyle) { NGTreeNodeCollection root = rootNode.Nodes; foreach (Altaxo.Main.Services.IFitFunctionInformation entry in info) { string[] path = entry.Category.Split(new char[] { '\\', '/' }); var where = root; for (int j = 0; j < path.Length; j++) { var node = GetPathNode(where, path[j]); if (node == null) { node = new CategoryNode(path[j]); where.Add(node); } where = node.Nodes; } var creationTime = entry.CreationTime; var nodeText = entry.Name; if (null != creationTime) { nodeText += " (" + creationTime.Value.ToString("yyyy-MM-dd HH:mm:ss") + ")"; } var leaf = new FitFunctionLeafNode(nodeText, entry); switch (menustyle) { case FitFunctionContextMenuStyle.None: leaf.SetMenuEnabled(false, false, false); break; case FitFunctionContextMenuStyle.EditAndDelete: // leaf.ContextMenu = _userFileLeafNodeContextMenu; leaf.SetMenuEnabled(false, true, true); break; case FitFunctionContextMenuStyle.Edit: // leaf.ContextMenu = _appFileLeafNodeContextMenu; leaf.SetMenuEnabled(true, false, false); break; } where.Add(leaf); } }
public void AddFitFunctionList(string rootname, Altaxo.Main.Services.IFitFunctionInformation[] entries, FitFunctionContextMenuStyle menustyle) { // The key of the entries is the FitFunctionAttribute, the value is the type of the fitting function this._twFitFunctions.BeginUpdate(); RootNode rnode = new RootNode(rootname, RootNodeType.Builtin); this._twFitFunctions.Nodes.Add(rnode); TreeNodeCollection root = rnode.Nodes; foreach (Altaxo.Main.Services.IFitFunctionInformation entry in entries) { string[] path = entry.Category.Split(new char[] { '\\', '/' }); TreeNodeCollection where = root; for (int j = 0; j < path.Length; j++) { TreeNode node = GetPathNode(where, path[j]); if (node == null) { node = new CategoryNode(path[j]); where.Add(node); } where = node.Nodes; } BuiltinLeafNode leaf = new BuiltinLeafNode(entry.Name, entry); switch (menustyle) { case FitFunctionContextMenuStyle.None: break; case FitFunctionContextMenuStyle.EditAndDelete: leaf.ContextMenu = _userFileLeafNodeContextMenu; break; case FitFunctionContextMenuStyle.Edit: leaf.ContextMenu = _appFileLeafNodeContextMenu; break; } where.Add(leaf); } this._twFitFunctions.EndUpdate(); }
public void AddFitFunctionList(string rootname, Altaxo.Main.Services.IFitFunctionInformation[] entries, FitFunctionContextMenuStyle menustyle) { // The key of the entries is the FitFunctionAttribute, the value is the type of the fitting function this._twFitFunctions.BeginUpdate(); RootNode rnode = new RootNode(rootname, RootNodeType.Builtin); this._twFitFunctions.Nodes.Add(rnode); TreeNodeCollection root = rnode.Nodes; foreach (Altaxo.Main.Services.IFitFunctionInformation entry in entries) { string[] path = entry.Category.Split(new char[]{'\\','/'}); TreeNodeCollection where = root; for(int j=0;j<path.Length;j++) { TreeNode node = GetPathNode(where,path[j]); if(node==null) { node = new CategoryNode(path[j]); where.Add(node); } where = node.Nodes; } BuiltinLeafNode leaf = new BuiltinLeafNode(entry.Name,entry); switch (menustyle) { case FitFunctionContextMenuStyle.None: break; case FitFunctionContextMenuStyle.EditAndDelete: leaf.ContextMenu = _userFileLeafNodeContextMenu; break; case FitFunctionContextMenuStyle.Edit: leaf.ContextMenu = _appFileLeafNodeContextMenu; break; } where.Add(leaf); } this._twFitFunctions.EndUpdate(); }
public void AddFitFunctionList(string rootname, Altaxo.Main.Services.IFitFunctionInformation[] info, FitFunctionContextMenuStyle menustyle) { if (_twFitFunctions.ItemsSource == null) { _twFitFunctions.ItemsSource = new NGTreeNode().Nodes; } var mainRoot = (NGTreeNodeCollection)_twFitFunctions.ItemsSource; // The key of the entries is the FitFunctionAttribute, the value is the type of the fitting function RootNode rnode = new RootNode(rootname, RootNodeType.RootNodeBuiltin); mainRoot.Add(rnode); NGTreeNodeCollection root = rnode.Nodes; foreach (Altaxo.Main.Services.IFitFunctionInformation entry in info) { string[] path = entry.Category.Split(new char[] { '\\', '/' }); var where = root; for (int j = 0; j < path.Length; j++) { var node = GetPathNode(where, path[j]); if (node == null) { node = new CategoryNode(path[j]); where.Add(node); } where = node.Nodes; } BuiltinLeafNode leaf = new BuiltinLeafNode(entry.Name, entry); switch (menustyle) { case FitFunctionContextMenuStyle.None: leaf.SetMenuEnabled(false, false); break; case FitFunctionContextMenuStyle.EditAndDelete: // leaf.ContextMenu = _userFileLeafNodeContextMenu; leaf.SetMenuEnabled(true, true); break; case FitFunctionContextMenuStyle.Edit: // leaf.ContextMenu = _appFileLeafNodeContextMenu; leaf.SetMenuEnabled(true, false); break; } where.Add(leaf); } }