Esempio n. 1
0
 void SetSurface(VirtualFile file)
 {
     txtPad.Text = file.GetCurrentText();
 }
Esempio n. 2
0
 /// <summary>
 /// Saves the current file
 /// </summary>
 private void SaveCurrentFile()
 {
     _currentFile = _documents[tbDocuments.TabIndex] as VirtualFile;
     if (_currentFile.FileName.Length == 0)
     {
         saveFileDialog1.Title = "Save " + tbDocuments.TabPages[tbDocuments.TabIndex].Text + " As";
         if (saveFileDialog1.ShowDialog() == DialogResult.OK)
         {
             SaveTextSurface(tbDocuments.TabIndex);
             _currentFile.WriteFile(saveFileDialog1.FileName);
             tbDocuments.TabPages[tbDocuments.TabIndex].Text = StripPath(saveFileDialog1.FileName);
         }
     }
     else
     {
         SaveTextSurface(tbDocuments.TabIndex);
         _currentFile.WriteFile((_documents[tbDocuments.TabIndex] as VirtualFile).FileName);
     }
 }
Esempio n. 3
0
 /// <summary>
 /// Saves the current file
 /// </summary>
 private void SaveFile(int index)
 {
     _currentFile = _documents[index] as VirtualFile;
     if (_currentFile.FileName.Length == 0)
     {
         saveFileDialog1.Title = "Save " + tbDocuments.TabPages[index].Text + " As";
         if (saveFileDialog1.ShowDialog() == DialogResult.OK)
         {
             _currentFile.WriteFile(saveFileDialog1.FileName);
             tbDocuments.TabPages[index].Text = saveFileDialog1.FileName;
         }
     }
     else
     {
         _currentFile.WriteFile((_documents[TabIndex] as VirtualFile).FileName);
     }
 }
Esempio n. 4
0
        private void OpenFile(string filename)
        {
            // if it all ready exists, just go to it
            int index = GetExistingFile(filename);
            if (index != -1)
            {
                _userClicked = false;
                MoveTextSurface(index);
                SetSurface(_currentFile);
                return;
            }

            _currentFile.SetCurrentText(txtPad.Text);
            _documentCount++;
            _currentFile = new VirtualFile(filename, this);
            if (_currentFile.CutOff)
            {
                MessageBox.Show(String.Format("File {1} was cut-off, because it was greater than {0} characters (the maximum buffer size)", VirtualFile.MAX_BUFFER_LENGTH, filename));
            }
            _documents.Add(_currentFile);
            // create a new tab
            tbDocuments.TabPages.Add(new TabPage(StripPath(filename)));
            // move text pad
            _userClicked = false;
            MoveTextSurface(_documentCount-1);

            SetSurface(_currentFile);
        }
Esempio n. 5
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            ConfigHandler.LoadConfigPath();
            _currentFile = new VirtualFile(this);
            _documents.Add(_currentFile);
            _documentCount++;
            LoadConfigurationFile();

            _textBoxPrinter = new TextBoxPrinter();
            //
            // TODO: Add any constructor code after InitializeComponent call
            //
            mRecent.Text = "Recent Files";
            menuItem1.MenuItems.Add(10, mRecent);

            mRecent.InitializeFromConfig(4);
            mRecent.MRUClicked+=new EventHandler(MRUClick);
            mRecent.MRUChanged+=new EventHandler(MRUChanged);
        }
Esempio n. 6
0
 void MoveTextSurface(int index)
 {
     tbDocuments.TabPages[tbDocuments.TabIndex].Controls.Remove(txtPad);
         tbDocuments.TabIndex = index;
         tbDocuments.TabPages[tbDocuments.TabIndex].Controls.Add(txtPad);
         tbDocuments.SelectedIndex = index;
         _currentFile = _documents[index] as VirtualFile;
 }
Esempio n. 7
0
        private void menuNew_Click(object sender, System.EventArgs e)
        {
            _currentFile.SetCurrentText(txtPad.Text);
            _documentCount++;
            _newFileCount++;
            _currentFile = new VirtualFile(this);
            _documents.Add(_currentFile);
            // create a new tab
            tbDocuments.TabPages.Add(new TabPage("Document" + _newFileCount));
            // move text pad
            _userClicked = false;
            MoveTextSurface(_documentCount-1);

            SetSurface(_currentFile);
        }
Esempio n. 8
0
 private void CloseAllDocuments()
 {
     while (_documents.Count > 1)
     {
         _currentFile = _documents[tbDocuments.TabIndex] as VirtualFile;
         bool saved = TestIfFileIsModifiedAndSave();
         CloseFile();
     }
 }