Exemple #1
0
        //Event handler for clicking the edit button.
        private void button_Edit_Click(object sender, RoutedEventArgs e)
        {
            if (listView_Master.SelectedItems.Count == 1 && listView_Master.SelectedIndex != -1)
            {
                //Instantiate a new AddItem window.
                LootItem i      = listView_Master.SelectedItem as LootItem;
                AddItem  window = new AddItem(i);

                //Show the window.
                window.ShowDialog();

                if (!window.canceled)
                {
                    //Set the properties on the lootitem.
                    i.itemname = window.textBox_Name.Text;
                    i.loottype = window.comboBox_Type.Text;
                    int tempCount = Convert.ToInt32(window.textBox_Count.Text);
                    if (tempCount < i.assignedcount && tempCount < i.count)
                    {
                        i.count = i.assignedcount;
                    }
                    else
                    {
                        i.count = (Convert.ToInt32(window.textBox_Count.Text));
                    }

                    i.basevalue  = (Convert.ToInt32(window.textBox_BaseValue.Text));
                    i.baseweight = (Convert.ToDecimal(window.textBox_BaseWeight.Text));
                    i.notes      = window.textBox_Notes.Text;

                    //Refresh the values and notify the UI that the lootlist has updated.
                    i.CalculateAllValues();
                }

                viewModel.NotifyPropertyChanged("LootList");
                viewModel.RefreshView();
            }
        }
Exemple #2
0
        //Event handler for clicking the equip button (also when double clicking an item).
        private void button_Assignments_Click(object sender, RoutedEventArgs e)
        {
            if (listView_Master.SelectedItems.Count == 1 && listView_Master.SelectedIndex != -1)
            {
                LootItem   l                 = (listView_Master.SelectedItem as LootItem);
                LootItem   l_temp            = l.Clone();
                AssignItem window_AssignItem = new AssignItem(viewModel.PlayerList, l_temp);
                window_AssignItem.ShowDialog();

                if (window_AssignItem.isCancelled == false)
                {
                    //Update the assignments.
                    l.assignments = l_temp.assignments;

                    //Refresh the values and notify the UI that the lootlist has updated.
                    l.CalculateAllValues();

                    //Refresh the view.
                    viewModel.RefreshView();
                    viewModel.NotifyPropertyChanged("LootList");
                }
            }
        }