Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="designer"></param>
        /// <param name="rootComponentType">it can be null. if not null then it must be a type derived from Diagram</param>
        public ItemDesignerHost(IXDesignerHost designer, Type rootComponentType)
        {
            InitializeComponent();
            _undoEngine = new UndoEngine2();
            if (rootComponentType == null)
            {
                dsf = new DesignSurface(typeof(Diagram));
            }
            else
            {
                dsf = new DesignSurface(rootComponentType);
            }
            Control control = dsf.View as Control;

            this.Controls.Add(control);
            control.Dock    = DockStyle.Fill;
            control.Visible = true;
            //
            IDesignerHost host = (IDesignerHost)dsf.GetService(typeof(IDesignerHost));

            root      = (Diagram)host.RootComponent;
            root.Dock = DockStyle.Fill;
            //
            DesignMessageFilter filter = new DesignMessageFilter(dsf);

            Application.AddMessageFilter(filter);
        }
Пример #2
0
        //
        public DiagramDesignerHolder()
        {
            InitializeComponent();
            btOK.BringToFront();
            btCancel.BringToFront();
            _undoEngine = new UndoEngine2();
            //
            dsf = new DesignSurface(typeof(DiagramViewer));
            Control control = dsf.View as Control;             //DesignerFrame

            splitContainer1.Panel2.Controls.Add(control);
            control.Dock    = DockStyle.Fill;
            control.Visible = true;
            splitContainer1.SplitterMoved += new SplitterEventHandler(splitContainer1_SplitterMoved);
            this.Resize += new EventHandler(designview_Resize);
            splitContainer1.SplitterWidth = 3;
            //
            IDesignerHost host = (IDesignerHost)dsf.GetService(typeof(IDesignerHost));

            root      = (DiagramViewer)host.RootComponent;
            root.Dock = DockStyle.Fill;
            root.AssignHolder(this);
            //
            host.AddService(typeof(PropertyGrid), propertyGrid1);
            host.AddService(typeof(INameCreationService), new NameCreation());
            //
            selectionService = (ISelectionService)dsf.GetService(typeof(ISelectionService));
            if (selectionService != null)
            {
                selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);
            }
            IComponentChangeService componentChangeService = (IComponentChangeService)dsf.GetService(typeof(IComponentChangeService));

            componentChangeService.ComponentAdded    += new ComponentEventHandler(componentChangeService_ComponentAdded);
            componentChangeService.ComponentRemoving += new ComponentEventHandler(componentChangeService_ComponentRemoving);
            componentChangeService.ComponentRemoved  += new ComponentEventHandler(componentChangeService_ComponentRemoved);
            componentChangeService.ComponentChanged  += new ComponentChangedEventHandler(componentChangeService_ComponentChanged);
            //
            root.ControlRemoved += new ControlEventHandler(root_ControlRemoved);
            //
            _msgFilter = new DesignMessageFilter(dsf);
            Application.AddMessageFilter(_msgFilter);
            //
            propertyGrid1.PropertyValueChanged += new PropertyValueChangedEventHandler(propertyGrid1_PropertyValueChanged);
            propertyGrid1.HelpVisible           = false;
            propertyGrid1.PropertySort          = PropertySort.Alphabetical;
            propertyGrid1.SelectedObject        = root;
            //
        }