Esempio n. 1
0
 /// <summary>
 /// Safely clears action of non-null sig.
 /// </summary>
 public static void ClearBoolOutAction(BoolOutputSig sig)
 {
     if (sig != null)
     {
         sig.UserObject = null;
     }
 }
Esempio n. 2
0
 public UIButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin,
                 BoolInputSig enableDigitalJoin, BoolInputSig visibleDigitalJoin)
     : this(pressDigitalJoin, feedbackDigitalJoin)
 {
     this.EnableDigitalJoin  = enableDigitalJoin;
     this.VisibleDigitalJoin = visibleDigitalJoin;
 }
Esempio n. 3
0
 public UITextField(BoolOutputSig hasFocusJoin, BoolInputSig setFocusJoinOn, BoolInputSig setFocusJoinOff,
                    BoolInputSig enableJoin, BoolInputSig visibleJoin, StringInputSig textJoinToDevice,
                    StringOutputSig textJoinFromDevice, UILabel titleLabel, UIButton enterButton, UIButton escButton, UIButton clearButton)
 {
     HasFocusJoin    = hasFocusJoin;
     SetFocusJoinOn  = setFocusJoinOn;
     SetFocusJoinOff = setFocusJoinOff;
     EnableJoin      = enableJoin;
     if (EnableJoin != null)
     {
         EnableJoin.BoolValue = true;
     }
     VisibleJoin = visibleJoin;
     if (VisibleJoin != null)
     {
         VisibleJoin.BoolValue = true;
     }
     TextJoinToDevice             = textJoinToDevice;
     TextJoinToDevice.StringValue = "";
     TextJoinFromDevice           = textJoinFromDevice;
     Device                 = hasFocusJoin.Owner as BasicTriList;
     TitleLabel             = titleLabel;
     this.EnterButton       = enterButton;
     this.EnterButton.Title = "Enter";
     this.EscButton         = escButton;
     this.EscButton.Title   = "Escape";
     this.ClearButton       = clearButton;
     this.ClearButton.Enable();
 }
Esempio n. 4
0
 /// <summary>
 /// Safely sets an action to non-null sig
 /// </summary>
 public static void SetBoolOutAction(BoolOutputSig sig, Action <bool> a)
 {
     if (sig != null)
     {
         sig.UserObject = a;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Attaches a void Action to an output sig's UserObject, to be run on release
 /// </summary>
 /// <returns>The Sig</returns>
 public static BoolOutputSig SetSigFalseAction(this BoolOutputSig sig, Action a)
 {
     return(sig.SetBoolSigAction(b => { if (!b)
                                        {
                                            a();
                                        }
                                 }));
 }
Esempio n. 6
0
 /// <summary>
 /// Set Press action
 /// </summary>
 /// <param name="sig">The BoolOutputSig to attach the Action to</param>
 /// <param name="pressAction">Action when button pressed</param>
 public static void Press(this BoolOutputSig sig, Action pressAction)
 {
     sig.UserObject = new Action <bool>(x => { if (x)
                                               {
                                                   pressAction();
                                               }
                                        });
 }
Esempio n. 7
0
 /// <summary>
 /// Set Release action
 /// </summary>
 /// <param name="sig">The BoolOutputSig to attach the Action to</param>
 /// <param name="releaseAction">Action when button released</param>
 public static void Release(this BoolOutputSig sig, Action releaseAction)
 {
     sig.UserObject = new Action <bool>(x => { if (!x)
                                               {
                                                   releaseAction();
                                               }
                                        });
 }
Esempio n. 8
0
        public UIKeypad(BoolOutputSig digitalStartJoin)
        {
            this.Buttons = new UIButtonCollection();

            for (uint join = digitalStartJoin.Number; join <= digitalStartJoin.Number + 11; join++)
            {
                UIButton newButton = new UIButton(((BasicTriList)digitalStartJoin.Owner).BooleanOutput[join]);
                this.Buttons.Add(newButton);
            }
        }
Esempio n. 9
0
 /// <summary>
 /// Set Release action
 /// </summary>
 /// <param name="sig">The BoolOutputSig to attach the Action to</param>
 /// <param name="pressAction">Action when button is pressed</param>
 /// <param name="pressAction">Action when button is released</param>
 public static void PressRelease(this BoolOutputSig sig, Action pressAction, Action releaseAction)
 {
     sig.UserObject = new Action <bool>(x => { if (x)
                                               {
                                                   pressAction();
                                               }
                                               else
                                               {
                                                   releaseAction();
                                               } });
 }
 public SoundWebChannelUIMuteButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin, SoundWebChannel channel)
     : base(pressDigitalJoin, feedbackDigitalJoin)
 {
     this.Channel              = channel;
     this.Channel.ChangeEvent += new SoundWebChannelEventHandler(Channel_ChangeEvent);
     this.Channel.Owner.Device.Socket.SocketConnectionEvent += new UXLib.Sockets.SimpleClientSocketConnectionEventHandler(Socket_SocketConnectionEvent);
     if (this.Channel.Owner.Device.Socket.Connected)
     {
         Channel.Subscribe(SoundWebChannelParamType.Mute);
     }
 }
Esempio n. 11
0
        /// <summary>
        /// Sets an action to press and release, press and hold and press and relase after hold
        /// Code taken from PaperDash Essentialc Core, little refactored for my own clarity
        /// </summary>
        /// <param name="sig">The BoolOutputSig to attach the Action to</param>
        /// <param name="pressTime">time in milliseconds to react on press and hold events</param>
        /// <param name="pressAction">Action when button was pressed and released before press and hold timer expired</param>
        /// <param name="holdAction">Action when button pressed, timer expired but not yet released.</param>
        /// <param name="holdAction">Action when button pressed and released after hold time.</param>
        /// <returns>BoolOutputSig, so it can be chained</returns>
        public static void PressHoldRelease(this BoolOutputSig sig, uint pressTime, Action pressAction, Action holdAction, Action holdReleasedAction)
        {
            CTimer holdTimer = null;
            bool   holdFlag  = false; // when true indicates press and hold time passed

            Action <bool> action = (press =>
            {
                if (press)
                {
                    holdFlag = false;
                    holdTimer = new CTimer(o =>
                    {
                        // if still held and there's an action
                        if (sig.BoolValue && holdAction != null)
                        {
                            holdFlag = true;
                            holdAction();
                        }
                    }, pressTime);
                }
                else if (!press && !holdFlag) // released, no hold, i.e. press and release before timer expires
                {
                    holdTimer.Stop();
                    if (pressAction != null)
                    {
                        pressAction();
                    }
                }
                else // !press && holdFlag // released after held
                {
                    holdTimer.Stop();
                    if (holdReleasedAction != null)
                    {
                        holdReleasedAction();
                    }
                }
            });

            sig.UserObject = action;
            //return sig;
        }
Esempio n. 12
0
        /// <summary>
        /// Sets an action to a held sig as well as a released-without-hold action
        /// </summary>
        /// <returns></returns>
        public static BoolOutputSig SetSigHeldAction(this BoolOutputSig sig, uint heldMs, Action heldAction, Action holdReleasedAction, Action releaseAction)
        {
            CTimer heldTimer = null;
            bool   wasHeld   = false;

            return(sig.SetBoolSigAction(press =>
            {
                if (press)
                {
                    wasHeld = false;
                    // Could insert a pressed action here
                    heldTimer = new CTimer(o =>
                    {
                        // if still held and there's an action
                        if (sig.BoolValue && heldAction != null)
                        {
                            wasHeld = true;
                            // Hold action here
                            heldAction();
                        }
                    }, heldMs);
                }
                else if (!press && !wasHeld)                 // released, no hold
                {
                    heldTimer.Stop();
                    if (releaseAction != null)
                    {
                        releaseAction();
                    }
                }
                else                 // !press && wasHeld // released after held
                {
                    heldTimer.Stop();
                    if (holdReleasedAction != null)
                    {
                        holdReleasedAction();
                    }
                }
            }));
        }
Esempio n. 13
0
 public void OverridePressDigitalJoinNumber(BoolOutputSig digitalJoinSig)
 {
     this.PressDigitalJoin = digitalJoinSig;
 }
 public static void DetachSigEventHandler(this BoolOutputSig cue, UnifiedSigEventHandler handler)
 {
     cue.DetachSigEventHandler(handler, eSigEvent.BoolChange);
 }
Esempio n. 15
0
 public UIButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin)
     : this(pressDigitalJoin)
 {
     this.FeedbackDigitalJoin = feedbackDigitalJoin;
 }
Esempio n. 16
0
 public UIButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin,
                 StringInputSig textSerialJoin)
     : this(pressDigitalJoin, feedbackDigitalJoin)
 {
     this.TextSerialJoin = textSerialJoin;
 }
Esempio n. 17
0
 /// <summary>
 /// Attaches Action to Sig's user object and returns the same Sig. This provides no protection
 /// from null sigs
 /// </summary>
 /// <param name="sig">The BoolOutputSig to attach the Action to</param>
 /// <param name="a">An action to run when sig is pressed and when released</param>
 /// <returns>The Sig, sig</returns>
 public static BoolOutputSig SetBoolSigAction(this BoolOutputSig sig, Action <bool> a)
 {
     sig.UserObject = a;
     return(sig);
 }
Esempio n. 18
0
 public void SetTransitionCompleteJoin(BoolOutputSig transitionCompleteDigitalJoin)
 {
     TransitionCompleteDigitalJoin = transitionCompleteDigitalJoin;
 }
Esempio n. 19
0
 public UIActionSheetButton(BoolOutputSig digitalPressJoin,
                            BoolInputSig digitalFeedbackJoin, StringInputSig serialJoinSig, ActionSheetButtonAction action)
     : base(digitalPressJoin, digitalFeedbackJoin, serialJoinSig)
 {
     this.Action = action;
 }
Esempio n. 20
0
 public UIButton(BoolOutputSig pressDigitalJoin)
 {
     this.PressDigitalJoin = pressDigitalJoin;
 }