Ejemplo n.º 1
0
 public void ButtonEvent(ButtonEnum button, ButtonActionType buttonActionType)
 {
     _logger.Log("Click");
     //    var color = _gfx.GetPixel(x, y);
     //    _gfx.SetPixel(x, y, color == ScreenColor.Black ? ScreenColor.White : ScreenColor.Black);
     _gfx.Draw();
 }
Ejemplo n.º 2
0
        private bool SaveDepot()
        {
            try
            {
                if (_buttonAction == ButtonActionType.Add &&
                    IsExistDepot(txtDepotId.EditValue.ToString()))
                {
                    XtraMessageBox.Show(Cons.ErrorDuplicateDeportId, Cons.CaptionWarning,
                                        MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    txtDepotId.Focus();
                    txtDepotId.SelectAll();
                    return(false);
                }

                bdsDepot.EndEdit();
                this.taDepot.Update(this.dataSet.Kho);
                gbDepot.Enabled = false;
                bdsDepot.ResetCurrentItem();
                DisableEditMode();
                if (_buttonAction == ButtonActionType.Add)
                {
                    // Lưu vô stack trạng thái nút nhấn và data bị thay đổi
                    _userDo.Push(new ButtonAction(_buttonAction, ((DataRowView)bdsDepot[bdsDepot.Position]).Row.ItemArray));
                }
                _buttonAction     = ButtonActionType.None;
                bdsDepot.Position = _currentPosition;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 3
0
        private void btnEdit_ItemClick(object sender, ItemClickEventArgs e)
        {
            _buttonAction    = ButtonActionType.Edit;
            _currentPosition = bdsVT.Position;
            var row = ((DataRowView)bdsVT[_currentPosition]).Row.ItemArray;

            _userDo.Push(new ButtonAction(_buttonAction, row));
            EnableEditMode();
        }
Ejemplo n.º 4
0
        private void btnAdd_ItemClick(object sender, ItemClickEventArgs e)
        {
            _buttonAction    = ButtonActionType.Add;
            _currentPosition = bdsVT.Position;

            bdsVT.AddNew();
            EnableEditMode();

            txtMaterialId.Focus();
        }
Ejemplo n.º 5
0
        private void btnAdd_ItemClick(object sender, ItemClickEventArgs e)
        {
            _currentPosition = bdsDepot.Position;
            _buttonAction    = ButtonActionType.Add;

            bdsDepot.AddNew();
            txtEmpDepartment.EditValue = _currentDeploymentId;

            EnableEditMode();
            txtDepotId.Focus();
        }
Ejemplo n.º 6
0
        private void frmMaterials_Load(object sender, EventArgs e)
        {
            _buttonAction        = ButtonActionType.None;
            _userDo              = new MyStack();
            _userDo.StackPushed += userDo_StackPushed;
            _userDo.StackPopped += userDo_StackPopped;

            LoadTable();
            DisableEditMode();

            cboDVT.DataSource = GetDanhSachDVT();
        }
Ejemplo n.º 7
0
        private void EditDepot()
        {
            // lưu lại trạng thái nút ấn
            _currentPosition = bdsDepot.Position;
            _buttonAction    = ButtonActionType.Edit;

            // lưu lại data để undo
            var row = ((DataRowView)bdsDepot[_currentPosition]).Row.ItemArray;

            _userDo.Push(new ButtonAction(_buttonAction, row));

            EnableEditMode();
        }
        public static ElementStyle ToElementStyle(this ButtonActionType t)
        {
            switch (t)
            {
            case ButtonActionType.Create: return(ElementStyle.Primary);

            case ButtonActionType.Edit: return(ElementStyle.Primary);

            case ButtonActionType.Delete: return(ElementStyle.Danger);
            }

            return(ElementStyle.Primary);
        }
        public static string ToIconClass(this ButtonActionType t)
        {
            switch (t)
            {
            case ButtonActionType.Create: return("plus");

            case ButtonActionType.Edit: return("pencil");

            case ButtonActionType.Delete: return("trash");
            }

            return("");
        }
Ejemplo n.º 10
0
        private void frmDepot_Load(object sender, EventArgs e)
        {
            _buttonAction        = ButtonActionType.None;
            _userDo              = new MyStack();
            _userDo.StackPushed += userDo_StackPushed;
            _userDo.StackPopped += userDo_StackPopped;

            LoadTable();
            DisableEditMode();

            _currentDeploymentId = ((DataRowView)bdsDepot[0])["MACN"].ToString().Trim();

            // Quyền công ty => enable combobox chi nhánh
            ShowControlsByGroup(UtilDB.CurrentGroup);
        }
Ejemplo n.º 11
0
        private void btnCancelEdit_ItemClick(object sender, ItemClickEventArgs e)
        {
            dxErrorProvider.ClearErrors();

            try
            {
                gbDepot.Enabled = false;
                bdsDepot.CancelEdit();
                bdsDepot.ResetCurrentItem();
                bdsDepot.Position = _currentPosition;
                if (_buttonAction == ButtonActionType.Edit)
                {
                    _userDo.Pop();
                }
                _buttonAction = ButtonActionType.None;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
            }
            DisableEditMode();
        }
Ejemplo n.º 12
0
        private bool SaveEmployee()
        {
            if (_buttonAction == ButtonActionType.Add)
            {
                txtEmpId.EditValue = UtilDB.GenerateEmployeeId();
            }

            TrimAll();

            if (!IsValidEmptyValue())
            {
                (dxErrorProvider.GetControlsWithError()[0] as BaseEdit).SelectAll();
                return(false);
            }
            if (!IsValidCustom())
            {
                (dxErrorProvider.GetControlsWithError()[0] as BaseEdit).SelectAll();
                return(false);
            }

            try
            {
                EndEdit();
                if (_buttonAction == ButtonActionType.Add)
                {
                    // Lưu vô stack trạng thái nút nhấn và data bị mới
                    _userDo.Push(new ButtonAction(_buttonAction, ((DataRowView)bdsNV[bdsNV.Position]).Row.ItemArray));
                }
                _buttonAction  = ButtonActionType.None;
                bdsNV.Position = _currentPosition;
            }
            catch (Exception ex)
            {
                UtilDB.ShowError(ex);
                return(false);
            }
            return(true);
        }
Ejemplo n.º 13
0
 public ButtonAction(ButtonActionType actionType, object[] saveItems)
 {
     this.ActionType = actionType;
     this.SaveItems  = saveItems;
 }
Ejemplo n.º 14
0
        public IEnumerator TestButtonActionsDuringEvents(
            [Values(ButtonEventType.OnPress,
                    ButtonEventType.OnUnpress)] ButtonEventType buttonEventType,
            [Values(ButtonActionType.DisableIt,
                    ButtonActionType.DestroyIt)] ButtonActionType buttonActionType
            )
        {
            yield return(wait(beginningTestWait));

            InitTest(PRESS_BUTTON_RIG, DEFAULT_STAGE);
            recording.Stop(); // Don't play the recording until we're ready!

            // Wait before starting the test.
            yield return(wait(aWhile));

            // Play the button-pressing animation.
            recording.Play();

            // Create the test action to perform when the event is fired.
            System.Action buttonAction;
            switch (buttonActionType)
            {
            case ButtonActionType.DestroyIt:
                buttonAction = () => { GameObject.Destroy(button); }; break;

            case ButtonActionType.DisableIt:
                buttonAction = () => { button.gameObject.SetActive(false); }; break;

            default:
                throw new System.NotImplementedException("This action is not implemented.");
            }

            // Schedule the test action when the specified button event fires.
            bool eventFired = false;

            System.Action doOnEvent = () => {
                eventFired = true;

                buttonAction();
            };
            switch (buttonEventType)
            {
            case ButtonEventType.OnPress:
                button.OnPress += doOnEvent; break;

            case ButtonEventType.OnUnpress:
                button.OnUnpress += doOnEvent; break;

            default:
                throw new System.NotImplementedException("This button event is not implemented.");
            }

            // Wait until the button is pressed.
            int framesWaited = 0;

            while (!eventFired && framesWaited < WAIT_FOR_INTERACTION_FRAME_LIMIT)
            {
                yield return(null);

                framesWaited++;
            }
            Assert.That(framesWaited != WAIT_FOR_INTERACTION_FRAME_LIMIT,
                        "Test recording failed to press the button (fire the event).");

            // If the button was disabled or destroyed, the primary hover lock should not
            // be engaged.
            if (buttonActionType == ButtonActionType.DestroyIt ||
                buttonActionType == ButtonActionType.DisableIt)
            {
                Assert.That(rightHand.primaryHoverLocked == false,
                            "Primary hover lock was active even after the button was disabled "
                            + "or destroyed.");
            }

            yield return(wait(endingTestWait));
        }
Ejemplo n.º 15
0
 public static extern int OnButtonAction(ButtonAction action, ButtonActionType mode = ButtonActionType.DownAndUp);