Esempio n. 1
0
        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);
			}
		}