Ejemplo n.º 1
0
        /// <summary>
        /// Empties the action queue and retrieves every actions and their argument.
        /// </summary>
        /// <param name="uiActions">List of the retrieved actions.</param>
        /// <param name="firstParams">List of the first parameter of the actions.</param>
        /// <param name="secondParams">List of the second parameter of the actions.</param>
        public void GetAllActions(out UiActionType[] uiActions, out int[] firstParams, out int[] secondParams)
        {
            uiActions    = null;
            firstParams  = null;
            secondParams = null;

            lock (this.actionFifo)
            {
                if (this.actionFifo.Length == this.param0Fifo.Length && this.actionFifo.Length == this.param1Fifo.Length)
                {
                    uiActions    = new UiActionType[this.actionFifo.Length];
                    firstParams  = new int[this.param0Fifo.Length];
                    secondParams = new int[this.param1Fifo.Length];

                    for (int i = 0; i < uiActions.Length; i++)
                    {
                        uiActions[i]    = this.actionFifo.Get();
                        firstParams[i]  = this.param0Fifo.Get();
                        secondParams[i] = this.param1Fifo.Get();
                    }
                }
                else
                {
                    throw new Exception("Inconsistent state in UiActionQueue!");
                }
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Posts an action to the UiActionQueue. This function can be called from the context of the UI-thread.
 /// </summary>
 /// <param name="uiAction">The action to post.</param>
 /// <param name="param0">The first parameter of the action.</param>
 /// <param name="param1">The second parameter of the action.</param>
 public void PostAction(UiActionType uiAction, int param0, int param1)
 {
     lock (this.actionFifo)
     {
         this.actionFifo.Push(uiAction);
         this.param0Fifo.Push(param0);
         this.param1Fifo.Push(param1);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Subscribe event handlers for WPF controls
        /// </summary>
        /// <param name="actionType"></param>
        /// <param name="eventHandler"></param>
        public void Subscribe(UiActionType actionType, Action <object, RoutedEventArgs> eventHandler)
        {
            switch (actionType)
            {
            case UiActionType.SaveClose:
                _btnSaveCloseEventHandler = (o, ea) => eventHandler(o, ea);
                BtnSaveClose.Click       += _btnSaveCloseEventHandler;
                break;

            case UiActionType.Next:
                _btnNextEventHandler = (o, ea) => eventHandler(o, ea);
                BtnNext.Click       += _btnNextEventHandler;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(actionType), actionType, null);
            }
        }