private void WindowLoaded(object sender, RoutedEventArgs e){ // ... /* * ------------------ Command Binding ---------------------------- */ this.CommandBindings.Add( /* * CommandBinding Constructor (ICommand, ExecutedRoutedEventHandler, CanExecuteRoutedEventHandler) */ new CommandBinding( CommandBank.CloseWindowCommand, // System.Windows.Input.ICommand. The command to base the new RoutedCommand on. CommandBank.CloseWindowCommandExecute, // Input.ExecutedRoutedEventHandler. Handler for Executed event on new RoutedCommand. CommandBank.CanExecuteIfParameterIsNotNull)); // Input.CanExecuteRoutedEventHandler. The handler for CanExecute event on new RoutedCommand. /* * ------------------ Input Binding ------------------------------ */ foreach (CommandBinding binding in this.CommandBindings){ RoutedCommand command = (RoutedCommand)binding.Command; if (command.InputGestures.Count > 0){ foreach (InputGesture gesture in command.InputGestures){ var iBind = new InputBinding(command, gesture); iBind.CommandParameter = this; this.InputBindings.Add(iBind); } } } // menuItemExit is defined in XAML menuItemExit.Command = CommandBank.CloseWindow; menuItemExit.CommandParameter = this; // ... }
public List<string> BindingsUsing(InputBinding binding) { var bindingsUsing = new List<string>(); var keyBinding = AsKeyBinding(binding); if (keyBinding == null) return null; var cbinding = _bindings[AsKeyBinding(binding)]; if (cbinding != null) bindingsUsing.Add(cbinding); return bindingsUsing; }
public bool AddBinding(string bindingName, InputBinding binding) { var keyBinding = AsKeyBinding(binding); if (keyBinding == null) return false; // Clear existing bindings if (ContainsBinding(bindingName)) ClearBinding(bindingName); _bindings.Add(bindingName, keyBinding); return true; }
public static void SetCommand(InputBinding element, ICommand value) { element.Command = value; }
public static void Main() { ServiceDescription myDescription = ServiceDescription.Read("AddNumbers1.wsdl"); // Create the 'Binding' object. Binding myBinding = new Binding(); myBinding.Name = "Service1HttpPost"; XmlQualifiedName qualifiedName = new XmlQualifiedName("s0:Service1HttpPost"); myBinding.Type = qualifiedName; // <Snippet1> // <Snippet2> // Create the 'HttpBinding' object. HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; // Add the 'HttpBinding' to the 'Binding'. myBinding.Extensions.Add(myHttpBinding); // </Snippet2> // </Snippet1> // Create the 'OperationBinding' object. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myOperation = new HttpOperationBinding(); myOperation.Location = "/AddNumbers"; // Add the 'HttpOperationBinding' to 'OperationBinding'. myOperationBinding.Extensions.Add(myOperation); // Create the 'InputBinding' object. InputBinding myInput = new InputBinding(); MimeContentBinding postMimeContentbinding = new MimeContentBinding(); postMimeContentbinding.Type = "application/x-www-form-urlencoded"; myInput.Extensions.Add(postMimeContentbinding); // Add the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInput; // Create the 'OutputBinding' object. OutputBinding myOutput = new OutputBinding(); MimeXmlBinding postMimeXmlbinding = new MimeXmlBinding(); postMimeXmlbinding.Part = "Body"; myOutput.Extensions.Add(postMimeXmlbinding); // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.Bindings.Add(myBinding); // Create a 'Port' object. Port postPort = new Port(); postPort.Name = "Service1HttpPost"; postPort.Binding = new XmlQualifiedName("s0:Service1HttpPost"); // <Snippet3> // <Snippet4> // Create the 'HttpAddressBinding' object. HttpAddressBinding postAddressBinding = new HttpAddressBinding(); postAddressBinding.Location = "http://localhost/Service1.asmx"; // Add the 'HttpAddressBinding' to the 'Port'. postPort.Extensions.Add(postAddressBinding); // </Snippet4> // </Snippet3> // Add the 'Port' to 'PortCollection' of 'ServiceDescription'. myDescription.Services[0].Ports.Add(postPort); // Create a 'PortType' object. PortType postPortType = new PortType(); postPortType.Name = "Service1HttpPost"; Operation postOperation = new Operation(); postOperation.Name = "AddNumbers"; OperationMessage postInput = (OperationMessage) new OperationInput(); postInput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn"); OperationMessage postOutput = (OperationMessage) new OperationOutput(); postOutput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostOut"); postOperation.Messages.Add(postInput); postOperation.Messages.Add(postOutput); // Add the 'Operation' to 'PortType'. postPortType.Operations.Add(postOperation); // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'. myDescription.PortTypes.Add(postPortType); // Create the 'Message' object. Message postMessage1 = new Message(); postMessage1.Name = "AddNumbersHttpPostIn"; // Create the 'MessageParts'. MessagePart postMessagePart1 = new MessagePart(); postMessagePart1.Name = "firstnumber"; postMessagePart1.Type = new XmlQualifiedName("s:string"); MessagePart postMessagePart2 = new MessagePart(); postMessagePart2.Name = "secondnumber"; postMessagePart2.Type = new XmlQualifiedName("s:string"); // Add the 'MessagePart' objects to 'Messages'. postMessage1.Parts.Add(postMessagePart1); postMessage1.Parts.Add(postMessagePart2); // Create another 'Message' object. Message postMessage2 = new Message(); postMessage2.Name = "AddNumbersHttpPostOut"; MessagePart postMessagePart3 = new MessagePart(); postMessagePart3.Name = "Body"; postMessagePart3.Element = new XmlQualifiedName("s0:int"); // Add the 'MessagePart' to 'Message' postMessage2.Parts.Add(postMessagePart3); // Add the 'Message' objects to 'ServiceDescription'. myDescription.Messages.Add(postMessage1); myDescription.Messages.Add(postMessage2); // Write the 'ServiceDescription' as a WSDL file. myDescription.Write("AddNumbers.wsdl"); Console.WriteLine("WSDL file with name 'AddNumber.Wsdl' file created Successfully"); }
private static void OnBindableCommandChanged(DependencyObject depObj, DependencyPropertyChangedEventArgs e) { InputBinding ib = depObj as InputBinding; // BREAK POINT ib.Command = (ICommand)e.NewValue; }
public static int AbsoluteIndexOf(this InputAction inputAction, InputBinding binding) => inputAction.bindings.IndexOf(t => t == binding);
static void Main() { try { ServiceDescription myServiceDescription = ServiceDescription.Read("MathService_input_cs.wsdl"); // Add the OperationBinding for the Add operation. OperationBinding addOperationBinding = new OperationBinding(); string addOperation = "Add"; string myTargetNamespace = myServiceDescription.TargetNamespace; addOperationBinding.Name = addOperation; // Add the InputBinding for the operation. InputBinding myInputBinding = new InputBinding(); SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding(); mySoapBodyBinding.Use = SoapBindingUse.Literal; myInputBinding.Extensions.Add(mySoapBodyBinding); addOperationBinding.Input = myInputBinding; // Add the OutputBinding for the operation. OutputBinding myOutputBinding = new OutputBinding(); myOutputBinding.Extensions.Add(mySoapBodyBinding); addOperationBinding.Output = myOutputBinding; // Add the extensibility element for the SoapOperationBinding. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.Style = SoapBindingStyle.Document; mySoapOperationBinding.SoapAction = myTargetNamespace + addOperation; addOperationBinding.Extensions.Add(mySoapOperationBinding); // Get the BindingCollection from the ServiceDescription. BindingCollection myBindingCollection = myServiceDescription.Bindings; // Get the OperationBindingCollection of SOAP binding from // the BindingCollection. OperationBindingCollection myOperationBindingCollection = myBindingCollection[0].Operations; // <Snippet2> // Check for the Add OperationBinding in the collection. bool contains = myOperationBindingCollection.Contains (addOperationBinding); Console.WriteLine("\nWhether the collection contains the Add " + "OperationBinding : " + contains); // </Snippet2> // <Snippet3> // Add the Add OperationBinding to the collection. myOperationBindingCollection.Add(addOperationBinding); Console.WriteLine("\nAdded the OperationBinding of the Add" + " operation to the collection."); // </Snippet3> // <Snippet4> // <Snippet5> // Get the OperationBinding of the Add operation from the collection. OperationBinding myOperationBinding = myOperationBindingCollection[3]; // Remove the OperationBinding of the Add operation from // the collection. myOperationBindingCollection.Remove(myOperationBinding); Console.WriteLine("\nRemoved the OperationBinding of the " + "Add operation from the collection."); // </Snippet5> // </Snippet4> // <Snippet6> // <Snippet7> // Insert the OperationBinding of the Add operation at index 0. myOperationBindingCollection.Insert(0, addOperationBinding); Console.WriteLine("\nInserted the OperationBinding of the " + "Add operation in the collection."); // Get the index of the OperationBinding of the Add // operation from the collection. int index = myOperationBindingCollection.IndexOf(addOperationBinding); Console.WriteLine("\nThe index of the OperationBinding of the " + "Add operation : " + index); // </Snippet7> // </Snippet6> Console.WriteLine(""); // <Snippet8> OperationBinding[] operationBindingArray = new OperationBinding[myOperationBindingCollection.Count]; // Copy this collection to the OperationBinding array. myOperationBindingCollection.CopyTo(operationBindingArray, 0); Console.WriteLine("The operations supported by this service " + "are :"); foreach (OperationBinding myOperationBinding1 in operationBindingArray) { Binding myBinding = myOperationBinding1.Binding; Console.WriteLine(" Binding : " + myBinding.Name + " Name of " + "operation : " + myOperationBinding1.Name); } // </Snippet8> // Save the ServiceDescription to an external file. myServiceDescription.Write("MathService_new_cs.wsdl"); } catch (Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } }
public override bool IsEqual(InputBinding other, bool includeModifiers = false) { var bb = other as ButtonBinding; if (bb == null) return false; return bb.Button == Button && base.IsEqual(other, includeModifiers); }
public static void Main() { ServiceDescription myDescription = ServiceDescription.Read("HttpBinding_ctor_Input_CS.wsdl"); // <Snippet1> // <Snippet2> // Create 'Binding' object. Binding myBinding = new Binding(); myBinding.Name = "MyHttpBindingServiceHttpPost"; XmlQualifiedName qualifiedName = new XmlQualifiedName("s0:MyHttpBindingServiceHttpPost"); myBinding.Type = qualifiedName; // Create 'HttpBinding' object. HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; Console.WriteLine("HttpBinding Namespace : " + HttpBinding.Namespace); // </Snippet2> // Add 'HttpBinding' to 'Binding'. myBinding.Extensions.Add(myHttpBinding); // </Snippet1> // Create 'OperationBinding' object. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myOperation = new HttpOperationBinding(); myOperation.Location = "/AddNumbers"; // Add 'HttpOperationBinding' to 'OperationBinding'. myOperationBinding.Extensions.Add(myOperation); // Create 'InputBinding' object. InputBinding myInput = new InputBinding(); MimeContentBinding postMimeContentbinding = new MimeContentBinding(); postMimeContentbinding.Type = "application/x-www-form-urlencoded"; myInput.Extensions.Add(postMimeContentbinding); // Add 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInput; // Create 'OutputBinding' object. OutputBinding myOutput = new OutputBinding(); MimeXmlBinding postMimeXmlbinding = new MimeXmlBinding(); postMimeXmlbinding.Part = "Body"; myOutput.Extensions.Add(postMimeXmlbinding); // Add 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // Add 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.Bindings.Add(myBinding); // <Snippet3> // Create a 'Port' object. Port postPort = new Port(); postPort.Name = "MyHttpBindingServiceHttpPost"; postPort.Binding = new XmlQualifiedName("s0:MyHttpBindingServiceHttpPost"); // Create 'HttpAddressBinding' object. HttpAddressBinding postAddressBinding = new HttpAddressBinding(); postAddressBinding.Location = "http://localhost/HttpBinding_ctor/HttpBinding_ctor_Service.cs.asmx"; // Add 'HttpAddressBinding' to 'Port'. postPort.Extensions.Add(postAddressBinding); // </Snippet3> // Add 'Port' to 'PortCollection' of 'ServiceDescription'. myDescription.Services[0].Ports.Add(postPort); // Write 'ServiceDescription' as a WSDL file. myDescription.Write("HttpBinding_ctor_Output_CS.wsdl"); Console.WriteLine("WSDL file with name 'HttpBinding_ctor_Output_CS.wsdl' file created Successfully"); }
public void RemoveBinding(string bindingName, InputBinding binding) { // KeyboardManager has a 1:1 name:binding relationship, so remove and clear are identical ClearBinding(bindingName); }
/// <summary> /// Ensures only Ctrl/Alt/Shift modifiers are listed, returns null for non-Key InputBindings /// </summary> private static KeyBinding AsKeyBinding(InputBinding binding) { var keyBinding = binding as KeyBinding; if (keyBinding == null) return null; var coercedBinding = new KeyBinding(keyBinding.Key); foreach (var mod in ModifierKey.Values.Where(mod => binding.Modifiers.Contains(mod))) coercedBinding.Modifiers.Add(mod); return coercedBinding; }
/// <summary> /// Compares this Binding to another, and returns whether they are the same (with/without modifiers) /// </summary> public virtual bool IsEqual(InputBinding other, bool includeModifiers = false) { return !includeModifiers || Modifiers.SequenceEqual(other.Modifiers); }
public override bool IsEqual(InputBinding other, bool includeModifiers = false) { var tb = other as TriggerBinding; if (tb == null) return false; return tb.Trigger == Trigger && base.IsEqual(other, includeModifiers); }
public override bool IsEqual(InputBinding other, bool includeModifiers = false) { var tdb = other as ThumbstickDirectionBinding; if (tdb == null) return false; return tdb.Thumbstick == Thumbstick && tdb.Direction == Direction && base.IsEqual(other, includeModifiers); }
public static void SetCommandParameter(InputBinding element, object value) { element.CommandParameter = value; }
public override bool IsEqual(InputBinding other, bool includeModifiers = false) { var kb = other as KeyBinding; if (kb == null) return false; if (includeModifiers && other.Modifiers.Count > 0) return false; return (kb.Key == _key1 || kb.Key == _key2); }
public void UpdateHotkey_KeyOrMouseUpdated_ShouldSyncToObservableCollection(string id, InputBinding expectedBinding, Key expectedKey, ModifierKeys expectedModifierKeys, ExtendedMouseAction expectedMouseAction) { //Arrange var hotkeyCommandManager = GetMockedHotkeyCommandManager(); //Act hotkeyCommandManager.AddHotkey(id, expectedBinding); var gesture = expectedBinding.Gesture as PolyGesture; gesture.Key = expectedKey; gesture.ModifierKeys = expectedModifierKeys; gesture.MouseAction = expectedMouseAction; if (expectedMouseAction != default) { gesture.Type = GestureType.MouseGesture; } else { gesture.Type = GestureType.KeyGesture; } //if (expectedBinding is KeyBinding keyBinding) //{ // //change binding from a KeyBinding to a MouseBinding // if (expectedMouseAction != default) // { // var hotkey = hotkeyCommandManager.GetHotkey(id); // hotkey.Binding = new MouseBinding(emptyCommand, new MouseGesture(expectedMouseAction, expectedModifierKeys)); // expectedBinding = hotkey.Binding; // } // else // { // keyBinding.Key = expectedKey; // keyBinding.Modifiers = expectedModifierKeys; // } //} //else //{ // var mouseBinding = expectedBinding as MouseBinding; // //Change binding from a MouseBinding to a KeyBinding // if (expectedKey != default) // { // var hotkey = hotkeyCommandManager.GetHotkey(id); // hotkey.Binding = new KeyBinding // { // Command = emptyCommand, // Key = expectedKey, // Modifiers = expectedModifierKeys // }; // expectedBinding = hotkey.Binding; // } // else // { // //Can't set the Modifiers property without creating a new MouseGesture. // mouseBinding.Gesture = new MouseGesture(expectedMouseAction, expectedModifierKeys); // } //} var actualBinding = hotkeyCommandManager.ObservableCollection.First().Binding; //Assert Assert.Same(expectedBinding, actualBinding); var actualGesture = actualBinding.Gesture as PolyGesture; var expectedGesture = expectedBinding.Gesture as PolyGesture; AssertPolyGestureMatches(expectedGesture, actualGesture); }
public static IEnumerable <ServiceDescriptionFormatExtension> GetExtensions(this InputBinding inputBinding) { return(inputBinding.Extensions.Cast <ServiceDescriptionFormatExtension>()); }
static InputBinding Clone(InputBinding inputBinding) { // We must clone it since it contains a reference to the UIElement return((InputBinding)inputBinding.Clone()); }
public override bool IsEqual(InputBinding other, bool includeModifiers = false) { var tb = other as ThumbstickBinding; if (tb == null) return false; return tb.Thumbstick == Thumbstick && base.IsEqual(other, includeModifiers); }
float CalculateInputBindingViewRectHeight(InputBinding binding) { int numberOfFields = 3; InputType t = binding.Type; if (t == InputType.KeyButton || t == InputType.DigitalAxis) { numberOfFields++; } if (t == InputType.DigitalAxis) { numberOfFields++; } if (t == InputType.MouseAxis) { numberOfFields++; } if (t == InputType.GamepadButton) { numberOfFields++; } if (t == InputType.GamepadAnalogButton || t == InputType.GamepadAxis) { numberOfFields++; } bool isButton = t == InputType.GamepadButton || t == InputType.KeyButton; bool isAxis = t == InputType.GamepadAxis || t == InputType.MouseAxis; bool isFakeAxis = t == InputType.GamepadAnalogButton || t == InputType.DigitalAxis; if (isAxis) { numberOfFields++; } if (isButton) { numberOfFields++; } bool buttonAsAxis = isButton && binding.updateAsAxis; bool axisAsButton = isAxis && binding.updateAsButton; if (t == InputType.DigitalAxis || buttonAsAxis) { numberOfFields += 2; } if (isAxis || t == InputType.GamepadAnalogButton) { numberOfFields++; } if (isFakeAxis || axisAsButton) { numberOfFields++; } if (isFakeAxis || isAxis || buttonAsAxis) { numberOfFields += 4; } float height = INPUT_FIELD_HEIGHT * numberOfFields + FIELD_SPACING * numberOfFields + 10.0f; if (t == InputType.KeyButton && (Event.current == null || Event.current.type != EventType.KeyUp)) { if (IsGenericJoystickButton(binding.Positive)) { height += JOYSTICK_WARNING_SPACING + JOYSTICK_WARNING_HEIGHT; } } return(height); }
public bool ContainsBinding(InputBinding binding) { var keyBinding = AsKeyBinding(binding); return keyBinding != null && _bindings.Contains(keyBinding); }
void ChangeBindingPath(InputBinding b, string s) { b.path = s; b.overridePath = s; }
void ICradiatorView.AddWindowBinding(InputBinding binding) { InputBindings.Add(binding); }
public static void Main() { ServiceDescription myDescription = ServiceDescription.Read("AddNumbersInput_cs.wsdl"); // Create a 'Binding' object for the 'SOAP' protocol. Binding myBinding = new Binding(); myBinding.Name = "Service1Soap"; XmlQualifiedName qualifiedName = new XmlQualifiedName("s0:Service1Soap"); myBinding.Type = qualifiedName; // <Snippet1> SoapBinding mySoapBinding = new SoapBinding(); mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http"; mySoapBinding.Style = SoapBindingStyle.Document; // Get the URI for XML namespace of the SoapBinding class. String myNameSpace = SoapBinding.Namespace; Console.WriteLine("The URI of the XML Namespace is :" + myNameSpace); // </Snippet1> // Add the 'SoapBinding' object to the 'Binding' object. myBinding.Extensions.Add(mySoapBinding); // Create the 'OperationBinding' object for the 'SOAP' protocol. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; // Create the 'SoapOperationBinding' object for the 'SOAP' protocol. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.SoapAction = "http://tempuri.org/AddNumbers"; mySoapOperationBinding.Style = SoapBindingStyle.Document; // Add the 'SoapOperationBinding' object to 'OperationBinding' object. myOperationBinding.Extensions.Add(mySoapOperationBinding); // <Snippet2> // Create the 'InputBinding' object for the 'SOAP' protocol. InputBinding myInput = new InputBinding(); SoapBodyBinding mySoapBinding1 = new SoapBodyBinding(); mySoapBinding1.Use = SoapBindingUse.Literal; String[] myParts = new String[1]; myParts[0] = "parameters"; // Set the names of the message parts to appear in the SOAP body. mySoapBinding1.Parts = myParts; myInput.Extensions.Add(mySoapBinding1); // Add the 'InputBinding' object to 'OperationBinding' object. myOperationBinding.Input = myInput; // Create the 'OutputBinding' object'. OutputBinding myOutput = new OutputBinding(); myOutput.Extensions.Add(mySoapBinding1); // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // </Snippet2> // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.Bindings.Add(myBinding); // Write the 'ServiceDescription' as a WSDL file. myDescription.Write("AddNumbersOut_cs.wsdl"); Console.WriteLine(" 'AddNumbersOut_cs.Wsdl' file was generated"); }
void ICradiatorView.AddSettingsLinkBinding(InputBinding binding) { settingsLink.InputBindings.Add(binding); }
public static InputControl GetControl(this InputAction inputAction, InputBinding binding) { return(inputAction.controls[inputAction.IndexOfNonCompositeBinding(binding)]); }
// </SnippetKeyGestureGetProperties> private void OnLoaded(object sender, RoutedEventArgs e) { // <SnippetKeyBindingKeyGestureSetProperties> // Defining the KeyGesture. KeyGesture FindCmdKeyGesture = new KeyGesture(Key.F, (ModifierKeys.Shift | ModifierKeys.Alt)); // Defining the KeyBinding. KeyBinding FindKeyBinding = new KeyBinding( ApplicationCommands.Find, FindCmdKeyGesture); // Binding the KeyBinding to the Root Window. this.InputBindings.Add(FindKeyBinding); // </SnippetKeyBindingKeyGestureSetProperties> // <SnippetKeyBindingWithNoModifier> KeyGesture OpenCmdKeyGesture = new KeyGesture(Key.F12); KeyBinding OpenKeyBinding = new KeyBinding( ApplicationCommands.Open, OpenCmdKeyGesture); this.InputBindings.Add(OpenKeyBinding); // </SnippetKeyBindingWithNoModifier> // <SnippetKeyBindingWithKeyAndModifiers> KeyGesture CloseCmdKeyGesture = new KeyGesture( Key.L, ModifierKeys.Alt); KeyBinding CloseKeyBinding = new KeyBinding( ApplicationCommands.Close, CloseCmdKeyGesture); this.InputBindings.Add(CloseKeyBinding); // </SnippetKeyBindingWithKeyAndModifiers> // <SnippetKeyBindingMultipleModifiers> KeyBinding CopyKeyBinding = new KeyBinding( ApplicationCommands.Copy, Key.D, (ModifierKeys.Control | ModifierKeys.Shift)); this.InputBindings.Add(CopyKeyBinding); // </SnippetKeyBindingMultipleModifiers> // <SnippetKeyBindingDefatulCtor> KeyBinding RedoKeyBinding = new KeyBinding(); RedoKeyBinding.Modifiers = ModifierKeys.Alt; RedoKeyBinding.Key = Key.F; RedoKeyBinding.Command = ApplicationCommands.Redo; this.InputBindings.Add(RedoKeyBinding); // </SnippetKeyBindingDefatulCtor> // <SnippetMouseBindingAddedToInputBinding> MouseGesture OpenCmdMouseGesture = new MouseGesture(); OpenCmdMouseGesture.MouseAction = MouseAction.WheelClick; OpenCmdMouseGesture.Modifiers = ModifierKeys.Control; MouseBinding OpenCmdMouseBinding = new MouseBinding(); OpenCmdMouseBinding.Gesture = OpenCmdMouseGesture; OpenCmdMouseBinding.Command = ApplicationCommands.Open; this.InputBindings.Add(OpenCmdMouseBinding); // </SnippetMouseBindingAddedToInputBinding> // <SnippetMouseBindingAddedCommand> MouseGesture PasteCmdMouseGesture = new MouseGesture( MouseAction.MiddleClick, ModifierKeys.Alt); ApplicationCommands.Paste.InputGestures.Add(PasteCmdMouseGesture); // </SnippetMouseBindingAddedCommand> KeyGesture pasteBind = new KeyGesture(Key.V, ModifierKeys.Alt); ApplicationCommands.Paste.InputGestures.Add(pasteBind); // <SnippetInputBindingAddingCommand> KeyGesture HelpCmdKeyGesture = new KeyGesture(Key.H, ModifierKeys.Alt); InputBinding inputBinding; inputBinding = new InputBinding(ApplicationCommands.Help, HelpCmdKeyGesture); this.InputBindings.Add(inputBinding); // </SnippetInputBindingAddingCommand> // <SnippetMouseBindingMouseAction> MouseGesture CutCmdMouseGesture = new MouseGesture( MouseAction.MiddleClick); MouseBinding CutMouseBinding = new MouseBinding( ApplicationCommands.Cut, CutCmdMouseGesture); // RootWindow is an instance of Window. RootWindow.InputBindings.Add(CutMouseBinding); // </SnippetMouseBindingMouseAction> // <SnippetMouseBindingGesture> MouseGesture NewCmdMouseGesture = new MouseGesture(); NewCmdMouseGesture.Modifiers = ModifierKeys.Alt; NewCmdMouseGesture.MouseAction = MouseAction.MiddleClick; MouseBinding NewMouseBinding = new MouseBinding(); NewMouseBinding.Command = ApplicationCommands.New; NewMouseBinding.Gesture = NewCmdMouseGesture; // RootWindow is an instance of Window. RootWindow.InputBindings.Add(NewMouseBinding); // </SnippetMouseBindingGesture> }
static void Main() { try { ServiceDescription myServiceDescription = ServiceDescription.Read("MathService_input_cs.wsdl"); string myTargetNamespace = myServiceDescription.TargetNamespace; // <Snippet2> // <Snippet3> // Create an OperationBinding for the Add operation. OperationBinding addOperationBinding = new OperationBinding(); string addOperation = "Add"; addOperationBinding.Name = addOperation; // </Snippet3> // <Snippet4> // Create an InputBinding for the Add operation. InputBinding myInputBinding = new InputBinding(); SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding(); mySoapBodyBinding.Use = SoapBindingUse.Literal; myInputBinding.Extensions.Add(mySoapBodyBinding); // Add the InputBinding to the OperationBinding. addOperationBinding.Input = myInputBinding; // </Snippet4> // <Snippet5> // Create an OutputBinding for the Add operation. OutputBinding myOutputBinding = new OutputBinding(); myOutputBinding.Extensions.Add(mySoapBodyBinding); // Add the OutputBinding to the OperationBinding. addOperationBinding.Output = myOutputBinding; // </Snippet5> // <Snippet6> // Create an extensibility element for a SoapOperationBinding. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.Style = SoapBindingStyle.Document; mySoapOperationBinding.SoapAction = myTargetNamespace + addOperation; // Add the extensibility element SoapOperationBinding to // the OperationBinding. addOperationBinding.Extensions.Add(mySoapOperationBinding); // </Snippet6> // </Snippet2> // <Snippet7> ServiceDescriptionFormatExtensionCollection myExtensions; // Get the FaultBindingCollection from the OperationBinding. FaultBindingCollection myFaultBindingCollection = addOperationBinding.Faults; FaultBinding myFaultBinding = new FaultBinding(); myFaultBinding.Name = "ErrorFloat"; // Associate SOAP fault binding to the fault binding of the operation. myExtensions = myFaultBinding.Extensions; SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding(); mySoapFaultBinding.Use = SoapBindingUse.Literal; mySoapFaultBinding.Namespace = myTargetNamespace; myExtensions.Add(mySoapFaultBinding); myFaultBindingCollection.Add(myFaultBinding); // </Snippet7> // Get the BindingCollection from the ServiceDescription. BindingCollection myBindingCollection = myServiceDescription.Bindings; // Get the OperationBindingCollection of SOAP binding // from the BindingCollection. OperationBindingCollection myOperationBindingCollection = myBindingCollection[0].Operations; myOperationBindingCollection.Add(addOperationBinding); Console.WriteLine( "The operations supported by this service are:"); foreach (OperationBinding myOperationBinding in myOperationBindingCollection) { // <Snippet8> Binding myBinding = myOperationBinding.Binding; Console.WriteLine(" Binding : " + myBinding.Name + " :: Name of operation : " + myOperationBinding.Name); // </Snippet8> FaultBindingCollection myFaultBindingCollection1 = myOperationBinding.Faults; foreach (FaultBinding myFaultBinding1 in myFaultBindingCollection1) { Console.WriteLine(" Fault : " + myFaultBinding1.Name); } } // Save the ServiceDescripition to an external file. myServiceDescription.Write("MathService_new_cs.wsdl"); } catch (Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } }
public void AddOrReplace(InputBinding binding) { RemoveBindingIfExist(binding.Handle); _usedHandles.Add(binding.Handle, binding); OnPropertyChanged("Bindings"); }
public static ICommand GetCommand(InputBinding element) { return((ICommand)element.GetValue(CommandProperty)); }
public static void Main() { ServiceDescription myServiceDescription = ServiceDescription.Read("SoapBindingStyleInput_cs.wsdl"); Binding myBinding = new Binding(); myBinding.Name = "SOAPSvrMgr_SOAPBinding"; myBinding.Type = new XmlQualifiedName("tns:SOAPSvrMgr_portType"); // <Snippet1> SoapBinding mySoapBinding = new SoapBinding(); mySoapBinding.Transport = "http://schemas.xmlsoap.org/soap/http"; // Message to be transmitted contains parameters to call a procedure. mySoapBinding.Style = SoapBindingStyle.Rpc; myBinding.Extensions.Add(mySoapBinding); // </Snippet1> OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "GetServerStats"; SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.SoapAction = "http://tempuri.org/soapsvcmgr/GetServerStats"; myOperationBinding.Extensions.Add(mySoapOperationBinding); // Create InputBinding for operation for the 'SOAP' protocol. InputBinding myInputBinding = new InputBinding(); // <Snippet2> // <Snippet3> // <Snippet4> SoapBodyBinding mySoapBodyBinding = new SoapBodyBinding(); // Encode SOAP body using rules specified by the 'Encoding' property. mySoapBodyBinding.Use = SoapBindingUse.Encoded; // Set URI representing the encoding style for encoding the body. mySoapBodyBinding.Encoding = "http://schemas.xmlsoap.org/soap/encoding/"; // Set the Uri representing the location of the specification // for encoding of content not defined by 'Encoding' property'. mySoapBodyBinding.Namespace = "http://tempuri.org/soapsvcmgr/"; myInputBinding.Extensions.Add(mySoapBodyBinding); // </Snippet4> // </Snippet3> // </Snippet2> // <Snippet5> // <Snippet6> SoapHeaderBinding mySoapHeaderBinding = new SoapHeaderBinding(); mySoapHeaderBinding.Message = new XmlQualifiedName("tns:Soapsvcmgr_Headers_Request"); mySoapHeaderBinding.Part = "AuthCS"; // Encode SOAP header using rules specified by the 'Encoding' property. mySoapHeaderBinding.Use = SoapBindingUse.Encoded; // Set URI representing the encoding style for encoding the header. mySoapHeaderBinding.Encoding = "http://schemas.xmlsoap.org/soap/encoding/"; // Set the Uri representing the location of the specification // for encoding of content not defined by 'Encoding' property'. mySoapHeaderBinding.Namespace = "http://tempuri.org/SOAPSvr/soapsvcmgr/headers.xsd"; // Add mySoapHeaderBinding to the 'myInputBinding' object. myInputBinding.Extensions.Add(mySoapHeaderBinding); // </Snippet5> // </Snippet6> // Create OutputBinding for operation. OutputBinding myOutputBinding = new OutputBinding(); myOutputBinding.Extensions.Add(mySoapBodyBinding); mySoapHeaderBinding.Part = "AuthSC"; mySoapHeaderBinding.Message = new XmlQualifiedName("tns:Soapsvcmgr_Headers_Response"); myOutputBinding.Extensions.Add(mySoapHeaderBinding); // Add 'InputBinding' and 'OutputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; myOperationBinding.Output = myOutputBinding; myBinding.Operations.Add(myOperationBinding); myServiceDescription.Bindings.Add(myBinding); myServiceDescription.Write("SoapBindingStyleOutput_cs.wsdl"); Console.WriteLine("'SoapBindingStyleOutput_cs.wsdl' file is generated."); Console.WriteLine("Proxy could be created using command" + " 'wsdl SoapBindingStyleOutput_cs.wsdl'"); }
public static object GetCommandParameter(InputBinding element) { return(element.GetValue(CommandParameterProperty)); }
/// <summary> /// Add the Hot Keys and Key Bindings to the UI /// </summary> private void createCommandBindings() { try { // ---------------------------------------------------------------------------------------------- // Add the StartPauseSim Commands CommandBinding cb = new CommandBinding(startPausSimRoutedCommand, StartPausSim_CommandEventHandler); this.CommandBindings.Add(cb); toolBarStartPausSim.Command = startPausSimRoutedCommand; KeyGesture kg = new KeyGesture(Key.F11, ModifierKeys.None); InputBinding ib = new InputBinding(startPausSimRoutedCommand, kg); this.InputBindings.Add(ib); // ---------------------------------------------------------------------------------------------- // Add the StopSim Commands cb = new CommandBinding(stopSimRoutedCommand, StopSim_CommandEventHandler); this.CommandBindings.Add(cb); toolBarStopSim.Command = stopSimRoutedCommand; kg = new KeyGesture(Key.F12, ModifierKeys.None); ib = new InputBinding(stopSimRoutedCommand, kg); this.InputBindings.Add(ib); // ---------------------------------------------------------------------------------------------- // Add the OpenSim Commands cb = new CommandBinding(openSimRoutedCommand, OpenSim_CommandEventHandler); this.CommandBindings.Add(cb); toolBarOpen.Command = openSimRoutedCommand; kg = new KeyGesture(Key.O, ModifierKeys.Control); ib = new InputBinding(openSimRoutedCommand, kg); this.InputBindings.Add(ib); // ---------------------------------------------------------------------------------------------- // Add the SaveSim Commands cb = new CommandBinding(saveSimRoutedCommand, SaveSim_CommandEventHandler); this.CommandBindings.Add(cb); toolBarSave.Command = saveSimRoutedCommand; kg = new KeyGesture(Key.S, ModifierKeys.Control); ib = new InputBinding(saveSimRoutedCommand, kg); this.InputBindings.Add(ib); // ---------------------------------------------------------------------------------------------- // Add the Add new Sim Job Commands cb = new CommandBinding(addSimJobRoutedCommand, AddSimJob_CommandEventHandler); this.CommandBindings.Add(cb); toolBarAddJob.Command = addSimJobRoutedCommand; kg = new KeyGesture(Key.N, ModifierKeys.Control); ib = new InputBinding(addSimJobRoutedCommand, kg); this.InputBindings.Add(ib); // ---------------------------------------------------------------------------------------------- // Add the Remove Sim Job Commands cb = new CommandBinding(removeSimJobRoutedCommand, RemoveSimJob_CommandEventHandler); this.CommandBindings.Add(cb); toolBarRemoveJob.Command = removeSimJobRoutedCommand; // This is a standard from the Datagrid already //kg = new KeyGesture(Key.Delete, ModifierKeys.None); //ib = new InputBinding(removeSimJobRoutedCommand, kg); //this.InputBindings.Add(ib); // ---------------------------------------------------------------------------------------------- // Add the Change Continous Mode Commands cb = new CommandBinding(changeConiniousSimModeRoutedCommand, ChangeConinuousSimMode_CommandEventHandler); this.CommandBindings.Add(cb); toolBarContinousModeOnOff.Command = changeConiniousSimModeRoutedCommand; kg = new KeyGesture(Key.C, ModifierKeys.Control); ib = new InputBinding(changeConiniousSimModeRoutedCommand, kg); this.InputBindings.Add(ib); } catch { //handle exception error } }
//Modifiers public void AddHotkey_NewItemAdded_ShouldSyncToObservableCollection(string id, InputBinding expectedBinding) { //Arrange var hotkeyCommandManager = GetMockedHotkeyCommandManager(); //Act hotkeyCommandManager.AddHotkey(id, expectedBinding); hotkeyCommandManager.AddHotkey(id + "a", expectedBinding); hotkeyCommandManager.AddHotkey(id + "b", expectedBinding); var hotkey = hotkeyCommandManager.ObservableCollection.First(); //Assert Assert.Equal(3, hotkeyCommandManager.ObservableCollection.Count); Assert.Same(expectedBinding, hotkey.Binding); var actualGesture = hotkey.Binding.Gesture as PolyGesture; var expectedGesture = expectedBinding.Gesture as PolyGesture; AssertPolyGestureMatches(expectedGesture, actualGesture); }
private bool IsRebindableAction(InputAction action, InputBinding binding) { return(binding.isComposite || binding.isPartOfComposite || action.expectedControlType == "Button"); }
public static void Main() { ServiceDescription myDescription = ServiceDescription.Read("AddNumbersInput_cs.wsdl"); // Create a 'Binding' object for the 'SOAP' protocol. Binding myBinding = new Binding(); myBinding.Name = "Service1Soap"; XmlQualifiedName qualifiedName = new XmlQualifiedName("s0:Service1Soap"); myBinding.Type = qualifiedName; // <Snippet5> SoapBinding mySoapBinding = new SoapBinding(); mySoapBinding.Transport = SoapBinding.HttpTransport; mySoapBinding.Style = SoapBindingStyle.Document; // </Snippet5> // Add the 'SoapBinding' object to the 'Binding' object. myBinding.Extensions.Add(mySoapBinding); // Create the 'OperationBinding' object for the 'SOAP' protocol. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; // Create the 'SoapOperationBinding' object for the 'SOAP' protocol. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.SoapAction = "http://tempuri.org/AddNumbers"; mySoapOperationBinding.Style = SoapBindingStyle.Document; // Add the 'SoapOperationBinding' object to 'OperationBinding' object. myOperationBinding.Extensions.Add(mySoapOperationBinding); // Create the 'InputBinding' object for the 'SOAP' protocol. InputBinding myInput = new InputBinding(); SoapBodyBinding mySoapBinding1 = new SoapBodyBinding(); mySoapBinding1.Use = SoapBindingUse.Literal; myInput.Extensions.Add(mySoapBinding1); // Assign the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInput; // Create the 'OutputBinding' object' for the 'SOAP' protocol.. OutputBinding myOutput = new OutputBinding(); myOutput.Extensions.Add(mySoapBinding1); // Assign the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.Bindings.Add(myBinding); Port soapPort = new Port(); soapPort.Name = "Service1Soap"; soapPort.Binding = new XmlQualifiedName("s0:Service1Soap"); // Create a 'SoapAddressBinding' object for the 'SOAP' protocol. SoapAddressBinding mySoapAddressBinding = new SoapAddressBinding(); mySoapAddressBinding.Location = "http://localhost/AddNumbers.cs.asmx"; // Add the 'SoapAddressBinding' to the 'Port'. soapPort.Extensions.Add(mySoapAddressBinding); // Add the 'Port' to 'PortCollection' of 'ServiceDescription'. myDescription.Services[0].Ports.Add(soapPort); // Write the 'ServiceDescription' as a WSDL file. myDescription.Write("AddNumbersOut_cs.wsdl"); Console.WriteLine(" 'AddNumbersOut_cs.Wsdl' file was generated"); }
public static void Main() { try { // Input wsdl file. string myInputWsdlFile = "SoapFaultInput_cs.wsdl"; // Output wsdl file. string myOutputWsdlFile = "SoapFaultOutput_cs.wsdl"; // Initialize an instance of a 'ServiceDescription' object. ServiceDescription myServiceDescription = ServiceDescription.Read(myInputWsdlFile); // Get a SOAP binding object with binding name "MyService1Soap". Binding myBinding = myServiceDescription.Bindings["MyService1Soap"]; // Create the 'OperationBinding' object for the 'SOAP' protocol. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "Add"; // Create the 'SoapOperationBinding' object for the 'SOAP' protocol. SoapOperationBinding mySoapOperationBinding = new SoapOperationBinding(); mySoapOperationBinding.SoapAction = "http://tempuri.org/Add"; mySoapOperationBinding.Style = SoapBindingStyle.Document; // Add the 'SoapOperationBinding' object to 'OperationBinding' object. myOperationBinding.Extensions.Add(mySoapOperationBinding); // <Snippet1> // Create the 'InputBinding' object for the 'SOAP' protocol. InputBinding myInput = new InputBinding(); SoapBodyBinding mySoapBinding1 = new SoapBodyBinding(); mySoapBinding1.PartsString = "parameters"; mySoapBinding1.Use = SoapBindingUse.Literal; myInput.Extensions.Add(mySoapBinding1); // Assign the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInput; // Create the 'OutputBinding' object' for the 'SOAP' protocol.. OutputBinding myOutput = new OutputBinding(); myOutput.Extensions.Add(mySoapBinding1); // Assign the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutput; // </Snippet1> // <Snippet2> // <Snippet3> // <Snippet4> // <Snippet5> // Create a new instance of 'SoapFaultBinding' class. SoapFaultBinding mySoapFaultBinding = new SoapFaultBinding(); // Encode fault message using rules specified by 'Encoding' property. mySoapFaultBinding.Use = SoapBindingUse.Encoded; // Set the URI representing the encoding style. mySoapFaultBinding.Encoding = "http://tempuri.org/stockquote"; // Set the URI representing the location of the specification // for encoding of content not defined by 'Encoding' property'. mySoapFaultBinding.Namespace = "http://tempuri.org/stockquote"; // Create a new instance of 'FaultBinding'. FaultBinding myFaultBinding = new FaultBinding(); myFaultBinding.Name = "AddFaultbinding"; myFaultBinding.Extensions.Add(mySoapFaultBinding); // Get existing 'OperationBinding' object. myOperationBinding.Faults.Add(myFaultBinding); myBinding.Operations.Add(myOperationBinding); // </Snippet5> // </Snippet4> // </Snippet3> // </Snippet2> // Create a new wsdl file. myServiceDescription.Write(myOutputWsdlFile); Console.WriteLine("The new wsdl file created is :" + myOutputWsdlFile); Console.WriteLine("Proxy could be created using command : wsdl " + myOutputWsdlFile); } catch (Exception e) { Console.WriteLine("Error occurred : " + e.Message); } }
public static void Main() { try { ServiceDescription myDescription = ServiceDescription.Read("Operation_2_Input_CS.wsdl"); Binding myBinding = new Binding(); myBinding.Name = "Operation_2_ServiceHttpPost"; XmlQualifiedName myQualifiedName = new XmlQualifiedName("s0:Operation_2_ServiceHttpPost"); myBinding.Type = myQualifiedName; HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb="POST"; // Add the 'HttpBinding' to the 'Binding'. myBinding.Extensions.Add(myHttpBinding); OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myHttpOperationBinding = new HttpOperationBinding(); myHttpOperationBinding.Location="/AddNumbers"; // Add the 'HttpOperationBinding' to 'OperationBinding'. myOperationBinding.Extensions.Add(myHttpOperationBinding); InputBinding myInputBinding = new InputBinding(); MimeContentBinding myPostMimeContentbinding = new MimeContentBinding(); myPostMimeContentbinding.Type="application/x-www-form-urlencoded"; myInputBinding.Extensions.Add(myPostMimeContentbinding); // Add the 'InputBinding' to 'OperationBinding'. myOperationBinding.Input = myInputBinding; OutputBinding myOutputBinding = new OutputBinding(); MimeXmlBinding myPostMimeXmlbinding = new MimeXmlBinding(); myPostMimeXmlbinding .Part="Body"; myOutputBinding.Extensions.Add(myPostMimeXmlbinding); // Add the 'OutPutBinding' to 'OperationBinding'. myOperationBinding.Output = myOutputBinding; // Add the 'OperationBinding' to 'Binding'. myBinding.Operations.Add(myOperationBinding); // Add the 'Binding' to 'BindingCollection' of 'ServiceDescription'. myDescription.Bindings.Add(myBinding); Port myPostPort = new Port(); myPostPort.Name = "Operation_2_ServiceHttpPost"; myPostPort.Binding = new XmlQualifiedName("s0:Operation_2_ServiceHttpPost"); HttpAddressBinding myPostAddressBinding = new HttpAddressBinding(); myPostAddressBinding.Location = "http://localhost/Operation_2/Operation_2_Service.cs.asmx"; // Add the 'HttpAddressBinding' to the 'Port'. myPostPort.Extensions.Add(myPostAddressBinding); // Add the 'Port' to 'PortCollection' of 'ServiceDescription'. myDescription.Services[0].Ports.Add(myPostPort); PortType myPostPortType = new PortType(); myPostPortType.Name = "Operation_2_ServiceHttpPost"; Operation myPostOperation = new Operation(); myPostOperation.Name = "AddNumbers"; OperationMessage myPostOperationInput = (OperationMessage)new OperationInput(); myPostOperationInput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn"); OperationMessage myPostOperationOutput = (OperationMessage)new OperationOutput(); myPostOperationOutput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostout"); myPostOperation.Messages.Add(myPostOperationInput); myPostOperation.Messages.Add(myPostOperationOutput); // Add the 'Operation' to 'PortType'. myPostPortType.Operations.Add(myPostOperation); // Adds the 'PortType' to 'PortTypeCollection' of 'ServiceDescription'. myDescription.PortTypes.Add(myPostPortType); Message myPostMessage1 = new Message(); myPostMessage1.Name="AddNumbersHttpPostIn"; MessagePart myPostMessagePart1 = new MessagePart(); myPostMessagePart1.Name = "firstnumber"; myPostMessagePart1.Type = new XmlQualifiedName("s:string"); MessagePart myPostMessagePart2 = new MessagePart(); myPostMessagePart2.Name = "secondnumber"; myPostMessagePart2.Type = new XmlQualifiedName("s:string"); // Add the 'MessagePart' objects to 'Messages'. myPostMessage1.Parts.Add(myPostMessagePart1); myPostMessage1.Parts.Add(myPostMessagePart2); Message myPostMessage2 = new Message(); myPostMessage2.Name = "AddNumbersHttpPostout"; MessagePart myPostMessagePart3 = new MessagePart(); myPostMessagePart3.Name = "Body"; myPostMessagePart3.Element = new XmlQualifiedName("s0:int"); // Add the 'MessagePart' to 'Message'. myPostMessage2.Parts.Add(myPostMessagePart3 ); // Add the 'Message' objects to 'ServiceDescription'. myDescription.Messages.Add(myPostMessage1); myDescription.Messages.Add(myPostMessage2); // Write the 'ServiceDescription' as a WSDL file. myDescription.Write("Operation_2_Output_CS.wsdl"); Console.WriteLine(" 'Operation_2_Output_CS.wsdl' file created Successfully"); // <Snippet1> // <Snippet2> string myString = null ; Operation myOperation = new Operation(); myDescription = ServiceDescription.Read("Operation_2_Input_CS.wsdl"); Message[] myMessage = new Message[ myDescription.Messages.Count ] ; // Copy the messages from the service description. myDescription.Messages.CopyTo( myMessage, 0 ); for( int i = 0 ; i < myDescription.Messages.Count; i++ ) { MessagePart[] myMessagePart = new MessagePart[ myMessage[i].Parts.Count ]; // Copy the message parts into a MessagePart. myMessage[i].Parts.CopyTo( myMessagePart, 0 ); for( int j = 0 ; j < myMessage[i].Parts.Count; j++ ) { myString += myMessagePart[j].Name; myString += " " ; } } // Set the ParameterOrderString equal to the list of // message part names. myOperation.ParameterOrderString = myString; string[] myString1 = myOperation.ParameterOrder; int k = 0 ; Console.WriteLine("The list of message part names is as follows:"); while( k<5 ) { Console.WriteLine( myString1[k] ); k++; } // </Snippet2> // </Snippet1> } catch( Exception e ) { Console.WriteLine( "The following Exception is raised : " + e.Message ); } }
CollectionAction DrawInputBindingFields(Rect position, string label, InputAction action, int bindingIndex) { Rect headerRect = new Rect(position.x + 5.0f, position.y, position.width, INPUT_FIELD_HEIGHT); Rect layoutArea = new Rect(position.x + 10.0f, position.y + INPUT_FIELD_HEIGHT + FIELD_SPACING + 5.0f, position.width - 12.5f, position.height - (INPUT_FIELD_HEIGHT + FIELD_SPACING + 5.0f)); InputBinding binding = action.bindings[bindingIndex]; CollectionAction result = CollectionAction.None; EditorGUI.LabelField(headerRect, label, EditorStyles.boldLabel); GUILayout.BeginArea(layoutArea); binding.Type = (InputType)EditorGUILayout.EnumPopup("Type", binding.Type); InputType t = binding.Type; if (t == InputType.KeyButton || t == InputType.DigitalAxis) { binding.Positive = (KeyCode)EditorGUILayout.EnumPopup("Positive", binding.Positive); } if (t == InputType.DigitalAxis) { binding.Negative = (KeyCode)EditorGUILayout.EnumPopup("Negative", binding.Negative); } if (t == InputType.MouseAxis) { binding.MouseAxis = EditorGUILayout.Popup("Axis", binding.MouseAxis, InputBinding.mouseAxisNames); } if (t == InputType.GamepadButton) { binding.GamepadButton = (GamepadButton)EditorGUILayout.EnumPopup("Button", binding.GamepadButton); } if (t == InputType.GamepadAnalogButton || t == InputType.GamepadAxis) { binding.GamepadAxis = (GamepadAxis)EditorGUILayout.EnumPopup("Axis", binding.GamepadAxis); } bool isButton = t == InputType.GamepadButton || t == InputType.KeyButton; bool isAxis = t == InputType.GamepadAxis || t == InputType.MouseAxis; bool isFakeAxis = t == InputType.GamepadAnalogButton || t == InputType.DigitalAxis; if (isAxis) { binding.updateAsButton = EditorGUILayout.Toggle("Update As Button", binding.updateAsButton); } if (isButton) { binding.updateAsAxis = EditorGUILayout.Toggle("Update As Axis", binding.updateAsAxis); } bool buttonAsAxis = isButton && binding.updateAsAxis; bool axisAsButton = isAxis && binding.updateAsButton; if (isAxis || t == InputType.GamepadAnalogButton) { binding.DeadZone = EditorGUILayout.FloatField(m_deadZoneInfo, binding.DeadZone); } if (t == InputType.DigitalAxis || buttonAsAxis) { binding.Gravity = EditorGUILayout.FloatField(m_gravityInfo, binding.Gravity); binding.SnapWhenReadAsAxis = EditorGUILayout.Toggle(m_snapInfo, binding.SnapWhenReadAsAxis); } if (isFakeAxis || axisAsButton) { binding.useNegativeAxisForButton = EditorGUILayout.Toggle("Use Negative Axis For Button Query", binding.useNegativeAxisForButton); } binding.rebindable = EditorGUILayout.Toggle("Rebindable", binding.rebindable); if (isFakeAxis || isAxis || buttonAsAxis) { binding.Sensitivity = EditorGUILayout.FloatField(m_sensitivityInfo, binding.Sensitivity); binding.sensitivityEditable = EditorGUILayout.Toggle("Sensitivity Editable", binding.sensitivityEditable); binding.InvertWhenReadAsAxis = EditorGUILayout.Toggle("Invert When Axis Query", binding.InvertWhenReadAsAxis); binding.invertEditable = EditorGUILayout.Toggle("Invert Editable", binding.invertEditable); } GUILayout.EndArea(); Rect r = new Rect(position.width - 25.0f, position.y + 2, 20.0f, 20.0f); if (action.bindings.Count < InputAction.MAX_BINDINGS) { if (GUI.Button(r, m_plusButtonContent, GUITools.label)) { result = CollectionAction.Add; } } r.x -= r.width; if (GUI.Button(r, m_minusButtonContent, GUITools.label)) { result = CollectionAction.Remove; } r.x -= r.width; if (GUI.Button(r, m_upButtonContent, GUITools.label)) { result = CollectionAction.MoveUp; } r.x -= r.width; if (GUI.Button(r, m_downButtonContent, GUITools.label)) { result = CollectionAction.MoveDown; } r.x -= r.width; return(result); }
public void StartDetectPtt(DetectPttCallback callback) { _detectPtt = true; //detect the state of all current buttons var pttInputThread = new Thread(() => { while (_detectPtt) { var bindStates = GenerateBindStateList(); GetBindStates(ref bindStates); for (var i = 0; i < bindStates.Count; i++) { //contains main binding and optional modifier binding + states of each var bindState = bindStates[i]; if (bindState.ModifierDevice != null) { bindState.IsActive = bindState.MainDeviceState && bindState.ModifierState; } else { bindState.IsActive = bindState.MainDeviceState; } //now check this is the best binding and no previous ones are better //Means you can have better binds like PTT = Space and Radio 1 is Space +1 - holding space +1 will actually trigger radio 1 not PTT if (bindState.IsActive) { for (int j = 0; j < i; j++) { //check previous bindings var previousBind = bindStates[j]; if (previousBind.IsActive) { if (previousBind.ModifierDevice == null && bindState.ModifierDevice != null) { //set previous bind to off if previous bind Main == main or modifier of bindstate if (previousBind.MainDevice.IsSameBind(bindState.MainDevice)) { previousBind.IsActive = false; break; } if (previousBind.MainDevice.IsSameBind(bindState.ModifierDevice)) { previousBind.IsActive = false; break; } } else if (previousBind.ModifierDevice != null && bindState.ModifierDevice == null) { if (previousBind.MainDevice.IsSameBind(bindState.MainDevice)) { bindState.IsActive = false; break; } if (previousBind.ModifierDevice.IsSameBind(bindState.MainDevice)) { bindState.IsActive = false; break; } } } } } } callback(bindStates); //handle overlay foreach (var bindState in bindStates) { if (bindState.IsActive && bindState.MainDevice.InputBind == InputBinding.OverlayToggle) { //run on main Application.Current.Dispatcher.Invoke( () => { _toggleOverlayCallback(false); }); break; } else if ((int)bindState.MainDevice.InputBind >= (int)InputBinding.Up100 && (int)bindState.MainDevice.InputBind <= (int)InputBinding.RadioChannelDown) { if (bindState.MainDevice.InputBind == _lastActiveBinding && !bindState.IsActive) { //Assign to a totally different binding to mark as unassign _lastActiveBinding = InputBinding.ModifierIntercom; } //key repeat if (bindState.IsActive && (bindState.MainDevice.InputBind != _lastActiveBinding)) { _lastActiveBinding = bindState.MainDevice.InputBind; var dcsPlayerRadioInfo = ClientStateSingleton.Instance.DcsPlayerRadioInfo; if (dcsPlayerRadioInfo != null && dcsPlayerRadioInfo.IsCurrent()) { switch (bindState.MainDevice.InputBind) { case InputBinding.Up100: RadioHelper.UpdateRadioFrequency(100, dcsPlayerRadioInfo.selected); break; case InputBinding.Up10: RadioHelper.UpdateRadioFrequency(10, dcsPlayerRadioInfo.selected); break; case InputBinding.Up1: RadioHelper.UpdateRadioFrequency(1, dcsPlayerRadioInfo.selected); break; case InputBinding.Up01: RadioHelper.UpdateRadioFrequency(0.1, dcsPlayerRadioInfo.selected); break; case InputBinding.Up001: RadioHelper.UpdateRadioFrequency(0.01, dcsPlayerRadioInfo.selected); break; case InputBinding.Up0001: RadioHelper.UpdateRadioFrequency(0.001, dcsPlayerRadioInfo.selected); break; case InputBinding.Down100: RadioHelper.UpdateRadioFrequency(-100, dcsPlayerRadioInfo.selected); break; case InputBinding.Down10: RadioHelper.UpdateRadioFrequency(-10, dcsPlayerRadioInfo.selected); break; case InputBinding.Down1: RadioHelper.UpdateRadioFrequency(-1, dcsPlayerRadioInfo.selected); break; case InputBinding.Down01: RadioHelper.UpdateRadioFrequency(-0.1, dcsPlayerRadioInfo.selected); break; case InputBinding.Down001: RadioHelper.UpdateRadioFrequency(-0.01, dcsPlayerRadioInfo.selected); break; case InputBinding.Down0001: RadioHelper.UpdateRadioFrequency(-0.001, dcsPlayerRadioInfo.selected); break; case InputBinding.ToggleGuard: RadioHelper.ToggleGuard(dcsPlayerRadioInfo.selected); break; case InputBinding.ToggleEncryption: RadioHelper.ToggleEncryption(dcsPlayerRadioInfo.selected); break; case InputBinding.NextRadio: RadioHelper.SelectNextRadio(); break; case InputBinding.PreviousRadio: RadioHelper.SelectPreviousRadio(); break; case InputBinding.EncryptionKeyIncrease: RadioHelper.IncreaseEncryptionKey(dcsPlayerRadioInfo.selected); break; case InputBinding.EncryptionKeyDecrease: RadioHelper.DecreaseEncryptionKey(dcsPlayerRadioInfo.selected); break; case InputBinding.RadioChannelUp: RadioHelper.RadioChannelUp(dcsPlayerRadioInfo.selected); break; case InputBinding.RadioChannelDown: RadioHelper.RadioChannelDown(dcsPlayerRadioInfo.selected); break; default: break; } } break; } } } Thread.Sleep(1); } }); pttInputThread.Start(); }
public override bool IsEqual(InputBinding other, bool includeModifiers = false) { var kb = other as KeyBinding; if (kb == null) return false; return kb.Key == Key && base.IsEqual(other, includeModifiers); }