Exemplo n.º 1
0
        private void Button_Click_7(object sender, RoutedEventArgs e)
        {
            Calculator cal = new Calculator();

            cal.Show();
            Speak_Listen.CalcInit(cal);
        }
Exemplo n.º 2
0
        private void Button_Click_6(object sender, RoutedEventArgs e)
        {
            File_Manager fm = new File_Manager();

            fm.Show();
            Speak_Listen.FMInit(fm);
        }
Exemplo n.º 3
0
        private void Button_Click_5(object sender, RoutedEventArgs e)
        {
            Media_Player mp = new Media_Player();

            mp.Show();
            Speak_Listen.MPInit(mp);
        }
Exemplo n.º 4
0
        private bool ValidateWithAcknowlwdgement(string s, bool fo)                             // s => name of file/folder; (f == true) => folder, else file
        {
            string item = (fo?"folder":"file");

            if (!Valid(s))
            {
                Speak_Listen.StartPromptBuilder();
                Speak_Listen.AddPrompt("A " + item + " name can't contain any of these characters:");
                Speak_Listen.AddPrompt("Forward slash, Backslash, Pipe, Quote, Colon, Question Mark, Less Than, Greater Than, Asterisk");
                Speak_Listen.AddPrompt("A " + item + " can't contain only spaces. There has to be atleast one allowed character with space.");
                Speak_Listen.AddPrompt("Please type again");
                Speak_Listen.SpeakPrompt();
                TB1.Text = "";
                return(false);
            }
            if (fo)
            {
                return(true);
            }
            // Regular Expression (for File Format): Any name with atleast one letter in [a-z,A-Z,0-9] before "." and atleast one letter in [a-z,A-Z,0-9] after "."
            Regex regex = new Regex(@"^[a-zA-Z0-9]+\.[a-zA-Z0-9]+$");

            if (!regex.IsMatch(s))
            {
                Speak_Listen.Speak("File name can't be without an extension.");
                TB1.Text = "";
                return(false);
            }
            return(true);
        }
Exemplo n.º 5
0
        public void ReadOutControls(bool isBack, bool isNext, bool isUp, bool isDown, bool isFF, string ff)
        {
            Speak_Listen.StartPromptBuilder();
            if (isBack)
            {
                Speak_Listen.AddPrompt("Say Back to go back");
            }
            if (isNext)
            {
                Speak_Listen.AddPrompt("Say Next to go forward");
            }
            if (isUp)
            {
                Speak_Listen.AddPrompt("Say Up to move up the list");
            }
            if (isDown)
            {
                Speak_Listen.AddPrompt("Say Down to move down the list");
            }
            if (isFF)
            {
                Speak_Listen.AddPrompt("Say " + ff + " to dictate the " + ff);
            }

            Speak_Listen.AddPrompt("Say Refresh to refresh the list");
            Speak_Listen.AddPrompt("Say Read Out to dictate the list");
            Speak_Listen.AddPrompt("Say Controls to dictate the available controls");

            if (pD != null)
            {
                Speak_Listen.AddPrompt("Say Filter to filter the list");
            }

            Speak_Listen.SpeakPrompt();
        }
Exemplo n.º 6
0
 public static void Pdf2Speech(string filename)
 {
     Pdf2Text(filename);
     using (StreamReader sr = new StreamReader(filename + ".txt"))
     {
         string readout = sr.ReadToEnd();
         Speak_Listen.Speak(readout);
     }
 }
Exemplo n.º 7
0
        public void ReadOutListItems()
        {
            Speak_Listen.StartPromptBuilder();
            if (filter != "*")
            {
                string s = filter.Substring(1);
                if (isFolder != 0 && (isFolder == 1 || dirs.Count == 0))
                {
                    Speak_Listen.AddPrompt("This folder contains " + dirs.Count + " " + s + " folders and " + fileList.Count + " " + s + " files.");
                }
            }
            if (isFolder == 0)
            {
                if (filter == "*")
                {
                    Speak_Listen.AddPrompt("Sorry, this folder is empty");
                }
                else
                {
                    Speak_Listen.AddPrompt("Sorry, this folder has no " + filter.Substring(1) + " items");
                }
            }
            else
            {
                if (isFolder == 1)
                {
                    if (firstItemNo == 1 && filter == "*")
                    {
                        if (pD != null)
                        {
                            Speak_Listen.AddPrompt("There is a total of " + dirs.Count.ToString() + " folders and " + fileList.Count.ToString() + " files in this directory.");
                        }
                        else      // Indicates "This PC" part
                        {
                            Speak_Listen.AddPrompt("There is a total of " + (dirs.Count - 5).ToString() + " drives and 5 special folders in your Computer.");
                        }
                    }
                    if (pD != null)
                    {
                        Speak_Listen.AddPrompt("Here is the list of folders from " + firstItemNo.ToString() + " to " + lastItemNo.ToString());
                    }
                }
                else                                    // Files
                {
                    Speak_Listen.AddPrompt("Here is the list of files from " + firstItemNo.ToString() + " to " + lastItemNo.ToString());
                }

                int len = items.Count;
                for (int i = 1; i <= len; i++)
                {
                    Speak_Listen.AddPrompt("Number " + i.ToString() + ", " + items[i - 1].Folder);
                }
            }
            Speak_Listen.SpeakPrompt();
        }
Exemplo n.º 8
0
 private void ReadOutFilters()
 {
     Speak_Listen.StartPromptBuilder();
     for (int i = 1; i < 12; i++)
     {
         string s = ((ComboBoxItem)(DropDown.Items[i - 1])).Content.ToString();
         Speak_Listen.AddPrompt("Say " + (i.ToString()) + " to filter " + s);
     }
     Speak_Listen.AddPrompt("Say Repeat to repeat the list");
     Speak_Listen.SpeakPrompt();
 }
Exemplo n.º 9
0
        private void Filter(int index)
        {
            if (fmp == null || pD == null)                            // Occurs when the File_Manager() constructor is called
            {
                return;
            }
            string s = ((ComboBoxItem)(DropDown.Items[index - 1])).Content.ToString();

            fmp.Filter(s);
            UpdateMembers(false);
            Speak_Listen.Speak("Filter is set to " + s);
        }
Exemplo n.º 10
0
        private void DeleteFile(string fileName)
        {
            string pathString = Path.Combine(pD.FullName, fileName);

            if (File.Exists(pathString))
            {
                File.Delete(pathString);
                Refresh();
                Speak_Listen.Speak("The file named " + fileName + " is deleted successfully");
                return;
            }
            Speak_Listen.Speak("Sorry, the file has been removed by an unknown source.");
            modifyListStatus = 0;
        }
Exemplo n.º 11
0
        public void AcknowlwdgeOpen()
        {
            string s;

            if (pD == null)
            {
                s = "File Manager Home";
            }
            else
            {
                s = pD.Name;
            }
            Speak_Listen.Speak(s + " is Opened");
        }
Exemplo n.º 12
0
        private void DeleteDirectory(string dirName)
        {
            string pathString = Path.Combine(pD.FullName, dirName);

            if (Directory.Exists(pathString))
            {
                Directory.Delete(pathString);
                Refresh();
                Speak_Listen.Speak("The folder named " + dirName + " is deleted successfully");
                return;
            }
            Speak_Listen.Speak("Sorry, the folder has been removed by an unknown source.");
            modifyListStatus = 0;
        }
Exemplo n.º 13
0
        public void SelectItem(int n)
        {
            LB.SelectedIndex = n - firstItemNo;
            string s;

            if (isFolder == 1)
            {
                s = dictFolder[items[n - 1].Folder].Name;
            }
            else
            {
                s = dictFiles[items[n - 1].Folder].Name;
            }
            Speak_Listen.Speak(s + " is selected.");
        }
Exemplo n.º 14
0
 // start playing song after the choice is made
 public void StartPlay()
 {
     try
     {
         mediaElement.Source = new Uri(l1[SongNo]);
         TextBox1.Text       = l2[SongNo];
         Thread.Sleep(50);
         mediaElement.Close();
         mediaElement.Play();
     }
     catch (ArgumentOutOfRangeException e)
     {
         Speak_Listen.Speak("No Files in Your Computer.");
         Debug.WriteLine(e.Message);
     } catch (Exception e)
     {
         Debug.WriteLine(e.Message);
     }
 }
Exemplo n.º 15
0
        private static string parseUsingPDFBox(string input)
        {
            PDDocument doc = null;

            try
            {
                doc = PDDocument.load(input);
                PDFTextStripper stripper = new PDFTextStripper();
                return(stripper.getText(doc));
            }
            catch (Exception e) {
                Speak_Listen.Speak("Sorry, no such file found!");
                return("");
            }
            finally
            {
                if (doc != null)
                {
                    doc.close();
                }
            }
        }
Exemplo n.º 16
0
        private void CreateFile(string fileName)
        {
            if (!ValidateWithAcknowlwdgement(fileName, false))
            {
                return;
            }
            string pathString = Path.Combine(pD.FullName, fileName);

            if (File.Exists(pathString))
            {
                Debug.WriteLine("File Already Present");
                Speak_Listen.Speak("Sorry, a file named " + fileName + " already exists. Please type again.");
                TB1.Text = "";
                return;
            }
            File.Create(pathString);
            Refresh();
            TB1.Text           = "";
            BORDER.BorderBrush = Brushes.Gray;
            TB1.IsEnabled      = false;
            Speak_Listen.Speak("A new file named " + fileName + " is created successfully.");
            modifyListStatus = 0;
        }
Exemplo n.º 17
0
        private void CreateDirectory(string dirName)
        {
            if (!ValidateWithAcknowlwdgement(dirName, true))
            {
                return;
            }
            string pathString = Path.Combine(pD.FullName, dirName);

            if (Directory.Exists(pathString))
            {
                Debug.WriteLine("Directory Already Present");
                Speak_Listen.Speak("Sorry,a folder named " + dirName + " already exists. Please type again.");
                TB1.Text = "";
                return;
            }
            Directory.CreateDirectory(pathString);
            Refresh();
            TB1.Text           = "";
            BORDER.BorderBrush = Brushes.Gray;
            TB1.IsEnabled      = false;
            Speak_Listen.Speak("A new folder named " + dirName + " is created successfully.");
            modifyListStatus = 0;
        }
Exemplo n.º 18
0
        private void RenameFile(string newFileName, string oldFileName)
        {
            if (!ValidateWithAcknowlwdgement(newFileName, false))
            {
                return;
            }
            string newPathString = Path.Combine(pD.FullName, newFileName);
            string oldPathString = Path.Combine(pD.FullName, oldFileName);

            if (File.Exists(newPathString))
            {
                Debug.WriteLine("File Name Already Present");
                Speak_Listen.Speak("A Folder named " + newFileName + " already exists. Please type again.");
                TB1.Text = "";
                return;
            }
            File.Move(oldPathString, newPathString);
            Refresh();
            TB1.Text           = "";
            BORDER.BorderBrush = Brushes.Gray;
            TB1.IsEnabled      = false;
            Speak_Listen.Speak("The file " + oldFileName + " is renamed to " + newFileName + " successfully.");
            modifyListStatus = 0;
        }
Exemplo n.º 19
0
 public MainWindow()                                                     // Defines what to be done with assisstant start up
 {
     InitializeComponent();
     Test.Initialize();
     Speak_Listen.Initialize();
 }
Exemplo n.º 20
0
 private void OnContentLoaded(object sender, EventArgs e)
 {
     Speak_Listen.Speak("Hi I am your blind assistant!");
     Speak_Listen.Listen();
 }
Exemplo n.º 21
0
        public void Instruct(string cmd)
        {
            Debug.WriteLine("File Manager Input:  " + cmd);
            if (fmp != null)
            {
                firstItemNo = fmp.GetFirstItemNo();
                lastItemNo  = fmp.GetLastItemNo();
            }

            TB1.Text           = "";
            TB1.IsEnabled      = false;
            BORDER.BorderBrush = Brushes.Gray;
            Speak_Listen.Speak("");                                 // Tricky way to interrupt the file manager Voice Output

            /*
             *  READ THIS CAREFULLY BEFORE YOU ADD NEW case in switch
             *  =====================================================
             *
             *  NOTE 1:- Add this function at the start of your case(if it has nothing to do with variable "isFilterActive"):
             *  ------
             *              UpdateFilter(false);
             */

            switch (cmd)
            {
            case "Back":
                UpdateFilter(false);
                if (B.IsEnabled)
                {
                    Back();
                }
                else
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }
                break;

            case "Next":
                UpdateFilter(false);
                if (N.IsEnabled)
                {
                    Next();
                }
                else
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }
                break;

            case "Up":
                UpdateFilter(false);
                if (U.IsEnabled)
                {
                    Up();
                }
                else
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }
                break;

            case "Down":
                UpdateFilter(false);
                if (D.IsEnabled)
                {
                    Down();
                }
                else
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }
                break;

            case "Files":
            case "Folders":
                UpdateFilter(false);
                if (F.IsEnabled)
                {
                    if (cmd == F.Content.ToString())                        // If this is the same content as wrtten on the Button F.
                    {
                        FileOrFolder();
                    }
                    else
                    {
                        fmp.ReadOutListItems();
                    }
                }
                else
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }
                break;

            case "Refresh":
                UpdateFilter(false);
                Refresh();
                break;

            case "Read Out":
                if (isFilterActive)
                {
                    ReadOutFilters();
                    firstItemNo = 1;                // For Dynamic Loading of Grammar in "Speak_Listen" class
                    lastItemNo  = 11;               // For Dynamic Loading of Grammar in "Speak_Listen" class
                }
                else
                {
                    fmp.ReadOutListItems();
                }
                break;

            case "Controls":
                UpdateFilter(false);
                ReadOutControls();
                break;

            case "Filter":
                if (pD == null)                              // If this is the home page of the file manager
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }
                else
                {
                    UpdateFilter(true);
                    ReadOutFilters();
                    firstItemNo = 1;                        // Use to dynamically load grammar in Speak_Listen class
                    lastItemNo  = 11;                       // Use to dynamically load grammar in Speak_Listen class
                }
                break;

            case "New Folder":
                UpdateFilter(false);
                if (NF1.IsEnabled)
                {
                    modifyListStatus   = 1;
                    BORDER.BorderBrush = Brushes.Yellow;
                    Speak_Listen.Speak("Type the name of the new folder.");
                    TB1.IsEnabled = true;
                    TB1.Focus();
                }
                else
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }
                break;

            case "New File":
                UpdateFilter(false);
                if (NF2.IsEnabled)
                {
                    modifyListStatus   = 2;
                    BORDER.BorderBrush = Brushes.Yellow;
                    Speak_Listen.Speak("Type the name of the new file.");
                    TB1.IsEnabled = true;
                    TB1.Focus();
                }
                else
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }
                break;

            case "Delete":
                UpdateFilter(false);
                if (DF1.IsEnabled)
                {
                    int sel = fmp.GetSelectedItemNo();
                    if (sel == 0)
                    {
                        Speak_Listen.Speak("You haven't selected any item.");
                    }
                    else
                    {
                        modifyListStatus = 3;
                        if (isFolder == 1)
                        {
                            DeleteDirectory(fmp.GetSelectedFolder(sel).Name);
                        }
                        else                                    // isFolder == 2; isFolder == 0 not possible to reach here
                        {
                            DeleteFile(fmp.GetSelectedFile(sel).Name);
                        }
                    }
                }
                else
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }

                break;

            case "Rename":
                UpdateFilter(false);
                if (RNF1.IsEnabled)
                {
                    int sel = fmp.GetSelectedItemNo();
                    if (sel == 0)
                    {
                        Speak_Listen.Speak("You haven't selected any item.");
                    }
                    else
                    {
                        modifyListStatus   = 4;
                        BORDER.BorderBrush = Brushes.Yellow;
                        Speak_Listen.Speak("Type the new name of the item selected");
                        TB1.IsEnabled = true;
                        TB1.Focus();
                    }
                }
                else
                {
                    Speak_Listen.Speak("Sorry, No such control is present");
                }
                break;

            case "Open":
                UpdateFilter(false);
                Open(fmp.GetSelectedItemNo());
                break;

            default:                                         //  Number input
                int n = int.Parse(cmd);
                if (isFilterActive)                          //  Number input for filters
                {
                    if (n >= 1 && n <= 11)                   // In range
                    {
                        UpdateFilter(false);
                        Filter(n);
                    }
                    else                                     // Out of range
                    {
                        Speak_Listen.Speak("Wrong option. Say a number from 1 to 11.");
                    }
                }
                else                                         //  Number input for file/folder selection
                {
                    if (isFolder == 0)
                    {
                        Speak_Listen.Speak("Sorry, this folder is empty");
                    }
                    else
                    {
                        if ((n < firstItemNo) || (n > lastItemNo))          // Item no. selected is not actually present in the list
                        {
                            Speak_Listen.Speak("Wrong option. Say a number from " + firstItemNo.ToString() + " to " + lastItemNo.ToString());
                        }
                        else                                                // In Range
                        {
                            fmp.SelectItem(n);
                        }
                    }
                }
                break;
            }
        }
Exemplo n.º 22
0
        public static void Open(string cmd)
        {
            RetrieveSystemWebBrowsers();
            RetrieveAllOpenProcesses();
            switch (cmd)
            {
            case "Open Firefox":
                if (browser_path["Mozilla Firefox"] == "")                                  // Firefox is not installed
                {
                    Speak_Listen.Speak("Sorry, Firefox is not installed!");
                }
                else if (open_apps["firefox"])                                              // Firefox is already open and (in)/(not in) focus
                {
                    Process[] processes = Process.GetProcessesByName("firefox");
                    foreach (var p in processes)
                    {
                        IntPtr hWnd = p.MainWindowHandle;
                        if (IsIconic(hWnd))
                        {
                            ShowWindowAsync(hWnd, SW_RESTORE);
                        }
                        SetForegroundWindow(hWnd);
                    }
                    Speak_Listen.Speak("Firefox is opened!");
                }
                else                                                                        // Firefox is installed but not open
                {
                    /*
                     * TODO 1: Report error, if any, while opening the same.
                     */
                    Process p = Process.Start(browser_path["Mozilla Firefox"]);
                    p.WaitForInputIdle();
                    Speak_Listen.Speak("Firefox is Opened!");
                    p.WaitForExit();
                    p.Dispose();
                    Speak_Listen.Speak("Firefox is closed!");
                    Thread.Sleep(100);
                }
                break;

            case "Open Chrome":
                if (browser_path["Google Chrome"] == "")                                  // Chrome is not installed
                {
                    Speak_Listen.Speak("Sorry, Chrome is not installed!");
                }
                else if (open_apps["chrome"])                                              // Chrome is already open and (in)/(not in) focus
                {
                    Process[] processes = Process.GetProcessesByName("chrome");
                    foreach (var p in processes)
                    {
                        IntPtr hWnd = p.MainWindowHandle;
                        if (IsIconic(hWnd))
                        {
                            ShowWindowAsync(hWnd, SW_RESTORE);
                        }
                        SetForegroundWindow(hWnd);
                    }
                    Speak_Listen.Speak("Chrome is opened!");
                }
                else                                                                        // Chrome is installed but not open
                {
                    /*
                     * TODO 1: Report error, if any, while opening the same.
                     */
                    Process p = Process.Start(browser_path["Google Chrome"]);
                    p.WaitForInputIdle();
                    Speak_Listen.Speak("Chrome is Opened!");
                    p.WaitForExit();
                    p.Dispose();
                    Speak_Listen.Speak("Chrome is closed!");
                    Thread.Sleep(100);
                }
                break;

            case "Open Browser":
            case "Open Internet Explorer":
                if (browser_path["Internet Explorer"] == "")                                  // IE is not installed
                {
                    Speak_Listen.Speak("Sorry, Internet Explorer is not installed!");
                }
                else if (open_apps["iexplore"])                                              // IE is already open and (in)/(not in) focus
                {
                    Process[] processes = Process.GetProcessesByName("iexplore");
                    foreach (var p in processes)
                    {
                        IntPtr hWnd = p.MainWindowHandle;
                        if (IsIconic(hWnd))
                        {
                            ShowWindowAsync(hWnd, SW_RESTORE);
                        }
                        SetForegroundWindow(hWnd);
                    }
                    Speak_Listen.Speak("Internet Explorer is opened!");
                }
                else                                                                        // IE is installed but not open
                {
                    /*
                     * TODO 1: Report error, if any, while opening the same.
                     */
                    Process p = Process.Start(browser_path["Internet Explorer"]);
                    p.WaitForInputIdle();
                    Speak_Listen.Speak("Internet Explorer is Opened!");
                    p.WaitForExit();
                    p.Dispose();
                    Speak_Listen.Speak("Internet Explorer is closed!");
                    Thread.Sleep(100);
                }
                break;

            default:
                break;
            }
        }
Exemplo n.º 23
0
        private void Open(int selectedItemNo)
        {
            if (selectedItemNo == 0)
            {
                Speak_Listen.Speak("You haven't selected any item.");
            }
            else if (isFolder == 1)
            {
                DirectoryInfo dI = fmp.GetSelectedFolder(selectedItemNo);
                /*******************  Memory Management Start  ***************/

                temp = llnode.Next;

                while (temp != null)
                {
                    nxt = temp.Next;
                    temp.Value.Dispose();
                    ll.Remove(temp);
                    temp = nxt;
                }
                /*******************  Memory Management Finish  ****************/

                ll.AddAfter(llnode, new File_Manager_Page(dI));
                llnode      = llnode.Next;
                fmp         = llnode.Value;
                B.IsEnabled = true;
                N.IsEnabled = false;
                UpdateMembers(true);
                MainFrame.Navigate(fmp);
            }
            else
            {
                FileInfo fI = fmp.GetSelectedFile(selectedItemNo);
                Debug.WriteLine("QQQQQQQQQQQQQ    " + fI.Name);
                if (fI.Name == "firefox.exe" || fI.Name == "chrome.exe" || fI.Name == "iexplore")
                {
                    // TODO 1: Call the Web Browser Controller
                }
                else
                {
                    switch (fI.Extension)
                    {
                    case ".pdf":
                        // TODO 1: Call the PDF Reader
                        break;

                    case ".txt":
                        // TODO 1: Call the Respective Document Controller
                        break;

                    case ".doc":
                    case ".docx":
                        Document.MSWord_Controller mSWord = new Document.MSWord_Controller(fI.FullName);
                        break;

                    case ".mp3":
                    case ".mp4":
                    case ".wav":
                    case ".mpeg":
                    case ".wmv":
                    case ".avi":
                        // TODO 1: Call the Media Player
                        break;

                    default:
                        Speak_Listen.Speak("Sorry, the file format is not supported.");
                        break;
                    }
                }
            }
        }
Exemplo n.º 24
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     Speak_Listen.Speak("Hi Jerwin Mistry, how are you!");
 }
Exemplo n.º 25
0
        public static void VoiceOutput(object obj)
        {
            string speakout = (string)obj;

            Speak_Listen.Speak(speakout);
        }
Exemplo n.º 26
0
        public static Thread OutputThread = new Thread(new ParameterizedThreadStart(VoiceOutput));         // Thread for Voice Output


        /***************  Threads end here  ******************/

        /********  Functions to be run in threads  ***********/

        public static void VoiceInput()
        {
            Speak_Listen.Listen();
        }