コード例 #1
0
 public FormToolbox(FormHostingContainer container)
 {
     InitializeComponent();
     _container = container;
     _container.ActiveHostingChanged += new FormHostingContainer.OnActiveHostingChangedHandler(_container_ActiveHostingChanged);
     this.Icon    = DrawingTool.ImageToIcon(IconsLibrary.Toolbox);
     this.TabText = Language.Current.FormToolbox_TabText;
 }
コード例 #2
0
 public FormDesignerEventTree(FormHostingContainer container)
 {
     InitializeComponent();
     _container = container;
     _container.ActiveHostingChanged    += new FormHostingContainer.OnActiveHostingChangedHandler(_container_ActiveHostingChanged);
     _container.HostingSelectionChanged += new FormHostingContainer.OnHostingSelectionChangedHandler(_container_HostingSelectionChanged);
     this.Icon    = DrawingTool.ImageToIcon(IconsLibrary.Event);
     this.TabText = Language.Current.FormDesignerEventTree_TabText;
     Unity.ApplyResource(this);
     _eventTreeView.AllowDrop          = true;
     _eventTreeView.AfterSelect       += new TreeViewEventHandler(_eventTreeView_AfterSelect);
     _eventTreeView.EventChanged      += new EventTreeView.OnEventChangedHandler(_eventTreeView_EventChanged);
     _eventTreeView.EventOrderChanged += new EventTreeView.OnEventOrderChangedHandler(_eventTreeView_EventOrderChanged);
     this.Controls.Add(_eventTreeView);
     InitToolStrip();
     this.Controls.Add(_toolStrip.View);
     _toolStrip.View.UpdateStatus();
     _undounitAction = new Action <SEUndoUnitAbstract, SEUndoEngine.Type>(
         delegate(SEUndoUnitAbstract unit, SEUndoEngine.Type type)
     {
         if (unit is SEUndoUnitEventEdit)
         {
             SEUndoUnitEventEdit undoUnit = unit as SEUndoUnitEventEdit;
             if (undoUnit != null && ((EventBase)undoUnit.Value).HostEntity == this._eventTreeView.Entity)
             {
                 _eventTreeView.ReBuild();
             }
         }
         else if (unit is SEUndoTransaction)
         {
             SEUndoTransaction undoUnit = unit as SEUndoTransaction;
             if (undoUnit != null && undoUnit.GetAllUnits().Length > 0)
             {
                 SEUndoUnitEventEdit eventUnit = undoUnit.GetAllUnits()[0] as SEUndoUnitEventEdit;
                 if (eventUnit != null && ((EventBase)eventUnit.Value).HostEntity == this._eventTreeView.Entity)
                 {
                     _eventTreeView.ReBuild();
                 }
             }
         }
     });
 }
コード例 #3
0
        public FormPropertyGrid(FormHostingContainer container)
        {
            InitializeComponent();

            _container = container;
            _container.ActiveHostingChanged    += new FormHostingContainer.OnActiveHostingChangedHandler(_container_ActiveHostingChanged);
            _container.HostingSelectionChanged += new FormHostingContainer.OnHostingSelectionChangedHandler(_container_HostingSelectionChanged);
            _container.HostingInitFormElementsComponentComplete +=
                new FormHostingContainer.OnHostingInitFormElementsComponentCompleteHandler(_container_HostingInitFormElementsComponentComplete);

            #region PropertyGridValidator

            PropertyGridValidator validator = new PropertyGridValidator(typeof(EntityBase))
            {
                ActOnSub = true,
            };
            validator.Validator = (e) =>
            {
                bool   success = true;
                string message = null;

                //因为C#是区分大小写的,所以这里不转为全小写或全大写,避免Code和CODE两个不同Property
                //理论上我不会这么做
                if (e.Property == EntityBase.Property_Code)
                {
                    //判断是否使用了系统保留字
                    if (Keywords.Container(e.Value.ToString()))
                    {
                        success = false;
                        message = CommonLanguage.Current.ValueInefficacyUseKeywords;
                    }
                    else
                    {
                        Debug.Assert(e.Objects.Length == 1, "验证 Code 时对象数目只能是一个");
                        object obj = e.Objects[0];

                        string value = e.Value.ToString();

                        //判断在此窗体范围内,代码是否已被占用
                        if (FormHostingContainer.Instance.ActiveFormEntity.ValidateCode(value) == false)
                        {
                            success = false;
                            message = Language.Current.FormDesigner_FormPropertyGrid_MessageFormElementCodeExist;
                        }
                        else
                        {
                            //如果当前选择的目标对象是一个窗体,则还需判断指定的代码是否与其它窗体的代码冲突
                            //此处不用考虑多选的情况,因为多选状态下,代码属性不显示
                            WindowEntity windowEntity = e.Objects[0] as WindowEntity;
                            if (windowEntity != null)
                            {
                                //判断code是否已被占用
                                if (_windowComponentService.CheckExistByCode(value))
                                {
                                    success = false;
                                    message = Language.Current.FormDesigner_FormPropertyGrid_MessageFormEntityExist;
                                }
                            }
                        }
                    }
                }
                return(new PropertyGridValidateResult(success, message));
            };
            propertyGrid.AddValidator(validator);

            #endregion

            //注意,ComboBox里绑定的对象是实际控件,不是Entity
            this.comboBoxFormElementList.DrawMode              = DrawMode.OwnerDrawFixed;
            this.comboBoxFormElementList.Sorted                = false;
            this.comboBoxFormElementList.DrawItem             += new DrawItemEventHandler(ComboBoxDrawItem);
            this.comboBoxFormElementList.MeasureItem          += new MeasureItemEventHandler(ComboBoxMeasureItem);
            this.comboBoxFormElementList.SelectedIndexChanged += new EventHandler(ComboBoxSelectedIndexChanged);

            this.VisibleChanged += new EventHandler(FormPropertyGrid_VisibleChanged);

            this.Icon    = DrawingTool.ImageToIcon(IconsLibrary.Property);
            this.TabText = Language.Current.FormPropertyGrid_TabText;
        }
コード例 #4
0
        public FormDesignSurfaceHosting(WindowEntity windowEntity, SEDesignSurface designSurface, FormHostingContainer hostingContainer)
        {
            InitializeComponent();

            if (DesignMode)
            {
                return;
            }

            this._windowEntity = windowEntity;

            this.Icon = DrawingTool.ImageToIcon(IconsLibrary.Form);
            this.SetTabText();
            this.HideOnClose = false;

            this._undoEngine = new SEUndoEngineFormDesigner(this);

            this._designSurface = designSurface;

            this.HostingContainer = hostingContainer;

            this.TabPageContextMenuStrip = HostingTabPageContextMenuStrip.Instance.MenuStrip;

            //初始化DesignSurface
            //在此初始化,保证FormHostingContainer中的dockPanel_ActiveDocumentChanged执行时
            //能拿到DesignSurface中的服务
            this._designSurface = InitialseDesignSurface();
        }