Example #1
0
 private void create_Click(object sender, EventArgs e)
 {
     curFileName = null;
     MainRTB.Clear();
     WorkRTB.Clear();
     this.Text = "Textor";
 }
Example #2
0
 private async void NewToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(MainRTB.Text) || _currentFile != null)
     {
         if (MessageBox.Show("Save current file?", "Close File", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             await SaveFile();
         }
     }
     MainRTB.Clear();
 }
Example #3
0
 private async Task SaveFile()
 {
     if (_currentFile == null && !string.IsNullOrEmpty(MainRTB.Text))
     {
         _saveFileForm.ProcessTextData(MainRTB.Text);
         _saveFileForm.ShowDialog();
         if (_saveFileForm.IsFileSaved)
         {
             MainRTB.Clear();
         }
     }
     else if (_currentFile != null)
     {
         _currentFile.TextData = MainRTB.Text;
         await _dataProcessingService.UpdateFile(_currentFile);
     }
     else
     {
         MessageBox.Show("File is empty!", "Error");
     }
 }
Example #4
0
        private async void RemoveToolStripMenuItem_Click(object sender, EventArgs e)
        {
            _deleteFileFrom.UpdateData();
            _deleteFileFrom.ShowDialog();
            if (_deleteFileFrom.SelectedFile != null && MessageBox.Show("Delete this file?", "Remove File", MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                if (!(await _dataProcessingService.RemoveFile(_deleteFileFrom.SelectedFile)))
                {
                    MessageBox.Show("File not removed");
                }
                else if (_deleteFileFrom.SelectedFile.Id == _currentFile.Id)
                {
                    this.Text    = "Notepad";
                    _currentFile = null;
                    MainRTB.Clear();
                }

                _deleteFileFrom.SelectedFile = null;
                _openFileForm.SelectedFile   = null;
            }
        }
Example #5
0
        public void WriteConsole(MessageStatus Status, string text)
        {
            if (MainRTB.InvokeRequired)
            {
                var invokedMethod = new WriteConsoleDelegate(WriteConsole);
                this.Invoke(invokedMethod, new object[] { Status, text });
                return;
            }

            //if (Status == MessageStatus.Error)
            //{
            //    MessageBox.Show(text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}
            MainRTB.AppendText(Environment.NewLine);
            MainRTB.SelectionStart  = MainRTB.TextLength;
            MainRTB.SelectionLength = 0;

            MainRTB.SelectionColor = Status.DrawColor;
            MainRTB.AppendText(text);
            MainRTB.SelectionColor = MainRTB.ForeColor;
        }