private void unicastButtonTest(string buttonName, SetButton setButton, PictureBox pictureBox) { if (stopButton.Enabled == false) { return; } try { long ticksEpoch = DateTime.Now.Ticks; for (int i = 0; i < iterationsPerTest && stopButton.Enabled; i++) { setButton(XBoxButtonState.Released); } long ticksNow = DateTime.Now.Ticks; long unicastTime = (ticksNow - ticksEpoch + ticksRoundUp) / ticksPerTest; string entryLog = String.Format("{0:G} : {1} Button : Unicast {2} mS{3}", DateTime.Now, buttonName, unicastTime, Environment.NewLine); diagnosticsTextBox.AppendText(entryLog); SetPictureBoxStatus(pictureBox, unicastTime <= expectedUnicastTime ? PictureBoxStatus.Good : PictureBoxStatus.Bad); } catch { SetPictureBoxStatus(pictureBox, PictureBoxStatus.Bad); } }
public PopupButtonModel(ButtonType buttonType) { SetButton buttonSetter = buttonType switch { ButtonType.Close => SetAsClose, ButtonType.Cancel => SetAsCancel, ButtonType.Save => SetAsSave, ButtonType.SaveAndContinue => SetAsSaveAndContinue, ButtonType.Ok => SetAsOk, ButtonType.Back => SetAsBack, _ => SetAsClose }; buttonSetter?.Invoke(); }
private void roundTripButtonTest(string buttonName, SetButton setButton, GetButton getButton, PictureBox pictureBox) { if (stopButton.Enabled == false) { return; } try { setButton(XBoxButtonState.Released); DateTime timeOut = DateTime.Now.AddMilliseconds(100); while (getButton() == Microsoft.Xna.Framework.Input.ButtonState.Pressed && DateTime.Now < timeOut) { ; } long ticksEpoch = DateTime.Now.Ticks; for (int i = 0; i < iterationsPerTest && stopButton.Enabled; i++) { // Press Key setButton(XBoxButtonState.Pressed); timeOut = DateTime.Now.AddMilliseconds(100); while (getButton() == Microsoft.Xna.Framework.Input.ButtonState.Released && DateTime.Now < timeOut) { ; } // Release Key setButton(XBoxButtonState.Released); timeOut = DateTime.Now.AddMilliseconds(100); while (getButton() == Microsoft.Xna.Framework.Input.ButtonState.Pressed && DateTime.Now < timeOut) { ; } Application.DoEvents(); } long ticksNow = DateTime.Now.Ticks; long roundTripTime = (ticksNow - ticksEpoch + ticksRoundUp) / ticksPerTest; string entryLog = String.Format("{0:G} : {1} Button : Round Trip Time {2} mS{3}", DateTime.Now, buttonName, roundTripTime, Environment.NewLine); diagnosticsTextBox.AppendText(entryLog); SetPictureBoxStatus(pictureBox, roundTripTime <= expectedRoundTripTime ? PictureBoxStatus.Good : PictureBoxStatus.Bad); } catch { SetPictureBoxStatus(pictureBox, PictureBoxStatus.Bad); } }
void ReleaseDesignerOutlets() { if (EventTextField != null) { EventTextField.Dispose(); EventTextField = null; } if (LoginButton != null) { LoginButton.Dispose(); LoginButton = null; } if (ScreenTextField != null) { ScreenTextField.Dispose(); ScreenTextField = null; } if (SetButton != null) { SetButton.Dispose(); SetButton = null; } if (TestButton != null) { TestButton.Dispose(); TestButton = null; } if (TrackButton != null) { TrackButton.Dispose(); TrackButton = null; } if (UserIdTextField != null) { UserIdTextField.Dispose(); UserIdTextField = null; } }
private void SetupControls() { var expandButton = new Button {Text = GetCollapsedButtonString(), LayoutOptions = new[] {GUILayout.Width(30)}}; expandButton.Clicked = () => { _collapsed = !_collapsed; expandButton.Text = GetCollapsedButtonString(); }; var supersampleAmount = new TextField<int> { Value = _settings.SupersampleAmount, Caption = " Supersample: ", Validator = x => x > 0 }; var screenshotButton = new Button { Text = "Screenshot", LayoutOptions = new[] {GUILayout.Width(85)}, Clicked = () => Screenshot() }; _screenshotToggle = new ToggleButton { Caption = "Screenshot", Visible = false, LayoutOptions = new[] {GUILayout.Width(85)}, OnToggled = x => Screenshot() }; var toggleAutoHideUI = new Toggle { Caption = " Autohide UI: ", Value = _settings.AutoHideUI, OnToggled = x => { _settings.AutoHideUI = x; _settings.Save(); } }; var autoIntervalAmount = new TextField<int> { Value = _settings.AutoIntervalDelayInSeconds, Caption = " Interval: ", Validator = x => x > 0 }; var toggleAutoInterval = new Toggle { Caption = " Auto Interval: ", Value = _autoIntervalEnabled, OnToggled = x => { _autoIntervalEnabled = x; screenshotButton.Visible = !x; _screenshotToggle.Visible = x; if (!x) { _screenshotToggle.Value = false; _autoIntervalStopwatch.Reset(); } } }; var setButton = new SetButton { LayoutOptions = new[] {GUILayout.Height(25)}, SettableObjects = new List<ISettable> {supersampleAmount, autoIntervalAmount}, Clicked = () => { _settings.SupersampleAmount = supersampleAmount.Value; _settings.AutoIntervalDelayInSeconds = autoIntervalAmount.Value; _settings.Save(); } }; _expandedControls = new List<AControl> { new BeginVertical(), new BeginHorizontal(), screenshotButton, _screenshotToggle, expandButton, new EndHorizontal(), toggleAutoHideUI, toggleAutoInterval, new BeginVertical(true), supersampleAmount, autoIntervalAmount, setButton, new EndVertical(), new EndVertical() }; _collapsedControls = new List<AControl> { new BeginHorizontal(), screenshotButton, expandButton, new EndHorizontal() }; _expandedLayoutOptions = new[] {GUILayout.Width(180), GUILayout.ExpandHeight(true)}; _collapsedLayoutOptions = new[] {GUILayout.Width(120), GUILayout.Height(60)}; }
private void SetupControls() { var expandButton = new Button { Text = GetCollapsedButtonString(), LayoutOptions = new[] { GUILayout.Width(30) } }; expandButton.Clicked = () => { _collapsed = !_collapsed; expandButton.Text = GetCollapsedButtonString(); }; var supersampleAmount = new TextField <int> { Value = _settings.SupersampleAmount, Caption = " Supersample: ", Validator = x => x > 0 }; var screenshotButton = new Button { Text = "Screenshot", LayoutOptions = new[] { GUILayout.Width(85) }, Clicked = () => Screenshot() }; _screenshotToggle = new ToggleButton { Caption = "Screenshot", Visible = false, LayoutOptions = new[] { GUILayout.Width(85) }, OnToggled = x => Screenshot() }; var toggleAutoHideUI = new Toggle { Caption = " Autohide UI: ", Value = _settings.AutoHideUI, OnToggled = x => { _settings.AutoHideUI = x; _settings.Save(); } }; var autoIntervalAmount = new TextField <int> { Value = _settings.AutoIntervalDelayInSeconds, Caption = " Interval: ", Validator = x => x > 0 }; var toggleAutoInterval = new Toggle { Caption = " Auto Interval: ", Value = _autoIntervalEnabled, OnToggled = x => { _autoIntervalEnabled = x; screenshotButton.Visible = !x; _screenshotToggle.Visible = x; if (!x) { _screenshotToggle.Value = false; _autoIntervalStopwatch.Reset(); } } }; var setButton = new SetButton { LayoutOptions = new[] { GUILayout.Height(25) }, SettableObjects = new List <ISettable> { supersampleAmount, autoIntervalAmount }, Clicked = () => { _settings.SupersampleAmount = supersampleAmount.Value; _settings.AutoIntervalDelayInSeconds = autoIntervalAmount.Value; _settings.Save(); } }; _expandedControls = new List <AControl> { new BeginVertical(), new BeginHorizontal(), screenshotButton, _screenshotToggle, expandButton, new EndHorizontal(), toggleAutoHideUI, toggleAutoInterval, new BeginVertical(true), supersampleAmount, autoIntervalAmount, setButton, new EndVertical(), new EndVertical() }; _collapsedControls = new List <AControl> { new BeginHorizontal(), screenshotButton, expandButton, new EndHorizontal() }; _expandedLayoutOptions = new[] { GUILayout.Width(180), GUILayout.ExpandHeight(true) }; _collapsedLayoutOptions = new[] { GUILayout.Width(120), GUILayout.Height(60) }; }
private void testButton(string buttonName, SetButton setButton, GetButton getButton, PictureBox pictureBox) { roundTripButtonTest(buttonName, setButton, getButton, pictureBox); unicastButtonTest(buttonName, setButton, pictureBox); }
private void unicastButtonTest(string buttonName, SetButton setButton, PictureBox pictureBox) { if (stopButton.Enabled == false) return; try { long ticksEpoch = DateTime.Now.Ticks; for (int i = 0; i < iterationsPerTest && stopButton.Enabled; i++) setButton(XBoxButtonState.Released); long ticksNow = DateTime.Now.Ticks; long unicastTime = (ticksNow - ticksEpoch + ticksRoundUp) / ticksPerTest; string entryLog = String.Format("{0:G} : {1} Button : Unicast {2} mS{3}", DateTime.Now, buttonName, unicastTime, Environment.NewLine); diagnosticsTextBox.AppendText(entryLog); SetPictureBoxStatus(pictureBox, unicastTime <= expectedUnicastTime ? PictureBoxStatus.Good : PictureBoxStatus.Bad); } catch { SetPictureBoxStatus(pictureBox, PictureBoxStatus.Bad); } }
private void roundTripButtonTest(string buttonName, SetButton setButton, GetButton getButton, PictureBox pictureBox) { if (stopButton.Enabled == false) return; try { setButton(XBoxButtonState.Released); DateTime timeOut = DateTime.Now.AddMilliseconds(100); while (getButton() == Microsoft.Xna.Framework.Input.ButtonState.Pressed && DateTime.Now < timeOut) ; long ticksEpoch = DateTime.Now.Ticks; for (int i = 0; i < iterationsPerTest && stopButton.Enabled; i++) { // Press Key setButton(XBoxButtonState.Pressed); timeOut = DateTime.Now.AddMilliseconds(100); while (getButton() == Microsoft.Xna.Framework.Input.ButtonState.Released && DateTime.Now < timeOut) ; // Release Key setButton(XBoxButtonState.Released); timeOut = DateTime.Now.AddMilliseconds(100); while (getButton() == Microsoft.Xna.Framework.Input.ButtonState.Pressed && DateTime.Now < timeOut) ; Application.DoEvents(); } long ticksNow = DateTime.Now.Ticks; long roundTripTime = (ticksNow - ticksEpoch + ticksRoundUp) / ticksPerTest; string entryLog = String.Format("{0:G} : {1} Button : Round Trip Time {2} mS{3}", DateTime.Now, buttonName, roundTripTime, Environment.NewLine); diagnosticsTextBox.AppendText(entryLog); SetPictureBoxStatus(pictureBox, roundTripTime <= expectedRoundTripTime ? PictureBoxStatus.Good : PictureBoxStatus.Bad); } catch { SetPictureBoxStatus(pictureBox, PictureBoxStatus.Bad); } }