示例#1
0
        public bool Update(TreeNode node, String newName, String text, T newItem)
        {
            TreeNode parent      = node.Parent;
            String   currentName = node.Name;
            String   sourcePath  = TreeNodeUtilities.GetFullPathJoined(node.Parent, currentName);
            String   targetPath  = TreeNodeUtilities.GetFullPathJoined(node.Parent, newName);

            if (newName != currentName)//name changed, validate overriding
            {
                bool isNameExist = GetParentNodes(parent).ContainsKey(newName);
                if (isNameExist)
                {
                    String       message  = String.Format("The item with name <{0}> already exist. Press Yes to override the existing item.", newName);
                    DialogResult question = MessageBox.Show(message, "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (question != DialogResult.Yes)
                    {
                        return(false);
                    }
                }


                m_persistanceManager.MoveSetting(m_persistencyPath, sourcePath, targetPath);
            }

            m_persistanceManager.SaveSetting <T>(m_persistencyPath, newItem, targetPath);
            node.Name = newName;
            node.Tag  = newItem;
            node.Text = text;


            return(true);
        }
示例#2
0
        public override void Move(TreeNode node, TreeNode newParentNode)
        {
            String sourcePath = TreeNodeUtilities.GetFullPath(node);
            String targetPath = TreeNodeUtilities.GetFullPathJoined(newParentNode, node.Name);

            m_persistanceManager.MoveFolder(m_persistencyPath, sourcePath, targetPath);

            node.Remove();
            GetParentNodes(newParentNode).Add(node);
        }
示例#3
0
        public TreeNode AddNew(TreeNode parent)
        {
            String   newName = FindAvailableName(parent, "Unnamed folder");
            TreeNode node    = AddNode(parent, newName);

            String path = TreeNodeUtilities.GetFullPathJoined(node.Parent, newName);

            m_persistanceManager.CreateFolder(m_persistencyPath, path);
            return(node);
        }
示例#4
0
        public TreeNode AddNew(TreeNode parent)
        {
            String   newName = FindAvailableName(parent, "Unnamed");
            T        newItem = (T)Activator.CreateInstance <T>();
            TreeNode node    = AddNode(parent, newName, newItem);

            String path = TreeNodeUtilities.GetFullPathJoined(node.Parent, newName);

            m_persistanceManager.SaveSetting <T>(m_persistencyPath, newItem, path);

            return(node);
        }
示例#5
0
        public TreeNode Duplicate(TreeNode node)
        {
            String duplicatedName = FindAvailableName(node.Parent, node.Name);

            T entity = (T)Activator.CreateInstance <T>();

            entity.SetProperties(((T)node.Tag).GetProperties());
            TreeNode duplicatedNode = AddNode(node.Parent, duplicatedName, entity);

            String path = TreeNodeUtilities.GetFullPathJoined(duplicatedNode.Parent, duplicatedName);

            m_persistanceManager.SaveSetting <T>(m_persistencyPath, entity, path);

            return(duplicatedNode);
        }
示例#6
0
        public bool Update(TreeNode node, String name)
        {
            TreeNode parent      = node.Parent;
            String   currentName = node.Name;

            if (name == currentName)
            {
                return(true);
            }
            String sourcePath = TreeNodeUtilities.GetFullPathJoined(node.Parent, currentName);
            String targetPath = TreeNodeUtilities.GetFullPathJoined(node.Parent, name);

            m_persistanceManager.MoveFolder(m_persistencyPath, sourcePath, targetPath);

            node.Name = name;
            node.Text = name;

            return(true);
        }