Example #1
0
 private void FilesTabControl_SelectedIndexChanged(object sender, EventArgs e)
 {
     UpdateText();
     if (filesTabControl.SelectedIndex >= 0)
     {
         curFile = files[filesTabControl.SelectedIndex];
         curFile.ShowText(textEditorRichTextBox);
     }
     UpdateFont(currentFont);
 }
Example #2
0
 public BackUp(DoAtMainFormFile[] todo, MyFile myFile)
 {
     InitializeComponent();
     doBeforeClosure = todo;
     curFile         = myFile;
     foreach (var elem in myFile.timings)
     {
         versionsComboBox.Items.Add(elem);
     }
     versionsComboBox.SelectedIndex = myFile.timings.Count - 1;
 }
Example #3
0
        private void OpenFileMenuItem_Click(object sender, EventArgs e)
        {
            // Set limit for opened files.
            if (files.Count == 10)
            {
                MessageBox.Show("You can open no more than 10 files");
                return;
            }

            OpenFileDialog open = new OpenFileDialog
            {
                Title       = "Open File",
                Filter      = "(*.txt)|*.txt|(*.rtf)|*.rtf|(*.cs)|*.cs|All files (*.txt;*.rtf;*.cs*)|*.txt;*.rtf;*.cs;",
                FilterIndex = 4
            };

            if (open.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    UpdateText();
                    MyFile file = new MyFile(open.FileName);
                    files.Add(file);
                    curFile = file;

                    // Check for correct text assignment.
                    if (curFile.wasRtf)
                    {
                        textEditorRichTextBox.Rtf = curFile.FileText;
                    }
                    else
                    {
                        textEditorRichTextBox.Text = curFile.FileText;
                    }
                    textEditorRichTextBox.Visible = true;
                    AddTab(Path.GetFileName(curFile.FilePath));
                    filesTabControl.SelectedTab = curFile.Page;
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                }
            }
        }
Example #4
0
        /// <summary>
        /// Trying to get saved settings from ApplicationData.txt.
        /// </summary>
        private void PreLoadData()
        {
            var data = new ApplicationData();

            try
            {
                settingsList = data.settingsParams;
                files        = data.SetTabControl(filesTabControl);
                if (files.Count > 0)
                {
                    curFile = files[filesTabControl.SelectedIndex];
                    curFile.ShowTextFirstTime(textEditorRichTextBox);
                }
            }
            catch
            {
                data.SetDefault();
                settingsList = data.settingsParams;
                files        = new MyFileList();
                filesTabControl.TabPages.Clear();
            }
        }
Example #5
0
        /// <summary>
        /// Close opened tab.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void CloseCurrentTabMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                // If tab was unsaved.
                if (curFile.Changed || curFile.FilePath == null)
                {
                    switch (MessageBox.Show($"Do you want to save changes to {filesTabControl.SelectedTab.Text}?", "Text Editor", MessageBoxButtons.YesNoCancel))
                    {
                    case DialogResult.Yes:
                        curFile.Save();
                        break;

                    case DialogResult.Cancel:
                        return;
                    }
                }
                int id = filesTabControl.SelectedIndex;
                filesTabControl.TabPages.Remove(curFile.Page);
                curFile = files.Remove(id);
                if (curFile != null)
                {
                    filesTabControl.SelectedTab   = curFile.Page;
                    textEditorRichTextBox.Rtf     = curFile.FileText;
                    filesTabControl.SelectedIndex = Math.Max(id - 1, 0);
                }
                else
                {
                    textEditorRichTextBox.Visible = false;
                    filesTabControl.Visible       = false;
                    fontStylePanel.Visible        = false;
                }
            }
            catch
            {
            }
        }
Example #6
0
 /// <summary>
 /// Create new file.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void NewFileMenuItem_Click(object sender, EventArgs e)
 {
     // Set limit for opened files.
     if (files.Count == 10)
     {
         MessageBox.Show("You can open no more than 10 files");
         return;
     }
     try
     {
         UpdateText();
         MyFile file = new MyFile();
         files.Add(file);
         curFile = file;
         curFile.ShowText(textEditorRichTextBox);
         textEditorRichTextBox.Visible = true;
         AddTab($"New document {id++}");
         filesTabControl.SelectedTab = curFile.Page;
     }
     catch
     {
         MessageBox.Show("Error");
     }
 }
Example #7
0
 /// <summary>
 /// Synchronize textbox and curFile.
 /// </summary>
 /// <param name="file"> Fake parameter to set multidelegate. </param>
 private void UpdateCurFile(MyFile file)
 {
     curFile.ShowText(textEditorRichTextBox);
     UpdateTab();
 }
Example #8
0
 public void Add(MyFile e)
 {
     list.Add(e);
 }
Example #9
0
 public MyFileList(MyFile e)
 {
     Add(e);
 }