/// <summary> /// Parses the item. /// </summary> private async void ParseItem() { PoeItem item = default; var retryCount = 2; for (int i = 0; i < retryCount; i++) { this._simulator.Keyboard.ModifiedKeyStroke(WindowsInput.Native.VirtualKeyCode.CONTROL, WindowsInput.Native.VirtualKeyCode.VK_C); await Task.Delay(20); item = ClipboardHelper.GetItemInClipboard(); if (item == null) { return; } if (!item.Identified) { await Task.Delay(50); continue; } break; } if (item == null || !item.Identified) { return; } this.Newitem?.Invoke(this, item); ClipboardHelper.ClearClipboard(); }
/// <summary> /// Initializes a new instance of the <see cref="ClipboardLurker" /> class. /// </summary> public ClipboardLurker() { ClipboardHelper.ClearClipboard(); this._clipboardMonitor = new SharpClipboard(); this._clipboardMonitor.ClipboardChanged += this.ClipboardMonitor_ClipboardChanged; }
void OnSheetsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { IEnumerable enumerable = (e.NewItems == null) ? ((IEnumerable) new Worksheet[0]) : ((IEnumerable)e.NewItems); IEnumerable enumerable2 = (e.OldItems == null) ? ((IEnumerable) new Worksheet[0]) : ((IEnumerable)e.OldItems); switch (e.Action) { case NotifyCollectionChangedAction.Add: case NotifyCollectionChangedAction.Remove: case NotifyCollectionChangedAction.Replace: case NotifyCollectionChangedAction.Reset: foreach (Worksheet worksheet in enumerable2) { DetachSheet(worksheet); } foreach (Worksheet worksheet2 in enumerable) { AttachSheet(worksheet2); } if ((SpreadXClipboard.Worksheet != null) && ((Workbook.Sheets == null) || !Workbook.Sheets.Contains(SpreadXClipboard.Worksheet))) { ClipboardHelper.ClearClipboard(); } break; case NotifyCollectionChangedAction.Move: break; default: return; } }
/// <summary> /// Initializes a new instance of the <see cref="ClipboardLurker" /> class. /// </summary> /// <param name="settingsService">The settings service.</param> /// <param name="keyboardHelper">The keyboard helper.</param> public ClipboardLurker(SettingsService settingsService, PoeKeyboardHelper keyboardHelper) { ClipboardHelper.ClearClipboard(); this._keyboardHelper = keyboardHelper; this._simulator = new InputSimulator(); this._clipboardMonitor = new SharpClipboard(); this._settingsService = settingsService; this._settingsService.OnSave += this.SettingsService_OnSave; this._clipboardMonitor.ClipboardChanged += this.ClipboardMonitor_ClipboardChanged; this._itemParser.CheckPledgeStatus(); this.LurkForAction(); }
/// <summary> /// Handles the RightButtonUp event of the MouseHook control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="MouseMessageEventArgs"/> instance containing the event data.</param> private async void MouseHook_RightButtonUp(object sender, MouseMessageEventArgs e) { if (e.Alt && this._settingsService.SearchEnabled) { await Task.Delay(100); var item = await this.ParseItem(); if (item != null) { this.ItemDetails?.Invoke(this, item); } ClipboardHelper.ClearClipboard(); } }
/// <summary> /// Handles the MouseLeftButtonUp event of the MouseHookService control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private async void MouseHook_LeftButtonUp(object sender, MouseMessageEventArgs e) { if (e.Shift && this._settingsService.MapEnabled) { await Task.Delay(100); var item = await this.ParseItem(); if (item != null) { this.ItemIdentified?.Invoke(this, item); } ClipboardHelper.ClearClipboard(); } }
/// <summary> /// Gets the item base type in clipboard. /// </summary> /// <returns>The item search value.</returns> private async Task <string> GetItemSearchValueInClipboard() { try { this._simulator.Keyboard.ModifiedKeyStroke(WindowsInput.Native.VirtualKeyCode.CONTROL, WindowsInput.Native.VirtualKeyCode.VK_C); await Task.Delay(50); var text = ClipboardHelper.GetClipboardText(); ClipboardHelper.ClearClipboard(); return(this._itemParser.GetSearchValue(text)); } catch { return(null); } }
/// <summary> /// Gets the item base type in clipboard. /// </summary> /// <returns>The item search value.</returns> private async Task <string> GetItemSearchValueInClipboard() { try { await Simulate.Events().ClickChord(WindowsInput.Events.KeyCode.Control, WindowsInput.Events.KeyCode.C).Invoke(); await Task.Delay(50); var text = ClipboardHelper.GetClipboardText(); ClipboardHelper.ClearClipboard(); return(this._itemParser.GetSearchValue(text)); } catch { return(null); } }
/// <summary> /// Handles the MouseLeftButtonUp event of the MouseHookService control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param> private async void MouseHook_LeftButtonUp(object sender, MouseMessageEventArgs e) { this.MouseLeftButtonUp?.Invoke(this, e); if (e.Control || !e.Shift || (!this._settingsService.MapEnabled && !this._settingsService.SearchEnabled)) { return; } await Task.Delay(100); var item = await this.ParseItem(); if (item != null) { this.ItemIdentified?.Invoke(this, item); } ClipboardHelper.ClearClipboard(); }
/// <summary> /// Parses the item. /// </summary> private async Task ParseItem() { PoeItem item = default; var retryCount = 2; for (int i = 0; i < retryCount; i++) { item = await ClipboardHelper.GetItemInClipboard(); if (item == null) { return; } if (!item.Identified) { await Task.Delay(50); continue; } break; } if (item == null || !item.Identified) { return; } if (item.ItemClass == ItemClass.Unknown) { return; } this.Newitem?.Invoke(this, item); ClipboardHelper.ClearClipboard(); }
/// <summary> /// Parses the item. /// </summary> private async Task ParseItem() { PoeItem item = default; var retryCount = 2; for (int i = 0; i < retryCount; i++) { await Simulate.Events().ClickChord(WindowsInput.Events.KeyCode.LControlKey, WindowsInput.Events.KeyCode.C).Invoke(); await Task.Delay(100); item = ClipboardHelper.GetItemInClipboard(); if (item == null) { return; } if (!item.Identified) { await Task.Delay(50); continue; } break; } if (item == null || !item.Identified) { return; } this.Newitem?.Invoke(this, item); ClipboardHelper.ClearClipboard(); }