コード例 #1
0
ファイル: SigHelper.cs プロジェクト: xielong87/Essentials
 /// <summary>
 /// Safely clears action of non-null sig.
 /// </summary>
 public static void ClearBoolOutAction(BoolOutputSig sig)
 {
     if (sig != null)
     {
         sig.UserObject = null;
     }
 }
コード例 #2
0
 public UIButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin,
                 BoolInputSig enableDigitalJoin, BoolInputSig visibleDigitalJoin)
     : this(pressDigitalJoin, feedbackDigitalJoin)
 {
     this.EnableDigitalJoin  = enableDigitalJoin;
     this.VisibleDigitalJoin = visibleDigitalJoin;
 }
コード例 #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();
 }
コード例 #4
0
ファイル: SigHelper.cs プロジェクト: xielong87/Essentials
 /// <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;
     }
 }
コード例 #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();
                                        }
                                 }));
 }
コード例 #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();
                                               }
                                        });
 }
コード例 #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();
                                               }
                                        });
 }
コード例 #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);
            }
        }
コード例 #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();
                                               } });
 }
コード例 #10
0
 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);
     }
 }
コード例 #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;
        }
コード例 #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();
                    }
                }
            }));
        }
コード例 #13
0
 public void OverridePressDigitalJoinNumber(BoolOutputSig digitalJoinSig)
 {
     this.PressDigitalJoin = digitalJoinSig;
 }
コード例 #14
0
 public static void DetachSigEventHandler(this BoolOutputSig cue, UnifiedSigEventHandler handler)
 {
     cue.DetachSigEventHandler(handler, eSigEvent.BoolChange);
 }
コード例 #15
0
 public UIButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin)
     : this(pressDigitalJoin)
 {
     this.FeedbackDigitalJoin = feedbackDigitalJoin;
 }
コード例 #16
0
 public UIButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin,
                 StringInputSig textSerialJoin)
     : this(pressDigitalJoin, feedbackDigitalJoin)
 {
     this.TextSerialJoin = textSerialJoin;
 }
コード例 #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);
 }
コード例 #18
0
ファイル: UIViewBase.cs プロジェクト: uxav/UX-Simpl-Sharp
 public void SetTransitionCompleteJoin(BoolOutputSig transitionCompleteDigitalJoin)
 {
     TransitionCompleteDigitalJoin = transitionCompleteDigitalJoin;
 }
コード例 #19
0
 public UIActionSheetButton(BoolOutputSig digitalPressJoin,
                            BoolInputSig digitalFeedbackJoin, StringInputSig serialJoinSig, ActionSheetButtonAction action)
     : base(digitalPressJoin, digitalFeedbackJoin, serialJoinSig)
 {
     this.Action = action;
 }
コード例 #20
0
 public UIButton(BoolOutputSig pressDigitalJoin)
 {
     this.PressDigitalJoin = pressDigitalJoin;
 }