Inheritance: System.Windows.Forms.UserControl
Esempio n. 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VSCodeEditor"/> class.
 /// </summary>
 /// <param name="windowParent">The parent window.</param>
 /// <param name="services">The services broker.</param>
 public VSCodeEditor(VSCodeEditorUserControl windowParent, ServiceBroker services)
     : this()
 {
     parent        = windowParent;
     parentHandle  = parent.Handle;
     this.services = services;
     CreateCodeWindow();
 }
Esempio n. 2
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);
        }
    public VSCodeEditorWindow(ServiceBroker sb, UserControl parent)
    {
      Parent = (VSCodeEditorUserControl)parent;
      services = sb;
      coreEditor = new VSCodeEditor(parent.Handle, 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);
    }