/// <summary> /// Safely clears action of non-null sig. /// </summary> public static void ClearBoolOutAction(BoolOutputSig sig) { if (sig != null) { sig.UserObject = null; } }
public UIButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin, BoolInputSig enableDigitalJoin, BoolInputSig visibleDigitalJoin) : this(pressDigitalJoin, feedbackDigitalJoin) { this.EnableDigitalJoin = enableDigitalJoin; this.VisibleDigitalJoin = visibleDigitalJoin; }
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(); }
/// <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; } }
/// <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(); } })); }
/// <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(); } }); }
/// <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(); } }); }
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); } }
/// <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); } }
/// <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; }
/// <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(); } } })); }
public void OverridePressDigitalJoinNumber(BoolOutputSig digitalJoinSig) { this.PressDigitalJoin = digitalJoinSig; }
public static void DetachSigEventHandler(this BoolOutputSig cue, UnifiedSigEventHandler handler) { cue.DetachSigEventHandler(handler, eSigEvent.BoolChange); }
public UIButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin) : this(pressDigitalJoin) { this.FeedbackDigitalJoin = feedbackDigitalJoin; }
public UIButton(BoolOutputSig pressDigitalJoin, BoolInputSig feedbackDigitalJoin, StringInputSig textSerialJoin) : this(pressDigitalJoin, feedbackDigitalJoin) { this.TextSerialJoin = textSerialJoin; }
/// <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); }
public void SetTransitionCompleteJoin(BoolOutputSig transitionCompleteDigitalJoin) { TransitionCompleteDigitalJoin = transitionCompleteDigitalJoin; }
public UIActionSheetButton(BoolOutputSig digitalPressJoin, BoolInputSig digitalFeedbackJoin, StringInputSig serialJoinSig, ActionSheetButtonAction action) : base(digitalPressJoin, digitalFeedbackJoin, serialJoinSig) { this.Action = action; }
public UIButton(BoolOutputSig pressDigitalJoin) { this.PressDigitalJoin = pressDigitalJoin; }