Example #1
0
        void DestroyEditorAndSockets()
        {
            if (proxy != null)
            {
                proxy.Dispose();
                proxy = null;
            }

            if (editorProcess != null)
            {
                editorProcess.Dispose();
                editorProcess = null;
            }

            if (propGridSocket != null)
            {
                propertyFrame.Remove(propGridSocket);
                propGridSocket.Dispose();
                propGridSocket = null;
            }

            if (designerSocket != null)
            {
                designerFrame.Remove(designerSocket);
                designerSocket.Dispose();
                designerSocket = null;
            }
        }
Example #2
0
        public override void Selected()
        {
            //check that the Mozilla extension is installed correctly, and if not, display an error
            if (extensionError != null)
            {
                return;
            }
            else if (!CheckExtension(ref extensionError))
            {
                LoggingService.LogError(extensionError);
                Label errorlabel = new Label(extensionError);
                errorlabel.Wrap = true;

                HBox  box        = new HBox(false, 10);
                Image errorImage = new Image(Gtk.Stock.DialogError, Gtk.IconSize.Dialog);

                box.PackStart(new Label(), true, true, 0);
                box.PackStart(errorImage, false, false, 10);
                box.PackStart(errorlabel, true, false, 10);
                box.PackStart(new Label(), true, true, 0);

                designerFrame.Add(box);
                designerFrame.ShowAll();
                return;
            }
            else
            {
                extensionError = null;
            }

            if (editorProcess != null)
            {
                throw new Exception("Editor should be null when document is selected");
            }

            designerSocket = new Gtk.Socket();
            designerSocket.Show();
            designerFrame.Add(designerSocket);

            propGridSocket = new Gtk.Socket();
            propGridSocket.Show();
            propertyFrame.Add(propGridSocket);

            editorProcess = (EditorProcess)Runtime.ProcessService.CreateExternalProcessObject(typeof(EditorProcess), false);

            if (designerSocket.IsRealized)
            {
                editorProcess.AttachDesigner(designerSocket.Id);
            }
            if (propGridSocket.IsRealized)
            {
                editorProcess.AttachPropertyGrid(propGridSocket.Id);
            }

            designerSocket.Realized += delegate { editorProcess.AttachDesigner(designerSocket.Id); };
            propGridSocket.Realized += delegate { editorProcess.AttachPropertyGrid(propGridSocket.Id); };

            //designerSocket.FocusOutEvent += delegate {
            //	MonoDevelop.DesignerSupport.DesignerSupport.Service.PropertyPad.BlankPad (); };

            //hook up proxy for event binding
            string codeBehind = null;

            if (viewContent.Project != null)
            {
                string mimeType = DesktopService.GetMimeTypeForUri(viewContent.ContentName);

                var cu = MonoDevelop.Projects.Dom.Parser.ProjectDomService.Parse(viewContent.Project, viewContent.ContentName)
                         as MonoDevelop.AspNet.Parser.AspNetParsedDocument;

                if (cu != null && cu.PageInfo != null && !string.IsNullOrEmpty(cu.PageInfo.InheritedClass))
                {
                    codeBehind = cu.PageInfo.InheritedClass;
                }
            }
            proxy = new MonoDevelopProxy(viewContent.Project, codeBehind);

            ITextBuffer textBuf = (ITextBuffer)viewContent.GetContent(typeof(ITextBuffer));

            editorProcess.Initialise(proxy, textBuf.Text, viewContent.ContentName);

            activated = true;

            //FIXME: track 'dirtiness' properly
            viewContent.IsDirty = true;
        }
Example #3
0
            int IVsPersistDocData.LoadDocData(string pszMkDocument)
            {
                EditorProcess = Editor.Start(pszMkDocument, QtToolsPath,
                                             hideWindow: !Editor.Detached);
                if (EditorProcess == null)
                {
                    return(VSConstants.E_FAIL);
                }

                if (Editor.Detached)
                {
                    Editor.OnStart(EditorProcess);
                    CloseParentFrame();
                    return(VSConstants.S_OK);
                }

                EditorTitle.Text = Editor.GetTitle(EditorProcess);

                EditorProcess.WaitForInputIdle();
                EditorProcess.EnableRaisingEvents = true;
                EditorProcess.Exited += EditorProcess_Exited;

                var t = Stopwatch.StartNew();

                while (EditorWindow == IntPtr.Zero && t.ElapsedMilliseconds < 5000)
                {
                    var windows = new Dictionary <IntPtr, string>();
                    foreach (ProcessThread thread in EditorProcess.Threads)
                    {
                        NativeAPI.EnumThreadWindows(
                            dwThreadId: (uint)thread.Id,
                            lParam: IntPtr.Zero,
                            lpfn: (hWnd, lParam) =>
                        {
                            windows.Add(hWnd, NativeAPI.GetWindowCaption(hWnd));
                            return(true);
                        });
                    }

                    EditorWindow = windows
                                   .Where(w => Editor.WindowFilter(w.Value))
                                   .Select(w => w.Key)
                                   .FirstOrDefault();

                    if (EditorWindow == IntPtr.Zero)
                    {
                        Thread.Sleep(100);
                    }
                }

                if (EditorWindow == IntPtr.Zero)
                {
                    EditorProcess.Kill();
                    EditorProcess = null;
                    return(VSConstants.E_FAIL);
                }

                // Save editor window styles and icon
                EditorWindowStyle = NativeAPI.GetWindowLong(
                    EditorWindow, NativeAPI.GWL_STYLE);
                EditorWindowStyleExt = NativeAPI.GetWindowLong(
                    EditorWindow, NativeAPI.GWL_EXSTYLE);
                EditorIcon = NativeAPI.SendMessage(
                    EditorWindow, NativeAPI.WM_GETICON, NativeAPI.ICON_SMALL, 0);
                if (EditorIcon == IntPtr.Zero)
                {
                    EditorIcon = (IntPtr)NativeAPI.GetClassLong(EditorWindow, NativeAPI.GCL_HICON);
                }
                if (EditorIcon == IntPtr.Zero)
                {
                    EditorIcon = (IntPtr)NativeAPI.GetClassLong(EditorWindow, NativeAPI.GCL_HICONSM);
                }

                // Move editor window inside VS
                if (NativeAPI.SetParent(
                        EditorWindow, EditorControl.Handle) == IntPtr.Zero)
                {
                    EditorWindow = IntPtr.Zero;
                    EditorProcess.Kill();
                    EditorProcess = null;
                    return(VSConstants.E_FAIL);
                }
                if (NativeAPI.SetWindowLong(
                        EditorWindow, NativeAPI.GWL_STYLE, NativeAPI.WS_VISIBLE) == 0)
                {
                    EditorWindow = IntPtr.Zero;
                    EditorProcess.Kill();
                    EditorProcess = null;
                    return(VSConstants.E_FAIL);
                }
                if (!NativeAPI.MoveWindow(
                        EditorWindow, 0, 0, EditorControl.Width, EditorControl.Height, true))
                {
                    EditorWindow = IntPtr.Zero;
                    EditorProcess.Kill();
                    EditorProcess = null;
                    return(VSConstants.E_FAIL);
                }

                Editor.OnStart(EditorProcess);
                return(VSConstants.S_OK);
            }