This class serves as a) Command broker (subscribing once to the mappable keys of Visual Studio, instead of many times Solving a bug of backspace affecting the wrong mysql editor window when more than one is open). b) A repository to serve the connections of each SqlEditor for the Intellisense classifiers.
Inheritance: IOleCommandTarget
Beispiel #1
0
 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);
 }
Beispiel #2
0
 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;
     }
 }
Beispiel #3
0
 /// <summary>
 /// Unregister the editor to delete the handles and events to the window.
 /// </summary>
 public void UnregisterEditor()
 {
     if (_nativeWindow != null)
     {
         EditorBroker.UnregisterEditor(_nativeWindow);
     }
 }
Beispiel #4
0
        // 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);
        }
Beispiel #5
0
        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);
 }