Example #1
0
 /// <summary>
 /// Adds a new command to check for
 /// </summary>
 /// <param name="buttonName">Name of the button associated with the command</param>
 /// <param name="btnEvent">Event to check for</param>
 public void CreateCommand(string buttonName, ButtonEventType btnEvent)
 {
     Button btn = Owner.GetButton(buttonName);
     ButtonCommand command = new ButtonCommand(btn, btnEvent);
     _commands.Add(command);
 }
Example #2
0
        /// <summary>
        /// 保存市别
        /// <para>默认表示保存新增,1表示保存修改,3表示点击继续按钮</para>
        /// </summary>
        /// <param name="type"></param>
        private void SaveMarketType(ButtonEventType type)
        {
            if (type.Equals(ButtonEventType.DEFAULT))  //3
            {
                if (CommonUtil.IsNullOrEmpty(MarketTypeBean.Name))
                {
                    LoaderAddBaseData();
                    return;
                }
            }
            if (CommonUtil.IsNullOrEmpty(MarketTypeBean.Name))
            {
                MessageBox.Show("市别名称不能为空字符!");
                return;
            }
            if (CommonUtil.IsNullOrEmpty(MarketTypeBean.ShowStartTime))
            {
                MessageBox.Show("开始时间不能为空字符!");
                return;
            }
            if (!CommonUtil.IsCorrectFormatTime(MarketTypeBean.ShowStartTime))
            {
                MessageBox.Show("开始时间格式不正确,请核实!");
                return;
            }
            if (type.Equals(ButtonEventType.DEFAULT)) //3
            {
                CheckedTextChanged();                 //数据有变动
                return;
            }

            MarketType temp = null;
            MarketType mt   = MarketTypeBean.CreateMarketType(MarketTypeBean);

            switch (type)
            {
            default:
                //新增
                if (type.Equals(ButtonEventType.DEFAULT))
                {
                    if (string.IsNullOrEmpty(mt.Name))
                    {
                        return;
                    }
                }
                MarketTypeBean.StartTime = DateTime.Today;
                temp = _DataService.AddMarketType(mt);
                break;

            case ButtonEventType.UPDATE:
                //修改
                mt.UpdateDatetime = DateTime.Now;
                temp = _DataService.UpdateMarketType(mt);
                break;
            }
            if (temp != null)
            {
                MarketTypeSetView.IsTextBoxTextChanged = false;
                MessageBox.Show("保存成功");
                InitMarketTypeData();
            }
            else
            {
                MessageBox.Show("由于系统原因保存失败");
            }
        }
 public override void AddListener(ControllerButton button, RoleValueEventListener listener, ButtonEventType type = ButtonEventType.Click)
 {
     if (typeListeners == null)
     {
         typeListeners = new RoleValueEventListener[CONTROLLER_BUTTON_COUNT][];
     }
     if (typeListeners[(int)button] == null)
     {
         typeListeners[(int)button] = new RoleValueEventListener[BUTTON_EVENT_COUNT];
     }
     if (typeListeners[(int)button][(int)type] == null)
     {
         typeListeners[(int)button][(int)type] = listener;
     }
     else
     {
         typeListeners[(int)button][(int)type] += listener;
     }
 }
 public virtual void RemoveListener(ControllerButton button, Action listener, ButtonEventType type = ButtonEventType.Click)
 {
 }
 public static IDisposable BindAction <TElement>(this IReactive <UIButton> reactive,
                                                 RxAction <Unit, TElement> action, ButtonEventType eventType = ButtonEventType.Tap) =>
 reactive.BindAction(action, _ => Unit.Default, eventType);
 public override void AddListener(ControllerButton button, Action listener, ButtonEventType type = ButtonEventType.Click)
 {
     if (listeners == null)
     {
         listeners = new Action[CONTROLLER_BUTTON_COUNT][];
     }
     if (listeners[(int)button] == null)
     {
         listeners[(int)button] = new Action[BUTTON_EVENT_COUNT];
     }
     if (listeners[(int)button][(int)type] == null)
     {
         listeners[(int)button][(int)type] = listener;
     }
     else
     {
         listeners[(int)button][(int)type] += listener;
     }
 }
Example #7
0
 /// <typeparam name="TRole">
 /// Can be DeviceRole, TrackerRole or any other enum type that have ViveRoleEnumAttribute.
 /// Use ViveRole.ValidateViveRoleEnum() to validate role type
 /// </typeparam>
 /// <param name="role">
 /// TRole can be DeviceRole, TrackerRole or any other enum type that have ViveRoleEnumAttribute.
 /// Use ViveRole.ValidateViveRoleEnum() to validate role type
 /// </param>
 public static void AddListenerEx <TRole>(TRole role, ControllerButton button, ButtonEventType eventType, RoleValueEventListener callback)
 {
     GetState(role).AddListener(button, callback, eventType);
 }
 public static IDisposable BindAction(this IReactive <UIButton> reactive, UIAction action,
                                      ButtonEventType eventType = ButtonEventType.Tap) =>
 reactive.BindAction(action, _ => Unit.Default, eventType);
Example #9
0
 public static void AddListener(ViveRoleProperty role, ControllerButton button, ButtonEventType eventType, Action callback)
 {
     AddListenerEx(role.roleType, role.roleValue, button, eventType, callback);
 }
Example #10
0
 public static void RemoveListener(ViveRoleProperty role, ControllerButton button, ButtonEventType eventType, RoleValueEventListener callback)
 {
     RemoveListenerEx(role.roleType, role.roleValue, button, eventType, callback);
 }
 /// <summary>
 /// 保存市别
 /// <para>默认表示保存新增,1表示保存修改,3表示点击继续按钮</para>
 /// </summary>
 /// <param name="type"></param>
 private void SaveMarketType(ButtonEventType type)
 {
     if (type.Equals(ButtonEventType.DEFAULT))  //3
     {
         if (CommonUtil.IsNullOrEmpty(MarketTypeBean.Name))
         {
             LoaderAddBaseData();
             return;
         }
         
     }
     if (CommonUtil.IsNullOrEmpty(MarketTypeBean.Name))
     {
         MessageBox.Show("市别名称不能为空字符!");
         return;
     }
     if (CommonUtil.IsNullOrEmpty(MarketTypeBean.ShowStartTime))
     {
         MessageBox.Show("开始时间不能为空字符!");
         return;
     }
     if (!CommonUtil.IsCorrectFormatTime(MarketTypeBean.ShowStartTime))
     {
         MessageBox.Show("开始时间格式不正确,请核实!");
         return;
     }
     if (type.Equals(ButtonEventType.DEFAULT))  //3
     {
         CheckedTextChanged();  //数据有变动
         return;
     }
     
     MarketType temp=null;
     MarketType mt=MarketTypeBean.CreateMarketType(MarketTypeBean);
     
     switch (type)
     {
         default:
             //新增
             if (type.Equals( ButtonEventType.DEFAULT))
             {
                 if (string.IsNullOrEmpty(mt.Name))
                 {
                     return;
                 }
             }
             MarketTypeBean.StartTime = DateTime.Today;
             temp=_DataService.AddMarketType(mt);
             break;
         case ButtonEventType.UPDATE:
             //修改
             mt.UpdateDatetime = DateTime.Now;
             temp = _DataService.UpdateMarketType(mt);
             break;
     }
     if (temp != null)
     {
         MarketTypeSetView.IsTextBoxTextChanged = false;
         MessageBox.Show("保存成功");
         InitMarketTypeData();
     }
     else
     {
         MessageBox.Show("由于系统原因保存失败");
     }
 }
Example #12
0
 public ButtonEventArgs(V3dKey key, ButtonEventType type)
 {
     this.Key  = key;
     this.Type = type;
 }
        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);

            // 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));
        }
 public override void RemoveListener(ControllerButton button, RoleValueEventListener listener, ButtonEventType type = ButtonEventType.Click)
 {
     m_state.RemoveListener(button, listener, type);
 }
Example #15
0
 /// <typeparam name="TRole">
 /// Can be DeviceRole, TrackerRole or any other enum type that have ViveRoleEnumAttribute.
 /// Use ViveRole.ValidateViveRoleEnum() to validate role type
 /// </typeparam>
 /// <param name="role">
 /// TRole can be DeviceRole, TrackerRole or any other enum type that have ViveRoleEnumAttribute.
 /// Use ViveRole.ValidateViveRoleEnum() to validate role type
 /// </param>
 public static void RemoveListenerEx <TRole>(TRole role, ControllerButton button, ButtonEventType eventType, RoleEventListener <TRole> callback)
 {
     GetState(role).RemoveListener(button, callback, eventType);
 }
Example #16
0
        public static IDisposable BindAction <T>(this IReactive <View> reactive, OutputAction <T> action, ButtonEventType eventType = ButtonEventType.Tap)
        {
            IObservable <Unit> eventObservable = Observable.Empty <Unit>();

            switch (eventType)
            {
            case ButtonEventType.Tap:
                eventObservable = reactive.Base.Rx().Tap();
                break;

            case ButtonEventType.LongPress:
                eventObservable = reactive.Base.Rx().LongPress();
                break;
            }

            return(Observable.Using(
                       () => action.Enabled.Subscribe(e => { reactive.Base.Enabled = e; }),
                       _ => eventObservable
                       )
                   .Subscribe(action.Inputs));
        }
Example #17
0
 /// <param name="roleType">
 /// Can be DeviceRole, TrackerRole or any other enum type that have ViveRoleEnumAttribute.
 /// Use ViveRole.ValidateViveRoleEnum() to validate role type
 /// </param>
 public static void AddListenerEx(Type roleType, int roleValue, ControllerButton button, ButtonEventType eventType, Action callback)
 {
     GetState(roleType, roleValue).AddListener(button, callback, eventType);
 }
 public static IDisposable BindAction <TInput>(this IReactive <UIButton> reactive, InputAction <TInput> action,
                                               Func <UIButton, TInput> inputTransform, ButtonEventType eventType = ButtonEventType.Tap) =>
 reactive.BindAction <TInput, Unit>(action, inputTransform, eventType);
Example #19
0
 /// <param name="roleType">
 /// Can be DeviceRole, TrackerRole or any other enum type that have ViveRoleEnumAttribute.
 /// Use ViveRole.ValidateViveRoleEnum() to validate role type
 /// </param>
 public static void RemoveListenerEx(Type roleType, int roleValue, ControllerButton button, ButtonEventType eventType, RoleValueEventListener callback)
 {
     GetState(roleType, roleValue).RemoveListener(button, callback, eventType);
 }
        public static IDisposable BindAction <TInput, TElement>(this IReactive <UIButton> reactive,
                                                                RxAction <TInput, TElement> action, Func <UIButton, TInput> inputTransform, ButtonEventType eventType = ButtonEventType.Tap, bool useFeedback = false)
        {
            IObservable <Unit> eventObservable = Observable.Empty <Unit>();

            switch (eventType)
            {
            case ButtonEventType.Tap:
                eventObservable = reactive.Base.Rx().Tap();
                break;

            case ButtonEventType.LongPress:
                eventObservable = reactive.Base.Rx().LongPress(useFeedback);
                break;
            }

            return(Observable.Using(
                       () => action.Enabled.Subscribe(e => { reactive.Base.Enabled = e; }),
                       _ => eventObservable
                       )
                   .Select(_ => inputTransform(reactive.Base))
                   .Subscribe(action.Inputs));
        }
Example #21
0
File: IButton.cs Project: uxav/lib2
 internal ButtonEventArgs(ButtonEventType eventType, TimeSpan timeSincePress)
 {
     EventType = eventType;
     HoldTime  = timeSincePress;
 }
Example #22
0
 public override void RemoveListener(ControllerButton button, Action listener, ButtonEventType type = ButtonEventType.Click)
 {
     if (listeners == null)
     {
         return;
     }
     if (listeners[(int)button] == null)
     {
         return;
     }
     if (listeners[(int)button][(int)type] == null)
     {
         return;
     }
     listeners[(int)button][(int)type] -= listener;
 }
 public virtual void AddListener(ControllerButton button, RoleEventListener <TRole> listener, ButtonEventType type = ButtonEventType.Click)
 {
 }
Example #24
0
 public override void RemoveListener(ControllerButton button, RoleValueEventListener listener, ButtonEventType type = ButtonEventType.Click)
 {
     if (typeListeners == null)
     {
         return;
     }
     if (typeListeners[(int)button] == null)
     {
         return;
     }
     if (typeListeners[(int)button][(int)type] == null)
     {
         return;
     }
     typeListeners[(int)button][(int)type] -= listener;
 }
 protected virtual void TryInvokeListener(ControllerButton button, ButtonEventType type)
 {
 }
Example #26
0
 public virtual void RemoveListener(ControllerButton button, RoleValueEventListener listener, ButtonEventType type = ButtonEventType.Click)
 {
 }
 public override void AddListener(ControllerButton button, Action listener, ButtonEventType type = ButtonEventType.Click)
 {
     m_state.AddListener(button, listener, type);
 }
        /// <summary>
        /// 0代表是新增做法类型 1表示修改做法类型
        /// </summary>
        /// <param name="type"></param>
        private void OpenDishesWin(ButtonEventType type)
        {
            DishesWaySettingXaml = new DishesWaySettingWindow();
            switch (type)
            {
                case ButtonEventType.ADD:
                    if (SelectedTreeNode == null)
                    {
                        MessageBox.Show("请选择做法类型!");
                        return;
                    }
                    InitAddData();

                    DishesWaySettingXaml.AddDescription.Visibility = Visibility.Visible;
                    DishesWaySettingXaml.Continue.Visibility = Visibility.Visible;
                    DishesWaySettingXaml.UpdateRecord.Visibility = Visibility.Hidden;
                    break;
                case ButtonEventType.UPDATE:
                    if (DishesWaySelectedItem == null)
                    {
                        MessageBox.Show("请选择要修改的做法!");
                        return;
                    }

                    DishesWayBean = new DishesWayBean();
                    DishesWayBean.IsReadOnlyCode = true;
                    DishesWaySelectedItem.UpdateBy = SubjectUtils.GetAuthenticationId();
                    DishesWaySelectedItem.UpdateDatetime = DateTime.Now;
                    DishesWayBean.CreateDishesWayBean(DishesWaySelectedItem);
                    DishesWayBean.CurrentScaleText = (DishesWayTableItems.IndexOf(DishesWaySelectedItem) + 1) + "/" + DishesWayTableItems.Count;
                    DishesWaySettingXaml.AddDescription.Visibility = Visibility.Hidden;
                    DishesWaySettingXaml.Continue.Visibility = Visibility.Hidden;
                    DishesWaySettingXaml.UpdateRecord.Visibility = Visibility.Visible;
                    break;
            }
            DishesWaySettingXaml.ShowDialog();
        }
Example #29
0
 /// <summary>
 /// Constructor of ButtonCommand class
 /// </summary>
 /// <param name="btn">Button instance</param>
 /// <param name="btnEvent">Type of event</param>
 internal ButtonCommand(Button btn, ButtonEventType btnEvent)
 {
     _button = btn;
     _buttonEvent = btnEvent;
     AssignCheckMethod();
 }