Exemplo n.º 1
0
        //添加,编辑,删除,上下移动方法公开,是为了让外部按钮调用

        /// <summary>
        /// 添加事件
        /// </summary>
        public void Add()
        {
            if (EventSupport == null)
            {
                return;
            }

            FormEventEditor formEventSet = new FormEventEditor(this.Entity);

            formEventSet.FormEntity = this.FormEntity;
            formEventSet.EventList  = EventSupport.Events;

            if (formEventSet.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            EventSupport.Events.Add(formEventSet.Event);

            EventSupport.EventUpdate(this);

            BuildTree();

            if (EventChanged != null)
            {
                EventChanged(new CollectionEditEventArgs(this.EventSupport.Events, CollectionEditType.Add,
                                                         this.EventSupport.Events.IndexOf(formEventSet.Event), formEventSet.Event));
            }
        }
Exemplo n.º 2
0
        private void Edit()
        {
            if (dataGridViewEvent.SelectedRows.Count != 1)
            {
                return;
            }

            EventBase even  = this.dataGridViewEvent.SelectedRows[0].DataBoundItem as EventBase;
            int       index = this.EventList.IndexOf(even);

            //保持当前事件对象的副本,用于在编辑事件之后,进行Compare提取差异
            EventBase oldEvent = even.Clone() as EventBase;

            //FormEventEditor.Event编辑后还是原对象的引用,在原对象基础上修改的
            FormEventEditor formEventSet = new FormEventEditor(this._hostEntity, even);

            //这里暂时还能用using,因为窗体释放时,会把事件的编辑面板也释放掉,要另外处理这个问题
            //using (FormEventEditor formEventSet = new FormEventEditor(this._entity, even))
            //{
            formEventSet.FormEntity = this.FormEntity;
            formEventSet.EventList  = this.EventList;

            if (formEventSet.ShowDialog() == DialogResult.OK)
            {
                //CheckWarning
                IWarningable warningable = formEventSet.Event as IWarningable;
                if (warningable != null)
                {
                    warningable.CheckWarning();
                }

                _eventBindingList.ResetItem(index);

                EventUpdate();

                if (this.OnEdited != null)
                {
                    CollectionEditEventArgs args = new CollectionEditEventArgs(this.EventList,
                                                                               CollectionEditType.Edit, index, formEventSet.Event);
                    args.Members.Inject(ObjectCompare.Compare(oldEvent, formEventSet.Event));
                    OnEdited(this, args);
                }
            }
            //}
        }
Exemplo n.º 3
0
        private void FormEventSet_Load(object sender, EventArgs e)
        {
            _instance = this;

            //提取实体对象所支持的事件
            BindingSupportEventList();

            //如果EditEvent不为空,则当前窗体是在编辑模式下,编辑EditEvent
            if (this.Event != null)
            {
                this.isEdit = true;
            }

            //如果不是编辑状态,返回
            if (this.isEdit)
            {
                //加载编辑状态信息

                availableEvents.Enabled = false;

                //选择对应的动作
                availableEvents.SetSelectedValue(EventSupport.EventProvide.GetProvideAttribute(this.Event));

                List <EventTimeAbstract> eventTime = (from c in EventSupport.EventTimeProvide
                                                      where c.Code == this.Event.EventTime
                                                      select c).ToList <EventTimeAbstract>();
                Debug.Assert(eventTime.Count == 1, "触发时机未能正确获得");
                if (eventTime.Count == 1)
                {
                    //选择对应的触发时机
                    availableEventTimes.SetSelectedValue(eventTime[0]);
                }

                //把动作传到用户控件里去,设置相应信息
                CreateEventEditorSupport();

                this._eventEditorSupport.EditorAdapter.BeginEdit();
            }
            else
            {
                availableEvents.Enabled = true;

                availableEvents.SelectedValueChanged += new EventHandler <SEComboSelector2.OnSelectedValueChangedEventArgs>(availableEvents_SelectedValueChanged);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 编辑事件
        /// </summary>
        public void Edit()
        {
            EventTreeNode node = this.SelectedNode as EventTreeNode;

            //如果选择的不是事件,直接返回
            if (node == null)
            {
                return;
            }

            //保持当前事件对象的副本,用于在编辑事件之后,进行Compare提取差异
            EventBase oldEvent = null;

            if (EventChanged != null)
            {
                oldEvent = node.Event.Clone() as EventBase;
            }

            //FormEventEditor.Event编辑后还是原对象的引用,在原对象基础上修改的
            FormEventEditor formEventSet = new FormEventEditor(node.Event.HostEntity, node.Event);

            formEventSet.FormEntity = node.Event.HostFormEntity;
            formEventSet.EventList  = EventSupport.Events;

            if (formEventSet.ShowDialog() == DialogResult.OK)
            {
                EventSupport.EventUpdate(this);

                //直接重建树
                //如果想根据改变的触发时机来修改当前事件的父节点,涉及到事件的顺序问题
                //因为编辑的事件在移到新的触发时机下面时,不一定是最后一个
                BuildTree();

                //触发事件(如果有)
                if (EventChanged != null)
                {
                    CollectionEditEventArgs args = new CollectionEditEventArgs(this.EventSupport.Events, CollectionEditType.Edit,
                                                                               this.EventSupport.Events.IndexOf(node.Event), node.Event);
                    args.Members.Inject(ObjectCompare.Compare(oldEvent, node.Event));
                    EventChanged(args);
                }
            }
        }
Exemplo n.º 5
0
        private void Add()
        {
            FormEventEditor formEventSet = new FormEventEditor(this._hostEntity);

            formEventSet.FormEntity = this.FormEntity;
            formEventSet.EventList  = this.EventList;

            if (formEventSet.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            this.EventList.Add(formEventSet.Event);

            this._eventBindingList.ResetBindings();

            EventUpdate();

            if (this.OnEdited != null)
            {
                OnEdited(this, new CollectionEditEventArgs(this.EventList,
                                                           CollectionEditType.Add, this.EventList.IndexOf(formEventSet.Event), formEventSet.Event));
            }
        }