int IPersistFileFormat.Save(string pszFilename, int fRemember, uint nFormatIndex) { // --- switch into the NoScribble mode _savingFile = true; try { // --- If file is null or same --> SAVE if (pszFilename == null || pszFilename == FileName) { SaveFile(FileName); IsDirty = false; } else { // --- If remember --> SaveAs if (fRemember != 0) { FileName = pszFilename; SaveFile(FileName); IsDirty = false; EditorBroker.UpdateEditorDocumentPath(EditorBroker.Broker.GetActiveDocumentFullName(), FileName); } else // --- Else, Save a Copy As { SaveFile(pszFilename); } } } finally { // --- Switch into the Normal mode _savingFile = false; } return(VSConstants.S_OK); }
public void Dispose() { //Remove message filter //Application.RemoveMessageFilter((System.Windows.Forms.IMessageFilter)this); EditorBroker.UnregisterEditor(this); if (services != null) { // Remove this object from the list of the priority command targets. if (cmdTargetCookie != 0) { IVsRegisterPriorityCommandTarget register = services.VsRegisterPriorityCommandTarget; if (null != register) { int hr = register.UnregisterPriorityCommandTarget(cmdTargetCookie); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } } cmdTargetCookie = 0; } services = null; } if (coreEditor != null) { IVsCodeWindow win = coreEditor.CodeWindow; win.Close(); coreEditor = null; } }
/// <summary> /// Unregister the editor to delete the handles and events to the window. /// </summary> public void UnregisterEditor() { if (_nativeWindow != null) { EditorBroker.UnregisterEditor(_nativeWindow); } }
// this method must be externally synchronized internal static void CreateSingleton(ServiceBroker sb) { if (Broker != null) { throw new InvalidOperationException("The singleton broker has alreaby been created."); } Broker = new EditorBroker(sb); }
public VSCodeEditorWindow(ServiceBroker sb, VSCodeEditorUserControl parent) { Parent = parent; services = sb; coreEditor = new VSCodeEditor(Parent, services); //Create window IVsCodeWindow win = coreEditor.CodeWindow; cmdTarget = win as IOleCommandTarget; IVsTextView textView; int hr = win.GetPrimaryView(out textView); if (hr != VSConstants.S_OK) { Marshal.ThrowExceptionForHR(hr); } // assign the window handle IntPtr commandHwnd = textView.GetWindowHandle(); AssignHandle(commandHwnd); //// Register priority command target, this dispatches mappable keys like Enter, Backspace, Arrows, etc. //hr = services.VsRegisterPriorityCommandTarget.RegisterPriorityCommandTarget( // 0, (IOleCommandTarget)CommandBroker.Broker, out cmdTargetCookie); //if (hr != VSConstants.S_OK) // Marshal.ThrowExceptionForHR(hr); lock (typeof(EditorBroker)) { if (EditorBroker.Broker == null) { EditorBroker.CreateSingleton(services); } EditorBroker.RegisterEditor(this); } //Add message filter //Application.AddMessageFilter((System.Windows.Forms.IMessageFilter)this); }
// this method must be externally synchronized internal static void CreateSingleton(ServiceBroker sb) { if (Broker != null) throw new InvalidOperationException( "The singleton broker has alreaby been created." ); Broker = new EditorBroker(sb); }