Esempio n. 1
0
        void nonTransitionRepositoryItem_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            GridEditorButton gridButton = null;

            foreach (var b in nonTransitionRepositoryItem.Buttons)
            {
                gridButton = b as GridEditorButton;
                if (gridButton != null)
                {
                    if (gridButton.Tag == e.Button.Tag)
                    {
                        break;
                    }
                    else
                    {
                        gridButton = null;
                    }
                }
            }

            if (gridButton != null)
            {
                switch (gridButton.Tag as string)
                {
                case "plus":
                    PlusHandler(gridButton);
                    break;
                }
            }
        }
Esempio n. 2
0
        private void DeleteHandler(GridEditorButton gridEditorButton)
        {
            int orderNumber           = (int)(gv.GetRowCellValue(gridEditorButton.RowHandle, "Order"));
            StructAtom <string> value = gv.GetRowCellValue(gridEditorButton.RowHandle, "Input") as StructAtom <string>;

            if (value != null)
            {
                Items.RemoveAt(orderNumber);
                SyncItems();
            }
        }
Esempio n. 3
0
        void transitionRepositoryItem_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
        {
            GridEditorButton gridButton = null;

            foreach (var b in transitionRepositoryItem.Buttons)
            {
                gridButton = b as GridEditorButton;
                if (gridButton != null)
                {
                    if (gridButton.Tag == e.Button.Tag)
                    {
                        break;
                    }
                    else
                    {
                        gridButton = null;
                    }
                }
            }

            if (gridButton != null)
            {
                var ob = gvEdit.GetRowCellValue(gridButton.RowHandle, gridButton.Column);
                var tr = ob as TransitionRes <StructAtom <string>, StructAtom <string> >;
                if (tr != null)
                {
                    switch (gridButton.Tag as string)
                    {
                    case "ell":
                        EllHandler(tr, gridButton);
                        break;

                    case "delete":
                        DeleteHandler(tr, gridButton);
                        break;
                    }
                }
                else
                {
                    switch (gridButton.Tag as string)
                    {
                    case "plus":
                        PlusHandler(gridButton);
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
        private void PlusHandler(GridEditorButton button)
        {
            var state = fsm.StateSet.FirstOrDefault(s => s.ToString() == button.Column.FieldName);
            var cg    = gvEdit.Columns["Zs"];
            var v     = gvEdit.GetRowCellValue(button.RowHandle, cg);
            var input = v as string;

            if (state != null && input != null)
            {
                frmTransitionEdit frm = new frmTransitionEdit();
                frm.DataChanged += frm_DataChanged;

                var trans = fsm.Transitions.Values.FirstOrDefault(tr => tr.Input.KeyName == input && tr.SourceState.StateCore == state.StateCore);
                if (trans != null)
                {
                    frm.Show(trans);
                }
                else
                {
                    fsm.AddOutgoing(state, input);
                    trans = fsm.Transitions.Values.FirstOrDefault(tr => tr.Input.KeyName == input && tr.SourceState.StateCore == state.StateCore);
                    if (trans != null)
                    {
                        if (frm.Show(trans) != System.Windows.Forms.DialogResult.OK)
                        {
                        }
                        if (trans.destinationStates.Count == 0)
                        {
                            if (fsm.Transitions.Remove(trans.ToString()))
                            {
                                UpdateGrid();
                            }
                            else
                            {
                                Debug.WriteLine("Не удаётся откатить добавленый переход.");
                            }
                        }
                    }
                    else
                    {
                        Debug.WriteLine("Переход какбэ добавился и какбэ не добавился!");
                    }
                }
            }
        }
Esempio n. 5
0
        private void InitRepItems()
        {
            var plusBtn = new GridEditorButton();

            plusBtn.Tag  = "plus";
            plusBtn.Kind = ButtonPredefines.Plus;

            var deleteBtn = new GridEditorButton();

            deleteBtn.Tag  = "delete";
            deleteBtn.Kind = ButtonPredefines.Delete;

            var ellBtn = new GridEditorButton();

            ellBtn.Tag    = "ell";
            ellBtn.Kind   = ButtonPredefines.Ellipsis;
            ellBtn.IsLeft = true;

            transitionRepositoryItem.BeginInit();
            transitionRepositoryItem.ButtonClick += transitionRepositoryItem_ButtonClick;

            transitionRepositoryItem.Buttons.AddRange(new[] { ellBtn, deleteBtn });

            transitionRepositoryItem.Name          = "transitionRepositoryItem";
            transitionRepositoryItem.TextEditStyle = TextEditStyles.DisableTextEditor;
            transitionRepositoryItem.EndInit();


            nonTransitionRepositoryItem.BeginInit();
            nonTransitionRepositoryItem.ButtonClick += nonTransitionRepositoryItem_ButtonClick;

            nonTransitionRepositoryItem.Buttons.Add(plusBtn);

            nonTransitionRepositoryItem.Name          = "nonTransitionRepositoryItem";
            nonTransitionRepositoryItem.TextEditStyle = TextEditStyles.DisableTextEditor;
            nonTransitionRepositoryItem.EndInit();
        }
Esempio n. 6
0
 private void DeleteHandler(TransitionRes <StructAtom <string>, StructAtom <string> > transitionRes, GridEditorButton button)
 {
     if (transitionRes.RemoveFromTransition())
     {
         UpdateGrid();
     }
 }
Esempio n. 7
0
        private void EllHandler(TransitionRes <StructAtom <string>, StructAtom <string> > transitionRes, GridEditorButton button)
        {
            frmTransitionEdit frm = new frmTransitionEdit();

            frm.DataChanged += frm_DataChanged;
            frm.Show(transitionRes.Transition);
        }