예제 #1
0
            public DocumentClient(Editor editor, string extension)
            {
                m_editor = editor;
                string fileType = CodeDocument.GetDocumentType(extension);

                m_info = new DocumentClientInfo(fileType, extension, null, null);
            }
예제 #2
0
            public void Close(IDocument document)
            {
                CodeDocument codeDoc = document as CodeDocument;

                if (codeDoc != null)
                {
                    m_editor.m_controlHostService.UnregisterControl(codeDoc.Control);
                }
            }
예제 #3
0
            public void Save(IDocument document, Uri uri)
            {
                CodeDocument codeDoc = document as CodeDocument;

                if (codeDoc != null)
                {
                    codeDoc.Write();
                }
            }
예제 #4
0
            public void Show(IDocument document)
            {
                CodeDocument codeDoc = document as CodeDocument;

                if (codeDoc != null)
                {
                    m_editor.m_controlHostService.Show(codeDoc.Control);
                }
            }
예제 #5
0
        /// <summary>
        /// Requests permission to close the client's Control</summary>
        /// <param name="control">Client Control to be closed</param>
        /// <returns>True if the Control can close, or false to cancel</returns>
        /// <remarks>
        /// 1. This method is only called by IControlHostService if the Control was previously
        /// registered for this IControlHostClient.
        /// 2. If true is returned, the IControlHostService calls its own
        /// UnregisterControl. The IControlHostClient has to call RegisterControl again
        /// if it wants to re-register this Control.</remarks>
        public bool Close(Control control)
        {
            CodeDocument document = control.Tag as CodeDocument;

            if (document != null)
            {
                return(m_documentService.Close(document));
            }

            return(true);
        }
예제 #6
0
            public IDocument Open(Uri uri)
            {
                CodeDocument doc = new CodeDocument(uri);

                doc.Read();

                m_editor.m_controlHostService.RegisterControl(
                    doc.Control,
                    doc.ControlInfo,
                    m_editor);

                return(doc);
            }
예제 #7
0
        /// <summary>
        /// Checks whether the client can do the command, if it handles it</summary>
        /// <param name="commandTag">Command to be done</param>
        /// <returns>True iff client can do the command</returns>
        public bool CanDoCommand(object commandTag)
        {
            bool         canDo = false;
            CodeDocument doc   = m_documentRegistry.ActiveDocument as CodeDocument;

            if (commandTag is StandardCommand)
            {
                if (doc != null)
                {
                    switch ((StandardCommand)commandTag)
                    {
                    case StandardCommand.EditUndo:
                        canDo = doc.Editor.CanUndo;
                        break;

                    case StandardCommand.EditRedo:
                        canDo = doc.Editor.CanRedo;
                        break;

                    case StandardCommand.EditCut:
                    case StandardCommand.EditDelete:
                        canDo = doc.Editor.HasSelection && !doc.Editor.ReadOnly;
                        break;

                    case StandardCommand.EditCopy:
                        canDo = doc.Editor.HasSelection;
                        break;

                    case StandardCommand.EditPaste:
                        canDo = doc.Editor.CanPaste;
                        break;
                    }
                }
            }
            else if (commandTag is Command)
            {
                switch ((Command)commandTag)
                {
                case Command.Goto:
                case Command.FindReplace:
                    canDo = doc != null;
                    break;

                default:
                    canDo = true;
                    break;
                }
            }

            return(canDo);
        }
예제 #8
0
        /// <summary>
        /// Does the command</summary>
        /// <param name="commandTag">Command to be done</param>
        public void DoCommand(object commandTag)
        {
            CodeDocument activeDocument = m_documentRegistry.ActiveDocument as CodeDocument;

            if (commandTag is StandardCommand)
            {
                switch ((StandardCommand)commandTag)
                {
                case StandardCommand.EditUndo:
                    activeDocument.Editor.Undo();
                    break;

                case StandardCommand.EditRedo:
                    activeDocument.Editor.Redo();
                    break;

                case StandardCommand.EditCut:
                    activeDocument.Editor.Cut();
                    break;

                case StandardCommand.EditCopy:
                    activeDocument.Editor.Copy();
                    break;

                case StandardCommand.EditPaste:
                    activeDocument.Editor.Paste();
                    break;

                case StandardCommand.EditDelete:
                    activeDocument.Editor.Delete();
                    break;
                }
            }
            else if (commandTag is Command)
            {
                switch ((Command)commandTag)
                {
                case Command.FindReplace:
                    activeDocument.Editor.ShowFindReplaceForm();
                    break;

                case Command.Goto:
                    activeDocument.Editor.ShowGoToLineForm();
                    break;
                }
            }
        }
예제 #9
0
파일: Editor.cs 프로젝트: sbambach/ATF
            public IDocument Open(Uri uri)
            {
                CodeDocument doc = new CodeDocument(uri);
                doc.Read();

                m_editor.m_controlHostService.RegisterControl(
                    doc.Control,
                    doc.ControlInfo,
                    m_editor);

                return doc;
            }