Esempio n. 1
0
        /// <summary>
        /// ラベルに表示する名前を取得する。
        /// </summary>
        /// <param name="entry">アイテムエントリ</param>
        /// <returns>ラベルに表示する名前</returns>
        private static string GetLabelName(ItemEntry entry)
        {
            switch (entry.Kind)
            {
            case (int)(ItemType.Item):
                return($"Item:{entry.Id}");

            case (int)(ItemType.Weapon):
                return($"Weapon:{entry.Id}");

            case (int)(ItemType.Armor):
                return($"Armor:{entry.Id}");

            default:
                return($"type{entry.Kind}/{entry.Id}");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 表示するアイテム名を得る。
        /// </summary>
        /// <param name="entry">エントリ</param>
        /// <returns>アイテム名</returns>
        private string GetDisplayItemName(ItemEntry entry)
        {
            switch (entry.Kind)
            {
            case (int)(ItemType.Item):
                return("Item:" + GetItemName(items, entry.Id));

            case (int)(ItemType.Weapon):
                return("Weapon:" + GetItemName(weapons, entry.Id));

            case (int)(ItemType.Armor):
                return("Armor:" + GetItemName(armors, entry.Id));

            default:
                return($"Type{entry.Kind}:{entry.Id}");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// アイテムが選択された時に通知を受け取る。
        /// </summary>
        /// <param name="sender">送信元オブジェクト</param>
        /// <param name="e">イベントオブジェクト</param>
        private void OnItemListItemSelected(object sender, EventArgs e)
        {
            IItem    item = itemListForm.SelectedItem;
            DataShop shop = GetSelectedShop();

            if (shop == null)
            {
                return;
            }

            ItemEntry itemEntry = new ItemEntry();

            itemEntry.Id       = item.Id;
            itemEntry.Kind     = GetItemKind(item);
            itemEntry.MinCount = 0;
            itemEntry.MaxCount = 1;
            shop.ItemList.Add(itemEntry);

            DataTable dt  = (DataTable)(dataGridViewItems.DataSource);
            var       row = dt.NewRow();

            SetRowData(row, itemEntry);
            dt.Rows.Add(row);
        }
Esempio n. 4
0
        /// <summary>
        /// セルの値が変更されたときの処理を行う。
        /// </summary>
        /// <param name="sender">送信元オブジェクト</param>
        /// <param name="e">イベントオブジェクト</param>
        private void OnDataGridViewCellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                DataShop shop = GetSelectedShop();
                if (shop == null)
                {
                    return;
                }
                DataTable dt    = (DataTable)(dataGridViewItems.DataSource);
                ItemEntry entry = shop.ItemList[e.RowIndex];
                DataRow   row   = dt.Rows[e.RowIndex];
                switch (e.ColumnIndex)
                {
                case 1:
                    if (DBNull.Value.Equals(row[1]))
                    {
                        row[1] = entry.MinCount;
                    }
                    else
                    {
                        entry.MinCount = (int)(row[1]);
                    }
                    break;

                case 2:
                    if (DBNull.Value.Equals(row[2]))
                    {
                        row[2] = entry.MaxCount;
                    }
                    else
                    {
                        entry.MaxCount = (int)(row[2]);
                    }
                    break;

                case 3:
                    if (DBNull.Value.Equals(row[3]))
                    {
                        row[3] = entry.BuyingPrice;
                    }
                    else
                    {
                        entry.BuyingPrice = (int)(row[3]);
                    }
                    break;

                case 4:
                    if (DBNull.Value.Equals(row[4]))
                    {
                        row[4] = entry.SellingPrice;
                    }
                    else
                    {
                        entry.SellingPrice = (int)(row[4]);
                    }
                    break;

                case 5:
                    entry.Condition = row.Field <string>(5) ?? string.Empty;
                    break;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(this, ex.Message, "Error");
            }
        }