private void OnRemoveListViewItem(object sender, MailboxEventArgs e) { if (selectedIndex >= mailbox.MailboxCount) { if (mailbox.MailboxCount == 0) { selectedIndex = -1; listViewItems.SelectedIndex = selectedIndex; } else { selectedIndex--; listViewItems.SelectedIndex = selectedIndex; } } mailbox.ListViewItems.RemoveAt(e.Index); if (selectedIndex > mailbox.MailboxCount) { listViewItems.SelectedIndex = selectedIndex; } UpdateDetails(); }
private void OnMoveListViewItem(object sender, MailboxEventArgs e) { mailbox.ListViewItems.Move(e.OldIndex, e.NewIndex); }
private void OnAddListViewItem(object sender, MailboxEventArgs e) { ListViewItem listViewItem = new ListViewItem(); listViewItem.SnapsToDevicePixels = true; listViewItem.UseLayoutRounding = true; DockPanel dockPanel = new DockPanel(); dockPanel.Width = 300; Image image = new Image(); image.Source = ItemDatabase.GetItemImageFromID(e.Mail.MailItemID); image.Stretch = Stretch.None; image.SnapsToDevicePixels = true; image.UseLayoutRounding = true; TextBlock fromName = new TextBlock(); fromName.VerticalAlignment = VerticalAlignment.Center; fromName.Text = "From " + e.Mail.TrainerName; fromName.TextTrimming = TextTrimming.CharacterEllipsis; fromName.Margin = new Thickness(4, 0, 0, 0); /*TextBlock blockLv = new TextBlock(); * blockLv.VerticalAlignment = VerticalAlignment.Center; * blockLv.HorizontalAlignment = HorizontalAlignment.Right; * blockLv.TextAlignment = TextAlignment.Right; * blockLv.Text = "Lv"; * blockLv.Width = Double.NaN; * blockLv.MinWidth = 10; * * TextBlock blockLevel = new TextBlock(); * blockLevel.VerticalAlignment = VerticalAlignment.Center; * blockLevel.HorizontalAlignment = HorizontalAlignment.Right; * blockLevel.TextAlignment = TextAlignment.Right; * blockLevel.Width = 30; * blockLevel.Text = e.Pokeblock.Level.ToString();*/ listViewItem.Content = dockPanel; mailbox.ListViewItems.Insert(e.Index, listViewItem); dockPanel.Children.Add(image); dockPanel.Children.Add(fromName); //dockPanel.Children.Add(blockLevel); //dockPanel.Children.Add(blockLv); ContextMenu contextMenu = new ContextMenu(); MenuItem menuPokeblockSendTo = new MenuItem(); menuPokeblockSendTo.Header = "Send To"; menuPokeblockSendTo.Click += OnMailSendTo; contextMenu.Items.Add(menuPokeblockSendTo); MenuItem menuPokeblockToss = new MenuItem(); menuPokeblockToss.Header = "Return to Inventory"; menuPokeblockToss.Click += OnMailReturnToInventory; contextMenu.Items.Add(menuPokeblockToss); listViewItem.ContextMenu = contextMenu; //DockPanel.SetDock(image, Dock.Left); //DockPanel.SetDock(blockLevel, Dock.Right); UpdateDetails(); }