internal void SetData(LimnorXmlPane2 data)
 {
     _designPane = data;
     _folder     = _designPane.Project.ProjectFolder;
     _namespace  = _designPane.Loader.GetRootId().Namespace;
     if (string.IsNullOrEmpty(_namespace))
     {
         _namespace = _designPane.Loader.Namespace;
     }
 }
        private IntPtr CreateDesignerView(IVsHierarchy hierarchy, uint itemid, IVsTextLines textLines, ref string editorCaption, ref Guid cmdUI, string documentMoniker)
        {
            // Request the Designer Service
            IVSMDDesignerService designerService = (IVSMDDesignerService)GetService(typeof(IVSMDDesignerService));

            try
            {
                // Get the service provider
                IOleServiceProvider provider = serviceProvider.GetService(typeof(IOleServiceProvider)) as IOleServiceProvider;
                IObjectWithSite     ows      = (IObjectWithSite)textLines;
                ows.SetSite(provider);
                // Create loader for the designer
                LimnorXmlDesignerLoader2 designerLoader = new LimnorXmlDesignerLoader2(documentMoniker, itemid);

                // Create the designer using the provider and the loader
                IVSMDDesigner designer = designerService.CreateDesigner(provider, designerLoader);

                designerLoader.AddComponentChangeEventHandler();

                // Retrieve the design surface
                DesignSurface designSurface = (DesignSurface)designer;

                IDesignerHost dh = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));
                dh.AddService(typeof(INameCreationService), new NameCreationService());

                IServiceContainer serviceContainer = dh.GetService(typeof(ServiceContainer)) as IServiceContainer;
                dh.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(serviceContainer));
                //DesignerSerializationService uses CodeDomComponentSerializationService
                CodeDomComponentSerializationService codeDomComponentSerializationService = new CodeDomComponentSerializationService(serviceContainer);
                dh.AddService(typeof(ComponentSerializationService), codeDomComponentSerializationService);

                //LimnorUndoEngine undoEngine = new LimnorUndoEngine(serviceContainer);
                //undoEngine.Enabled = false;//not use undo during loading
                //dh.AddService(typeof(UndoEngine), undoEngine);
                //object v = dh.GetService(typeof(IOleUndoManager));
                //if (v != null)
                //{
                //    object v2 = dh.GetService(typeof(UndoEngine));
                //    if (v2 == null)
                //    {
                //        dh.AddService(typeof(UndoEngine), v);
                //    }
                //}
                // Create pane with this surface
                LimnorXmlPane2 limnorXmlPane = new LimnorXmlPane2(designSurface);//, winControlPME);

                // Get command guid from designer
                cmdUI         = limnorXmlPane.CommandGuid;
                editorCaption = " [Design]";
                if (designerLoader.IsSetup)
                {
                }
                else
                {
                    if (limnorXmlPane.Loader.ObjectMap != null)
                    {
                        limnorXmlPane.BeginApplyConfig();
                    }
                }
                // Return LimnorXmlPane
                return(Marshal.GetIUnknownForObject(limnorXmlPane));
            }
            catch (Exception ex)
            {
                MathNode.Log(ex);
                //Trace.WriteLine("Exception: " + ex.Message);
                // Just rethrow for now
                throw;
            }
        }
 public void SetData(string folder, string defaultNamespace)
 {
     _folder     = folder;
     _namespace  = defaultNamespace;
     _designPane = null;
 }
        public ILimnorDesignPane CreateDesigner(ClassData classData)
        {
            ILimnorDesignPane limnorXmlPane = null;

            try
            {
                DesignUtil.LogIdeProfile("Create designer loader");
                LimnorXmlDesignerLoader2 designerLoader = new LimnorXmlDesignerLoader2(classData);
                DesignUtil.LogIdeProfile("Create designer surface");
                HostSurface designSurface = (HostSurface)this.CreateDesignSurface(this.ServiceContainer);

                IDesignerHost dh = (IDesignerHost)designSurface.GetService(typeof(IDesignerHost));

                dh.AddService(typeof(INameCreationService), new NameCreationService());

                IServiceContainer serviceContainer = dh.GetService(typeof(ServiceContainer)) as IServiceContainer;
                DesignUtil.LogIdeProfile("Load designer surface");
                designSurface.Loader = designerLoader;
                designSurface.BeginLoad(designerLoader);
                if (VPLUtil.Shutingdown)
                {
                    return(null);
                }
                DesignUtil.LogIdeProfile("Add designer services");
                XMenuCommandService menuServices = new XMenuCommandService(serviceContainer);
                dh.AddService(typeof(IMenuCommandService), menuServices);
                menuServices.AddVerb(new DesignerVerb("Cut", null, StandardCommands.Cut));
                menuServices.AddVerb(new DesignerVerb("Copy", null, StandardCommands.Copy));
                menuServices.AddVerb(new DesignerVerb("Paste", null, StandardCommands.Paste));
                menuServices.AddVerb(new DesignerVerb("Delete", null, StandardCommands.Delete));
                menuServices.AddVerb(new DesignerVerb("Undo", null, StandardCommands.Undo));
                menuServices.AddVerb(new DesignerVerb("Redo", null, StandardCommands.Redo));

                if (dh.GetService(typeof(IDesignerSerializationService)) == null)
                {
                    dh.AddService(typeof(IDesignerSerializationService), new DesignerSerializationService(serviceContainer));
                }

                if (dh.GetService(typeof(ComponentSerializationService)) == null)
                {
                    //DesignerSerializationService uses CodeDomComponentSerializationService
                    CodeDomComponentSerializationService codeDomComponentSerializationService = new CodeDomComponentSerializationService(serviceContainer);
                    dh.AddService(typeof(ComponentSerializationService), codeDomComponentSerializationService);
                }
                VOB.UndoEngineImpl undoEngine = new VOB.UndoEngineImpl(serviceContainer);
                undoEngine.Enabled = false;
                dh.AddService(typeof(UndoEngine), undoEngine);

                designerLoader.AddComponentChangeEventHandler();
                DesignUtil.LogIdeProfile("Create designer pane");
                limnorXmlPane = new LimnorXmlPane2(designSurface, designerLoader);
                if (designerLoader.IsSetup)
                {
                }
                else
                {
                    DesignUtil.LogIdeProfile("Apply config");
                    if (limnorXmlPane.Loader.ObjectMap != null)
                    {
                        limnorXmlPane.BeginApplyConfig();
                    }
                }
                DesignUtil.LogIdeProfile("Initialize designer surface");
                designSurface.Initialize();
                ILimnorToolbox toolbox = (ILimnorToolbox)GetService(typeof(IToolboxService));
                toolbox.Host             = dh;
                this.ActiveDesignSurface = designSurface;
                //
            }
            catch (Exception ex)
            {
                MathNode.Log(TraceLogClass.MainForm, ex);
                // Just rethrow for now
                throw;
            }
            DesignUtil.LogIdeProfile("Finish creating designer");
            return(limnorXmlPane);
        }