示例#1
0
        /// <summary>
        /// 初始化具有HostDesign类的对象,加载当前所选控件变化时的事件服务和消息处理。
        /// 得到的服务:属性控件、上下文菜单、状态栏、标签控件(TabControl)、菜单栏、
        /// 添加的服务:撤消/重复
        /// </summary>
        internal void Initialize()
        {
            host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host == null)
            {
                return;
            }
            try
            {
                selectionService = (ISelectionService)(this.GetService(typeof(ISelectionService)));
                selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);
                if (host.RootComponent != null)
                {
                    ((Control)host.RootComponent).Resize += new EventHandler(CassView_Resize);
                }
                cassPropertyGrid    = (FilteredPropertyGrid)(this.GetService(typeof(FilteredPropertyGrid)));
                operateMenu         = (ContextMenuStrip)(this.GetService(typeof(ContextMenuStrip)));
                designMousePosition = (ToolStripStatusLabel)(this.GetService(typeof(ToolStripStatusLabel)));
                editToolMenuItem    = (ToolStripMenuItem)this.GetService(typeof(ToolStripMenuItem));

                //添加撤消/重复操作服务
                IServiceContainer serviceContainer = host.GetService(typeof(ServiceContainer)) as IServiceContainer;
                undoEngine         = new UndoEngineImplication(serviceContainer);
                undoEngine.Enabled = false;    //关闭撤消和重复功能
                host.AddService(typeof(UndoEngineImplication), undoEngine);
            }
            catch (Exception ex) { }
        }
        /// <summary>
        /// ��ʼ������HostDesign��Ķ��󣬼��ص�ǰ��ѡ�ؼ��仯ʱ���¼��������Ϣ�����
        /// �õ��ķ������Կؼ��������IJ˵���״̬������ǩ�ؼ���TabControl�����˵�����
        /// ��ӵķ��񣺳���/�ظ�
        /// </summary>
        internal void Initialize()
        {
            host = (IDesignerHost)this.GetService(typeof(IDesignerHost));

            if (host == null)
            {
                return;
            }
            try
            {
                selectionService = (ISelectionService)(this.GetService(typeof(ISelectionService)));
                selectionService.SelectionChanged += new EventHandler(selectionService_SelectionChanged);
                if (host.RootComponent != null)
                {
                    ((Control)host.RootComponent).Resize += new EventHandler(CassView_Resize);
                }
                cassPropertyGrid = (FilteredPropertyGrid)(this.GetService(typeof(FilteredPropertyGrid)));
                operateMenu = (ContextMenuStrip)(this.GetService(typeof(ContextMenuStrip)));
                designMousePosition = (ToolStripStatusLabel)(this.GetService(typeof(ToolStripStatusLabel)));
                editToolMenuItem = (ToolStripMenuItem)this.GetService(typeof(ToolStripMenuItem));

                //��ӳ���/�ظ���������
                IServiceContainer serviceContainer = host.GetService(typeof(ServiceContainer)) as IServiceContainer;
                undoEngine = new UndoEngineImplication(serviceContainer);
                undoEngine.Enabled = false;    //�رճ������ظ�����
                host.AddService(typeof(UndoEngineImplication), undoEngine);
            }
            catch (Exception ex) { }
        }