Пример #1
0
        public void OnAddListViewItem(object sender, ItemPocketEventArgs 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.Item.ID);
            image.Stretch             = Stretch.None;
            image.SnapsToDevicePixels = true;
            image.UseLayoutRounding   = true;

            TextBlock itemName = new TextBlock();

            itemName.VerticalAlignment = VerticalAlignment.Center;
            itemName.Text         = (pocket.PocketType == ItemTypes.Berries ? "No" + (e.Item.ID - 132).ToString("00") + " " : "") + e.Item.ItemData.Name;
            itemName.TextTrimming = TextTrimming.CharacterEllipsis;
            itemName.Margin       = new Thickness(4, 0, 0, 0);

            TextBlock itemX = new TextBlock();

            itemX.VerticalAlignment   = VerticalAlignment.Center;
            itemX.HorizontalAlignment = HorizontalAlignment.Right;
            itemX.TextAlignment       = TextAlignment.Right;
            itemX.Text       = "x";
            itemX.Width      = Double.NaN;
            itemX.MinWidth   = 10;
            itemX.Visibility = (e.Item.ItemData.IsImportant ? Visibility.Hidden : Visibility.Visible);

            TextBlock itemCount = new TextBlock();

            itemCount.VerticalAlignment   = VerticalAlignment.Center;
            itemCount.HorizontalAlignment = HorizontalAlignment.Right;
            itemCount.TextAlignment       = TextAlignment.Right;
            itemCount.Width      = 30;
            itemCount.Text       = e.Item.Count.ToString();
            itemCount.Visibility = (e.Item.ItemData.IsImportant ? Visibility.Hidden : Visibility.Visible);

            listViewItem.Content = dockPanel;
            pocket.ListViewItems.Insert(e.Index, listViewItem);
            dockPanel.Children.Add(image);
            dockPanel.Children.Add(itemName);
            dockPanel.Children.Add(itemCount);
            dockPanel.Children.Add(itemX);

            listViewItem.ContextMenu         = contextMenu;
            listViewItem.ContextMenuOpening += OnContextMenuOpening;

            DockPanel.SetDock(image, Dock.Left);
            DockPanel.SetDock(itemCount, Dock.Right);

            listViewItem.Tag = e.Item;

            UpdateDetails();
        }
Пример #2
0
 public void OnUpdateListViewItem(object sender, ItemPocketEventArgs e)
 {
     ((Image)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[0]).Source   = ItemDatabase.GetItemImageFromID(e.Item.ID);
     ((TextBlock)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[1]).Text = (pocket.PocketType == ItemTypes.Berries ? "No" + (e.Item.ID - 132).ToString("00") + " " : "") + e.Item.ItemData.Name;
     ((TextBlock)((DockPanel)pocket.ListViewItems[e.Index].Content).Children[2]).Text = e.Item.Count.ToString();
     pocket.ListViewItems[e.Index].Tag = e.Item;
 }
Пример #3
0
        public void OnRemoveListViewItem(object sender, ItemPocketEventArgs e)
        {
            if (e.Index == selectedIndex)
            {
                selectedItem  = null;
                selectedIndex = -1;
            }
            pocket.ListViewItems.RemoveAt(e.Index);

            UpdateDetails();
        }
Пример #4
0
        public void OnMoveListViewItem(object sender, ItemPocketEventArgs e)
        {
            ItemPocket pocket = sender as ItemPocket;

            pocket.ListViewItems.Move(e.OldIndex, e.NewIndex);
        }