Esempio n. 1
0
        public EnumView()
        {
            InitializeComponent();

            UIHelper.ProcessDataGridView(this.dataGridViewEnum);
            UIHelper.ProcessDataGridView(this.dataGridViewEnumItem);

            this.Single    = true;
            this.SingleKey = SINGLEKEY;

            this.HideOnClose = true;
            this.Icon        = DrawingTool.ImageToIcon(Resources.Enum);
            this.TabText     = Language.Current.DictionaryView_TabText;

            //DesignMode 拿不到 ServiceUnity.Container,报错
            if (DesignMode)
            {
                return;
            }

            //初始化命令
            InitCommands();

            //初始化菜单
            InitContextMenu();

            //初始化 DataGridView 控制器
            InitController();

            SubscribeEvent();
        }
Esempio n. 2
0
 public ExplorerView()
 {
     InitializeComponent();
     this.Single      = true;
     this.SingleKey   = SINGLEKEY;
     this.HideOnClose = true;
     this.Icon        = DrawingTool.ImageToIcon(IconsLibrary.Form);
     this.TabText     = Language.Current.ExplorerView_TabText;
     if (DesignMode)
     {
         return;
     }
     _treeView                          = new ExplorerTreeView();
     _treeView.PadAreas                 = PadAreas.DockLeft;
     _treeView.HideOnClose              = true;
     _treeView.AfterSelect             += new ExplorerTreeView.OnAfterSelectHandler(_treeView_AfterSelect);
     _treeView.NodeAdded               += new ExplorerTreeView.OnNodeAddedHandler(_treeView_NodeAdded);
     _propertyView                      = new ExplorerPropertyView();
     _propertyView.PadAreas             = PadAreas.DockLeft;
     _propertyView.HideOnClose          = true;
     _gridView                          = new ExplorerGridView();
     _gridView.DockAreas                = DockAreas.Document;
     _gridView.GridDoubleClick         += new ExplorerGridContainer.OnGridDoubleClickHandler(_gridView_GridDoubleClick);
     _gridView.GridSelectedItemChanged += new ExplorerGridContainer.OnGridSelectedItemChangedHandler(_gridView_GridSelectedItemChanged);
 }
        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();
        }
Esempio n. 4
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;
 }
Esempio n. 5
0
 public ExplorerView()
 {
     InitializeComponent();
     this.Single      = true;
     this.SingleKey   = SINGLEKEY;
     this.HideOnClose = true;
     this.Icon        = DrawingTool.ImageToIcon(IconsLibrary.Image2);
     this.TabText     = Language.Current.ExplorerView_TabText;
 }
        /// <summary>
        /// Fetches an image of the requested size.
        /// </summary>
        /// <param name="size">Size of image to obtain.</param>
        /// <returns>If supported, returns requested image. A value of null
        /// indicates that the requested size is not supported.</returns>
        public virtual Image GetImage(ShengToolStripImageSize size)
        {
            if (DefaultImageProvider == null)
                throw new NullReferenceException();

            if (DefaultImageProvider == this)
            {
                Size iconSize = ShengToolStripIconImageProvider.GetIconSize(size);
                Bitmap icon = new Bitmap(16, 16);
                Icon iconResult = new Icon(DrawingTool.ImageToIcon(icon), iconSize);
                return iconResult.ToBitmap();
            }

            return DefaultImageProvider.GetImage(size);
        }
 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();
                 }
             }
         }
     });
 }
        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;
        }