Пример #1
0
        private void initDocument(Control parent, DesignerHost host)
        {
            System.Diagnostics.Trace.WriteLine("Creating document...");

            // get the ExtensibleTextEditor instance of the Source code's view
            textEditor = IdeApp.Workbench.ActiveDocument.PrimaryView.GetContent <SourceEditorView> ().TextEditor;

            if (!(parent is WebFormPage))
            {
                throw new NotImplementedException("Only WebFormsPages can have a document for now");
            }
            this.parent = parent;
            this.host   = host;

            if (!host.Loading)
            {
                throw new InvalidOperationException("The document cannot be initialised or loaded unless the host is loading");
            }

            directives            = new Hashtable(StringComparer.InvariantCultureIgnoreCase);
            txtDocDirty           = true;
            suppressSerialization = false;
            // create and set the event, to let the parser run the first time
            updateEditorContent = new ManualResetEvent(true);
            undoTracker         = new UndoTracker();
            undoHandler         = IdeApp.Workbench.ActiveDocument.PrimaryView.GetContent <IUndoHandler> ();
            if (undoHandler == null)
            {
                throw new NullReferenceException("Could not obtain the IUndoHandler from the SourceEditorView");
            }
        }
Пример #2
0
        protected void OnRedo()
        {
            IUndoHandler editable = GetContent <IUndoHandler> ();

            if (editable != null)
            {
                editable.Redo();
            }
        }
Пример #3
0
        public override void Run()
        {
            IUndoHandler editable = WorkbenchSingleton.Workbench.ActiveContent as IUndoHandler;

            if (editable != null)
            {
                editable.Redo();
            }
        }
Пример #4
0
        private void menuEditRedo_Click(object sender, EventArgs e)
        {
            IUndoHandler h = this.DockPanel.ActiveContent as IUndoHandler;

            if (h != null && h.CanRedo)
            {
                h.Redo();
            }
        }
Пример #5
0
        /// <summary>
        /// Register a new undo command along with an undo handler. The
        /// undo handler is used to perform the actual undo or redo
        /// operation later when requested.
        /// </summary>
        /// <param name="cmd">New command to add to the manager.</param>
        /// <param name="undoHandler">Undo handler to perform the actual undo/redo operation.</param>
        public void AddUndoCommand(UndoCommand cmd, IUndoHandler undoHandler)
        {
            AddUndoCommand(cmd);

            if (m_undoList.Count > 0)
            {
                UndoInfo info = (UndoInfo)m_undoList[m_undoList.Count - 1];
                Debug.Assert(info != null);
                info.m_undoHandler = undoHandler;
                undoHandler.refreshHistory(m_undoList);
            }
        }
Пример #6
0
 public void ResetHandler(object handler)
 {
     hUndo                  = handler as IUndoHandler;
     hClip                  = handler as IClipboardHandler;
     hDelete                = handler as IDeleteHandler;
     hSelectAll             = handler as ISelectAllHandler;
     hFind                  = handler as IFindReplaceHandler;
     this.menuUndo.Tag      = hUndo != null;
     this.menuRedo.Tag      = hUndo != null;
     this.menuCut.Tag       = hClip != null;
     this.menuCopy.Tag      = hClip != null;
     this.menuPaste.Tag     = hClip != null;
     this.menuDelete.Tag    = hDelete != null;
     this.menuSelectAll.Tag = hSelectAll != null;
     this.menuFind.Tag      = hFind != null;
     this.menuReplace.Tag   = hFind != null;
 }
Пример #7
0
        public override void Run()
        {
            IUndoHandler editable = WorkbenchSingleton.Workbench.ActiveContent as IUndoHandler;

            if (editable != null)
            {
                editable.Undo();
            }
            else
            {
                TextBoxBase textBox = WorkbenchSingleton.ActiveControl as TextBoxBase;
                if (textBox != null)
                {
                    textBox.Undo();
                }
            }
        }
Пример #8
0
        protected void OnUpdateRedo(CommandInfo info)
        {
            IUndoHandler textBuffer = GetContent <IUndoHandler> ();

            info.Enabled = textBuffer != null && textBuffer.EnableRedo;
        }
Пример #9
0
		private void initDocument (Control parent, DesignerHost host)
		{
			System.Diagnostics.Trace.WriteLine ("Creating document...");

			// get the ExtensibleTextEditor instance of the Source code's view
			textEditor = IdeApp.Workbench.ActiveDocument.PrimaryView.GetContent<SourceEditorView> ().TextEditor;

			if (!(parent is WebFormPage))
				throw new NotImplementedException ("Only WebFormsPages can have a document for now");
			this.parent = parent;
			this.host = host;
			
			if (!host.Loading)
				throw new InvalidOperationException ("The document cannot be initialised or loaded unless the host is loading"); 

			directives = new Hashtable (StringComparer.InvariantCultureIgnoreCase);
			txtDocDirty = true;
			suppressSerialization = false;
			// create and set the event, to let the parser run the first time
			updateEditorContent = new ManualResetEvent (true);
			undoTracker = new UndoTracker ();
			undoHandler = IdeApp.Workbench.ActiveDocument.PrimaryView.GetContent <IUndoHandler> ();
			if (undoHandler == null)
				throw new NullReferenceException ("Could not obtain the IUndoHandler from the SourceEditorView");
		}
Пример #10
0
 public void ResetHandler(object handler)
 {
     hUndo = handler as IUndoHandler;
     hClip = handler as IClipboardHandler;
     hDelete = handler as IDeleteHandler;
     hSelectAll = handler as ISelectAllHandler;
     hFind = handler as IFindReplaceHandler;
     this.menuUndo.Tag = hUndo != null;
     this.menuRedo.Tag = hUndo != null;
     this.menuCut.Tag = hClip != null;
     this.menuCopy.Tag = hClip != null;
     this.menuPaste.Tag = hClip != null;
     this.menuDelete.Tag = hDelete != null;
     this.menuSelectAll.Tag = hSelectAll != null;
     this.menuFind.Tag = hFind != null;
     this.menuReplace.Tag = hFind != null;
 }
Пример #11
0
        private void menuEdit_DropDownOpening(object sender, EventArgs e)
        {
            IUndoHandler        hUndo      = this.DockPanel.ActiveContent as IUndoHandler;
            IClipboardHandler   hClip      = this.DockPanel.ActiveContent as IClipboardHandler;
            IDeleteHandler      hDelete    = this.DockPanel.ActiveContent as IDeleteHandler;
            ISelectAllHandler   hSelectAll = this.DockPanel.ActiveContent as ISelectAllHandler;
            IFindReplaceHandler hFind      = this.DockPanel.ActiveContent as IFindReplaceHandler;

            if (hUndo != null)
            {
                this.menuEditUndo.Enabled = hUndo.CanUndo;
                this.menuEditRedo.Enabled = hUndo.CanRedo;
            }
            else
            {
                this.menuEditUndo.Enabled = false;
                this.menuEditRedo.Enabled = false;
            }

            if (hClip != null)
            {
                this.menuEditCut.Enabled   = hClip.CanCut;
                this.menuEditCopy.Enabled  = hClip.CanCopy;
                this.menuEditPaste.Enabled = hClip.CanPaste;
            }
            else
            {
                this.menuEditCut.Enabled   = false;
                this.menuEditCopy.Enabled  = false;
                this.menuEditPaste.Enabled = false;
            }

            if (hDelete != null)
            {
                this.menuEditDelete.Enabled = hDelete.CanDelete;
            }
            else
            {
                this.menuEditDelete.Enabled = false;
            }

            if (hSelectAll != null)
            {
                this.menuEditSelectAll.Enabled = hSelectAll.CanSelectAll;
            }
            else
            {
                this.menuEditSelectAll.Enabled = false;
            }

            if (hFind != null)
            {
                this.menuEditFind.Enabled    = hFind.CanShowFindDialog;
                this.menuEditReplace.Enabled = hFind.CanShowReplaceDialog;
            }
            else
            {
                this.menuEditFind.Enabled    = false;
                this.menuEditReplace.Enabled = false;
            }
        }
Пример #12
0
 public UndoInfo()
 {
     m_undoCommand = null;
     m_undoHandler = null;
 }
Пример #13
0
        /// <summary>
        /// Register a new undo command along with an undo handler. The
        /// undo handler is used to perform the actual undo or redo
        /// operation later when requested.
        /// </summary>
        /// <param name="cmd">New command to add to the manager.</param>
        /// <param name="undoHandler">Undo handler to perform the actual undo/redo operation.</param>
        public void AddUndoCommand(UndoCommand cmd, IUndoHandler undoHandler)
        {
            AddUndoCommand(cmd);

            if (m_undoList.Count > 0)
            {
                UndoInfo info = (UndoInfo)m_undoList[m_undoList.Count - 1];
                Debug.Assert(info != null);
                info.m_undoHandler = undoHandler;
                undoHandler.refreshHistory(m_undoList);
            }
        }
Пример #14
0
 public UndoInfo()
 {
     m_undoCommand = null;
     m_undoHandler = null;
 }