internal static InputScopeNameValue ConvertInputScope(InputTypes inputType) { switch (inputType) { default: return(InputScopeNameValue.Default); case InputTypes.ClassNumber: return(InputScopeNameValue.Number); case InputTypes.TextVariationUri: return(InputScopeNameValue.Url); case InputTypes.ClassPhone: // Could also be InputScope.NumberAndPunctuation, beware. return(InputScopeNameValue.TelephoneNumber); case InputTypes.ClassText: return(InputScopeNameValue.Search); case InputTypes.TextVariationEmailAddress: return(InputScopeNameValue.EmailSmtpAddress); case InputTypes.NumberFlagDecimal: return(InputScopeNameValue.CurrencyAmount); } }
internal static void ShowWorking(InputTypes operation, int result, params int[] input) { // If it is a test, there is no valid console if (!ValidConsoleBuffer()) { return; } if (!(input.Length == 1 || input.Length == 2)) { // Should be 1 (flip) or two arguments (everything else) throw new ArgumentOutOfRangeException(nameof(input)); } // Space each output entry by a line Console.WriteLine(); // Show each input value foreach (var value in input) { Console.WriteLine(GetBinaryString(value) + " = " + value); } // Show divider var operationString = operation.ToString(); Console.WriteLine(operationString + " " + new string('-', Console.WindowWidth - (operationString.Length + 1))); // Show output Console.WriteLine(GetBinaryString(result) + " = " + result); }
public Input(Buttons button) { Type = InputTypes.Controller; Key = Keys.None; MouseInput = MouseInputs.None; ControllerButton = button; }
protected override NumberKeyListener GetDigitsKeyListener(InputTypes inputTypes) { // Disable the NumberFlagSigned bit inputTypes &= ~InputTypes.NumberFlagSigned; return(base.GetDigitsKeyListener(inputTypes)); }
public Input(MouseInputs mouseIn) { Type = InputTypes.Mouse; Key = Keys.None; MouseInput = mouseIn; ControllerButton = null; }
public static NumberKeyListener Create(InputTypes inputTypes) { if ((inputTypes & InputTypes.NumberFlagDecimal) == 0) { // If decimal isn't allowed, we can just use the Android version #pragma warning disable 0618 return(DigitsKeyListener.GetInstance(inputTypes.HasFlag(InputTypes.NumberFlagSigned), false)); #pragma warning restore 0618 } // Figure out what the decimal separator is for the current locale char decimalSeparator = GetDecimalSeparator(); if (decimalSeparator == '.') { // If it's '.', then we can just use the default Android version #pragma warning disable 0618 return(DigitsKeyListener.GetInstance(inputTypes.HasFlag(InputTypes.NumberFlagSigned), true)); #pragma warning restore 0618 } // If decimals are enabled and the locale's decimal separator is not '.' // (which is hard-coded in the Android DigitKeyListener), then use // our custom one with a configurable decimal separator return(GetInstance(inputTypes, decimalSeparator)); }
/// <summary> /// Fires the event <see cref="OnKeyPressed"/>. /// </summary> /// <param name="itype">The type of the user input.</param> private void FireOnKeyPressed(InputTypes itype) { if (this.OnKeyPressed != null) { this.OnKeyPressed(this, new ControlPlayerOnKeyPressedEventArgs(itype)); } }
private void updateMethodHeader() { //public double getData(){ //public static boolean CustomConversionUpdate2(DataType long arg0) { string methodHeader = "public"; string staticText = ""; string outputTypeText = ""; string methodNameText = ""; string argumentsText = "("; staticText = InputTypes.Empty() ? "" : " static"; outputTypeText = " " + OutputType.MinimizedName; methodNameText = InputTypes.Empty() ? " getData" : " " + ElementName.RemoveAll(" ", "_"); for (int i = 0; i < InputTypes.Count; i++) { if (i != 0) { argumentsText += ", "; } argumentsText += InputTypes[i].MinimizedName + " arg" + i; } argumentsText = argumentsText + ")"; methodHeader = methodHeader + staticText + outputTypeText + methodNameText + argumentsText + " {"; tempTbHeader.Text = methodHeader; }
public static IMouse New(InputTypes inputType, IDisposableResource parent) { IMouse api = null; #if WIN32 if (inputType == InputTypes.WinForms) api = new WinForms.Mouse(parent); #endif #if WINRT if (inputType == InputTypes.WinRT) api = new WinRT.Mouse(parent); #endif #if OSX if (inputType == InputTypes.Cocoa) api = new Cocoa.Mouse(parent); #endif #if LINUX if (inputType == InputTypes.X11) api = new X11.Mouse(parent); #endif #if NaCl if (inputType == InputTypes.NaCl) api = new NaCl.Mouse(parent); #endif if (api == null) Debug.ThrowError("MouseAPI", "Unsuported InputType: " + inputType); return api; }
void UpdateInputType() { SearchBar model = Element; var keyboard = model.Keyboard; _inputType = keyboard.ToInputType(); if (!(keyboard is Internals.CustomKeyboard)) { if (model.IsSet(InputView.IsSpellCheckEnabledProperty)) { if ((_inputType & InputTypes.TextFlagNoSuggestions) != InputTypes.TextFlagNoSuggestions) { if (!model.IsSpellCheckEnabled) { _inputType = _inputType | InputTypes.TextFlagNoSuggestions; } } } } Control.SetInputType(_inputType); if (keyboard == Keyboard.Numeric) { _editText = _editText ?? Control.GetChildrenOfType <EditText>().FirstOrDefault(); if (_editText != null) { _editText.KeyListener = GetDigitsKeyListener(_inputType); } } }
public override bool IsValid(InputTypes type) { if (type == InputTypes.Username || type == InputTypes.Password) { return(base.IsValid(type)); } Regex re = new Regex(InputTypeValue.Value(type)); switch (type) { case InputTypes.FirstName: return(re.IsMatch(user.GetFirstName())); case InputTypes.LastName: return(re.IsMatch(user.GetLastName())); case InputTypes.Email: return(RegexUtilities.IsValidEmail(user.GetEmail())); case InputTypes.FullAddress: return(AddressAPI.IsAddressValid(user)); default: return(false); } }
public bool isNewlyPressed(InputTypes action) { switch (action) { case InputTypes.up: return ((keyboardState.IsKeyDown(KEYUP) && oldKeyboardState.IsKeyUp(KEYUP)) || (gamePadState.ThumbSticks.Left.Y > STICK_THRESHOLD && oldGamePadState.ThumbSticks.Left.Y <= STICK_THRESHOLD)); case InputTypes.down: return ((keyboardState.IsKeyDown(KEYDOWN) && oldKeyboardState.IsKeyUp(KEYDOWN)) || (gamePadState.ThumbSticks.Left.Y < -STICK_THRESHOLD && oldGamePadState.ThumbSticks.Left.Y >= -STICK_THRESHOLD)); case InputTypes.left: return ((keyboardState.IsKeyDown(KEYLEFT) && oldKeyboardState.IsKeyUp(KEYLEFT)) || (gamePadState.ThumbSticks.Left.X < -STICK_THRESHOLD && oldGamePadState.ThumbSticks.Left.X >= -STICK_THRESHOLD)); case InputTypes.right: return ((keyboardState.IsKeyDown(KEYRIGHT) && oldKeyboardState.IsKeyUp(KEYRIGHT)) || (gamePadState.ThumbSticks.Left.X > STICK_THRESHOLD && oldGamePadState.ThumbSticks.Left.X <= STICK_THRESHOLD)); case InputTypes.start: return ((keyboardState.IsKeyDown(KEYSTART) && oldKeyboardState.IsKeyUp(KEYSTART)) || (gamePadState.Buttons.Start == ButtonState.Pressed && oldGamePadState.Buttons.Start == ButtonState.Released)); case InputTypes.jump: return ((keyboardState.IsKeyDown(KEYJUMP) && oldKeyboardState.IsKeyUp(KEYJUMP)) || (gamePadState.Buttons.A == ButtonState.Pressed && oldGamePadState.Buttons.A == ButtonState.Released)); case InputTypes.pull: return ((keyboardState.IsKeyDown(KEYPULL) && oldKeyboardState.IsKeyUp(KEYPULL)) || (gamePadState.Buttons.B == ButtonState.Pressed && oldGamePadState.Buttons.B == ButtonState.Released)); case InputTypes.bolt: return ((keyboardState.IsKeyDown(KEYBOLT) && oldKeyboardState.IsKeyUp(KEYBOLT)) || (gamePadState.Buttons.X == ButtonState.Pressed && oldGamePadState.Buttons.X == ButtonState.Released)); case InputTypes.gather: return ((keyboardState.IsKeyDown(KEYGATHER) && oldKeyboardState.IsKeyUp(KEYGATHER)) || (gamePadState.Buttons.Y == ButtonState.Pressed && oldGamePadState.Buttons.Y == ButtonState.Released)); default: return false; } }
public void InjectInputPlayer1(InputTypes inputType) { lock (InjectedInput) { InjectedInput[inputType] = InjectedInputFramePermamence; } }
void RespondToInput(InputTypes inputType, bool wasPressed) { switch (inputType) { case InputTypes.UP: break; case InputTypes.DOWN: break; case InputTypes.LEFT: break; case InputTypes.RIGHT: break; case InputTypes.ATTACK: break; case InputTypes.SKILL1: break; case InputTypes.SKILL2: break; case InputTypes.SKILL3: break; default: break; } }
internal Button(string name, int playerIndex, Buttons gamePadButton) { Name = name; _type = InputTypes.GamePad; _playerIndex = playerIndex; _gamePad = gamePadButton; }
protected virtual NumberKeyListener GetDigitsKeyListener(InputTypes inputTypes) { // Override this in a custom renderer to use a different NumberKeyListener // or to filter out input types you don't want to allow // (e.g., inputTypes &= ~InputTypes.NumberFlagSigned to disallow the sign) return(LocalizedDigitsKeyListener.Create(inputTypes)); }
public Input(InputTypes t) { Type = t; Key = Keys.None; MouseInput = MouseInputs.None; ControllerButton = null; }
///<summary> ///Формирует текстовые сообщения для ввода данных и пояснения для пользователя. ///</summary> public static void GetInput(bool firstTime, int inputType, string operandNumber = "первый") { if (firstTime) { View.Render(0, "Welcome to MVC Calculator.\nEnter first operand(x), then a math operator to be applied, and then the second operand(y).\nType \"Exit\" to quit the program.\n" + "Available operators:\nx + y\nx - y\nx * y\nx / y\nx ^ y\n\n"); } ; InputTypes _inputType = (InputTypes)inputType; //TODO локальные переменные - camalCase switch (_inputType) //TODO Будь ленивым - так короче switch ((InputTypes)_inputType) { case InputTypes.Operand: View.Render(1, ($"Введите {operandNumber} операнд:\t\t")); break; case InputTypes.Operator: View.Render(2, ($"Введите оператор:\t\t")); break; default: break; } }
void UpdateInputType() { var keyboard = _searchHandler.Keyboard; _inputType = keyboard.ToInputType(); bool isSpellCheckEnableSet = false; bool isSpellCheckEnable = false; // model.IsSet(InputView.IsSpellCheckEnabledProperty) if (!(keyboard is Internals.CustomKeyboard)) { if (isSpellCheckEnableSet) { if ((_inputType & InputTypes.TextFlagNoSuggestions) != InputTypes.TextFlagNoSuggestions) { if (!isSpellCheckEnable) { _inputType = _inputType | InputTypes.TextFlagNoSuggestions; } } } } _editText.InputType = _inputType; if (keyboard == Keyboard.Numeric) { _editText.KeyListener = GetDigitsKeyListener(_inputType); } }
public PickerFragment(string title, List <NameValueItem> collection, string updateProperty, InputTypes inputType = InputTypes.ClassText) : base(title, updateProperty, Resource.Layout.PickerLayout) { _collection = collection; _filteredColection = collection; _inputType = inputType; }
public InputField() { Name = string.Empty; Type = string.Empty; Value = string.Empty; InputType = InputTypes.None; }
public Input(Keys key) { Type = InputTypes.Keyboard; Key = key; MouseInput = MouseInputs.None; ControllerButton = null; }
/// <summary> /// Inputs the with later validation. Will be validated for TextLength and Remove Action on Position 0. /// </summary> /// <param name="inputType">Type of the input.</param> /// <param name="input">The input.</param> private Boolean inputWithLaterValidation(InputTypes inputType, string input) { Boolean validInput = true; if (inputType != null && Title != null && InputBox != null && InputBox.BoxHeightType != null && InputBox.BoxHeightType != BoxHeightTypes.Unknown) { if (inputType == InputTypes.AddContent && input != null && !Validator.ValidateTextLength(Title + input)) { EventManager.fire_ValidationError(Validator.LastError, this); validInput = false; } else { //Validate for pattern and spaces upon saving, else just execute if (inputType == InputTypes.Save) { if (validateForSpaces(Title) && validate(Title, input)) { executeInput(inputType, input); } else { validInput = false; } } else { executeInput(inputType, input); } } } return(validInput); }
private bool validateWithSpaceValidation(InputTypes inputType, string Title, string input) { Boolean valid = true; switch (inputType) { case InputTypes.AddContent: valid = validateForSpaces_AddContent(Title, input) && validate(Title, input); break; case InputTypes.RemoveContent: valid = validateForSpaces_RemoveContent(Title); break; case InputTypes.RemoveContentAfter: valid = validateForSpaces_RemoveContentAfter(Title); break; case InputTypes.Save: break; default: break; } return(valid); }
public Input(InputTypes _inputType, String _identifier, String _idRef, Rectangle _rect) { this.iDRef = _idRef; this.inputType = _inputType; this.identifer = _identifier; this.rect = _rect; }
// This direct access function should be used sparingly (likely only for internal features like the freecam). // All other input queries should use binds. public bool Query(InputTypes inputType, int data, InputStates state) { var inputData = dataArray[(int)inputType]; Debug.Assert(inputData != null, $"Direct input access for type {inputType} is not connected."); return(inputData.Query(data, state)); }
public override bool IsValid(InputTypes input) { if (newUser) { return(false); } return(base.IsValid(input)); }
protected ControllerData(InputTypes inputType, int maxButton, InputStates[] buttons, JoystickData leftStick, JoystickData rightStick) : base(inputType) { this.maxButton = maxButton; this.buttons = buttons; this.leftStick = leftStick; this.rightStick = rightStick; }
public ActionResult DeleteConfirmed(int id) { InputTypes inputtypes = db.InputTypes.Find(id); db.InputTypes.Remove(inputtypes); db.SaveChanges(); return(RedirectToAction("Index")); }
public Control(InputTypes t, int i, int p, string s, KeyCode k) { type = t; impulse = i; playerNum = p; name = s; keyCode = k; }
private static bool IsInputTypeVariation(InputTypes inputType, InputTypes inputTypeVariation) { if (!InputTypes.MaskVariation.HasFlag(inputTypeVariation)) { throw new Exception("invalid inputTypeVariation"); } return((((int)inputType) & (int)InputTypes.MaskVariation) == (int)(inputTypeVariation)); }
private static bool IsInputTypeClass(InputTypes inputType, InputTypes inputTypeClass) { if (!InputTypes.MaskClass.HasFlag(inputTypeClass)) { throw new Exception("invalid inputTypeClas"); } return((((int)inputType) & (int)InputTypes.MaskClass) == (int)(inputTypeClass)); }
public void Add(InputTypes type) { // Unique columns? if (!_format.Contains(type)) { _format.Add(type); } }
public static IGamePad New(InputTypes inputType, IDisposableResource parent) { IGamePad api = null; #if XNA if (inputType == InputTypes.XNA) api = new XNA.GamePad(disposable); #endif if (api == null) Debug.ThrowError("GamePadAPI", "Unsuported InputType: " + inputType); return api; }
public static bool Validate(InputTypes type, string value) { int number; bool result = false; switch (type) { case InputTypes.Number: result = (int.TryParse(value, out number) && number > 0) ? true : false; break; } return result; }
public InputMessage( InputTypes inputType, MessageTypes messageType, Vector2 fingerPosition, Vector2 fingerDelta = default(Vector2), float gestureData = default(float) ) { this.InputType = inputType; this.MessageType = messageType; this.FingerPositions = new List<Vector2>() { fingerPosition }; this.FingerDeltas = new List<Vector2>() { fingerDelta }; this.GestureData = new List<float>() { gestureData }; this.Propogate = true; GenerateNormalisedLists(); }
public InputMessage( InputTypes inputType, MessageTypes messageType, List<Vector2> fingerPositions, List<Vector2> fingerDeltas = null, List<float> gestureData = null ) { this.InputType = inputType; this.MessageType = messageType; this.FingerPositions = fingerPositions; this.FingerDeltas = fingerDeltas; this.GestureData = gestureData; this.Propogate = true; GenerateNormalisedLists(); }
public override void OnMouseDown(object sender, MouseEventArgs e) { switch (e.Button) { case MouseButtons.Left: inputType = InputTypes.Rotate; break; case MouseButtons.Right: inputType = InputTypes.Pan; break; case MouseButtons.Middle: inputType = InputTypes.Zoom; break; } }
public static ITouchScreen New(InputTypes inputType, IDisposableResource parent) { ITouchScreen api = null; #if iOS if (inputType == InputTypes.Cocoa) TouchScreenAPI.Init(Reign.Input.Cocoa.TouchScreen.New); #endif #if ANDROID if (inputType == InputTypes.Android) TouchScreenAPI.Init(Reign.Input.Android.TouchScreen.New); #endif if (api == null) Debug.ThrowError("TouchScreenAPI", "Unsuported InputType: " + inputType); return api; }
private DevComponents.AdvTree.Node AddNode(DevComponents.AdvTree.Node parentNode, string tag, string name, string description, InputTypes inputType, object value, bool selected, SetOptionValue setOptionValue) { DevComponents.DotNetBar.SuperTooltipInfo tooltip = new DevComponents.DotNetBar.SuperTooltipInfo(name, null, description, null, null, DevComponents.DotNetBar.eTooltipColor.Gray); DevComponents.DotNetBar.Controls.CheckBoxX checkBoxSelect = new DevComponents.DotNetBar.Controls.CheckBoxX() { Checked = selected, Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled, BackColor = Color.Transparent, CheckBoxPosition = DevComponents.DotNetBar.eCheckBoxPosition.Right }; DevComponents.AdvTree.Node newNode = new DevComponents.AdvTree.Node() { HostedControl = checkBoxSelect, Name = tag }; DevComponents.AdvTree.Cell nameCell = new DevComponents.AdvTree.Cell() { Text = name }; DevComponents.AdvTree.Cell valueCell = new DevComponents.AdvTree.Cell() { EditorType = DevComponents.AdvTree.eCellEditorType.Custom, Editable = true }; switch (inputType) { case InputTypes.Double: double? doubleValue = (double?)value; DevComponents.Editors.DoubleInput doubleInput = new DevComponents.Editors.DoubleInput() { Value = doubleValue.HasValue ? doubleValue.Value : 0 }; valueCell.HostedControl = doubleInput; doubleInput.ValueChanged += delegate(object sender, EventArgs e) { ValueChanged(checkBoxSelect, doubleInput, setOptionValue); }; break; case InputTypes.Integer: int? intValue = (int?)value; DevComponents.Editors.IntegerInput integerInput = new DevComponents.Editors.IntegerInput() { Value = intValue.HasValue ? intValue.Value : 0 }; valueCell.HostedControl = integerInput; integerInput.ValueChanged += delegate(object sender, EventArgs e) { ValueChanged(checkBoxSelect, integerInput, setOptionValue); }; break; case InputTypes.String: TextBox textBox = new TextBox() { Text = (string)value }; valueCell.HostedControl = textBox; textBox.TextChanged += delegate(object sender, EventArgs e) { ValueChanged(checkBoxSelect, textBox, setOptionValue); }; break; case InputTypes.Boolean: bool? boolValue = (bool?)value; DevComponents.DotNetBar.Controls.CheckBoxX checkBox = new DevComponents.DotNetBar.Controls.CheckBoxX() { Checked = boolValue.HasValue ? boolValue.Value : false, Style = DevComponents.DotNetBar.eDotNetBarStyle.StyleManagerControlled, BackColor = Color.Transparent, }; checkBox.CheckedChanged += delegate (object sender, EventArgs e) { ValueChanged(checkBoxSelect, checkBox, setOptionValue); }; valueCell.HostedControl = checkBox; break; default: throw new NotImplementedException("InputType not handled yet: " + inputType.ToString()); } newNode.Cells.Add(nameCell); newNode.Cells.Add(valueCell); nameCell.Enabled = checkBoxSelect.Checked; valueCell.Enabled = checkBoxSelect.Checked; valueCell.HostedControl.Enabled = checkBoxSelect.Checked; superTooltip1.SetSuperTooltip(newNode, tooltip); superTooltip1.SetSuperTooltip(checkBoxSelect, tooltip); superTooltip1.SetSuperTooltip(valueCell.HostedControl, tooltip); checkBoxSelect.CheckedChanged += delegate { nameCell.Enabled = checkBoxSelect.Checked; valueCell.Enabled = checkBoxSelect.Checked; valueCell.HostedControl.Enabled = checkBoxSelect.Checked; if (checkBoxSelect.Checked) valueCell.HostedControl.Focus(); }; if (parentNode == null) advTree1.Nodes.Add(newNode); else parentNode.Nodes.Add(newNode); return newNode; }
public void SendInput(InputTypes inputType) { inputList.Add(new InputPair(inputType)); }
public InputPair(InputTypes newInput) { inputType = newInput; frames = ttl; }
public InputCodes(KeyCode key) { InputType = InputTypes.Keyboard; Value = (int)key; }
public InputCodes(Buttons button) { InputType = InputTypes.Controller; Value = (int)button; }
public InputCodes(Mouse button) { InputType = InputTypes.Mouse; Value = (int)button; }
public override void OnMouseUp(object sender, MouseEventArgs e) { inputType = InputTypes.None; }
/// <summary> /// Constructor for deserialization. /// </summary> /// <param name="info">info is the serialization info to deserialize with</param> /// <param name="context">context is the context in which to deserialize...?</param> protected ScriptNode(SerializationInfo info, StreamingContext context) { mName = info.GetString("NodeName"); mInputType = (ScriptNode.InputTypes)Enum.Parse(typeof(ScriptNode.InputTypes), info.GetString("InputType")); mOutputType = (ScriptNode.OutputTypes)Enum.Parse(typeof(ScriptNode.OutputTypes), info.GetString("OutputType")); }
private DevComponents.AdvTree.Node AddNode(string tag, string name, string description, InputTypes inputType, object value, bool selected, SetOptionValue setOptionValue) { return AddNode(null, tag, name, description, inputType, value, selected, setOptionValue); }
public bool isPressed(InputTypes action) { switch (action) { case InputTypes.up: return (keyboardState.IsKeyDown(KEYUP) || gamePadState.ThumbSticks.Left.Y > STICK_THRESHOLD); case InputTypes.down: return (keyboardState.IsKeyDown(KEYDOWN) || gamePadState.ThumbSticks.Left.Y < -STICK_THRESHOLD); case InputTypes.left: return (keyboardState.IsKeyDown(KEYLEFT) || gamePadState.ThumbSticks.Left.X < -STICK_THRESHOLD); case InputTypes.right: return (keyboardState.IsKeyDown(KEYRIGHT) || gamePadState.ThumbSticks.Left.X > STICK_THRESHOLD); case InputTypes.start: return (keyboardState.IsKeyDown(KEYSTART) || gamePadState.Buttons.Start == ButtonState.Pressed); case InputTypes.jump: return (keyboardState.IsKeyDown(KEYJUMP) || gamePadState.Buttons.A == ButtonState.Pressed); case InputTypes.pull: return (keyboardState.IsKeyDown(KEYPULL) || gamePadState.Buttons.B == ButtonState.Pressed); case InputTypes.bolt: return (keyboardState.IsKeyDown(KEYBOLT) || gamePadState.Buttons.X == ButtonState.Pressed); case InputTypes.gather: return (keyboardState.IsKeyDown(KEYGATHER) || gamePadState.Buttons.Y == ButtonState.Pressed); case InputTypes.quit: return (keyboardState.IsKeyDown(KEYQUIT)); default: return false; } }
public InputData(int InputValue, DelegateFunctionCall Function, InputStates InputState, InputTypes InputType, bool PauseMenu) { this.Function = Function; this.InputState = InputState; this.InputValue = InputValue; this.InputType = InputType; this.Enabled = true; this.PauseMenu = PauseMenu; }
/// <summary> /// Constructor that specifies a type. /// </summary> /// <param name="type">The type if the input event.</param> public Input(InputTypes type) : this() { Type = type; }
// Switch between input types private void menuInputType_Clicked(object sender, RoutedEventArgs e) { // Construct references to all context menu items ContextMenu contextMenu = Resources["menuInputType"] as ContextMenu; MenuItem menuItemInputLink = contextMenu.Items[0] as MenuItem; MenuItem menuItemInputConstant = contextMenu.Items[1] as MenuItem; MenuItem menuItemInputVarying = contextMenu.Items[2] as MenuItem; MenuItem menuItemInputFloat1 = menuItemInputConstant.Items[0] as MenuItem; MenuItem menuItemInputFloat2 = menuItemInputConstant.Items[1] as MenuItem; MenuItem menuItemInputFloat3 = menuItemInputConstant.Items[2] as MenuItem; MenuItem menuItemInputFloat4 = menuItemInputConstant.Items[3] as MenuItem; MenuItem menuItemInputColor = menuItemInputConstant.Items[4] as MenuItem; MenuItem menuItemInputBoolean = menuItemInputConstant.Items[5] as MenuItem; // If the clicked menu item was already checked we are done MenuItem clickedMenuItem = e.Source as MenuItem; if (clickedMenuItem.IsChecked) return; // Uncheck all other items menuItemInputLink.IsChecked = false; menuItemInputFloat1.IsChecked = false; menuItemInputFloat2.IsChecked = false; menuItemInputFloat3.IsChecked = false; menuItemInputFloat4.IsChecked = false; menuItemInputColor.IsChecked = false; menuItemInputBoolean.IsChecked = false; menuItemInputVarying.IsChecked = false; clickedMenuItem.IsChecked = true; // Change input type if (clickedMenuItem == menuItemInputLink) { InputType = InputTypes.Link; } else if (clickedMenuItem == menuItemInputFloat1) { InputType = InputTypes.Float1; } else if (clickedMenuItem == menuItemInputFloat2) { InputType = InputTypes.Float2; } else if (clickedMenuItem == menuItemInputFloat3) { InputType = InputTypes.Float3; } else if (clickedMenuItem == menuItemInputFloat4) { InputType = InputTypes.Float4; } else if (clickedMenuItem == menuItemInputColor) { InputType = InputTypes.Color; } else if (clickedMenuItem == menuItemInputBoolean) { InputType = InputTypes.Boolean; } else if (clickedMenuItem == menuItemInputVarying) { InputType = InputTypes.Varying; } }