Beispiel #1
0
        public CodeEditorControl(CodeEditorContent content, OpenedFile file)
        {
            InitializeComponent();

            _content   = content;
            _extension = (CodeEditorExtension)content.ParentExtension;
            _file      = file;

            SetupTextBox();
            _errorStyle   = new ErrorStyle(_extension.StyleMap.DefaultText.Description);
            _warningStyle = new WarningStyle(_extension.StyleMap.DefaultText.Description);

            contextMenuStrip1.Renderer = _extension.ExtensionHost.ControlManager.MenuRenderer;

            _componentMuiIdentifiers = new Dictionary <object, string>()
            {
                { this.cutToolStripMenuItem, "CodeEditorControl.ContextMenu.Cut" },
                { this.copyToolStripMenuItem, "CodeEditorControl.ContextMenu.Copy" },
                { this.pasteToolStripMenuItem, "CodeEditorControl.ContextMenu.Paste" },
                { this.selectAllToolStripMenuItem, "CodeEditorControl.ContextMenu.SelectAll" },
            };

            _extension.ExtensionHost.UILanguageChanged += ExtensionHost_UILanguageChanged;
            _extension.ExtensionHost.BookmarkManager.Bookmarks.InsertedItem += Bookmarks_InsertedItem;
            _extension.ExtensionHost.BookmarkManager.Bookmarks.RemovedItem  += Bookmarks_RemovedItem;
            _extension.ExtensionHost.ErrorManager.Errors.InsertedItem       += Errors_InsertedItem;
            _extension.ExtensionHost.ErrorManager.Errors.RemovedItem        += Errors_RemovedItem;
            _extension.ExtensionHost.ErrorManager.Errors.ClearedCollection  += Errors_ClearedCollection;
            _extension.ExtensionHost.DebugStarted += ExtensionHost_DebugStarted;
            _extension.ExtensionHost.DebugStopped += ExtensionHost_DebugStopped;

            _instructionPointer = new CodeEditorInstructionPointer(TextBox, _extension.StyleMap.InstructionPointerStyle);

            if (_extension.ExtensionHost.IsDebugging)
            {
                ExtensionHost_DebugStarted(null, null);
            }

            ExtensionHost_UILanguageChanged(null, null);

            _extension.AppliedSettings += extension_AppliedSettings;
            extension_AppliedSettings(null, null);

            file.HasUnsavedDataChanged += file_HasUnsavedDataChanged;
        }
        public void OpenFile(OpenedFile file)
        {
            CodeEditorContent documentContent;
            if (!_codeEditors.TryGetValue(file, out documentContent))
            {
                documentContent = new CodeEditorContent(this, file);
                documentContent.Closed += content_Closed;
                _codeEditors.Add(file, documentContent);
                ExtensionHost.ControlManager.OpenDocumentContents.Add(documentContent);
            }

            ExtensionHost.ControlManager.SelectedDocumentContent = documentContent;
        }