Пример #1
0
 private void ClipboardPanelCurrentItems_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     if (ItemsControl.ContainerFromElement(ClipboardPanelCurrentItems, e.OriginalSource as DependencyObject) is ListBoxItem item)
     {
         if (Guid.TryParse(((ClipboardManager.Models.ClipboardData)item?.DataContext)?.Id.ToString(), out Guid itemGuid))
         {
             var itemToPaste = (ClipboardText)ClipboardController.ClipboardRecentData.Where(c => c.Id == itemGuid).FirstOrDefault();
             if (itemToPaste != null)
             {
                 clipboardController?.UnRegisterListener(); //Stop listening because we are injecting our clipboard message to the clipboard list.
                 System.Windows.Forms.Clipboard.SetText(itemToPaste.Data);
                 clipboardController?.RegisterListenter();  //Re-register the listener
                 this.Hide();
                 clipboardController?.Paste();
             }
         }
     }
 }