/// <summary> /// Removes the item with the given index from the list /// </summary> public bool RemoveItem(long index) { if (m_items == null || m_items.Count == 0) { m_status = $"Removed no item with index '{index}'. List is empty"; return(false); } IClipboardItem matchingItem = m_items.FirstOrDefault(i => i.Index == index); if (matchingItem == null) { m_status = $"No item with index '{index}' found to remove"; return(false); } ClipboardItemEventArgs args = new ClipboardItemEventArgs(matchingItem); m_items.Remove(matchingItem); ItemsChanged(ItemsChangeType.ItemRemoved, args); m_status = $"Removed item with index '{index}'"; return(true); }
private void ItemsChangedHandler(ItemsChangeType changeType, ClipboardItemEventArgs e) { UpdateItemsList(); }
private void ClipboardItemView_ClickHandler(object sender, ItemAction action, ClipboardItemEventArgs e) { IClipboardItem currentItem = ((FrameworkElement)sender).DataContext as IClipboardItem; if (currentItem != null) { switch (action) { case ItemAction.ItemCopy: if (!ClipDataManager.Instance.CopyDataToClipboard(currentItem)) { MessageBox.Show(ClipDataManager.Instance.Status, $"{Title}: Copy to clipboard failed", MessageBoxButton.OK, MessageBoxImage.Error); } break; case ItemAction.ItemFileCopy: if (!ClipDataManager.Instance.WriteDataToFile(currentItem.Index)) { MessageBox.Show( "Saving failed: " + Environment.NewLine + ClipDataManager.Instance.Status, Title + " - Save content to file...", MessageBoxButton.OK, MessageBoxImage.Error); } break; case ItemAction.ItemEdit: ContentViewWindow contentViewWindow = new ContentViewWindow(currentItem); contentViewWindow.ShowDialog(); if (contentViewWindow.ContentChanged) { ListBoxClipboardItems.Items.Refresh(); } break; case ItemAction.ItemDelete: ClipDataManager.Instance.RemoveItem(currentItem.Index); break; default: break; } } }