private void SendData(ClipboardVM vm) { bool isAppActivated = Convert.ToBoolean(App.Current.Properties[AppEnums.APP_PROP_KEY_ISACTIVATED]); if (isAppActivated) { this.Hide(); } //Set the clipboard data. bool bSet = false; for (int i = 0; i < 100 && !bSet; i++) { try { SkipClipboardUpdate(100); System.Windows.Forms.Clipboard.SetDataObject(vm.GetDataObject()); bSet = true; } catch (Exception e) { Debug.WriteLine(e.Message); bSet = false; } } //Send data. SendKeys.SendWait("^{v}"); }
private void On_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) { ClipboardVM vm = this.DataContext as ClipboardVM; if (vm != null) { vm.CmdSendData.Execute(null); } }
private bool On_ClipboardVM_CommandAction_Execute(String cmdKey, ClipboardVM vm) { if (cmdKey == ClipboardVM.CmdKey_SendData) { SendData(vm); this.Hide(); return(true); } return(false); }
private void On_Clipboard_Update() { if (_skipClipUpdate == false) { try { Dictionary <String, Object> dict = new Dictionary <String, Object>(); var dataObject = System.Windows.Forms.Clipboard.GetDataObject(); ClipboardVM vm = new ClipboardVM(dataObject); ClipboardVM lastVM = _clipColle.ElementAtOrDefault(0); if (vm.Type != ClipboardVM.ClipboardDataType.Unknown && vm.DataObjectCount != 0) { if (lastVM != null) { bool bSame = lastVM.Compare(vm); if (bSame) { return; } } vm.CommandAction += On_ClipboardVM_CommandAction_Execute; _clipColle.Insert(0, vm); while (_clipColle.Count > Properties.Settings.Default.ClipBoardCount) { _clipColle.RemoveAt(Properties.Settings.Default.ClipBoardCount); } } } catch (Exception e) { Debug.WriteLine(e.Message); } } }
private void On_Window_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) { if (e.Key == Key.Escape) { Close(); } else if (e.Key == Key.Enter) { if (_gaoPanel) { if (LB_Gaos.SelectedItem != null) { GaoVM vm = LB_Gaos.SelectedItem as GaoVM; vm.CmdSendText.Execute(null); } } else { if (LB_ClipItems.SelectedItem != null) { ClipboardVM vm = LB_ClipItems.SelectedItem as ClipboardVM; vm.CmdSendData.Execute(null); } } } else if (e.Key == Key.Up || e.Key == Key.Down) { if (_gaoPanel) { int idx = LB_Gaos.SelectedIndex + (e.Key == Key.Up ? -1 : 1); if (idx >= 0 && idx <= LB_Gaos.Items.Count) { LB_Gaos.SelectedIndex = idx; LB_Gaos.ScrollIntoView(LB_Gaos.SelectedItem); } } else { int idx = LB_ClipItems.SelectedIndex + (e.Key == Key.Up ? -1 : 1); if (idx >= 0 && idx <= LB_ClipItems.Items.Count) { LB_ClipItems.SelectedIndex = idx; LB_ClipItems.ScrollIntoView(LB_ClipItems.SelectedItem); } } } else if (e.Key == Key.Left || e.Key == Key.Right) { _gaoPanel = (e.Key == Key.Left); if (_gaoPanel) { LB_Gaos.Visibility = Visibility.Visible; LB_ClipItems.Visibility = Visibility.Collapsed; } else { LB_Gaos.Visibility = Visibility.Collapsed; LB_ClipItems.Visibility = Visibility.Visible; } } else { TXTBOX_Search.Focus(); } }