Ejemplo n.º 1
0
        public void AddOpenedFilePage(string filePath)
        {
            // Create a rich text box and initialize style
            ExtRichTextBox fileRichTextBox = new ExtRichTextBox();

            fileRichTextBox.Dock = DockStyle.Fill;

            if (filePath.Length != 0)
            {
                // save path in rich text control name
                fileRichTextBox.Name     = filePath + " ";
                fileRichTextBox.filePath = filePath;
                fileRichTextBox.LoadFile(filePath, RichTextBoxStreamType.PlainText);
            }
            else
            {
                fileRichTextBox.Name     = "NewFile" + this.NewFileIndex.ToString() + " ";
                fileRichTextBox.Text     = "";
                fileRichTextBox.filePath = "";
                this.NewFileIndex++;
                // set filePath with a name since it will be displayed as tab page name
                filePath = fileRichTextBox.Name;
            }

            ExtTabPage newPage = new ExtTabPage(Path.GetFileName(filePath));

            TabPages.Add(newPage);
            TabPages[TabPages.Count - 1].Controls.Add(fileRichTextBox);
            SelectTab(TabPages.Count - 1);

            // open existed file and add it into tabcontrol always trigger Modifed; reset it
            fileRichTextBox.Modified = false;
        }
Ejemplo n.º 2
0
        private void prvSaveSpecficedFile(TabPage page, bool saveAs, bool showHint, bool disposePage)
        {
            // A tabpages' close menu is triggered; save file if it is not been saved
            foreach (Control control in page.Controls)
            {
                if (control is ExtRichTextBox)
                {
                    ExtRichTextBox extRichTextBoxItem = control as ExtRichTextBox;
                    extRichTextBoxItem.SaveFileHelper(saveAs, showHint);
                }
            }

            if (disposePage)
            {
                page = this.filesTab.SelectedTab;
                this.filesTab.TabPages.Remove(page);
                foreach (Control control in page.Controls)
                {
                    control.Dispose();
                }
                page.Dispose();
            }
        }