Exemplo n.º 1
0
        void ExecuteRedo(object sender, EventArgs e)
        {
            UndoEngineExt undoEngine = GetService(typeof(UndoEngine)) as UndoEngineExt;

            if (undoEngine != null)
            {
                undoEngine.Redo();
            }
        }
Exemplo n.º 2
0
        internal void Initialize()
        {
            Control       control = null;
            IDesignerHost host    = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host == null)
            {
                return;
            }

            try
            {
                // Set the backcolor
                Type hostType = host.RootComponent.GetType();
                if (hostType == typeof(Form))
                {
                    control           = this.View as Control;
                    control.BackColor = Color.White;
                }
                else if (hostType == typeof(UserControl))
                {
                    control           = this.View as Control;
                    control.BackColor = Color.White;
                }
                else if (hostType == typeof(Component))
                {
                    control           = this.View as Control;
                    control.BackColor = Color.FloralWhite;
                }
                else
                {
                    throw new Exception("Undefined Host Type: " + hostType.ToString());
                }

                // Set SelectionService - SelectionChanged event handler
                _selectionService = (ISelectionService)(this.ServiceContainer.GetService(typeof(ISelectionService)));
                //_selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.ToString());
            }
            //lizheng add
            //- 1. CodeDomComponentSerializationService
            _codeDomComponentSerializationService = new CodeDomComponentSerializationService(this.ServiceContainer);
            if (_codeDomComponentSerializationService != null)
            {
                //- the CodeDomComponentSerializationService is ready to be replaced
                this.ServiceContainer.RemoveService(typeof(ComponentSerializationService), false);
                this.ServiceContainer.AddService(typeof(ComponentSerializationService), _codeDomComponentSerializationService);
            }
            //- 2. IDesignerSerializationService
            _designerSerializationService = new DesignerSerializationServiceImpl(this.ServiceContainer);
            if (_designerSerializationService != null)
            {
                //- the IDesignerSerializationService is ready to be replaced
                this.ServiceContainer.RemoveService(typeof(IDesignerSerializationService), false);
                this.ServiceContainer.AddService(typeof(IDesignerSerializationService), _designerSerializationService);
            }
            //
            //- 3. UndoEngine
            _undoEngine = new UndoEngineExt(this.ServiceContainer);
            //- disable the UndoEngine
            _undoEngine.Enabled = false;
            if (_undoEngine != null)
            {
                //- the UndoEngine is ready to be replaced
                this.ServiceContainer.RemoveService(typeof(UndoEngine), false);
                this.ServiceContainer.AddService(typeof(UndoEngine), _undoEngine);
            }
            _undoEngine.Enabled = true;

            //xhy
//             serviceProvider = this.GetService(typeof(IServiceContainer)) as IServiceContainer;
//             opsService = serviceProvider.GetService(typeof(DesignerOptionService)) as DesignerOptionService;
//             if (null != opsService)
//             {
//                 serviceProvider.RemoveService(typeof(DesignerOptionService));
//             }
//             DesignerOptionService opsService2 = new DesignerOptionServiceExt4NoGuides();
//             serviceProvider.AddService(typeof(DesignerOptionService), opsService2);
        }