Esempio n. 1
0
 private void PerformCopy(TabPageEx page)
 {
     if (page != null)
     {
         page.EditBox.Copy();
     }
 }
Esempio n. 2
0
        private void PerformClose(TabPageEx page)
        {
            if (page != null)
            {
                if (page.IsDirty)
                {
                    string message = String.Format("Document \"{0}\" is not yet saved! Do you want to save it now?", page.Name);

                    DialogResult result = this.UserChoice(message);

                    if (result == DialogResult.Yes)
                    {
                        this.PerformSave(page);
                        this.tabEditView.TabPages.Remove(page);
                    }
                    else if (result == DialogResult.No)
                    {
                        this.tabEditView.TabPages.Remove(page);
                    }
                }
                else
                {
                    this.tabEditView.TabPages.Remove(page);
                }
            }
        }
Esempio n. 3
0
        private void PerformClear(TabPageEx page)
        {
            if (page != null)
            {
                page.EditBox.Clear();
            }

            this.UpdateControlState();
        }
Esempio n. 4
0
        private void OnEditViewSelectedIndexChanged(object sender, EventArgs args)
        {
            TabPageEx selected = this.tabEditView.SelectedTab as TabPageEx;

            if (selected != null)
            {
                this.UpdateControlState(selected.IsDirty);
            }
            else
            {
                this.UpdateControlState(false);
            }
        }
Esempio n. 5
0
        public TabPageEx AddPage(string name)
        {
            TabPageEx page = new TabPageEx(name);

            this.Controls.Add(page);

            page.EditBox.IsDirtyChanged += new EventHandler(this.OnEditBoxIsDirtyChanged);

            page.Activate();

            this.SelectedTab = page;

            return(page);
        }
Esempio n. 6
0
 private void OnEditViewDragDrop(object sender, DragEventArgs args)
 {
     try
     {
         if (this.tabEditView.TabCount == 0)
         {
             TabPageEx page = this.PerformNew();
             this.PerformPaste("Drop Content", page.EditBox, args.Data);
         }
     }
     catch (Exception exception)
     {
         Debug.WriteLine(exception);
     }
 }
Esempio n. 7
0
        private TabPageEx PerformNew()
        {
            TabPageEx page = this.tabEditView.AddPage();

            if (page != null)
            {
                // Adjust page resp. edit-box settings.
                page.EditBox.BackColor         = this.EditBoxBackColor;
                page.EditBox.SelectionChanged += new EventHandler(this.OnEditBoxSelectionChanged);
                page.EditBox.DragDrop         += new DragEventHandler(this.OnEditBoxDragDrop);
                page.EditBox.AllowDrop         = true;
            }

            this.UpdateControlState();

            return(page);
        }
Esempio n. 8
0
        private void OnPageHeaderMenuOpening(object sender, CancelEventArgs args)
        {
            TabPageEx selected = this.tabEditView.SelectedTab as TabPageEx;

            if (selected != null)
            {
                bool dirty = selected.IsDirty;
                this.pageHeaderMenuClose.Enabled = this.CanClose(dirty);
                this.pageHeaderMenuSave.Enabled  = this.CanSave(dirty);
                this.pageHeaderMenuCopy.Enabled  = this.CanCopy(dirty);
                this.pageHeaderMenuClear.Enabled = this.CanClear(dirty);
            }
            else
            {
                args.Cancel = true;
            }
        }
Esempio n. 9
0
        private void PerformSave(TabPageEx page)
        {
            if (page != null && page.IsDirty && !this.IsDialogVisible)
            {
                try
                {
                    this.IsDialogVisible = true;

                    string fullname = page.FullName;
                    if (String.IsNullOrEmpty(fullname))
                    {
                        this.saveFileDialog.FileName = page.Name;
                        if (DialogResult.OK != this.saveFileDialog.ShowDialog(this))
                        {
                            return;
                        }
                        else
                        {
                            fullname = this.saveFileDialog.FileName;
                        }
                    }

                    using (new CursorWrapper(this, Cursors.WaitCursor))
                    {
                        page.Save(fullname);
                    }
                }
                catch (Exception exception)
                {
                    Debug.WriteLine(exception);
                }
                finally
                {
                    this.IsDialogVisible = false;
                }
            }

            this.UpdateControlState();
        }
Esempio n. 10
0
        private void PerformLoad()
        {
            try
            {
                this.IsDialogVisible = true;

                this.openFileDialog.FileName         = String.Empty;
                this.openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

                if (DialogResult.OK == this.openFileDialog.ShowDialog(this))
                {
                    TabPageEx page = null;

                    if (this.tabEditView.ActiveEditBox != null && this.tabEditView.ActiveEditBox.IsEmpty)
                    {
                        page = this.tabEditView.SelectedTab as TabPageEx;
                    }
                    else
                    {
                        page = this.PerformNew();
                    }

                    using (new CursorWrapper(this, Cursors.WaitCursor))
                    {
                        page.Load(this.openFileDialog.FileName);
                    }
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception);
            }
            finally
            {
                this.IsDialogVisible = false;
            }
        }