private void LogRecording(IInputSequence sequence) { if (InvokeRequired) { Invoke((Action) (() => LogRecording(sequence))); return; } string message = string.Format("{0}", sequence.HumanString); this.recordLog.AppendText(message); this.recordLog.AppendText(Environment.NewLine); }
private void RecordingMade(IInputSequence input) { this.provider.Detach(); if (input.IsSystem) { var result = MessageBox.Show( string.Format("The input you provided ({0}) is a known system sequence. Binding this to a command may make your computer inoperable. Do you want to bind the sequence anyway?", input.HumanString), "System Binding Detected", MessageBoxButton.YesNo, MessageBoxImage.Warning ); if (result != MessageBoxResult.Yes) { StartRecording(); return; } } if (input.IsCommon) { var result = MessageBox.Show( string.Format("The input you provided ({0}) is a known commonly-used sequence. Binding this to a command may make your computer inoperable or difficult to use. Do you want to bind the sequence anyway?", input.HumanString), "Common Binding Detected", MessageBoxButton.YesNo, MessageBoxImage.Warning ); if (result != MessageBoxResult.Yes) { StartRecording(); return; } } InputSequence = input; var closeSuccess = new Action(() => { if (IsVisible) { DialogResult = true; Close(); } }); Dispatcher.BeginInvoke(closeSuccess); }
public CommandBinding(IInputSequence input, ICommand command) { this.input = input; this.command = command; }
private void StartRecording() { if (!Dispatcher.CheckAccess()) { Dispatcher.BeginInvoke(new Action(StartRecording)); return; } InputSequence = null; var handle = new WindowInteropHelper(this).Handle; this.provider.AttachRecorder(RecordingMade); }
public DefaultBindingAttribute(Type providerType, IInputSequence inputSequence) { this.providerType = providerType; this.inputSequence = inputSequence; }
public DefaultBindingAttribute(Type providerType, Type inputSequenceType, params object[] constructorParameters) { this.providerType = providerType; this.inputSequence = (IInputSequence) Activator.CreateInstance(inputSequenceType, constructorParameters); }
public bool Equals(IInputSequence other) { var otherSequence = other as DirectInputSequence; if (otherSequence == null) { return false; } return this.inputString == otherSequence.inputString; }
private void OnNewRecording(IInputSequence sequence) { // Calling the recording handler must be asynchronous. Else, if // the handler calls e.g. Detach, a deadlock will occur. // In addition, calls to the handler are in a single thread // so only one handler executes at a time, so it appears // synchronous to calling code. this.recordedSequenceQueue.Enqueue(sequence); }