private void targetElementPressed(object sender, PointerRoutedEventArgs e) { if (lastToggleState == ToggleState.Open) { lastToggleState = ToggleState.Close; } else { lastToggleState = ToggleState.Open; } //update trigger SetActive(toggleState == lastToggleState); }
public void Toggle() { if (state == ToggleState.Off) { Debug.Log("TOGGLE ON"); onToggleOn.ForEach(s => s.Fire()); state = ToggleState.On; } else { Debug.Log("TOGGLE OFF"); onToggleOff.ForEach(s => s.Fire()); state = ToggleState.Off; } }
private void TestToggleEventWithToggle (IToggleProvider provider, ToggleState expectedState) { bridge.ResetEventLists (); object oldState = provider.ToggleState; provider.Toggle (); // Test IToggleProvider.ToggleState Assert.AreEqual (expectedState, provider.ToggleState, "ToggleState"); // Test event was fired as expected Assert.AreEqual (1, bridge.AutomationPropertyChangedEvents.Count, "event count"); AutomationPropertyChangedEventArgs eventArgs = bridge.AutomationPropertyChangedEvents [0].e; Assert.AreEqual (TogglePatternIdentifiers.ToggleStateProperty, eventArgs.Property, "event args property"); Assert.AreEqual (oldState, eventArgs.OldValue, "old value"); Assert.AreEqual (expectedState, eventArgs.NewValue, "new value"); }
/// ------------------------------------------------------------------- /// <summary></summary> /// ------------------------------------------------------------------- void TS_ToggleTo(ToggleState toggleState, Type exceptionExpected, CheckType checkType) { // I don't know, lets try 5 times max<g> const int MAX = 5; for (int count = 0; count < MAX; count++) { patternToggle(exceptionExpected, checkType); if (toggleState == pToggleState) { m_TestStep++; return; } } ThrowMe(checkType, "Could not set ToggeState == " + toggleState + " in " + MAX + " tries"); }
/// <summary> /// Move the state of the toggle button to the next state. States order is: Unchecked -> Checked [-> Indeterminate] -> Unchecked -> ... /// </summary> protected void GoToNextState() { switch (State) { case ToggleState.Checked: State = IsThreeState ? ToggleState.Indeterminate : ToggleState.UnChecked; break; case ToggleState.Indeterminate: State = ToggleState.UnChecked; break; case ToggleState.UnChecked: State = ToggleState.Checked; break; default: throw new ArgumentOutOfRangeException(); } }
private void ValidateToggleState (ToggleState old, ToggleState got) { if (old == ToggleState.On) Assert.AreEqual (ToggleState.Off, got, "On -> Off"); else if (old == ToggleState.Off) { if (got != ToggleState.Indeterminate && got != ToggleState.On) Assert.Fail ("Off -> Indeterminate or On"); } else if (old == ToggleState.Indeterminate) Assert.AreEqual (ToggleState.On, got, "Indeterminate -> On"); }
//Method to change Toggle State On the Fly public void ChangeToggleState(ToggleState state) { switch (state) { case ToggleState.Unchecked: tglStateSlctAll = state; btnSlctAll.GetComponent<Image>().sprite = stateSprites[0]; break; case ToggleState.Partial: bool flagOn = false, flagOff = false; foreach (var item in listInvites) { if (item.tglBtn.isOn) { flagOn = true; } else { flagOff = true; } } if (flagOn && flagOff) { tglStateSlctAll = state; btnSlctAll.GetComponent<Image>().sprite = stateSprites[1]; //Debug.Log("Partial"); } else if (flagOn && !flagOff) { ChangeToggleState(ToggleState.Checked); //Debug.Log("Checked"); } else if (!flagOn && flagOff) { ChangeToggleState(ToggleState.Unchecked); //Debug.Log("Unchecked"); } break; case ToggleState.Checked: tglStateSlctAll = state; btnSlctAll.GetComponent<Image>().sprite = stateSprites[2]; break; } }
public static bool IsOff(this ToggleState state) { return(state == ToggleState.Off); }
public void SetCheckBoxState(ToggleState state) { _suspendProcessingToggleStateChanged = true; _checkbox.ToggleState = state; _suspendProcessingToggleStateChanged = false; }
private static extern string Test_IToggleProviderToggle( [MarshalAs(UnmanagedType.IUnknown)] object pUnk, ToggleState expected);
private static void NativeSetToggleState(BaseProdControl control, ToggleState checkstate) { //note ProdCheckBoxNative.SetCheckStateNative((IntPtr)control.UIAElement.Current.NativeWindowHandle, checkstate); }
private static void UiaSetToggleState(BaseProdControl control, ToggleState checkstate) { AutomationEventVerifier.Register(new EventRegistrationMessage(control, TogglePatternIdentifiers.ToggleStateProperty)); LogController.ReceiveLogMessage(new LogMessage(checkstate.ToString())); TogglePatternHelper.SetToggleState(control.UIAElement, checkstate); }
/// <summary> /// Sets the <see cref="ToggleState"/>. /// </summary> /// <param name="extension">The extended interface.</param> /// <param name="control">The UI Automation element</param> /// <param name="checkstate">The <see cref="ToggleState"/>.</param> public static void SetToggleStateHook(this ToggleAdapter extension, BaseProdControl control, ToggleState checkstate) { try { UiaSetToggleState(control, checkstate); } catch (ArgumentNullException err) { throw new ProdOperationException(err); } catch (ElementNotAvailableException err) { throw new ProdOperationException(err); } catch (InvalidOperationException) { NativeSetToggleState(control, checkstate); } }
public override VisualStyleElement GetXPVisualStyle() { VisualStyleElement visualStyleElement = (VisualStyleElement)null; ToggleState toggleState = this.ToggleState; if (!this.Enabled) { switch (toggleState) { case ToggleState.Off: visualStyleElement = VisualStyleElement.Button.CheckBox.UncheckedDisabled; break; case ToggleState.On: visualStyleElement = VisualStyleElement.Button.CheckBox.CheckedDisabled; break; case ToggleState.Indeterminate: visualStyleElement = VisualStyleElement.Button.CheckBox.MixedDisabled; break; } } else if (this.IsMouseDown) { switch (toggleState) { case ToggleState.Off: visualStyleElement = this.IsMouseOver ? VisualStyleElement.Button.CheckBox.UncheckedPressed : VisualStyleElement.Button.CheckBox.UncheckedHot; break; case ToggleState.On: visualStyleElement = this.IsMouseOver ? VisualStyleElement.Button.CheckBox.CheckedPressed : VisualStyleElement.Button.CheckBox.CheckedHot; break; case ToggleState.Indeterminate: visualStyleElement = this.IsMouseOver ? VisualStyleElement.Button.CheckBox.MixedPressed : VisualStyleElement.Button.CheckBox.MixedHot; break; } } else if (this.IsMouseOver) { switch (toggleState) { case ToggleState.Off: visualStyleElement = VisualStyleElement.Button.CheckBox.UncheckedHot; break; case ToggleState.On: visualStyleElement = VisualStyleElement.Button.CheckBox.CheckedHot; break; case ToggleState.Indeterminate: visualStyleElement = VisualStyleElement.Button.CheckBox.MixedHot; break; } } else { switch (toggleState) { case ToggleState.Off: visualStyleElement = VisualStyleElement.Button.CheckBox.UncheckedNormal; break; case ToggleState.On: visualStyleElement = VisualStyleElement.Button.CheckBox.CheckedNormal; break; case ToggleState.Indeterminate: visualStyleElement = VisualStyleElement.Button.CheckBox.MixedNormal; break; } } return(visualStyleElement); }
public StateChangingEventArgs(ToggleState oldValue, ToggleState newValue, bool canceled) { this.oldValue = oldValue; this.newValue = newValue; this.canceled = canceled; }
public static bool IsOn(this ToggleState state) { return(state == ToggleState.On); }
//離開頁面時 重置UI public void ResetPageUI() { _cuurState = ToggleState.DAILY; ChangeActivityUI(); }
//Click Handler of Select ALl Button public void TglSelectAllClickHandler() { switch (tglStateSlctAll) { case ToggleState.Partial: case ToggleState.Unchecked: foreach (var item in listInvites) { item.tglBtn.isOn = true; } tglStateSlctAll = ToggleState.Checked; ChangeToggleState(ToggleState.Checked); break; case ToggleState.Checked: foreach (var item in listInvites) { item.tglBtn.isOn = false; } ChangeToggleState(ToggleState.Unchecked); break; } }
//離開頁面時 重置UI public void ResetPageUI() { _cuurState = ToggleState.PROFILE; ChangeSettingUI(); }
internal static void SetToggleStateWin32(AutomationElement automationElement, ToggleState state) { if (automationElement.Properties.NativeWindowHandle.IsSupported) { var windowHandle = automationElement.Properties.NativeWindowHandle.ValueOrDefault; if (windowHandle != IntPtr.Zero) { var className = new StringBuilder(256); User32.GetClassName(windowHandle, className, 256); if (className.ToString() == "Button") // Common Win32 Checkbox window { var result = User32.SendMessage(windowHandle, ButtonMessages.BM_GETCHECK, IntPtr.Zero, IntPtr.Zero); if (state == ToggleState.On) { if (result.ToInt32() != (int)ButtonStates.BST_CHECKED) { User32.SendMessage(windowHandle, ButtonMessages.BM_SETCHECK, new IntPtr(ButtonStates.BST_CHECKED), IntPtr.Zero); } } else if (state == ToggleState.Off) { if (result.ToInt32() != (int)ButtonStates.BST_UNCHECKED) { User32.SendMessage(windowHandle, ButtonMessages.BM_SETCHECK, new IntPtr(ButtonStates.BST_UNCHECKED), IntPtr.Zero); } } else // indeterminate state { if (result.ToInt32() != (int)ButtonStates.BST_INDETERMINATE) { User32.SendMessage(windowHandle, ButtonMessages.BM_SETCHECK, new IntPtr(ButtonStates.BST_INDETERMINATE), IntPtr.Zero); } } } } } }
public static void SetToggleState(ToggleState newState) { toggleState = newState; }
void Update() { //Update Local Vals for Inspector localInput = inputState; localToggle = toggleState; //Hide Mouse if it's not used if (Cursor.lockState == CursorLockMode.Locked || ((Input.anyKey || (controllers.Count > 0 && (controllers[0].GetRawInput("MenuHorizontal") != 0 || controllers[0].GetRawInput("MenuVertical") != 0))) && !Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2))) { Cursor.visible = false; } if (Cursor.lockState != CursorLockMode.Locked && (Input.GetMouseButton(0) || Input.GetMouseButton(1) || Input.GetMouseButton(2) || Input.GetAxis("Mouse X") != 0f || Input.GetAxis("Mouse Y") != 0f)) { Cursor.visible = true; } if (mouseLock && !Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2)) { mouseLock = false; } //Check for new inputs if (inputState != InputState.Locked && inputState != InputState.LockedShowing) { if (controllers.Count < maxPlayers) { //Get a list of Joysticks in Use List <int> inputsInUse = new List <int>(); foreach (InputDevice controller in controllers) { inputsInUse.Add(controller.joystickID); } //Get Keyboard Inputs if (inputState != InputState.AnyMinusKeyboard) { //If Keyboard is not already in if (!inputsInUse.Contains(0)) { bool recivedKey = false; for (int i = 1; i < 300; i++) { if (Input.GetKey((KeyCode)i)) { recivedKey = true; break; } } if (recivedKey || (Input.GetMouseButton(0) && controllers.Count == 0)) { controllers.Add(new KeyboardDevice(0)); } } } //Get Joystick Inputs for (int i = 1; i <= maxJoysticks; i++) { //If Joystick is not in use if (!inputsInUse.Contains(i)) { //If we get an input if (RecieveInput(i)) { if (inputState == InputState.Locked || inputState == InputState.LockedShowing) { //Do Locked GUI Flash } else { //Detect Type of Input Device (Or don't) //Add this Joystick to the Controllers controllers.Add(new XBox360Device(i)); } } } } } } //Controller Removing foreach (InputDevice controller in controllers.ToArray()) { //Do Controller Removing if (controller.GetButton("Leave")) { if (inputState != InputState.Locked && inputState != InputState.LockedShowing) { controller.killing = true; } else { //Do Locked GUI Flash } } } //Controller Unlocking and Toggling //bool firstController = true; foreach (InputDevice controller in controllers.ToArray()) { //Kill Controller if (controller.killing) { controllers.Remove(controller); } //Do InputLock unlocking if (controller.inputLock != "") { if (controller.GetRawInput(controller.inputLock, true) == 0f) { controller.inputLock = ""; controller.inputTimer = 0f; } } /* * //Make sure Controller has correct Layout * if (!controller.toggle && controller.currentLayout != configsPerType[(int)controller.inputType][controller.currentSelection]) * controller.SetLayout(configsPerType[(int)controller.inputType][controller.currentSelection]); * * //Do Controller Toggling * if (toggleState == ToggleState.Any || (toggleState == ToggleState.AnyButOne && !firstController)) * if (controller.GetButtonWithLockForToggle("Toggle")) * { * //Show Layout Selection * controller.toggle = !controller.toggle; * } * * //Do Toggle Menu Controls * if (controller.toggle && controller.boxHeight == 450f) * { * bool submit = controller.GetButtonWithLockForToggle("Submit"); * bool cancel = controller.GetButtonWithLockForToggle("Cancel"); * int vert = controller.GetRawIntInputWithLockForToggle("MenuVertical"); * * if (vert != 0) * controller.currentSelection = MathHelper.NumClamp(controller.currentSelection + vert, 0, InputManager.configsPerType[(int)controller.inputType].Count); * * if (submit) * { * controller.SetLayout(InputManager.configsPerType[(int)controller.inputType][controller.currentSelection]); * controller.toggle = false; * } * * if (cancel) * controller.toggle = false; * } * * //Set to false at end of first loop * firstController = false; */ } //Toggle States if (toggleState == ToggleState.Locked) { foreach (InputDevice device in controllers) { device.toggle = false; } } if (toggleState == ToggleState.AnyButOne && controllers.Count >= 1) { controllers[0].toggle = false; } }
/// ------------------------------------------------------------------- /// <summary></summary> /// ------------------------------------------------------------------- void TestToggle1(ToggleState expectedState, EventFired eventShouldFire, bool usingKeyboard) { ToggleState orgState = pToggleState; // "Precondition: ToggleStateProperty == expectedState", TS_VerifyToggleState(orgState, true, CheckType.IncorrectElementConfiguration); // "SetFocus to the element", TS_SetFocus(m_le, null, CheckType.IncorrectElementConfiguration); // "Step: Setup a StateProperty PropertyChange event", TSC_AddPropertyChangedListener(m_le, TreeScope.Element, new AutomationProperty[] { TogglePattern.ToggleStateProperty }, CheckType.Verification); // "Verify: Successful call TogglePattern.Toggle()", if (!usingKeyboard) TS_Toggle(null, CheckType.Verification); else TS_PressKeys(true, System.Windows.Input.Key.Space); // "Step: Wait for 1 event to occur TSC_WaitForEvents(1); // "Verify: The StateProperty PropertyChange event is fired", TSC_VerifyPropertyChangedListener(m_le, new EventFired[] { eventShouldFire }, new AutomationProperty[] { TogglePattern.ToggleStateProperty }, CheckType.Verification); // "Verify: The StateProperty has changed", TS_VerifyToggleState(orgState, false, CheckType.Verification); // "Cleanup: Call Toggle() until ToggleStateProperty == original state(Off)" //TS_ToggleTo(orgState, null, CheckType.Verification); m_TestStep++; }
/* Forces the play band to enter the pause toggle state. */ public void ForceIntoPauseToggleState() { meshRenderer.material = pauseMaterial; toggleState = ToggleState.Pause; }
/// ------------------------------------------------------------------- /// <summary></summary> /// ------------------------------------------------------------------- void TS_VerifyToggleState(ToggleState state, bool shouldBe, CheckType checkType) { ToggleState ts = pToggleState; if ((ts == state) != shouldBe) ThrowMe(checkType, "TogglePattern.ToggleState == " + ts); m_TestStep++; }
/* Forces the undo band to enter the undo toggle state. */ public void ForceIntoUndoToggleState() { meshRenderer.material = undoMaterial; toggleState = ToggleState.Undo; }
private bool IsChecked (ToggleState state) { switch (state) { case ToggleState.On: return true; case ToggleState.Indeterminate: case ToggleState.Off: return false; default: throw new NotSupportedException ("Unknown toggleState " + state.ToString ()); } }
public static ToggleState ToggleButton(ToggleState toggle, string text, Action on, Action off, GUIStyle style = null, params GUILayoutOption[] options) { ToggleButton(ref toggle, text, on, off, style, options); return(toggle); }
/// ------------------------------------------------------------------- /// <summary></summary> /// ------------------------------------------------------------------- bool HelperCheckBoxCurrentToggleState(AutomationElement element, ToggleState state) { Library.ValidateArgumentNonNull(element, "AutomationElement"); return ((ToggleState)element.GetCurrentPropertyValue(TogglePattern.ToggleStateProperty) == state); }
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { ToggleState state = (ToggleState)value; return(state == ToggleState.Enabled); }