Пример #1
0
        /// <summary>
        /// Perform the operation - page through the list,
        /// activate a window etc
        /// </summary>
        /// <param name="itemTag">Meta data about seleted item</param>
        private void handleSelect(ItemTag itemTag)
        {
            switch (itemTag.DataType)
            {
            case ItemTag.ItemType.NextPage:
                gotoNextPage();
                break;

            case ItemTag.ItemType.PreviousPage:
                gotoPreviousPage();
                break;

            case ItemTag.ItemType.OrderBy:
                switchSortOrder();
                break;

            case ItemTag.ItemType.Window:
                if (itemTag.WInfo != null)
                {
                    if (!User32Interop.IsWindow(itemTag.WInfo.Handle) || !User32Interop.IsWindowVisible(itemTag.WInfo.Handle))
                    {
                        DialogUtils.ShowTimedDialog(this, "Window does not exist");
                    }
                    else if (DialogUtils.ConfirmScanner("Switch to " + itemTag.WInfo.Title + "?"))
                    {
                        if (EvtActivateWindow != null)
                        {
                            EvtActivateWindow.BeginInvoke(this, itemTag.WInfo, null, null);
                        }
                    }
                }

                break;
            }
        }
Пример #2
0
        /// <summary>
        /// User selected a file from the list.  If reqd,
        /// ask the user if she wants to open or delete the file
        /// </summary>
        /// <param name="fileInfo">FileInfo of the file selected</param>
        /// <returns>true on success</returns>
        private bool onFileSelected(FileInfo fileInfo)
        {
            bool doHighlightOff = true;

            if (fileInfo != null && File.Exists(fileInfo.FullName))
            {
                FileOperation operation = FileOperation.None;
                if (SelectActionOpen)
                {
                    if (DialogUtils.ConfirmScanner(string.Format(Resources._confirmActionVerb, ActionVerb, fileInfo.Name)))
                    {
                        operation = FileOperation.Open;
                    }
                }
                else
                {
                    operation = getFileOperationFromUser(fileInfo);
                }

                if (operation != FileOperation.None)
                {
                    handleFileOperation(operation, fileInfo);
                    if (operation == FileOperation.Open)
                    {
                        doHighlightOff = false;
                    }
                }
                else
                {
                    SelectedFile = String.Empty;
                }
            }

            return(doHighlightOff);
        }
Пример #3
0
        /// <summary>
        /// Event handler for when the user selects a file. Depending
        /// on the configuration, the file will be opened or the name
        /// of the file will be returned to the caller
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void _fileBrowserScanner_EvtFileOpen(object sender, EventArgs e)
        {
            _autoLaunchFile = AutoLaunchFile;
            SelectedFile    = _fileBrowserScanner.SelectedFile;

            var extension = Path.GetExtension(SelectedFile);

            if (String.IsNullOrEmpty(FileUtils.GetFileAssociationForExtension(extension)))
            {
                if (!DialogUtils.ConfirmScanner("No program associated with file. Open anyway?"))
                {
                    return;
                }
            }

            closeScanner();

            if (_autoLaunchFile && !String.IsNullOrEmpty(SelectedFile.Trim()))
            {
                handleOpenFile(SelectedFile);
            }
            else
            {
                ExitCode = CompletionCode.None;
            }

            Close();
        }
Пример #4
0
        /// <summary>
        /// Handle the selection - navigate, launch app etc
        /// </summary>
        /// <param name="itemTag">item tag of selected item</param>
        private void handleSelect(ItemTag itemTag)
        {
            switch (itemTag.DataType)
            {
            case ItemTag.ItemType.NextPage:
                gotoNextPage();
                break;

            case ItemTag.ItemType.PreviousPage:
                gotoPreviousPage();
                break;

            case ItemTag.ItemType.OrderBy:
                switchSortOrder();
                break;

            case ItemTag.ItemType.App:
                if (itemTag.ApplicationInfo != null)
                {
                    if (DialogUtils.ConfirmScanner("Launch " + itemTag.ApplicationInfo.Name + "?"))
                    {
                        if (EvtLaunchApp != null)
                        {
                            EvtLaunchApp.BeginInvoke(this, itemTag.ApplicationInfo, null, null);
                            return;
                        }
                    }
                }

                break;
            }
        }
Пример #5
0
        /// <summary>
        /// Event handler for when the user selects a file. Depending
        /// on the configuration, either the file will be opened or the name
        /// of the file will be returned to the caller.
        /// The SelectedFile property will contain the name of the selected file.
        /// </summary>
        /// <param name="sender">event sender</param>
        /// <param name="e">event args</param>
        private void _fileBrowserScanner_EvtFileOpen(object sender, EventArgs e)
        {
            _autoLaunchFile = AutoLaunchFile;
            SelectedFile    = _fileBrowserScanner.SelectedFile;

            var extension = Path.GetExtension(SelectedFile);

            if (String.IsNullOrEmpty(FileUtils.GetFileAssociationForExtension(extension)))
            {
                if (!DialogUtils.ConfirmScanner(PanelManager.Instance.GetCurrentForm(),
                                                R.GetString("NoProgramAssociatedWithFile")))
                {
                    return;
                }
            }

            closeScanner();

            if (_autoLaunchFile && !String.IsNullOrEmpty(SelectedFile.Trim()))
            {
                handleOpenFile(SelectedFile);
            }
            else
            {
                ExitCode = CompletionCode.None;
            }

            Close();
        }
Пример #6
0
            /// <summary>
            /// Executes the specified command
            /// </summary>
            /// <param name="handled">true if it was handled</param>
            /// <returns>true on success</returns>
            public override bool Execute(ref bool handled)
            {
                var form = Dispatcher.Scanner.Form as VolumeSettingsScanner;

                if (form._isDirty)
                {
                    String prompt;

                    if (form._volumeSelected == 0)
                    {
                        prompt = "Mute Speaker?";
                    }
                    else
                    {
                        prompt = "Set volume to " + form._volumeSelected + "?";
                    }

                    if (DialogUtils.ConfirmScanner(prompt))
                    {
                        Context.AppTTSManager.SetNormalizedVolume(form._volumeSelected);
                        Context.AppTTSManager.ActiveEngine.Save();
                    }
                    else
                    {
                        Context.AppTTSManager.ActiveEngine.SetVolume(form._initialSetting);
                    }
                }

                Windows.CloseForm(form);
                return(true);
            }
Пример #7
0
        /// <summary>
        /// Executes the command
        /// </summary>
        /// <param name="handled">set to true if the command was handled</param>
        /// <returns>true on success</returns>
        public override bool Execute(ref bool handled)
        {
            handled = true;

            switch (Command)
            {
            case "CmdRestartScanning":
                restartScanningHandler();
                break;

            case "CmdSwitchLanguage":
                switchLanguageHandler();
                break;

            case "CmdExitAppWithConfirm":
                if (DialogUtils.ConfirmScanner(null, R.GetString("QuitApplication")))
                {
                    quitApplication();
                }
                break;

            case "CmdExitApp":
                quitApplication();
                break;

            default:
                handled = false;
                break;
            }

            return(true);
        }
Пример #8
0
        /// <summary>
        /// User selected a file from the list.  If reqd,
        /// ask the user if she wants to open or delete the file
        /// </summary>
        /// <param name="itemTag">Tag of the file item selected</param>
        /// <returns>true on success</returns>
        private bool onFileSelected(ItemTag itemTag)
        {
            bool doHighlightOff = true;

            if (itemTag != null && itemTag.FInfo != null && File.Exists(itemTag.FInfo.FullName))
            {
                FileOperation operation = FileOperation.None;
                if (SelectActionOpen)
                {
                    if (DialogUtils.ConfirmScanner(ActionVerb + " " + itemTag.FInfo.Name + "?"))
                    {
                        operation = FileOperation.Open;
                    }
                }
                else
                {
                    operation = getFileOperationFromUser(itemTag);
                }

                if (operation != FileOperation.None)
                {
                    handleFileOperation(operation, itemTag);
                    if (operation == FileOperation.Open)
                    {
                        doHighlightOff = false;
                    }
                }
                else
                {
                    SelectedFile = String.Empty;
                }
            }

            return(doHighlightOff);
        }
Пример #9
0
 /// <summary>
 /// Delete the file
 /// </summary>
 /// <param name="fileInfo">info about the file</param>
 private void handleDeleteFile(FileInfo fileInfo)
 {
     if (DialogUtils.ConfirmScanner(String.Format(R.GetString("DeleteFileQ"), fileInfo.Name)))
     {
         Windows.SetText(SearchFilter, String.Empty);
         File.Delete(fileInfo.FullName);
         loadFiles();
     }
 }
Пример #10
0
        /// <summary>
        /// Invoked to run a command
        /// </summary>
        /// <param name="command">The command to execute</param>
        /// <param name="commandArg">Optional arguments for the command</param>
        /// <param name="handled">set this to true if handled</param>
        public override void OnRunCommand(String command, object commandArg, ref bool handled)
        {
            handled = true;
            switch (command)
            {
            case "SaveFile":
                AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.S);
                //DialogUtils.Toast("Saved");
                break;

            case "CmdFind":
                AgentManager.Instance.Keyboard.Send(Keys.LControlKey, Keys.F);
                break;

            case "NotepadLectureManager":
                if (TextControlAgent != null)
                {
                    String text = TextControlAgent.GetText();
                    if (String.IsNullOrEmpty(text.Trim()))
                    {
                        DialogUtils.ShowTimedDialog(PanelManager.Instance.GetCurrentPanel() as Form,
                                                    R.GetString("LectureManager"), R.GetString("DocumentIsEmpty"));

                        break;
                    }

                    if (DialogUtils.ConfirmScanner(R.GetString("LoadThisDocIntoLM")))
                    {
#pragma warning disable 4014
                        launchLectureManager();
#pragma warning restore 4014
                    }
                }

                break;

            case "SwitchAppWindow":
                DialogUtils.ShowTaskSwitcher(_notepadProcessName);
                break;

            case "CmdSnapMaxDockWindowToggle":
                if (snapWindowDockAlphabetScanner)
                {
                    Windows.ToggleForegroundWindowMaximizeDock(Context.AppPanelManager.GetCurrentForm() as Form,
                                                               Context.AppWindowPosition, true);
                }
                else
                {
                    Windows.ToggleSnapForegroundWindow(Context.AppWindowPosition, Common.AppPreferences.WindowSnapSizePercent);
                }
                break;

            default:
                base.OnRunCommand(command, commandArg, ref handled);
                break;
            }
        }
Пример #11
0
 /// <summary>
 /// User wants to add a new abbreviation
 /// </summary>
 private void handleAddNewAbbreviation()
 {
     if (EvtAddAbbreviation != null)
     {
         if (DialogUtils.ConfirmScanner(R.GetString("AddNewAbbreviation")))
         {
             Invoke(new MethodInvoker(() => EvtAddAbbreviation(Windows.GetText(SearchFilter))));
         }
     }
 }
Пример #12
0
 /// <summary>
 /// Gets confirmation from the user and quits
 /// </summary>
 private void quitFileBrowser()
 {
     if (_fileBrowserScanner != null)
     {
         if (DialogUtils.ConfirmScanner("Exit File Browser?"))
         {
             quit();
         }
     }
 }
Пример #13
0
 /// <summary>
 /// User wants to quit the app. Confirm and exit
 /// </summary>
 private void confirmAndQuitApplication()
 {
     Invoke(new MethodInvoker(delegate()
     {
         if (DialogUtils.ConfirmScanner(null, "Quit Application?"))
         {
             quitApplication();
         }
     }));
 }
Пример #14
0
 /// <summary>
 /// Confirms if the user wants to launch the selected
 /// app. If so, triggers an event to indicate that the user
 /// wants to launch the app.
 /// </summary>
 /// <param name="appInfo"></param>
 private void handleAppSelect(AppInfo appInfo)
 {
     if (DialogUtils.ConfirmScanner("Launch " + appInfo.Name + "?"))
     {
         if (EvtLaunchApp != null)
         {
             EvtLaunchApp.BeginInvoke(this, appInfo, null, null);
         }
     }
 }
Пример #15
0
 /// <summary>
 /// User wants to quit the app. Confirm and exit
 /// </summary>
 private void confirmAndQuitApplication()
 {
     Invoke(new MethodInvoker(delegate
     {
         if (DialogUtils.ConfirmScanner(null, R.GetString("QuitApplication")))
         {
             quitApplication();
         }
     }));
 }
Пример #16
0
 /// <summary>
 /// Confirms if the user wants to launch the selected
 /// app. If so, triggers an event to indicate that the user
 /// wants to launch the app.
 /// </summary>
 /// <param name="appInfo"></param>
 private void handleAppSelect(AppInfo appInfo)
 {
     if (DialogUtils.ConfirmScanner(string.Format(Resources.Launch0, appInfo.Name)))
     {
         if (EvtLaunchApp != null)
         {
             EvtLaunchApp.BeginInvoke(this, appInfo, null, null);
         }
     }
 }
Пример #17
0
 /// <summary>
 /// Clears the search filter
 /// </summary>
 public void ClearFilter()
 {
     Invoke(new MethodInvoker(delegate
     {
         if (SearchFilter.Text.Length > 0 && DialogUtils.ConfirmScanner("Clear filter?"))
         {
             SearchFilter.Text = String.Empty;
         }
     }));
 }
Пример #18
0
 /// <summary>
 /// User wants to quit the app. Confirm and exit
 /// </summary>
 private void confirmAndQuitApplication()
 {
     Invoke(new MethodInvoker(delegate()
     {
         if (DialogUtils.ConfirmScanner(null, ACAT.Extensions.Default.UI.Menus.Properties.Resources.QuitApplication))
         {
             quitApplication();
         }
     }));
 }
Пример #19
0
 /// <summary>
 /// Confirms if the user wants to launch the selected
 /// app. If so, triggers an event to indicate that the user
 /// wants to launch the app.
 /// </summary>
 /// <param name="appInfo"></param>
 private void handleAppSelect(AppInfo appInfo)
 {
     if (DialogUtils.ConfirmScanner(String.Format(R.GetString("LaunchAppQ"), appInfo.Name)))
     {
         if (EvtLaunchApp != null)
         {
             EvtLaunchApp.BeginInvoke(this, appInfo, null, null);
         }
     }
 }
Пример #20
0
 private void handleOpenFile(FileInfo fileInfo)
 {
     if (DialogUtils.ConfirmScanner(String.Format(R.GetString("OpenFileQ"), fileInfo.Name)))
     {
         SelectedFile = fileInfo.FullName;
         if (EvtFileOpen != null)
         {
             EvtFileOpen.BeginInvoke(this, new EventArgs(), null, null);
         }
     }
 }
Пример #21
0
 /// <summary>
 /// Gets confirmation from the user and quits
 /// </summary>
 private void quitFileBrowser()
 {
     if (_fileBrowserScanner != null)
     {
         if (DialogUtils.ConfirmScanner(PanelManager.Instance.GetCurrentForm(), R.GetString("CloseQ")))
         {
             ExitCode = CompletionCode.None;
             quit();
         }
     }
 }
Пример #22
0
        /// <summary>
        /// Gets confirmation whether the user wants to open the file
        /// and closes the form
        /// </summary>
        private void handleOpenFile()
        {
            if (FInfo != null)
            {
                if (!DialogUtils.ConfirmScanner("Open " + FInfo.Name + "?"))
                {
                    return;
                }
            }

            OpenFile = true;
            Windows.CloseForm(this);
        }
Пример #23
0
        /// <summary>
        /// Gets confirmation whether the user wants to open the file
        /// and closes the form
        /// </summary>
        private void handleOpenFile()
        {
            if (FInfo != null)
            {
                if (!DialogUtils.ConfirmScanner(PanelManager.Instance.GetCurrentForm(),
                                                "Open " + FInfo.Name + "?"))
                {
                    return;
                }
            }

            OpenFile = true;
            Windows.CloseForm(this);
        }
Пример #24
0
 /// <summary>
 /// User selected a window to switch to.  Trigger an event
 /// to indicate this.
 /// </summary>
 /// <param name="wInfo">Window info of the window selected</param>
 private void handleWindowSelect(EnumWindows.WindowInfo wInfo)
 {
     if (!User32Interop.IsWindow(wInfo.Handle) || !User32Interop.IsWindowVisible(wInfo.Handle))
     {
         DialogUtils.ShowTimedDialog(this, R.GetString("WindowNotFound"));
     }
     else if (DialogUtils.ConfirmScanner(String.Format(R.GetString("ConfirmSwitchToWindow"), wInfo.Title)))
     {
         if (EvtActivateWindow != null)
         {
             EvtActivateWindow.BeginInvoke(this, wInfo, null, null);
         }
     }
 }
Пример #25
0
        /// <summary>
        /// Gets confirmation whether the user wants to delete the file
        /// and closes the form
        /// </summary>
        private void handleDeleteFile()
        {
            if (FInfo != null)
            {
                if (!DialogUtils.ConfirmScanner(PanelManager.Instance.GetCurrentForm(),
                                                string.Format(Resources.Delete0, FInfo.Name)))
                {
                    return;
                }
            }

            DeleteFile = true;
            Windows.CloseForm(this);
        }
Пример #26
0
        /// <summary>
        /// Gets confirmation whether the user wants to open the file
        /// and closes the form
        /// </summary>
        private void handleOpenFile()
        {
            if (FInfo != null)
            {
                if (!DialogUtils.ConfirmScanner(PanelManager.Instance.GetCurrentForm(),
                                                String.Format(R.GetString("OpenFileQ"), FInfo.Name)))
                {
                    return;
                }
            }

            OpenFile = true;
            Windows.CloseForm(this);
        }
Пример #27
0
 /// <summary>
 /// User selected a window to switch to.  Trigger an event
 /// to indicate this.
 /// </summary>
 /// <param name="wInfo">Window info of the window selected</param>
 private void handleWindowSelect(EnumWindows.WindowInfo wInfo)
 {
     if (!User32Interop.IsWindow(wInfo.Handle) || !User32Interop.IsWindowVisible(wInfo.Handle))
     {
         DialogUtils.ShowTimedDialog(this, Resources.WindowDoesNotExist);
     }
     else if (DialogUtils.ConfirmScanner(string.Format(Resources.SwitchTo, wInfo.Title)))
     {
         if (EvtActivateWindow != null)
         {
             EvtActivateWindow.BeginInvoke(this, wInfo, null, null);
         }
     }
 }
Пример #28
0
 /// <summary>
 /// Confirm and close the scanner
 /// </summary>
 private void close()
 {
     if (EvtQuit != null)
     {
         EvtQuit.BeginInvoke(this, null, null, null);
     }
     else
     {
         if (DialogUtils.ConfirmScanner(PanelManager.Instance.GetCurrentForm(), R.GetString("CloseQ")))
         {
             Windows.CloseForm(this);
         }
     }
 }
Пример #29
0
 /// <summary>
 /// User selected a window to switch to.  Trigger an event
 /// to indicate this.
 /// </summary>
 /// <param name="wInfo">Window info of the window selected</param>
 private void handleWindowSelect(EnumWindows.WindowInfo wInfo)
 {
     if (!User32Interop.IsWindow(wInfo.Handle) || !User32Interop.IsWindowVisible(wInfo.Handle))
     {
         DialogUtils.ShowTimedDialog(this, "Window does not exist");
     }
     else if (DialogUtils.ConfirmScanner("Switch to " + wInfo.Title + "?"))
     {
         if (EvtActivateWindow != null)
         {
             EvtActivateWindow.BeginInvoke(this, wInfo, null, null);
         }
     }
 }
        /// <summary>
        /// If text-to-speech is handled by hardware, this function
        /// can be used to send any escape sequences to control
        /// speech parameters in the hw.
        /// First checks if the speech controller supports
        /// the feature.
        /// </summary>
        private void handleSpeechControl()
        {
            String word = String.Empty;

            if (!Context.AppTTSManager.ActiveEngine.GetInvoker().SupportsMethod("SpeechControl") ||
                !Context.AppTTSManager.ActiveEngine.GetInvoker().SupportsMethod("IsValidSpeechControlSequence"))
            {
                return;
            }

            try
            {
                using (AgentContext context = Context.AppAgentMgr.ActiveContext())
                {
                    context.TextAgent().GetWordAtCaret(out word);
                }

                object ret = Context.AppTTSManager.ActiveEngine.GetInvoker()
                             .InvokeExtensionMethod("IsValidSpeechControlSequence", word);
                bool retVal = false;
                if (ret is bool)
                {
                    retVal = (bool)ret;
                }

                if (retVal)
                {
                    var prompt = Resources.SendSpeechControlSequence;
                    if (Context.AppTTSManager.ActiveEngine.GetInvoker().SupportsMethod("GetSpeechControlPrompt"))
                    {
                        ret = Context.AppTTSManager.ActiveEngine.GetInvoker()
                              .InvokeExtensionMethod("GetSpeechControlPrompt", word);
                        if (ret is String)
                        {
                            prompt = ret as String;
                        }

                        if (DialogUtils.ConfirmScanner(prompt))
                        {
                            Context.AppTTSManager.ActiveEngine.GetInvoker().InvokeExtensionMethod("SpeechControl", word);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }