public static bool TryGetKeyByCharacter(string text, out HardwareKey key) { key = HardwareKey.None; if (string.IsNullOrEmpty(text)) { return(false); } if (text.Length != 1) { return(false); } var mappingExists = SpecialDefaultTexts.Any(p => p.Value == text); if (!mappingExists) { return(false); } var mapping = SpecialDefaultTexts.First(p => p.Value == text); key = mapping.Key; return(true); }
public StatLog() { _stats = new Collection <Stat>(); // Get the key for this display _hardwareKey = new HardwareKey(); }
public BlackList() { // Check that the black list file is available blackListFile = ApplicationSettings.Default.LibraryPath + @"\" + ApplicationSettings.Default.BlackListLocation; // Get the key for this display hardwareKey = new HardwareKey(); }
/// <summary> /// Runs the agent /// </summary> public void Run() { Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Started"), LogType.Info.ToString()); while (!_forceStop) { lock (_locker) { try { // If we are restarting, reset _manualReset.Reset(); HardwareKey key = new HardwareKey(); Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Woken and Lock Obtained"), LogType.Info.ToString()); using (xmds.xmds xmds = new xmds.xmds()) { xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds; xmds.UseDefaultCredentials = false; RegisterAgent.ProcessRegisterXml(xmds.RegisterDisplay(ApplicationSettings.Default.ServerKey, key.Key, ApplicationSettings.Default.DisplayName, "windows", ApplicationSettings.Default.ClientVersion, ApplicationSettings.Default.ClientCodeVersion, Environment.OSVersion.ToString(), key.MacAddress)); // Set the flag to indicate we have a connection to XMDS ApplicationSettings.Default.XmdsLastConnection = DateTime.Now; // Do we need to send a screenshot? if (ApplicationSettings.Default.ScreenShotRequested) { ApplicationSettings.Default.ScreenShotRequested = false; ScreenShot.TakeAndSend(); } } } catch (WebException webEx) { // Increment the quantity of XMDS failures and bail out ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("RegisterAgent - Run", "WebException in Run: " + webEx.Message), LogType.Error.ToString()); } catch (Exception ex) { // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Exception in Run: " + ex.Message), LogType.Error.ToString()); } } // Sleep this thread until the next collection interval _manualReset.WaitOne((int)(ApplicationSettings.Default.CollectInterval * ApplicationSettings.Default.XmdsCollectionIntervalFactor() * 1000)); } Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Stopped"), LogType.Info.ToString()); }
private void InitializeListener() { // Make a new collection of TraceMessages _traceMessages = new Collection <TraceMessage>(); _logPath = ApplicationSettings.Default.LibraryPath + @"\" + ApplicationSettings.Default.LogLocation; // Get the key for this display _hardwareKey = new HardwareKey(); }
/// <summary> /// Runs the agent /// </summary> public void Run() { Trace.WriteLine(new LogMessage("LogAgent - Run", "Thread Started"), LogType.Info.ToString()); while (!_forceStop) { lock (_locker) { try { // If we are restarting, reset _manualReset.Reset(); HardwareKey key = new HardwareKey(); Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Woken and Lock Obtained"), LogType.Audit.ToString()); using (xmds.xmds xmds = new xmds.xmds()) { xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=submitLog"; xmds.UseDefaultCredentials = false; // Log ProcessFiles(xmds, key.Key, ApplicationSettings.Default.LogLocation); xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=submitStats"; // Stat ProcessFiles(xmds, key.Key, ApplicationSettings.Default.StatsLogFile); } } catch (WebException webEx) { // Increment the quantity of XMDS failures and bail out ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("LogAgent - Run", "WebException in Run: " + webEx.Message), LogType.Info.ToString()); } catch (Exception ex) { // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("LogAgent - Run", "Exception in Run: " + ex.Message), LogType.Error.ToString()); } } // Sleep this thread until the next collection interval _manualReset.WaitOne((int)(ApplicationSettings.Default.CollectInterval * ApplicationSettings.Default.XmdsCollectionIntervalFactor() * 1000)); } Trace.WriteLine(new LogMessage("LogAgent - Run", "Thread Stopped"), LogType.Info.ToString()); }
/// <summary> /// Runs the agent /// </summary> public void Run() { Trace.WriteLine(new LogMessage("LogAgent - Run", "Thread Started"), LogType.Info.ToString()); while (!_forceStop) { lock (_locker) { try { // If we are restarting, reset _manualReset.Reset(); HardwareKey key = new HardwareKey(); Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Woken and Lock Obtained"), LogType.Info.ToString()); using (xmds.xmds xmds = new xmds.xmds()) { xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.R23SignageClient_xmds_xmds; xmds.UseDefaultCredentials = false; // Log ProcessFiles(xmds, key.Key, ApplicationSettings.Default.LogLocation); // Stat ProcessFiles(xmds, key.Key, ApplicationSettings.Default.StatsLogFile); } } catch (WebException webEx) { // Increment the quantity of XMDS failures and bail out ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("LogAgent - Run", "WebException in Run: " + webEx.Message), LogType.Error.ToString()); } catch (Exception ex) { // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("LogAgent - Run", "Exception in Run: " + ex.Message), LogType.Error.ToString()); } } // Sleep this thread until the next collection interval _manualReset.WaitOne((int)(ApplicationSettings.Default.CollectInterval * ApplicationSettings.Default.XmdsCollectionIntervalFactor() * 1000)); } Trace.WriteLine(new LogMessage("LogAgent - Run", "Thread Stopped"), LogType.Info.ToString()); }
public HardwareKeyMappingTarget(HardwareKey hardwareKey, Modifier modifiers = Modifier.None) { HardwareKey = hardwareKey; Modifiers = modifiers; var modifiersString = modifiers.ToCombinedString(); if (modifiersString != null) { Name = modifiersString + ModifierExtensions.ModifierCombiner; } Name += Enum.GetName(typeof(HardwareKey), hardwareKey); }
private string callRegister(xmds.xmds xmds, HardwareKey key) { return(xmds.RegisterDisplay( ApplicationSettings.Default.ServerKey, key.Key, ApplicationSettings.Default.DisplayName, "windows", ApplicationSettings.Default.ClientVersion, ApplicationSettings.Default.ClientCodeVersion, Environment.OSVersion.ToString(), key.MacAddress, key.Channel, key.getXmrPublicKey())); }
/// <summary> /// Register display clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonRegister_Click(object sender, EventArgs e) { // Make a new hardware key just in case we have changed it in the form. _hardwareKey = new HardwareKey(); textBoxResults.Text = "Sending Request"; Settings.Default.Xmds = textBoxXmdsUri.Text.TrimEnd('/') + @"/data.asmx"; // xmds.Url = Settings.Default.Xmds; Settings.Default.displayName = textBoxDisplayName.Text; Settings.Default.Save(); xmds.RegisterDisplayAsync(Settings.Default.ServerKey, _hardwareKey.Key, textBoxDisplayName.Text, Settings.Default.Version); }
public void InitializeComponents() { this._hardwareKey = new HardwareKey(); this._xmdsProcessing = false; this._xmds2.RequiredFilesCompleted += new EventHandler <RequiredFilesCompletedEventArgs>(this.Xmds2RequiredFilesCompleted); this._xmds2.ScheduleCompleted += new EventHandler <ScheduleCompletedEventArgs>(this.xmds2_ScheduleCompleted); Trace.WriteLine(string.Format("Collection Interval: {0}", Settings.Default.collectInterval), "Schedule - InitializeComponents"); new Thread(() => { while (true) { XmdsTimerTick(null, null); Thread.Sleep(1000); } }).Start(); //System.Timers.Timer timer = new System.Timers.Timer //{ // Interval = 1000.0 //}; //timer.Elapsed += new ElapsedEventHandler(this.XmdsTimerTick); //timer.Start(); new Thread(() => { while (true) { ScheduleTimerTick(null, null); Thread.Sleep(10000); } }).Start(); //System.Timers.Timer timer2 = new System.Timers.Timer //{ // Interval = 10000.0 //}; //timer2.Elapsed += new ElapsedEventHandler(this.ScheduleTimerTick); //timer2.Start(); this._xmdsProcessing = true; this.UpdateLayoutSchedule(true); if (!CollectingFiles) { CollectingFiles = true; this._xmds2.RequiredFilesAsync(Settings.Default.ServerKey, this._hardwareKey.Key, Settings.Default.Version); } }
public static bool ProcessCharacter(VisualElement element, char keyCode) { if (element == null) { return(false); } if (keyDownCaptured) { keyDownCaptured = false; return(false); } var keyInput = ("" + keyCode).ToUpper(); //System.Diagnostics.Debug.WriteLine("ProcessCharacter keyInput=[" + keyInput + "]"); var modifiers = GetModifierKeys(char.IsLetter(keyCode)); //var result = new Forms9Patch.HardwareKey(keyInput, GetModifierKeys()); var listeners = element.GetHardwareKeyListeners(); #pragma warning disable CC0006 // Use foreach for (int i = 0; i < listeners.Count; i++) #pragma warning restore CC0006 // Use foreach { var listener = listeners[i]; if (string.IsNullOrEmpty(listener?.HardwareKey?.KeyInput)) { continue; } if (listener.HardwareKey.KeyInput == keyInput.ToUpper() && (listener.HardwareKey.ModifierKeys == modifiers || listener.HardwareKey.ModifierKeys.HasFlag(HardwareKeyModifierKeys.Any))) { if (listener.Command != null && listener.Command.CanExecute(listener.CommandParameter)) { listener.Command.Execute(listener.CommandParameter); } var observedHardwareKey = new HardwareKey(keyInput.ToUpper(), modifiers); listener.Pressed?.Invoke(element, new HardwareKeyEventArgs(observedHardwareKey, element)); return(true); } } return(false); }
/// <summary> /// Initialize the Schedule components /// </summary> public void InitializeComponents() { // Get the key for this display _hardwareKey = new HardwareKey(); // Start up the Xmds Service Object //_xmds2.Credentials = null; //_xmds2.Url = Properties.Settings.Default.Client_xmds_xmds; //_xmds2.UseDefaultCredentials = false; _xmdsProcessing = false; _xmds2.RequiredFilesCompleted += (Xmds2RequiredFilesCompleted); _xmds2.ScheduleCompleted += (xmds2_ScheduleCompleted); Trace.WriteLine(String.Format("Collection Interval: {0}", Settings.Default.collectInterval), "Schedule - InitializeComponents"); // The Timer for the Service call Timer xmdsTimer = new Timer(); xmdsTimer.Interval = 1000;// (int) Settings.Default.collectInterval * 1000; xmdsTimer.Elapsed += XmdsTimerTick; xmdsTimer.Start(); // The Timer for the Schedule Polling Timer scheduleTimer = new Timer(); scheduleTimer.Interval = 10000; // 10 Seconds scheduleTimer.Elapsed += ScheduleTimerTick; scheduleTimer.Start(); // Manual first tick _xmdsProcessing = true; // We must have a schedule by now. UpdateLayoutSchedule(true); // Fire off a get required files event - async _xmds2.RequiredFilesAsync(Settings.Default.ServerKey, _hardwareKey.Key, Settings.Default.Version); }
public OptionForm() { InitializeComponent(); // Set the icon Icon = Icon.ExtractAssociatedIcon(Application.ExecutablePath); // Hide unnecessary fields if (Application.ProductName != "Xibo") { label17.Hide(); linkLabel1.Hide(); } // Get a hardware key here, just in case we havent been able to get one before _hardwareKey = new HardwareKey(); // XMDS completed event xmds1.RegisterDisplayCompleted += new XiboClient2.Processor.xmds.RegisterDisplayCompletedEventHandler(xmds1_RegisterDisplayCompleted); // Set global proxy information OptionForm.SetGlobalProxy(); // Settings Tab textBoxXmdsUri.Text = ApplicationSettings.Default.ServerUri; textBoxServerKey.Text = ApplicationSettings.Default.ServerKey; textBoxLibraryPath.Text = ApplicationSettings.Default.LibraryPath; tbHardwareKey.Text = ApplicationSettings.Default.HardwareKey; // Proxy Tab textBoxProxyUser.Text = ApplicationSettings.Default.ProxyUser; maskedTextBoxProxyPass.Text = ApplicationSettings.Default.ProxyPassword; textBoxProxyDomain.Text = ApplicationSettings.Default.ProxyDomain; // Appearance Tab splashOverride.Text = ApplicationSettings.Default.SplashOverride; Debug.WriteLine("Loaded Options Form", "OptionForm"); }
public bool Equals(CharacterMappingTarget other) { var equals = false; // Try to convert char to key switch (Modifiers) { case Modifier.Shift: equals = other.Character.ToString() == HardwareKey.ToString().ToUpper(); break; case Modifier.None: equals = other.Character.ToString() == HardwareKey.ToString().ToLower(); break; } // Special case: Space if (!equals) { equals |= (other.Character == ' ' && HardwareKey == HardwareKey.Space); } return(equals); }
/// <summary> /// Runs the agent /// </summary> public void Run() { Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Started"), LogType.Info.ToString()); int retryAfterSeconds = 0; while (!_forceStop) { lock (_locker) { try { // If we are restarting, reset _manualReset.Reset(); // Reset backOff retryAfterSeconds = 0; HardwareKey key = new HardwareKey(); Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Woken and Lock Obtained"), LogType.Info.ToString()); using (xmds.xmds xmds = new xmds.xmds()) { xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=registerDisplay"; xmds.UseDefaultCredentials = false; // Store the XMR address string xmrAddress = ApplicationSettings.Default.XmrNetworkAddress; RegisterAgent.ProcessRegisterXml(callRegister(xmds, key)); // Set the flag to indicate we have a connection to XMDS ApplicationSettings.Default.XmdsLastConnection = DateTime.Now; // Has the XMR address changed? if (xmrAddress != ApplicationSettings.Default.XmrNetworkAddress) { OnXmrReconfigure(); } // Notify Status NotifyStatus(); // Have we been asked to move CMS instance? // CMS MOVE // -------- if (!string.IsNullOrEmpty(ApplicationSettings.Default.NewCmsAddress) && !string.IsNullOrEmpty(ApplicationSettings.Default.NewCmsKey) && ApplicationSettings.Default.NewCmsAddress != ApplicationSettings.Default.ServerUri ) { // Make a call using the new details, and see if it works. string oldUri = ApplicationSettings.Default.ServerUri; string oldKey = ApplicationSettings.Default.ServerKey; ApplicationSettings.Default.ServerUri = ApplicationSettings.Default.NewCmsAddress; ApplicationSettings.Default.ServerKey = ApplicationSettings.Default.NewCmsKey; Trace.WriteLine(new LogMessage("RegisterAgent - Run", "We have been asked to move to a new CMS. " + ApplicationSettings.Default.NewCmsAddress), LogType.Info.ToString()); // Try it and see. try { xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=registerDisplay"; string xml = callRegister(xmds, key); // If that worked (no errors), update our settings ApplicationSettings.Default.NewCmsAddress = ""; ApplicationSettings.Default.NewCmsKey = ""; // ServerUri/Key will be updated too. ApplicationSettings.Default.Save(); ProcessRegisterXml(xml); } catch (Exception e) { Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Error swapping to new CMS. E = " + e.Message.ToString()), LogType.Error.ToString()); // Switch back to the old values for subsequent tries ApplicationSettings.Default.ServerUri = oldUri; ApplicationSettings.Default.ServerKey = oldKey; } } // Have we been asked to switch to HTTPS? // HTTPS MOVE // ---------- if (ApplicationSettings.Default.ForceHttps && xmds.Url.ToLowerInvariant().StartsWith("http://")) { Trace.WriteLine(new LogMessage("RegisterAgent - Run", "We have been asked to move to HTTPS from our current HTTP."), LogType.Info.ToString()); // Try it and see. try { string url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=registerDisplay"; xmds.Url = url.Replace("http://", "https://"); callRegister(xmds, key); // If that worked (no errors), update our setting ApplicationSettings.Default.ServerUri = ApplicationSettings.Default.ServerUri.Replace("http://", "https://"); ApplicationSettings.Default.Save(); } catch (Exception e) { Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Error swapping to HTTPS. E = " + e.Message.ToString()), LogType.Error.ToString()); } } } } catch (WebException webEx) when(webEx.Response is HttpWebResponse httpWebResponse && (int)httpWebResponse.StatusCode == 429) { // Get the header for how long we ought to wait retryAfterSeconds = webEx.Response.Headers["Retry-After"] != null?int.Parse(webEx.Response.Headers["Retry-After"]) : 120; // Log it. Trace.WriteLine(new LogMessage("LogAgent", "Run: 429 received, waiting for " + retryAfterSeconds + " seconds."), LogType.Info.ToString()); } catch (WebException webEx) { // Increment the quantity of XMDS failures and bail out ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("RegisterAgent - Run", "WebException in Run: " + webEx.Message), LogType.Info.ToString()); } catch (Exception ex) { // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Exception in Run: " + ex.Message), LogType.Info.ToString()); } } if (retryAfterSeconds > 0) { // Sleep this thread until we've fulfilled our try after _manualReset.WaitOne(retryAfterSeconds * 1000); } else { // Sleep this thread until the next collection interval _manualReset.WaitOne((int)(ApplicationSettings.Default.CollectInterval * ApplicationSettings.Default.XmdsCollectionIntervalFactor() * 1000)); } } Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Stopped"), LogType.Info.ToString()); }
public static string GetDefaultText(this HardwareKey key) => SpecialDefaultTexts.ContainsKey(key) ? SpecialDefaultTexts[key] : key.ToString();
/// <summary> /// Runs the agent /// </summary> public void Run() { Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Started"), LogType.Info.ToString()); while (!_forceStop) { lock (_locker) { try { // If we are restarting, reset _manualReset.Reset(); HardwareKey key = new HardwareKey(); Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Woken and Lock Obtained"), LogType.Info.ToString()); using (xmds.xmds xmds = new xmds.xmds()) { xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=registerDisplay"; xmds.UseDefaultCredentials = false; // Store the XMR address string xmrAddress = ApplicationSettings.Default.XmrNetworkAddress; RegisterAgent.ProcessRegisterXml(xmds.RegisterDisplay( ApplicationSettings.Default.ServerKey, key.Key, ApplicationSettings.Default.DisplayName, "windows", ApplicationSettings.Default.ClientVersion, ApplicationSettings.Default.ClientCodeVersion, Environment.OSVersion.ToString(), key.MacAddress, key.Channel, key.getXmrPublicKey())); // Set the flag to indicate we have a connection to XMDS ApplicationSettings.Default.XmdsLastConnection = DateTime.Now; // Has the XMR address changed? if (xmrAddress != ApplicationSettings.Default.XmrNetworkAddress) { OnXmrReconfigure(); } // Is the timezone empty? if (string.IsNullOrEmpty(ApplicationSettings.Default.DisplayTimeZone)) { reportTimezone(); } } } catch (WebException webEx) { // Increment the quantity of XMDS failures and bail out ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("RegisterAgent - Run", "WebException in Run: " + webEx.Message), LogType.Info.ToString()); } catch (Exception ex) { // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Exception in Run: " + ex.Message), LogType.Info.ToString()); } } // Sleep this thread until the next collection interval _manualReset.WaitOne((int)(ApplicationSettings.Default.CollectInterval * ApplicationSettings.Default.XmdsCollectionIntervalFactor() * 1000)); } Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Stopped"), LogType.Info.ToString()); }
/// <summary> /// Runs the agent /// </summary> public void Run() { Trace.WriteLine(new LogMessage("StatAgent", "Run: Thread Started"), LogType.Info.ToString()); // Assume no backlog when we first start out. bool isBacklog = false; int retryAfterSeconds = 0; int countBacklogBatches = 0; int processing = 0; while (!_forceStop) { lock (_locker) { // What is out processing flag? processing = (new Random()).Next(1, 1000); try { // If we are restarting, reset _manualReset.Reset(); // Reset backOff retryAfterSeconds = 0; // How many records do we have to send? int recordsReady = StatManager.Instance.TotalReady(); // Does this mean we're in a backlog situation? isBacklog = (recordsReady >= 500); // Check to see if we have anything to send if (StatManager.Instance.MarkRecordsForSend(processing, isBacklog)) { HardwareKey key = new HardwareKey(); Trace.WriteLine(new LogMessage("StatAgent", "Run: Thread Woken and Lock Obtained, Key: " + processing), LogType.Audit.ToString()); using (xmds.xmds xmds = new xmds.xmds()) { xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=submitStats"; xmds.UseDefaultCredentials = false; // Get the starts we've marked to process as XML. xmds.SubmitStats(ApplicationSettings.Default.ServerKey, key.Key, StatManager.Instance.GetXmlForSend(processing)); } // Update the last send date to indicate we've just done so StatManager.Instance.LastSendDate = DateTime.Now; // Remove the ones we've just sent StatManager.Instance.DeleteSent(processing); } } catch (WebException webEx) when(webEx.Response is HttpWebResponse httpWebResponse && (int)httpWebResponse.StatusCode == 429) { // We got a backoff, so none of those records are processed. StatManager.Instance.UnmarkRecordsForSend(processing); // Get the header for how long we ought to wait retryAfterSeconds = webEx.Response.Headers["Retry-After"] != null?int.Parse(webEx.Response.Headers["Retry-After"]) : 120; // Log it. Trace.WriteLine(new LogMessage("StatAgent", "Run: 429 received, waiting for " + retryAfterSeconds + " seconds."), LogType.Info.ToString()); } catch (WebException webEx) { // Increment the quantity of XMDS failures and bail out ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("StatAgent", "Run: WebException in Run: " + webEx.Message), LogType.Info.ToString()); // Something went wrong sending those records, set them to be reprocessed StatManager.Instance.UnmarkRecordsForSend(processing); } catch (Exception ex) { // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("StatAgent", "Run: Exception in Run: " + ex.Message), LogType.Error.ToString()); // Something went wrong sending those records, set them to be reprocessed StatManager.Instance.UnmarkRecordsForSend(processing); } } if (retryAfterSeconds > 0) { // Sleep this thread until we've fulfilled our try after _manualReset.WaitOne(retryAfterSeconds * 1000); } else if (isBacklog) { // We've just completed a send in backlog mode, so add to batches. countBacklogBatches++; // How many batches have we sent without a cooldown? if (countBacklogBatches > 2) { // Reset batches countBacklogBatches = 0; // Come back in 30 seconds _manualReset.WaitOne(30000); } else { // Come back much more quickly (10 seconds) _manualReset.WaitOne(10000); } } else { // Reset batches countBacklogBatches = 0; // Sleep this thread until the next collection interval _manualReset.WaitOne((int)(ApplicationSettings.Default.CollectInterval * ApplicationSettings.Default.XmdsCollectionIntervalFactor() * 1000)); } } Trace.WriteLine(new LogMessage("StatAgent", "Run: Thread Stopped"), LogType.Info.ToString()); }
public static bool IsModifier(this HardwareKey key) => ModifierMapping.ContainsKey(key);
void OnKeyPress(UIKeyCommand cmd) { var element = HardwareKeyPage.FocusedElement ?? HardwareKeyPage.DefaultFocusedElement; if (element == null) { return; } //System.Diagnostics.Debug.WriteLine("Forms9Patch.PageRenderer: cmd.Input=[" + cmd.Input + "] cmd.ModifierFlags[" + cmd.ModifierFlags + "] "); //var isFirstResponder = CanBecomeFirstResponder; //var directBinding = (bool)this.GetPropertyValue("IsDirectBinding"); string keyInput = cmd.Input.ToString().ToUpper(); bool useShift = true; if (cmd.Input == UIKeyCommand.DownArrow) { keyInput = HardwareKey.DownArrowKeyInput; } else if (cmd.Input == UIKeyCommand.UpArrow) { keyInput = HardwareKey.UpArrowKeyInput; } else if (cmd.Input == UIKeyCommand.LeftArrow) { keyInput = HardwareKey.LeftArrowKeyInput; } else if (cmd.Input == UIKeyCommand.RightArrow) { keyInput = HardwareKey.RightArrowKeyInput; } else if (cmd.Input == UIKeyCommand.Escape) { keyInput = HardwareKey.EscapeKeyInput; } else if (cmd.Input == "\b") { keyInput = HardwareKey.BackspaceDeleteKeyInput; } else if (cmd.Input == "\0x7F") { keyInput = HardwareKey.ForwardDeleteKeyInput; } else if (cmd.Input == "\t") { keyInput = HardwareKey.TabKeyInput; } else if (cmd.Input == "\r") { keyInput = HardwareKey.EnterReturnKeyInput; } else if (cmd.Input == "UIKeyInputPageUp") { keyInput = HardwareKey.PageUpKeyInput; } else if (cmd.Input == "UIKeyInputPageDown") { keyInput = HardwareKey.PageDownKeyInput; } else if (cmd.Input == "UIKeyInputHome") { keyInput = HardwareKey.HomeKeyInput; } else if (cmd.Input == "UIKeyInputEnd") { keyInput = HardwareKey.EndKeyInput; } else if (cmd.Input == "UIKeyInputInsert") { keyInput = HardwareKey.InsertKeyInput; } else if (cmd.Input == "UIKeyInputDelete") { keyInput = HardwareKey.ForwardDeleteKeyInput; } else { useShift = keyInput.Length > 0 && char.IsLetter(keyInput[0]); } /* * else if (cmd.Input == "\\^P") * input = HardwareKey.F1Label; * else if (cmd.Input == "UIKeyInputF2") * input = HardwareKey.F2KeyInput; * else if (cmd.Input == "UIKeyInputF3") * input = HardwareKey.F3KeyInput; * else if (cmd.Input == "UIKeyInputF4") * input = HardwareKey.F4KeyInput; * else if (cmd.Input == "UIKeyInputF5") * input = HardwareKey.F5KeyInput; * else if (cmd.Input == "UIKeyInputF6") * input = HardwareKey.F6KeyInput; * else if (cmd.Input == "UIKeyInputF7") * input = HardwareKey.F7KeyInput; * else if (cmd.Input == "UIKeyInputF8") * input = HardwareKey.F8KeyInput; * else if (cmd.Input == "UIKeyInputF9") * input = HardwareKey.F9KeyInput; * else if (cmd.Input == "UIKeyInputF10") * input = HardwareKey.F10KeyInput; * else if (cmd.Input == "UIKeyInputF11") * input = HardwareKey.F11KeyInput; * else if (cmd.Input == "UIKeyInputF12") * input = HardwareKey.F12KeyInput; */ /* * var modifiers = HardwareKeyModifierKeys.None; * if ((cmd.ModifierFlags & UIKeyModifierFlags.AlphaShift) > 0) * modifiers |= HardwareKeyModifierKeys.CapsLock; * if ((cmd.ModifierFlags & UIKeyModifierFlags.Alternate) > 0) * modifiers |= HardwareKeyModifierKeys.Alternate; * if ((cmd.ModifierFlags & UIKeyModifierFlags.Control) > 0) * modifiers |= HardwareKeyModifierKeys.Control; * if ((cmd.ModifierFlags & UIKeyModifierFlags.NumericPad) > 0) * modifiers |= HardwareKeyModifierKeys.NumericPadKey; * if ((cmd.ModifierFlags & UIKeyModifierFlags.Command) > 0) * modifiers |= HardwareKeyModifierKeys.PlatformKey; * if (keyInput.Length > 0 && char.IsLetter(keyInput[0]) && (cmd.ModifierFlags & UIKeyModifierFlags.Shift) > 0) * modifiers |= HardwareKeyModifierKeys.Shift; */ var modifiers = GetModifierKeys(cmd.ModifierFlags, useShift); /* * if (!modifiers.HasFlag(HardwareKeyModifierKeys.NumericPadKey)) * { * switch (Forms9Patch.KeyboardService.LanguageRegion) * { * case "fr-FR": * { * switch (cmd.Input) * { * case "1": * keyInput = "&"; * break; * case "2": * keyInput = "é"; * break; * case "3": * keyInput = "\""; * break; * case "4": * keyInput = "'"; * break; * case "5": * keyInput = "("; * System.Diagnostics.Debug.WriteLine("fr-FR [ ( ]"); * break; * case "6": * keyInput = "-"; * break; * case "7": * keyInput = "è"; * break; * case "8": * keyInput = "_"; * break; * case "9": * keyInput = "ç"; * break; * case "0": * keyInput = "à"; * break; * case "-": * keyInput = ")"; * break; * } * } * break; * } * } */ var listeners = element.GetHardwareKeyListeners(); for (int i = 0; i < listeners.Count; i++) { var listener = listeners[i]; if (string.IsNullOrEmpty(listener?.HardwareKey?.KeyInput)) { continue; } if (listener.HardwareKey.KeyInput == keyInput.ToUpper() && (listener.HardwareKey.ModifierKeys == modifiers || listener.HardwareKey.ModifierKeys.HasFlag(HardwareKeyModifierKeys.Any))) { if (listener.Command != null && listener.Command.CanExecute(listener.CommandParameter)) { listener.Command.Execute(listener.CommandParameter); } var observedHardwareKey = new HardwareKey(keyInput.ToUpper(), modifiers); listener.Pressed?.Invoke(element, new HardwareKeyEventArgs(observedHardwareKey, element)); //System.Diagnostics.Debug.WriteLine("SUCCESS!!!"); return; } } }
public OptionForm() { InitializeComponent(); System.Diagnostics.Debug.WriteLine("Initialise Option Form Components", "OptionForm"); // Get a hardware key here, just in case we havent been able to get one before _hardwareKey = new HardwareKey(); // XMDS completed event xmds.RegisterDisplayCompleted += (Xmds1RegisterDisplayCompleted); // Library Path if (Settings.Default.LibraryPath == "DEFAULT") { Debug.WriteLine("Getting the Library Path", "OptionForm"); Settings.Default.LibraryPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + @"\ Library"; Settings.Default.Save(); } // Computer name if the display name hasnt been set yet if (Settings.Default.displayName == "COMPUTERNAME") { Debug.WriteLine("Getting the display Name", "OptionForm"); Settings.Default.displayName = Environment.MachineName; Settings.Default.Save(); } // Set global proxy information OptionForm.SetGlobalProxy(); // Settings Tab textBoxXmdsUri.Text = Settings.Default.serverURI; textBoxServerKey.Text = Settings.Default.ServerKey; textBoxLibraryPath.Text = Settings.Default.LibraryPath; tbHardwareKey.Text = Settings.Default.hardwareKey; numericUpDownCollect.Value = Settings.Default.collectInterval; checkBoxPowerPoint.Checked = Settings.Default.powerpointEnabled; checkBoxStats.Checked = Settings.Default.statsEnabled; nupScrollStepAmount.Value = Settings.Default.scrollStepAmount; // Register Tab labelXmdsUrl.Text = Settings.Default.Xmds; textBoxDisplayName.Text = Settings.Default.displayName; // Proxy Tab textBoxProxyUser.Text = Settings.Default.ProxyUser; maskedTextBoxProxyPass.Text = Settings.Default.ProxyPassword; textBoxProxyDomain.Text = Settings.Default.ProxyDomain; // Client Tab clientWidth.Value = Settings.Default.sizeX; clientHeight.Value = Settings.Default.sizeY; offsetX.Value = Settings.Default.offsetX; offsetY.Value = Settings.Default.offsetY; // Advanced Tab numericUpDownEmptyRegions.Value = Settings.Default.emptyLayoutDuration; cbExpireModifiedLayouts.Checked = Settings.Default.expireModifiedLayouts; enableMouseCb.Checked = Settings.Default.EnableMouse; doubleBufferingCheckBox.Checked = Settings.Default.DoubleBuffering; System.Diagnostics.Debug.WriteLine("Loaded Options Form", "OptionForm"); }
internal static void ProcessKeyPress(UIKeyCommand cmd) { if (cmd == _lastKeyCommand) { return; } _lastKeyCommand = cmd; var element = HardwareKeyPage.FocusedElement ?? HardwareKeyPage.DefaultFocusedElement; if (element == null) { return; } //System.Diagnostics.Debug.WriteLine("Forms9Patch.PageRenderer: cmd.Input=[" + cmd.Input + "] cmd.ModifierFlags[" + cmd.ModifierFlags + "] "); //var isFirstResponder = CanBecomeFirstResponder; //var directBinding = (bool)this.GetPropertyValue("IsDirectBinding"); string keyInput = cmd.Input.ToString().ToUpper(); bool useShift = true; if (cmd.Input == UIKeyCommand.DownArrow) { keyInput = HardwareKey.DownArrowKeyInput; } else if (cmd.Input == UIKeyCommand.UpArrow) { keyInput = HardwareKey.UpArrowKeyInput; } else if (cmd.Input == UIKeyCommand.LeftArrow) { keyInput = HardwareKey.LeftArrowKeyInput; } else if (cmd.Input == UIKeyCommand.RightArrow) { keyInput = HardwareKey.RightArrowKeyInput; } else if (cmd.Input == UIKeyCommand.Escape) { keyInput = HardwareKey.EscapeKeyInput; } else if (cmd.Input == UIKeyCommand_BackspaceDeleteKeyInput) { keyInput = HardwareKey.BackspaceDeleteKeyInput; } else if (cmd.Input == UIKeyCommand_ForwardDeleteKeyInput) { keyInput = HardwareKey.ForwardDeleteKeyInput; } else if (cmd.Input == UIKeyCommand_TabKeyInput) { keyInput = HardwareKey.TabKeyInput; } else if (cmd.Input == UIKeyCommand_EnterReturnKeyInput) { keyInput = HardwareKey.EnterReturnKeyInput; } else if (cmd.Input == UIKeyCommand_PageUpKeyInput) { keyInput = HardwareKey.PageUpKeyInput; } else if (cmd.Input == UIKeyCommand_PageDownKeyInput) { keyInput = HardwareKey.PageDownKeyInput; } else if (cmd.Input == UIKeyCommand_HomeKeyInput) { keyInput = HardwareKey.HomeKeyInput; } else if (cmd.Input == UIKeyCommand_EndKeyInput) { keyInput = HardwareKey.EndKeyInput; } else if (cmd.Input == UIKeyCommand_InsertKeyInput) { keyInput = HardwareKey.InsertKeyInput; } else if (cmd.Input == UIKeyCommand_InputDeleteKeyInput) { keyInput = HardwareKey.ForwardDeleteKeyInput; } else { useShift = keyInput.Length > 0 && char.IsLetter(keyInput[0]); } var modifiers = GetModifierKeys(cmd.ModifierFlags, useShift); var listeners = element.GetHardwareKeyListeners(); for (int i = 0; i < listeners.Count; i++) { var listener = listeners[i]; if (string.IsNullOrEmpty(listener?.HardwareKey?.KeyInput)) { continue; } if (listener.HardwareKey.KeyInput == keyInput.ToUpper() && (listener.HardwareKey.ModifierKeys == modifiers || listener.HardwareKey.ModifierKeys.HasFlag(HardwareKeyModifierKeys.Any))) { if (listener.Command != null && listener.Command.CanExecute(listener.CommandParameter)) { listener.Command.Execute(listener.CommandParameter); } var observedHardwareKey = new HardwareKey(keyInput.ToUpper(), modifiers); listener.Pressed?.Invoke(element, new HardwareKeyEventArgs(observedHardwareKey, element)); //System.Diagnostics.Debug.WriteLine("SUCCESS!!!"); return; } } }
/// <summary> /// Runs the agent /// </summary> public void Run() { Trace.WriteLine(new LogMessage("LogAgent - Run", "Thread Started"), LogType.Info.ToString()); int retryAfterSeconds = 0; while (!_forceStop) { lock (_locker) { try { // If we are restarting, reset _manualReset.Reset(); // Reset backOff retryAfterSeconds = 0; HardwareKey key = new HardwareKey(); Trace.WriteLine(new LogMessage("RegisterAgent - Run", "Thread Woken and Lock Obtained"), LogType.Audit.ToString()); using (xmds.xmds xmds = new xmds.xmds()) { xmds.Credentials = null; xmds.Url = ApplicationSettings.Default.XiboClient_xmds_xmds + "&method=submitLog"; xmds.UseDefaultCredentials = false; // Log ProcessFiles(xmds, key.Key, ApplicationSettings.Default.LogLocation); } } catch (WebException webEx) when(webEx.Response is HttpWebResponse httpWebResponse && (int)httpWebResponse.StatusCode == 429) { // Get the header for how long we ought to wait retryAfterSeconds = webEx.Response.Headers["Retry-After"] != null?int.Parse(webEx.Response.Headers["Retry-After"]) : 120; // Log it. Trace.WriteLine(new LogMessage("LogAgent", "Run: 429 received, waiting for " + retryAfterSeconds + " seconds."), LogType.Info.ToString()); } catch (WebException webEx) { // Increment the quantity of XMDS failures and bail out ApplicationSettings.Default.IncrementXmdsErrorCount(); // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("LogAgent - Run", "WebException in Run: " + webEx.Message), LogType.Info.ToString()); } catch (Exception ex) { // Log this message, but dont abort the thread Trace.WriteLine(new LogMessage("LogAgent - Run", "Exception in Run: " + ex.Message), LogType.Error.ToString()); } } if (retryAfterSeconds > 0) { // Sleep this thread until we've fulfilled our try after _manualReset.WaitOne(retryAfterSeconds * 1000); } else { // Sleep this thread until the next collection interval _manualReset.WaitOne((int)(ApplicationSettings.Default.CollectInterval * ApplicationSettings.Default.XmdsCollectionIntervalFactor() * 1000)); } } Trace.WriteLine(new LogMessage("LogAgent - Run", "Thread Stopped"), LogType.Info.ToString()); }
public static bool OnKeyDown(Android.Views.Keycode keyCode, Android.Views.KeyEvent e) { /* * //System.Diagnostics.Debug.WriteLine("HardwareKeyPageListener.OnKeyDown[" + keyCode + "] dispLabel=[" + (e.DisplayLabel == 0 ? "" : "" + e.DisplayLabel) + "] number=[" + (e.Number == 0 ? "" : "" + e.Number) + "] [" + (char)e.UnicodeChar == null + "] [" + e + "] "); * System.Diagnostics.Debug.WriteLine("HardwareKeyPageListener.OnKeyDown:"); * System.Diagnostics.Debug.WriteLine("\t\t keyCode=[" + keyCode + "]"); * System.Diagnostics.Debug.WriteLine("\t\t DisplayLabel=[" + (e.DisplayLabel == 0 ? "" : "" + e.DisplayLabel) + "]"); * System.Diagnostics.Debug.WriteLine("\t\t Number=[" + (e.Number == 0 ? "" : "" + e.Number) + "]"); * System.Diagnostics.Debug.WriteLine("\t\t UnicodeChar=[" + (e.UnicodeChar == 0 ? "" : ((char)e.UnicodeChar).ToString()) + "]"); */ var element = HardwareKeyPage.FocusedElement ?? HardwareKeyPage.DefaultFocusedElement; if (element == null) { return(false); } var keyInput = ("" + Convert.ToChar(e.UnicodeChar)).ToUpper(); var modifiers = HardwareKeyModifierKeys.None; bool useShift = true; switch (keyCode) { case Android.Views.Keycode.Numpad0: keyInput = "0"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.Numpad1: keyInput = "1"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.Numpad2: keyInput = "2"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.Numpad3: keyInput = "3"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.Numpad4: keyInput = "4"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.Numpad5: keyInput = "5"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.Numpad6: keyInput = "6"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.Numpad7: keyInput = "7"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.Numpad8: keyInput = "8"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.Numpad9: keyInput = "9"; modifiers = HardwareKeyModifierKeys.NumericPadKey; useShift = false; break; case Android.Views.Keycode.NumpadAdd: keyInput = "+"; useShift = false; break; case Android.Views.Keycode.NumpadComma: keyInput = ","; useShift = false; break; case Android.Views.Keycode.NumpadDivide: keyInput = "/"; useShift = false; break; case Android.Views.Keycode.NumpadDot: keyInput = "."; useShift = false; break; case Android.Views.Keycode.NumpadEnter: keyInput = HardwareKey.EnterReturnKeyInput; break; case Android.Views.Keycode.NumpadEquals: keyInput = "="; useShift = false; break; case Android.Views.Keycode.NumpadLeftParen: keyInput = "("; useShift = false; break; case Android.Views.Keycode.NumpadRightParen: keyInput = ")"; useShift = false; break; case Android.Views.Keycode.NumpadSubtract: keyInput = "-"; useShift = false; break; case Android.Views.Keycode.DpadDown: keyInput = HardwareKey.DownArrowKeyInput; break; case Android.Views.Keycode.DpadUp: keyInput = HardwareKey.UpArrowKeyInput; break; case Android.Views.Keycode.DpadLeft: keyInput = HardwareKey.LeftArrowKeyInput; break; case Android.Views.Keycode.DpadRight: keyInput = HardwareKey.RightArrowKeyInput; break; case Android.Views.Keycode.Escape: keyInput = HardwareKey.EscapeKeyInput; break; case Android.Views.Keycode.Enter: keyInput = HardwareKey.EnterReturnKeyInput; break; case Android.Views.Keycode.F1: keyInput = HardwareKey.F1KeyInput; break; case Android.Views.Keycode.F2: keyInput = HardwareKey.F2KeyInput; break; case Android.Views.Keycode.F3: keyInput = HardwareKey.F3KeyInput; break; case Android.Views.Keycode.F4: keyInput = HardwareKey.F4KeyInput; break; case Android.Views.Keycode.F5: keyInput = HardwareKey.F5KeyInput; break; case Android.Views.Keycode.F6: keyInput = HardwareKey.F6KeyInput; break; case Android.Views.Keycode.F7: keyInput = HardwareKey.F7KeyInput; break; case Android.Views.Keycode.F8: keyInput = HardwareKey.F8KeyInput; break; case Android.Views.Keycode.F9: keyInput = HardwareKey.F9KeyInput; break; case Android.Views.Keycode.F10: keyInput = HardwareKey.F10KeyInput; break; case Android.Views.Keycode.F11: keyInput = HardwareKey.F11KeyInput; break; case Android.Views.Keycode.F12: keyInput = HardwareKey.F12KeyInput; break; case Android.Views.Keycode.PageUp: keyInput = HardwareKey.PageUpKeyInput; break; case Android.Views.Keycode.PageDown: keyInput = HardwareKey.PageDownKeyInput; break; case Android.Views.Keycode.Insert: keyInput = HardwareKey.InsertKeyInput; break; case Android.Views.Keycode.Del: keyInput = HardwareKey.BackspaceDeleteKeyInput; break; case Android.Views.Keycode.ForwardDel: keyInput = HardwareKey.ForwardDeleteKeyInput; break; case Android.Views.Keycode.Home: keyInput = HardwareKey.HomeKeyInput; break; case Android.Views.Keycode.Endcall: keyInput = HardwareKey.EndKeyInput; break; /* * case Android.Views.Keycode.Num0: * keyInput = "0"; * break; * case Android.Views.Keycode.Num1: * keyInput = "1"; * break; * case Android.Views.Keycode.Num2: * keyInput = "2"; * break; * case Android.Views.Keycode.Num3: * keyInput = "3"; * break; * case Android.Views.Keycode.Num4: * keyInput = "4"; * break; * case Android.Views.Keycode.Num5: * keyInput = "5"; * break; * case Android.Views.Keycode.Num6: * keyInput = "6"; * break; * case Android.Views.Keycode.Num7: * keyInput = "7"; * break; * case Android.Views.Keycode.Num8: * keyInput = "8"; * break; * case Android.Views.Keycode.Num9: * keyInput = "9"; * break; */ default: if (e.UnicodeChar == 0) { return(false); } useShift = keyInput.Length > 0 && char.IsLetter(keyInput[0]); break; } /* * if ((e.Modifiers & Android.Views.MetaKeyStates.CapsLockOn) > 0) * modifiers |= HardwareKeyModifierKeys.CapsLock; * if ((e.Modifiers & Android.Views.MetaKeyStates.AltMask) > 0) * modifiers |= HardwareKeyModifierKeys.Alternate; * if ((e.Modifiers & Android.Views.MetaKeyStates.CtrlMask) > 0) * modifiers |= HardwareKeyModifierKeys.Control; * if ((e.Modifiers & Android.Views.MetaKeyStates.FunctionOn) > 0) * modifiers |= HardwareKeyModifierKeys.FunctionKey; * if ((e.Modifiers & Android.Views.MetaKeyStates.SymOn) > 0) * modifiers |= HardwareKeyModifierKeys.PlatformKey; * if (keyInput.Length > 0 && char.IsLetter(keyInput[0]) && (e.Modifiers & Android.Views.MetaKeyStates.ShiftMask) > 0) * modifiers |= HardwareKeyModifierKeys.Shift; */ modifiers |= GetModifierKeys(e.Modifiers, useShift); var listeners = element.GetHardwareKeyListeners(); for (int i = 0; i < listeners.Count; i++) { var listener = listeners[i]; if (string.IsNullOrEmpty(listener?.HardwareKey?.KeyInput)) { continue; } if (listener.HardwareKey.KeyInput == keyInput.ToUpper() && (listener.HardwareKey.ModifierKeys == modifiers || listener.HardwareKey.ModifierKeys.HasFlag(HardwareKeyModifierKeys.Any))) { if (listener.Command != null && listener.Command.CanExecute(listener.CommandParameter)) { listener.Command.Execute(listener.CommandParameter); } var observedHardwareKey = new HardwareKey(keyInput.ToUpper(), modifiers); listener.Pressed?.Invoke(element, new HardwareKeyEventArgs(observedHardwareKey, element)); //System.Diagnostics.Debug.WriteLine("SUCCESS!!!"); return(true); } } return(false); }