Пример #1
0
        public void ExecuteCommand(IEnsoService service, Command command)
        {
            Logging.AddActionLog(string.Format("WebSearcher: Executing command '{0}' ...", command.Name));

            if (command.Name == "learn as web search command with name")
            {
                ShortcutTemplates.CreateShortcutTemplate(command.parametersOnExecute[0].GetValueAsText(), command.parametersOnExecute[1].GetValueAsText());
                SuggestionsCache.DropCache(typeof(WorkItemsProviders.ShortcutTemplates.ShortcutTemplates));
                EnsoPlus.current.Reinitialize();
                string message = string.Format("{0} is now a command.", command.parametersOnExecute[0].GetValueAsText());
                Logging.AddActionLog(string.Format("WebSearcher: {0}", message));
                MessagesHandler.Display(message);
            }
            else
            {
                string  shortcutFilePath = ShortcutTemplates.BuildFilePath(command.Name);
                string  template         = ShortcutTemplates.GetTemplate(shortcutFilePath);
                string  queryString      = string.Format(template, command.parametersOnExecute[0].GetValueAsText());
                Process process          = new Process();
                process.StartInfo.UseShellExecute = true;
                process.StartInfo.FileName        = queryString;
                Logging.AddActionLog(string.Format("WebSearcher: Starting '{0}' ...", process.StartInfo.FileName));
                process.Start();
            }
        }
Пример #2
0
        private void SetSourceFolderOnBackupProfile(Extension.IEnsoService service, Command command, string name, string sourceFolder)
        {
            string        filePath      = WorkItemsProviders.BackupProfiles.BackupProfiles.GetFilePath(name);
            BackupProfile backupProfile = null;

            if (File.Exists(filePath))
            {
                backupProfile = WorkItemsProviders.BackupProfiles.BackupProfiles.Load(name);
            }
            else
            {
                backupProfile      = new BackupProfile();
                backupProfile.Name = name;
            }
            backupProfile.SourceFolder = sourceFolder;
            WorkItemsProviders.BackupProfiles.BackupProfiles.Save(backupProfile);

            if (string.IsNullOrEmpty(backupProfile.DestinationFolder))
            {
                SuggestionsCache.DropCache(this.GetType());
                MessagesHandler.Display(string.Format("Profile created. Use 'set as backup destination...' command now.", command.Name));
            }
            else
            {
                MessagesHandler.Display(string.Format(string.Format("Profile updated. You can now use 'backup {0}' command to create backups quickly.", name)));
            }
        }
Пример #3
0
        public void Remove(IWorkItem workItemToRemove)
        {
            MemorizedString memorizedString = workItemToRemove as MemorizedString;

            System.IO.File.Delete(memorizedString.filePath);
            SuggestionsCache.DropCache(this.GetType());
        }
Пример #4
0
        public void Remove(IWorkItem workItemToRemove)
        {
            Shortcut bookmark            = (Shortcut)workItemToRemove;
            string   destinationFilePath = Path.Combine(Settings.Current.EnsoLearnAsOpenCommandsFolder, Path.GetFileName(bookmark.shortcutFilePath));

            File.Move(bookmark.shortcutFilePath, destinationFilePath);
            SuggestionsCache.DropCache(this.GetType());
        }
Пример #5
0
        public void Remove(IWorkItem workItemToRemove)
        {
            ShortcutTemplate shortcutTemplate = workItemToRemove as ShortcutTemplate;

            File.Delete(shortcutTemplate.filePath);
            SuggestionsCache.DropCache(this.GetType());
            EnsoPlus.current.Reinitialize();
        }
Пример #6
0
        public void Remove(IWorkItem workItemToRemove)
        {
            Shortcut shortcutToRemove = workItemToRemove as Shortcut;
            string   retiredFilePath  = Path.Combine(Settings.Current.EnsoLearnAsOpenCommandsRetiredFilesFolder, Path.GetFileName(shortcutToRemove.shortcutFilePath));

            System.IO.File.Move(shortcutToRemove.shortcutFilePath, retiredFilePath);
            SuggestionsCache.DropCache(this.GetType());
        }
Пример #7
0
        public void Remove(IWorkItem workItemToRemove)
        {
            string filePath = GetFilePath(workItemToRemove.GetCaption());

            File.Delete(filePath);
            SuggestionsCache.DropCache(this.GetType());
            EnsoPlus.current.Reinitialize();
        }
Пример #8
0
        public void Remove(IWorkItem workItemToRemove)
        {
            Macro macro = workItemToRemove as Macro;

            File.Delete(macro.filePath);
            SuggestionsCache.DropCache(this.GetType());
            EnsoPlus.current.Reinitialize();
        }
Пример #9
0
        public void ExecuteCommand(Extension.IEnsoService service, Command command)
        {
            Logging.AddActionLog(string.Format("Opener: Executing command '{0}' ...", command.Name));

            if (command.Name == "open")
            {
                //if (command.parametersOnExecute[0] is Entities.WorkItems.Shortcuts)
                //{
                //	Entities.WorkItems.Shortcuts shortcuts = command.parametersOnExecute[0] as Entities.WorkItems.Shortcuts;

                //	Logging.AddActionLog(string.Format("Opener: Opening '{0}' in Chrome ...", shortcuts.shortcutsFilePath));
                //	MessagesHandler.Display( string.Format("Opening {0} ...", shortcuts.caption));

                //	foreach (Shortcut shortcut in shortcuts.shortcuts)
                //	{
                //		Logging.AddActionLog(string.Format("COpener: Opening '{0}' in Chrome ...", shortcut.targetPath));

                //		OpenInChrome(shortcut.targetPath, command.Name.Contains("tab"), command.Name.Contains("incognito"));
                //	}
                //}
                //else
                //{
                Logging.AddActionLog(string.Format("Opener: Opening '{0}' ...", command.parametersOnExecute[0].GetValueAsText()));

                string message = command.parametersOnExecute[0].GetValueAsText();
                if (File.Exists(message))
                {
                    message = Path.GetFileNameWithoutExtension(message);
                }
                else if (Directory.Exists(message))
                {
                    message = Path.GetFileNameWithoutExtension(message);
                }

                MessagesHandler.Display(string.Format("Opening {0} ...", message));

                Open(command.parametersOnExecute[0].GetValueAsText());
                //}
            }
            else if (command.Name == "learn as open")
            {
                Logging.AddActionLog(string.Format("Opener: learn as open '{0}' ...", command.parametersOnExecute[0].GetValueAsText()));
                string content         = "[InternetShortcut]\r\nURL=" + command.parametersOnExecute[1].GetValueAsText();
                string shortcutsFolder = Settings.Current.EnsoLearnAsOpenCommandsFolder;
                CraftSynth.BuildingBlocks.IO.FileSystem.CreateFolderIfItDoesNotExist(shortcutsFolder);
                string filePath = Path.Combine(shortcutsFolder, command.parametersOnExecute[0].GetValueAsText() + ".url");
                File.WriteAllText(filePath, content);
                SuggestionsCache.DropCache(typeof(WorkItemsProviders.Shortcuts.FilesWorkItems));
                MessagesHandler.Display("Learned 'open " + command.parametersOnExecute[0].GetValueAsText() + "'");
            }
        }
Пример #10
0
        public static void SaveAllTabs(bool saveInOneFile, Extension.IEnsoService service, string caption, string shortcutsFolder, string commandProviderNameForLog)
        {
            string clipboardText = CraftSynth.BuildingBlocks.IO.Clipboard.GetTextFromClipboard();

            clipboardText = clipboardText.Trim();
            if (string.IsNullOrEmpty(clipboardText))
            {
                MessagesHandler.Display("Error: Clipboard empty.", saveAllTabsUserManual);
            }
            else
            {
                Entities.WorkItems.Shortcuts shortcuts = null;
                try
                {
                    shortcuts = new Entities.WorkItems.Shortcuts(caption, clipboardText);
                    if (shortcuts.shortcuts.Count == 0)
                    {
                        throw new ApplicationException("No urls in clipboard.");
                    }
                }
                catch (Exception)
                {
                    MessagesHandler.Display("Error: Invalid text format in clipboard.", saveAllTabsUserManual);
                    Logging.AddErrorLog(commandProviderNameForLog + ": Error: Invalid text format in clipboard");
                }

                if (shortcuts != null && shortcuts.shortcuts.Count > 0)
                {
                    if (string.IsNullOrEmpty(shortcutsFolder))
                    {
                        shortcutsFolder = Settings.Current.EnsoLearnAsOpenCommandsFolder;
                    }
                    CraftSynth.BuildingBlocks.IO.FileSystem.CreateFolderIfItDoesNotExist(shortcutsFolder);

                    if (saveInOneFile)
                    {
                        shortcuts.Save(shortcutsFolder);
                        SuggestionsCache.DropCache(typeof(WorkItemsProviders.Shortcuts.ShortcutsLists));
                        Logging.AddActionLog(string.Format(commandProviderNameForLog + ": {0} tabs saved in '{1}'.", shortcuts.shortcuts.Count, Path.Combine(shortcutsFolder, caption)));
                        MessagesHandler.Display(string.Format("{0} tabs saved in one shortcut {1}.", shortcuts.shortcuts.Count, caption));
                    }
                    else
                    {
                        shortcuts.SaveAsSeparateShortcuts(shortcutsFolder);
                        Logging.AddActionLog(string.Format(commandProviderNameForLog + ": {0} tabs saved as separate files in '{1}'.", shortcuts.shortcuts.Count, shortcutsFolder));
                        MessagesHandler.Display(string.Format("{0} shortcuts saved in category {1}.", shortcuts.shortcuts.Count, caption));
                    }
                }
            }
        }
Пример #11
0
        public void ExecuteCommand(IEnsoService service, Command command)
        {
            Logging.AddActionLog(string.Format("Memorizer: Executing command '{0}' ...", command.Name));

            if (command.Name == "memorize" && command.Postfix == "[what to memorize] as [item name]")
            {
                if (!Directory.Exists(Settings.Current.MemorizerDataFolder))
                {
                    Directory.CreateDirectory(Settings.Current.MemorizerDataFolder);
                    Logging.AddActionLog(string.Format("Memorizer: Folder '{0}' created.", Settings.Current.MemorizerDataFolder));
                }
                string filePath = Path.Combine(Settings.Current.MemorizerDataFolder, command.parametersOnExecute[1].GetValueAsText() + ".txt");
                File.WriteAllText(filePath, command.parametersOnExecute[0].GetValueAsText());
                SuggestionsCache.DropCache(typeof(WorkItemsProviders.MemorizedData.MemorizedData));
                string message = string.Format("{0} memorized", command.parametersOnExecute[1].GetValueAsText());
                Logging.AddActionLog(string.Format("Memorizer: {0}", message));
                MessagesHandler.Display(message);
            }
            else
            if (command.Name == "memorize-as" && command.Postfix == "[item name] [what to memorize]")
            {
                if (!Directory.Exists(Settings.Current.MemorizerDataFolder))
                {
                    Directory.CreateDirectory(Settings.Current.MemorizerDataFolder);
                    Logging.AddActionLog(string.Format("Memorizer: Folder '{0}' created.", Settings.Current.MemorizerDataFolder));
                }
                string filePath = Path.Combine(Settings.Current.MemorizerDataFolder, command.parametersOnExecute[0].GetValueAsText() + ".txt");
                File.WriteAllText(filePath, command.parametersOnExecute[1].GetValueAsText());
                SuggestionsCache.DropCache(typeof(WorkItemsProviders.MemorizedData.MemorizedData));
                string message = string.Format("{0} memorized", command.parametersOnExecute[0].GetValueAsText());
                Logging.AddActionLog(string.Format("Memorizer: {0}", message));
                MessagesHandler.Display(message);
            }
            else
            if (command.Name == "display" && command.Postfix == "[item name]")
            {
                MessagesHandler.Display(command.parametersOnExecute[0].GetValueAsText());
                Logging.AddActionLog(string.Format("Memorizer: {0} displayed.", command.parametersOnExecute[0].GetValueAsText()));
            }
            else
            if (command.Name == "drop" && command.Postfix == "[item name]")
            {
                HandlerForSelection.Put(command.parametersOnExecute[0].GetValueAsText());
                Logging.AddActionLog(string.Format("Memorizer: {0} dropped.", command.parametersOnExecute[0].GetValueAsText()));
            }
            else
            {
                throw new ApplicationException(string.Format("Memorizer: Command not found. Command: {0} {1}", command.Name, command.Postfix));
            }
        }
Пример #12
0
        public void ExecuteCommand(Extension.IEnsoService service, Command command)
        {
            Logging.AddActionLog(string.Format("Misc: Executing command '{0}' ...", command.Name));

            if (command.Name == "edit general settings")
            {
                Logging.AddActionLog(string.Format("Misc: Opening settings file '{0}' ...", Settings.FilePath));
                MessagesHandler.Display(string.Format("Opening {0} ...", Settings.FilePath));

                Process process = new Process();
                process.StartInfo.UseShellExecute = true;
                process.StartInfo.Arguments       = string.Format("\"{0}\"", Settings.FilePath);
                process.StartInfo.FileName        = "Notepad";
                process.Start();
                CraftSynth.BuildingBlocks.WindowsNT.Misc.SetForegroundWindow("EnsoPlusSettings.xml - Notepad");
                Logging.AddActionLog("Misc: Settings file opened.");
            }
            else
            if (command.Name == "edit selection listener settings")
            {
                Logging.AddActionLog(string.Format("Misc: Opening settings file '{0}' ...", SelectionListener.Settings.FilePath));
                MessagesHandler.Display(string.Format("Opening {0} ...", SelectionListener.Settings.FilePath));

                Process process = new Process();
                process.StartInfo.UseShellExecute = true;
                process.StartInfo.Arguments       = string.Format("\"{0}\"", SelectionListener.Settings.FilePath);
                process.StartInfo.FileName        = "Notepad";
                process.Start();
                CraftSynth.BuildingBlocks.WindowsNT.Misc.SetForegroundWindow("SelectionListener.ini - Notepad");
                Logging.AddActionLog("Misc: Settings file opened.");
            }
            else
            if (command.Name == "exit Enso+" || command.Name == "close Enso+")
            {
                Exit();
            }
            else
            if (command.Name == "caps lock on")
            {
                Logging.AddActionLog("Misc: Turning caps lock on ...");
                //MessagesHandler.Display( string.Format("Exiting Enso+ ..."));
                Program.cornerLauncher.TurnOnCapsLock();
            }
            else
            if (command.Name == "caps lock off")
            {
                Logging.AddActionLog("Misc: Turning caps lock off ...");
                //MessagesHandler.Display( string.Format("Exiting Enso+ ..."));
                Program.cornerLauncher.TurnOffCapsLock();
            }
            else
            if (command.Name == "clear cached suggestions")
            {
                SuggestionsCache.DropAllCache();
                Logging.AddActionLog("Misc: Cache cleared.");
                MessagesHandler.Display("Cache cleared.");
            }
            else
            if (command.Name == "restart Enso+")
            {
                Restart();
            }
            else
            if (command.Name == "open in notepad" || command.Name == "preview in notepad")
            {
                //MessagesHandler.Display( string.Format("Executing {0} ...", command.Name));
                CraftSynth.BuildingBlocks.WindowsNT.Misc.OpenTextInNotepad(Common.Helper.GetEnsoTempraryFilePath("txt"), command.parametersOnExecute[0].GetValueAsText());
            }
            else
            //if (command.Name == "command name" && command.Postfix == "postfix [item] [item2]")
            //{
            //    MessagesHandler.Display( string.Format("Executing {0} ...", command.Name));

            //}
            //else
            {
                throw new ApplicationException(string.Format("Misc: Command not found. Command: {0} {1}", command.Name, command.Postfix));
            }
        }