Exemple #1
0
        public static bool CreateNewFolder(string caption, CommandKeyFolder parentFolder, ref string value, ref bool inRoot)
        {
            NewFolderName newFolderName = new NewFolderName();

            newFolderName.Text         = caption;
            newFolderName.RootFolder   = newFolderName.GetRootFolder(parentFolder);
            newFolderName.ParentFolder = parentFolder;
            newFolderName.CreateInRoot = (newFolderName.ParentFolder == null || newFolderName.ParentFolder == newFolderName.RootFolder);
            bool needToUpdateRootFlag = (newFolderName.chkRoot.Enabled == (newFolderName.ParentFolder != newFolderName.RootFolder));

            newFolderName.chkRoot.Enabled = (newFolderName.ParentFolder != newFolderName.RootFolder);

            if (needToUpdateRootFlag)
            {
                newFolderName.UpdateRootCheckedValue();
            }

            newFolderName.FolderName = value;

            if (newFolderName.ShowDialog() == DialogResult.OK)
            {
                value  = newFolderName.FolderName;
                inRoot = newFolderName.CreateInRoot;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
 public void SetParent(CommandKeyFolder parentFolder)
 {
     for (int i = 0; i < this.Count; i++)
     {
         this[i].SetParentFolder(parentFolder);
     }
 }
Exemple #3
0
        private CommandKeyBinding Load(DecoupledStorage storage, string folderName)
        {
            if (storage == null)
            {
                return(null);
            }

            CommandKeyBinding lLastSelected = null;

            Hashtable lFolders = storage.GetSubFolders(folderName);

            foreach (DictionaryEntry lEntry in lFolders)
            {
                string            lFolderName           = (string)lEntry.Key;
                CommandKeyFolder  lNewFolder            = new CommandKeyFolder(this);
                CommandKeyBinding lLastSelectedInFolder = lNewFolder.Load(storage, lFolderName);
                if (lLastSelectedInFolder != null)
                {
                    lLastSelected = lLastSelectedInFolder;
                }
            }

            _Name = ProcessFolderName(folderName);
            _Name = CodeRush.StrUtil.DecodeName(_Name);

            storage.FolderName = folderName;

            CommandKeyBinding lLastSelectedInBindings = LoadThisFolder(storage);

            if (lLastSelected == null)
            {
                lLastSelected = lLastSelectedInBindings;
            }
            return(lLastSelected);
        }
Exemple #4
0
        private void GetExistingFolders(CommandKeyFolder folder)
        {
            if (_ExistingFolders == null)
            {
                _ExistingFolders = new StringCollection();
            }
            else
            {
                _ExistingFolders.Clear();
            }

            if (folder == null || folder.Folders == null)
            {
                return;
            }

            for (int i = 0; i < folder.Folders.Count; i++)
            {
                CommandKeyFolder lFolder = folder.Folders[i] as CommandKeyFolder;
                if (lFolder == null)
                {
                    continue;
                }

                if (!lFolder.IsDeleted)
                {
                    _ExistingFolders.Add(lFolder.Name);
                }
            }
        }
Exemple #5
0
 public CommandKeyFolder(CommandKeyFolder parentFolder)
     : this()
 {
     if (parentFolder != null)
     {
         parentFolder.AddFolder(this);
     }
 }
Exemple #6
0
 public CommandKeyFolder()
 {
     _Enabled         = true;
     _IsDeleted       = false;
     _ParentFolder    = null;
     _Folders         = new ArrayList();
     _CommandBindings = new CommandKeyBindingCollection();
 }
Exemple #7
0
 // private methods...
 #region AddFoldersToCollection
 private void AddFoldersToCollection(CommandKeyBindingCollection collection)
 {
     for (int i = 0; i < _Folders.Count; i++)
     {
         CommandKeyFolder lFolder = _Folders[i] as CommandKeyFolder;
         lFolder.ToPlainCollection(collection);
     }
 }
Exemple #8
0
 public void RemoveFolder(CommandKeyFolder folder)
 {
     if (folder == null)
     {
         return;
     }
     folder._ParentFolder = null;
     _Folders.Remove(folder);
 }
Exemple #9
0
 // public methods...
 #region AddFolder
 public void AddFolder(CommandKeyFolder folder)
 {
     if (folder == null)
     {
         return;
     }
     folder._ParentFolder = this;
     _Folders.Add(folder);
 }
Exemple #10
0
 private void ChangeParent(CommandKeyFolder newParent)
 {
     if (_ParentFolder != null)
     {
         _ParentFolder.RemoveBinding(this);
     }
     if (newParent != null)
     {
         newParent.AddBinding(this);
     }
 }
Exemple #11
0
        public CommandKeyFolder Clone()
        {
            CommandKeyFolder lNewFolder = new CommandKeyFolder();

            lNewFolder._Name            = this.Name;
            lNewFolder._CommandBindings = this.CommandBindings.Clone();
            lNewFolder._CommandBindings.SetParent(lNewFolder);
            CloneFolders(lNewFolder);

            return(lNewFolder);
        }
Exemple #12
0
 private CommandKeyFolder GetRootFolder(CommandKeyFolder folder)
 {
     if (folder == null)
     {
         return(null);
     }
     if (folder.ParentFolder == null)
     {
         return(folder);
     }
     return(GetRootFolder(folder.ParentFolder));
 }
Exemple #13
0
        private void CloneFolders(CommandKeyFolder newParent)
        {
            for (int i = 0; i < Folders.Count; i++)
            {
                CommandKeyFolder lOldFolder = Folders[i] as CommandKeyFolder;
                if (lOldFolder == null)
                {
                    continue;
                }

                CommandKeyFolder lNewFolder = lOldFolder.Clone();
                newParent.AddFolder(lNewFolder);
            }
        }
Exemple #14
0
        private void ChangeName(string newName)
        {
            if (newName.Length == 0 || newName == Name)
            {
                return;
            }

            if (_Name != null && _Name != string.Empty)
            {
                CommandKeyFolder lNewFolder = this.Clone();
                lNewFolder.IsDeleted = true;
                _ParentFolder.AddFolder(lNewFolder);
            }

            _Name = newName;
        }
Exemple #15
0
 private CommandKeyBinding FindInFolders(string name)
 {
     if (_Folders == null)
     {
         return(null);
     }
     for (int i = 0; i < _Folders.Count; i++)
     {
         CommandKeyFolder  lFolder  = _Folders[i] as CommandKeyFolder;
         CommandKeyBinding lBinding = lFolder.Find(name);
         if (lBinding != null)
         {
             return(lBinding);
         }
     }
     return(null);
 }
Exemple #16
0
 private CommandKeyBinding FindInFolders(EditorCustomInputEventArgs ea)
 {
     if (_Folders == null)
     {
         return(null);
     }
     for (int i = 0; i < _Folders.Count; i++)
     {
         CommandKeyFolder  folder   = _Folders[i] as CommandKeyFolder;
         CommandKeyBinding lBinding = folder.Find(ea);
         if (lBinding != null)
         {
             return(lBinding);
         }
     }
     return(null);
 }
Exemple #17
0
        /// <summary>
        /// Loads the command key bindings from storage.
        /// </summary>
        /// <param name="aDecoupledStorage"></param>
        /// <returns>Returns the most recently selected command key binding.</returns>
        public CommandKeyBinding Load(DecoupledStorage aDecoupledStorage, CommandKeyFolder parentFolder)
        {
            Clear();
            CommandKeyBinding lLastSelected      = null;
            CommandKeyBinding lCommandKeyBinding = null;
            int thisCount = aDecoupledStorage.ReadInt32("Header", "Count", Count);

            for (int i = 0; i < thisCount; i++)
            {
                lCommandKeyBinding = new CommandKeyBinding();
                lCommandKeyBinding.SetParentFolder(parentFolder);
                if (lCommandKeyBinding.Load(aDecoupledStorage, "Command" + i.ToString()))
                {
                    lLastSelected = lCommandKeyBinding;
                }
                Add(lCommandKeyBinding);
            }
            return(lLastSelected);
        }
Exemple #18
0
        private void RemoveDeletedFolders(DecoupledStorage storage)
        {
            if (storage == null)
            {
                return;
            }

            for (int i = 0; i < Folders.Count; i++)
            {
                CommandKeyFolder lFolder = (CommandKeyFolder)Folders[i];
                if (lFolder.IsDeleted)
                {
                    storage.DeleteFolder(lFolder.TreePath.Trim(STR_PathSeparator[0]));
                }
                else
                {
                    lFolder.RemoveDeletedFolders(storage);
                }
            }
        }
Exemple #19
0
        private void SaveSubFolders(DecoupledStorage storage, CommandKeyBinding lastSelected)
        {
            if (storage == null || _Folders == null)
            {
                return;
            }

            for (int i = 0; i < _Folders.Count; i++)
            {
                CommandKeyFolder lFolder = _Folders[i] as CommandKeyFolder;
                if (lFolder == null)
                {
                    continue;
                }
                if (!lFolder.IsDeleted)
                {
                    lFolder.Save(storage, lastSelected);
                }
            }
        }
Exemple #20
0
 public bool ContainsFolder(string name)
 {
     if (name == null || name == "")
     {
         return(false);
     }
     for (int i = 0; i < Folders.Count; i++)
     {
         CommandKeyFolder lFolder = Folders[i] as CommandKeyFolder;
         if (lFolder == null)
         {
             continue;
         }
         if (lFolder.Name.ToLower() == name.ToLower() && !lFolder.IsDeleted)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #21
0
 private CommandKeyFolder SearchInSubFolders(ArrayList folders, string path)
 {
     if (folders == null)
     {
         return(null);
     }
     for (int i = 0; i < folders.Count; i++)
     {
         if (!(folders[i] is CommandKeyFolder))
         {
             continue;
         }
         CommandKeyFolder lFolder      = (CommandKeyFolder)folders[i];
         CommandKeyFolder lFoundFolder = lFolder.FindFolderByPath(path);
         if (lFoundFolder != null)
         {
             return(lFoundFolder);
         }
     }
     return(null);
 }
        private void FillFoldersRecursive(TreeListNodes nodes)
        {
            if (nodes == null || nodes.Count == 0)
            {
                return;
            }
            for (int i = 0; i < nodes.Count; i++)
            {
                if (!(nodes[i].Tag is CommandKeyFolder))
                {
                    continue;
                }
                CommandKeyFolder lFolder = nodes[i].Tag as CommandKeyFolder;
                if (FolderName.Length > 0 && lFolder.Name == FolderName)
                {
                    _Folders.Add(nodes[i]);
                }

                FillFoldersRecursive(nodes[i].Nodes);
            }
        }
Exemple #23
0
        public static bool RenameFolder(string caption, CommandKeyFolder parentFolder, ref string value)
        {
            NewFolderName newFolderName = new NewFolderName();

            newFolderName.Text            = caption;
            newFolderName.chkRoot.Visible = false;
            newFolderName.RootFolder      = null;
            newFolderName.ParentFolder    = parentFolder;
            newFolderName.GetExistingFolders(newFolderName.ParentFolder);
            newFolderName.FolderName = value;

            if (newFolderName.ShowDialog() == DialogResult.OK)
            {
                value = newFolderName.FolderName;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #24
0
 private void ChangeParent(CommandKeyFolder newParent)
 {
     if (_ParentFolder != null || newParent != null)
     {
         if (_ParentFolder == null)
         {
             newParent.AddFolder(this);
         }
         else if (newParent == null)
         {
             _ParentFolder.RemoveFolder(this);
         }
         else
         {
             CommandKeyFolder lNewFolder = this.Clone();
             lNewFolder._IsDeleted = true;
             _ParentFolder.AddFolder(lNewFolder);
             _ParentFolder.RemoveFolder(this);
             newParent.AddFolder(this);
         }
     }
 }
Exemple #25
0
        /// <summary>
        /// Finds folder by the given path inside subfolders of this folder.
        /// If folder is not found retuns null
        /// </summary>
        /// <param name="path">The path to use.</param>
        /// <returns></returns>
        public CommandKeyFolder FindFolderByPath(string path)
        {
            if (path == null || path == String.Empty)
            {
                return(null);
            }

            string lName;
            string lTrailingPath;

            SplitPath(path, out lName, out lTrailingPath);
            if (lName == Name)
            {
                CommandKeyFolder lFolder = SearchInSubFolders(Folders, lTrailingPath);
                if (lFolder != null)
                {
                    return(lFolder);
                }
                return(this);
            }
            return(null);
        }
Exemple #26
0
 protected internal void SetParentFolder(CommandKeyFolder parentFolder)
 {
     _ParentFolder = parentFolder;
 }
        // private methods...

        #region LoadShortcuts
        private void LoadShortcuts()
        {
            _RootFolder = new CommandKeyFolder();
            _RootFolder.Load(OptXkeysShortcuts.GetCategory(), OptXkeysShortcuts.GetPageName());
            _Shortcuts = _RootFolder.ToPlainCollection();
        }