Example #1
0
        //Event Handler for creating a new lootitem from highlighted notes text.
        private void NewItemFromNotes_Click(object sender, RoutedEventArgs e)
        {
            if (textBox_Notes.SelectedText.Length > 0)
            {
                //Instantiate a new AddItem window.
                AddItem window = new AddItem(textBox_Notes.SelectedText);

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

                if (!window.canceled)
                {
                    LootItem item = new LootItem(window.textBox_Name.Text, window.comboBox_Type.Text, (Convert.ToInt32(window.textBox_Count.Text)), (Convert.ToInt32(window.textBox_BaseValue.Text)), (Convert.ToDecimal(window.textBox_BaseWeight.Text)), window.textBox_Notes.Text);
                    viewModel.AddItemToModel(item);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Item control event handlers.
        /// </summary>
        //Event handler for clicking the new item menu item.
        private void NewItem_Click(object sender, RoutedEventArgs e)
        {
            //Instantiate a new AddItem window.
            AddItem window = new AddItem();

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

            if (!window.canceled)
            {
                LootItem item = new LootItem(window.textBox_Name.Text, window.comboBox_Type.Text, (Convert.ToInt32(window.textBox_Count.Text)), (Convert.ToInt32(window.textBox_BaseValue.Text)), (Convert.ToDecimal(window.textBox_BaseWeight.Text)), window.textBox_Notes.Text);
                viewModel.AddItemToModel(item);
            }

            viewModel.NotifyPropertyChanged("LootList");
            viewModel.RefreshView();
        }
Example #3
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();
            }
        }