示例#1
0
 private void OutputTextBox_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.Control && e.KeyCode == Keys.A)
     {
         OutputTextBox.SelectAll();
     }
 }
示例#2
0
 private void Copy2ClipboardButton_Click(object sender, EventArgs e)
 {
     if (OutputTextBox.TextLength > 0)
     {
         OutputTextBox.SelectAll();
         Clipboard.SetText(OutputTextBox.SelectedText);
     }
     else
     {
         SCTcommon.SendMessage("Nothing in output box to copy!");
     }
 }
示例#3
0
        /*
         *  METHOD        : MenuSaveClick
         *  DESCRIPTION   : This method allows the user to save the contents of the Incoming Textbox area, into a txt file
         *  PARAMETERS    : Parameters are as follows,
         *   object menuUIEvent : The object from which the even was triggered
         *   RoutedEventArgs eventTrigger : Identifier for the triggered event
         *  RETURNS       : void : The method has no return value
         *
         *  NOTE: Much of the methods functionality was provided by Microsoft in their Dialog Boxes Overview Example;
         *        For more information, please see: Microsoft. (2017). Dialog Boxes Overview. Retrieved Octover 2, 2018, from
         *           https://docs.microsoft.com/en-us/dotnet/api/microsoft.win32.openfiledialog?view=netframework-4.7.2
         */
        private void MenuSaveClick(object menuUIEvent, RoutedEventArgs eventTrigger)
        {
            FileIO fileManager = new FileIO();


            try
            {
                SaveFileDialog saveFileWindow = new SaveFileDialog();


                //Configure save file dialog box
                saveFileWindow.Title            = "Save Chat Log: Save";         //Set the window title
                saveFileWindow.FileName         = "";                            //Default file name
                saveFileWindow.DefaultExt       = ".txt";                        //Default file extension
                saveFileWindow.Filter           = "Text documents (.txt)|*.txt"; //Filter files by extension
                saveFileWindow.InitialDirectory = @"%userprofile%\desktop";      //Set the initial open directory to the users dektop


                //Display the file menu, and capture the users response if they select a file
                Nullable <bool> fileSelected = saveFileWindow.ShowDialog();
                if (fileSelected == true)
                {
                    //Check if the target filename exists; if true, save the path and open the file
                    if (saveFileWindow.CheckPathExists == true)
                    {
                        //Get the filepath from the diolog box, and select all the text in the document
                        string filepath = saveFileWindow.FileName;


                        //Split the text into the string array, and write each line to the file
                        OutputTextBox.SelectAll();
                        string   textboxContents = OutputTextBox.SelectedText;
                        string[] textArray       = Utility.StringSplitter(textboxContents);
                        fileManager.WriteToFile(filepath, textArray);
                    }
                }
            }//try


            catch (Exception errorMessage)
            {
                string filepath = fileManager.ReadXMLDocument("logFilePath");   //Indicator of the element to search in the XML doc
                Logger.LogApplicationEvents(filepath, errorMessage.ToString());
            }
        }//MenuSaveClick