Exemple #1
0
        public LimnorContextMenuCollection GetObjectMenuData(object obj)
        {
            LimnorXmlDesignerLoader2 l = this.Loader as LimnorXmlDesignerLoader2;
            UInt32 id = l.ObjectMap.GetObjectID(obj);

            if (_menuData == null)
            {
                _menuData = new Dictionary <UInt32, LimnorContextMenuCollection>();
            }
            LimnorContextMenuCollection data;

            if (!_menuData.TryGetValue(id, out data))
            {
                if (obj == l.RootObject)
                {
                    data = new LimnorContextMenuCollection(l.GetRootId());
                }
                else
                {
                    MemberComponentId mc = MemberComponentId.CreateMemberComponentId(l.GetRootId(), obj, id, null);
                    data = new LimnorContextMenuCollection(mc);
                }
                _menuData.Add(id, data);
            }
            return(data);
        }
Exemple #2
0
        public HostControl3(HostSurface hostSurface, LimnorXmlDesignerLoader2 loader)
        {
            _loader    = loader;
            _pane      = new MultiPanes();
            _pane.Dock = DockStyle.Fill;
            FormViewer fv = new FormViewer(hostSurface.View as Control);

            _pane.AddViewer(fv);
        }
        public LimnorContextMenuCollection GetObjectMenuData(object obj)
        {
            LimnorXmlDesignerLoader2 l = this.Loader as LimnorXmlDesignerLoader2;
            IClass ic = l.GetRootId().CreateMemberPointer(obj);

            if (ic != null)
            {
                return(LimnorContextMenuCollection.GetMenuCollection(ic));
            }
            return(null);
        }
        public ObjectExplorerView(LimnorXmlDesignerLoader2 designerLoader)
        {
            InitializeComponent();
            _loader      = designerLoader;
            BackColor    = Color.LightGray;
            _objExplorer = new TreeViewObjectExplorer();
            _objExplorer.SetProject(designerLoader.Project);
            _objExplorer.ActionsHolder = _loader.GetRootId();
            this.splitContainer1.Panel1.Controls.Add(_objExplorer);
            _objExplorer.Dock     = DockStyle.Fill;
            txtDesc.AcceptsTab    = true;
            txtDesc.AcceptsReturn = true;
            ContextMenu cm = new ContextMenu();

            cm.MenuItems.Add(new MenuItem("View/Edit", mnu_editDesc));
            txtDesc.ContextMenu = cm;
        }
        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 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);
        }