public void ExecuteBinding(CommandKeyBinding binding)
 {
     if (binding != null && binding.IsAvailable)
     {
         binding.Execute();
     }
 }
        private void FillCustomDataBindingsRecursive(TreeListNodes nodes)
        {
            if (nodes == null || nodes.Count == 0 || _CustomInputShortcut == null)
            {
                return;
            }

            for (int i = 0; i < nodes.Count; i++)
            {
                if (nodes[i].Tag is CommandKeyFolder)
                {
                    FillCustomDataBindingsRecursive(nodes[i].Nodes);
                }
                else
                {
                    CommandKeyBinding binding = nodes[i].Tag as CommandKeyBinding;
                    if (binding == null)
                    {
                        continue;
                    }

                    if (binding.Matches(_CustomInputShortcut) == MatchQuality.FullMatch)
                    {
                        _CustomInputBindings.Add(nodes[i]);
                    }
                }
            }
        }
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);
        }
 private void FillCommandsRecursive(TreeListNodes nodes)
 {
     if (nodes == null || nodes.Count == 0)
     {
         return;
     }
     for (int i = 0; i < nodes.Count; i++)
     {
         if (nodes[i].Tag is CommandKeyFolder)
         {
             FillCommandsRecursive(nodes[i].Nodes);
         }
         else
         {
             CommandKeyBinding lBinding = nodes[i].Tag as CommandKeyBinding;
             if (lBinding == null)
             {
                 continue;
             }
             if (lBinding.Command != null && lBinding.Command == CommandName)
             {
                 _CommandBindings.Add(nodes[i]);
             }
         }
     }
 }
Exemple #5
0
 protected void SaveBindings(DecoupledStorage storage, CommandKeyBinding lastSelected)
 {
     if (storage == null)
     {
         return;
     }
     _CommandBindings.Save(storage, lastSelected);
 }
Exemple #6
0
 public void RemoveBinding(CommandKeyBinding binding)
 {
     if (binding == null)
     {
         return;
     }
     binding.SetParentFolder(null);
     _CommandBindings.Remove(binding);
 }
Exemple #7
0
 public void AddBinding(CommandKeyBinding binding)
 {
     if (binding == null)
     {
         return;
     }
     binding.SetParentFolder(this);
     _CommandBindings.Add(binding);
 }
Exemple #8
0
 public void Save(string category, string pageName, CommandKeyBinding lastSelected)
 {
     using (DecoupledStorage lStorage = new DecoupledStorage(category, pageName))
     {
         lStorage.LoadSubFolders();
         RemoveDeletedFolders(lStorage);
         lStorage.ClearAll();
         Save(lStorage, lastSelected);
     }
 }
Exemple #9
0
        // protected methods...
        #region SaveThisFolder(DecoupledStorage storage, CommandKeyBinding lastSelected)
        protected void SaveThisFolder(DecoupledStorage storage, CommandKeyBinding lastSelected)
        {
            if (storage == null)
            {
                return;
            }

            SaveFolderInfo(storage);
            SaveBindings(storage, lastSelected);
        }
Exemple #10
0
        public CommandKeyBinding Find(EditorCustomInputEventArgs ea)
        {
            CommandKeyBinding keyInBindings = _CommandBindings.Find(ea);

            if (keyInBindings != null)
            {
                return(keyInBindings);
            }
            return(FindInFolders(ea));
        }
Exemple #11
0
        public CommandKeyBinding Find(string name)
        {
            CommandKeyBinding lKeyInBindings = _CommandBindings.Find(name);

            if (lKeyInBindings != null)
            {
                return(lKeyInBindings);
            }
            return(FindInFolders(name));
        }
Exemple #12
0
        public CommandKeyBinding Load(string category, string pageName)
        {
            CommandKeyBinding lResult = null;

            using (DecoupledStorage lStorage = new DecoupledStorage(category, pageName))
            {
                lStorage.LoadSubFolders();
                lResult = Load(lStorage, "");
            }
            return(lResult);
        }
Exemple #13
0
        public void Save(DecoupledStorage aDecoupledStorage, CommandKeyBinding lastSelected)
        {
            aDecoupledStorage.WriteInt32("Header", "Count", Count);
            int lIndex = 0;

            foreach (CommandKeyBinding lCommandKeyBinding in this)
            {
                lCommandKeyBinding.Save(aDecoupledStorage, "Command" + lIndex.ToString(), lastSelected == lCommandKeyBinding);
                lIndex++;
            }
        }
Exemple #14
0
        public CommandKeyBindingCollection Clone()
        {
            CommandKeyBindingCollection lNewCollection = new CommandKeyBindingCollection();

            for (int i = 0; i < this.Count; i++)
            {
                CommandKeyBinding lNewBinding = this[i].Clone();
                lNewCollection.Add(lNewBinding);
            }

            return(lNewCollection);
        }
Exemple #15
0
        private void Save(DecoupledStorage storage, CommandKeyBinding lastSelected)
        {
            if (storage == null)
            {
                return;
            }

            string lFolderName = TreePath;

            storage.FolderName = lFolderName.Trim(STR_PathSeparator[0]);
            storage.Clear();
            //if (CommandBindings.Count != 0)
            SaveThisFolder(storage, lastSelected);
            SaveSubFolders(storage, lastSelected);
        }
Exemple #16
0
        public CommandKeyBinding Clone()
        {
            CommandKeyBinding result = new CommandKeyBinding();

            result.Command    = Command;
            result.Comments   = Comments;
            result.CustomData = CustomData;
            result.Parameters = Parameters;
            result.SetContext(Context);
            result.AltKeyDown       = AltKeyDown;
            result.CtrlKeyDown      = CtrlKeyDown;
            result.AnyShiftModifier = AnyShiftModifier;
            result.ShiftKeyDown     = ShiftKeyDown;

            return(result);
        }
Exemple #17
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 #18
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 #19
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 #20
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 #21
0
 public void Remove(CommandKeyBinding aCommandKeyBinding)
 {
     InnerList.Remove(aCommandKeyBinding);
 }
Exemple #22
0
 // public methods...
 #region Add
 public void Add(CommandKeyBinding aCommandKeyBinding)
 {
     InnerList.Add(aCommandKeyBinding);
 }