Exemplo n.º 1
0
        /*——————————【文件】菜单功能结束分割线——————————*/

        /*——————————【编辑】菜单功能开始分割线——————————*/
        private void 撤销ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MainTextBox.CanUndo == true)
            {
                MainTextBox.Undo();
            }
        }
Exemplo n.º 2
0
        private void UpdateLineNumbers()
        {
            Point pt = new Point(0, 0);

            int firstIndex = MainTextBox.GetCharIndexFromPosition(pt);
            int firstLine  = MainTextBox.GetLineFromCharIndex(firstIndex);

            pt.X = ClientRectangle.Width;
            pt.Y = ClientRectangle.Height;

            int lastIndex = MainTextBox.GetCharIndexFromPosition(pt);
            int lastLine  = MainTextBox.GetLineFromCharIndex(lastIndex);

            LineNumbers.SelectionAlignment = HorizontalAlignment.Center;
            LineNumbers.Text  = "";
            LineNumbers.Width = GetWidth();

            if (MainTextBox.Lines.Length > 1)
            {
                for (int i = firstLine; i <= lastLine + 1; i++)
                {
                    int lineNum = (i + 1);
                    if (lineNum <= Lines.Length)
                    {
                        LineNumbers.Text += (i + 1) + "\n";
                    }
                }
            }
            else
            {
                LineNumbers.Text += 1 + "\n";
            }
        }
Exemplo n.º 3
0
 private void MainTextBox_LostFocus(object sender, RoutedEventArgs e)
 {
     if (CurrentSelectingPosition != 0 && !string.IsNullOrEmpty(CurrentlySelectedText))
     {
         MainTextBox.Select(CurrentSelectingPosition, CurrentlySelectedText.Length);
     }
 }
Exemplo n.º 4
0
 public void WinFromLog(string log)
 {
     if (MainTextBox.InvokeRequired)
     {
         Action <string> actionDelegate = (x) =>
         {
             MainTextBox.AppendText(Environment.NewLine);
             MainTextBox.AppendText(x.ToString());
             MainTextBox.AppendText(Environment.NewLine);
             MainTextBox.ScrollToCaret();
         };
         MainTextBox.Invoke(actionDelegate, log);
     }
     else
     {
         try
         {
             MainTextBox.AppendText(log);
             MainTextBox.AppendText(Environment.NewLine);
             MainTextBox.AppendText(Environment.NewLine);
             MainTextBox.ScrollToCaret();
         }
         catch (Exception)
         {
             return;
         }
     }
 }
 private void NewFileButton_Click(object sender, EventArgs e)
 {
     sapi5engine.SpeakAsyncCancelAll();
     sapi5engine.Resume();
     playButton.Enabled             = true;
     pauseButton.Enabled            = false;
     stopButton.Enabled             = false;
     playToolStripMenuItem.Enabled  = true;
     pauseToolStripMenuItem.Enabled = false;
     stopToolStripMenuItem.Enabled  = false;
     if (changesMade)
     {
         DialogResult r = MessageBox.Show("Changes were made. Do you wish to save your changes before starting a new file?", "OutLoud Text Reader", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
         if (r != DialogResult.Cancel)
         {
             if (r == DialogResult.Yes)
             {
                 AttemptSave(false);
             }
         }
         else
         {
             return;
         }
     }
     MainTextBox.Clear();
     MainTextBox.ClearUndo();
     changesMade = false;
     fileName    = "";
 }
 /// <summary>
 /// Open a new text file in Noteplaid.
 /// </summary>
 /// <param name="sender">Sender object</param>
 /// <param name="e">Arguments passed</param>
 private void NewCommand_Executed(object sender, System.Windows.Input.ExecutedRoutedEventArgs e)
 {
     // Should check for saving...
     MainTextBox.Clear();
     this.currOpenFile = null;
     this.UpdateTitle(null);
 }
Exemplo n.º 7
0
        private void AsciiButton_Checked(object sender, RoutedEventArgs e)
        {
            Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate
            {
                if (MainTextBox != null)
                {
                    MainTextBox.Clear();

                    foreach (var packet in packets)
                    {
                        if (packet.type == true && RecieveStringNoti.IsChecked == true)      // receive
                        {
                            MainTextBox.Text += " <<< " + packet.message;
                        }
                        else if (packet.type == false && SendStringNoti.IsChecked == true)   // send
                        {
                            MainTextBox.Text += " >>> " + packet.message;
                        }
                        MainTextBox.Text += Environment.NewLine;
                    }
                }
                if (Transmit_box != null)
                {
                    string prev_string = Transmit_box.Text;
                    Transmit_box.Clear();
                    Transmit_box.Text = ConvertHexToCharString(prev_string);
                }
            }));
        }
Exemplo n.º 8
0
 public void EditMode(bool edit)
 {
     if (edit)
     {
         MainTextBlock.Visibility = Visibility.Collapsed;
         MainTextBox.Visibility   = Visibility.Visible;
         MainButton.Visibility    = Visibility.Visible;
         MainTextBox.Text         = ((Connection)DataContext).Value.Text.ToString();
         MainTextBox.Focus();
         MainTextBox.SelectAll();
     }
     else
     {
         MainTextBlock.Visibility = Visibility.Visible;
         MainTextBox.Visibility   = Visibility.Collapsed;
         MainButton.Visibility    = Visibility.Collapsed;
         try
         {
             ((Connection)DataContext).Value = new ConnectionInscription(int.Parse(MainTextBox.Text));
         }
         catch
         {
             EditMode(true);
         }
     }
 }
Exemplo n.º 9
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     if (updaterThread == null)
     {
         MainTextBox.Text = ToString(Settings.Default.LastTimeSpan.Ticks < 0 ? TimeSpan.Zero : Settings.Default.LastTimeSpan);
         MainTextBox.Focus();
     }
 }
 private void MainTextBox_OnIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if ((bool)e.NewValue)
     {
         Keyboard.Focus(MainTextBox);
         MainTextBox.SelectAll();
     }
 }
Exemplo n.º 11
0
        private void CounterBtn_Click(object sender, EventArgs e)
        {
            PBA = BattleActions.Counter;
            Enemy();
            Decision();

            MainTextBox.SelectionStart = MainTextBox.TextLength - 1;
            MainTextBox.ScrollToCaret();
        }
Exemplo n.º 12
0
 public SavePresetDialog()
 {
     InitializeComponent();
     this.IsVisibleChanged += (s, x) =>
     {
         this.Center();
         MainTextBox.Focus();
     };
 }
Exemplo n.º 13
0
        private void MainTextBox_SelectionChanged(object sender, EventArgs e)
        {
            Point pt = MainTextBox.GetPositionFromCharIndex(MainTextBox.SelectionStart);

            if (pt.X == 1)
            {
                UpdateLineNumbers();
            }
        }
Exemplo n.º 14
0
 private void MainTextBox_GotFocus(object sender, RoutedEventArgs e)
 {
     if (MainTextBox.Text == "Timer expired")
     {
         MainTextBox.Text = ToString(Settings.Default.LastTimeSpan.Ticks < 0 ? TimeSpan.Zero : Settings.Default.LastTimeSpan);
     }
     MainTextBox.SelectAll();
     TaskbarUtility.StopFlash(interopHelper.Handle);
 }
Exemplo n.º 15
0
 public RenameProgramDialog()
 {
     InitializeComponent();
     this.IsVisibleChanged += (s, x) =>
     {
         this.Center();
         MainTextBox.Focus();
     };
 }
Exemplo n.º 16
0
        internal void ShowStatus(string Status)
        {
            if (IsClosing)
            {
                return;
            }

            MainTextBox.AppendText(Status + "\r\n");
        }
Exemplo n.º 17
0
        private void LoadButton_Click(object sender, EventArgs e)
        {
            if (OpenFileDialog.ShowDialog() == DialogResult.Cancel)
            {
                return;
            }

            MainTextBox.ResetText();

            string filename = OpenFileDialog.FileName;

            using (StreamReader inputfile = new StreamReader(filename, Encoding.GetEncoding(1251)))
            {
                while (!inputfile.EndOfStream)
                {
                    inputfile.ReadLine();
                    string temp1  = inputfile.ReadLine();
                    string temp2  = inputfile.ReadLine();
                    string temp3  = inputfile.ReadLine();
                    uint   temp3u = 0;

                    if (uint.TryParse(temp3, out temp3u))
                    {
                        temp = new Facility(temp1, temp2, temp3u);
                    }
                    else
                    {
                        temp = new WorkPlace(temp1, temp2, temp3);
                    }

                    if (temp.name != "")
                    {
                        Corporation.AddDepartment(temp);
                        inputfile.ReadLine();

                        while ((inputfile.Peek() != '[') && (!inputfile.EndOfStream))
                        {
                            Corporation.AddEmployee(new Employee(inputfile.ReadLine(), inputfile.ReadLine(),
                                                                 temp, inputfile.ReadLine(), inputfile.ReadLine()));
                            if (!inputfile.EndOfStream)
                            {
                                inputfile.ReadLine();
                            }
                        }
                    }
                    else
                    {
                        break;
                    }
                }

                CounterLabel.Text = "Число отделов: " + Corporation.GetDepartmentCount()
                                    + ". Число сотрудников: " + Corporation.GetEmployeeCount() + ".";

                inputfile.Close();
            }
        }
Exemplo n.º 18
0
        private void LoadContent(Guid contentId, string title)
        {
            var data = _persistenceManager.GetContentReadStream(contentId, title);

            MainTextBox.SelectAll();
            MainTextBox.Selection.Load(data, DataFormats.Rtf);
            MainTextBox.Selection.Select(MainTextBox.Document.ContentStart, MainTextBox.Document.ContentStart);
            data.Close();
        }
Exemplo n.º 19
0
        public AdvancedTextBox()
        {
            InitializeComponent();

            LineNumbers.Font = MainTextBox.Font;
            MainTextBox.Select();
            UpdateLineNumbers();
            CreateSnapshot();
        }
Exemplo n.º 20
0
        /// <summary>
        /// Gets the placeholder of the main input box and compares it.
        /// </summary>
        /// <param name="expected"></param>
        /// <returns></returns>
        public bool DoesPlaceholderMatch(string expected)
        {
            string actual = MainTextBox.GetAttribute("placeholder");

            if (actual == expected)
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 21
0
        public void AppendToTextBox(string value)

        {
            if (InvokeRequired)
            {
                this.Invoke(new Action <string>(AppendToTextBox), new object[] { value });
                return;
            }
            MainTextBox.AppendText(value + "\n");
        }
Exemplo n.º 22
0
 internal void Initialize()
 {
     MainTextBox.TextChanged -= MainTextBox_TextChanged;
     MainTextBox.Text         = string.Empty;
     lenBefore = 0;
     MainTextBox.Focus(Windows.UI.Xaml.FocusState.Programmatic);
     MainTextBox.IsTextPredictionEnabled = false;
     MainTextBox.IsSpellCheckEnabled     = false;
     //MainTextBox.IsHitTestVisible = false;
     MainTextBox.TextChanged += MainTextBox_TextChanged;
 }
Exemplo n.º 23
0
 public void FocusFindInputBox(bool focusFind)
 {
     if (focusFind)
     {
         findInputBox.Focus();
     }
     else
     {
         MainTextBox.Focus();
     }
 }
Exemplo n.º 24
0
        private void ProcessTagSelection(ListBox list_box)
        {
            TagSuggestionPopup.IsOpen = false;

            string tag_name = list_box.SelectedItem.ToString() + "]";
            int    i        = MainTextBox.CaretIndex;

            MainTextBox.Text       = MainTextBox.Text.Insert(i, tag_name);
            MainTextBox.CaretIndex = i + tag_name.Length;

            MainTextBox.Focus();
        }
        private void OpenButton_Click(object sender, EventArgs e)
        {
            sapi5engine.SpeakAsyncCancelAll();
            sapi5engine.Resume();
            playButton.Enabled             = true;
            pauseButton.Enabled            = false;
            stopButton.Enabled             = false;
            playToolStripMenuItem.Enabled  = true;
            pauseToolStripMenuItem.Enabled = false;
            stopToolStripMenuItem.Enabled  = false;
            if (changesMade)
            {
                DialogResult r = MessageBox.Show("Changes were made. Do you wish to save your changes before opening another file?", "OutLoud Text Reader", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
                if (r != DialogResult.Cancel)
                {
                    if (r == DialogResult.Yes)
                    {
                        AttemptSave(false);
                    }
                }
                else
                {
                    return;
                }
            }
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    MainTextBox.Clear();

                    fileName         = openFileDialog1.FileName;
                    MainTextBox.Text = File.ReadAllText(fileName);
                    MainTextBox.ClearUndo();
                    changesMade = false;
                }
                catch (FileLoadException x)
                {
                    MessageBox.Show($"There was an error loading the file: {x.Message}", "OutLoud Text Reader", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MainTextBox.Clear();
                    MainTextBox.ClearUndo();
                    changesMade = false;
                    return;
                }
                catch (Exception x)
                {
                    MessageBox.Show($"PLEASE REPORT THIS PROBLEM!\nException message: {x.Message}\nSource: {x.Source}\n--Stack Trace--\n{x.StackTrace}", "OutLoud Text Reader", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MainTextBox.Clear();
                    MainTextBox.ClearUndo();
                    changesMade = false;
                }
            }
        }
 private void CancelButton_Click(object sender, EventArgs e)
 {
     try
     {
         MainTextBox.Clear();
         this.DialogResult = DialogResult.No;
     }
     catch (Exception ex)
     {
         CommonItem.ErrManger.ErrorManagement(ex, false, this);
     }
 }
 private void PasteText_Event(object sender, EventArgs e)
 {
     try
     {
         MainTextBox.Paste(Clipboard.GetText().ToString());
     }
     catch (Exception ae)
     {
         //no data on clipboard
         MessageBox.Show("no data on clipboard");
     }        
 }
Exemplo n.º 28
0
        public void FillInAdditionalInformationDummyData(string input)
        {
            input = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, " +
                    "sed do eiusmod tempor incididunt ut labore et dolore magna aliqua." +
                    " Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi" +
                    " ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit " +
                    "in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur " +
                    "sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit" +
                    " anim id est laborum.";

            MainTextBox.Clear();
            MainTextBox.SendKeys(input);
        }
 private void openToolStripMenuItem_Click(object sender, EventArgs e)
 {
     DialogResult result = openFileDialog1.ShowDialog(); // Show the dialog.
     if (result == DialogResult.OK) // Test result.
     {
         string file = openFileDialog1.FileName;
         try
         {
              MainTextBox.Paste( File.ReadAllText(file));
         }
         catch (IOException){}
     }
 }
 private void newToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if(MainTextBox.Text != null)
     {
         DialogResult result =  MessageBox.Show("You do want to save before opening a new file", "", MessageBoxButtons.YesNo);
         if(result == DialogResult.Yes)
         {
             saveToolStripMenuItem_Click(sender, e);
         }
         if(result == DialogResult.No)
         {
             MainTextBox.Clear();
         }
     }    
 }