public InventoryRetriever(CsgoItemsGameFileParser parser, InventoryFileLoader loader)
        {
            if (parser.IsValid)
            {
                _invSolver = new ItemSolver(parser);
            }

            _itemInv = new List<CompleteItemInfo>();
            _inventoryFileLoader = loader;
        }
示例#2
0
        private void btnRescanInv_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtItems_games.Text) == false && string.IsNullOrWhiteSpace(txtItems_730Bin.Text) == false)
            {
                if (_kvFileReader == null || _kvFileReader.IsClosed)
                {
                    _kvFileReader = new CsgoItemsGameFileParser(txtItems_games.Text);
                }

                if (_kvFileReader.IsValid)
                {
                    lblItems_gameTxt.ForeColor = Color.Green;
                    lblItems_gameTxt.Text = @"Correct file";
                }
                else
                {
                    lblItems_gameTxt.ForeColor = Color.Red;
                    lblItems_gameTxt.Text = @"Invalid file";
                }

                if (_inventoryFileLoader == null)
                {
                    _inventoryFileLoader = new InventoryFileLoader(txtItems_730Bin.Text);
                }

                switch (_inventoryFileLoader.FileLoadResult)
                {
                    case LoadFileReturnValue.ValidAndUseable:
                        lblItems_730Bin.ForeColor = Color.Green;
                        lblItems_730Bin.Text = @"Correct file";
                        btnReloadInv.Enabled = false;
                        btnSave.Enabled = true;

                        if (_inventoryFileLoader.Manager.IsClosed)
                        {
                            _inventoryFileLoader = new InventoryFileLoader(txtItems_730Bin.Text);
                        }
                        break;
                    case LoadFileReturnValue.ReadOnly:
                        lblItems_730Bin.ForeColor = Color.Red;
                        lblItems_730Bin.Text = @"File is readonly!";
                        btnReloadInv.Enabled = true;
                        btnSave.Enabled = false;
                        break;
                    case LoadFileReturnValue.ValidHeaderBrokenInside:
                        lblItems_730Bin.ForeColor = Color.Red;
                        lblItems_730Bin.Text = @"File is unsupported/wrong file!";
                        btnReloadInv.Enabled = true;
                        btnSave.Enabled = false;
                        break;
                    case LoadFileReturnValue.NotValid:
                        lblItems_730Bin.ForeColor = Color.Red;
                        lblItems_730Bin.Text = @"Invalid file!";
                        btnReloadInv.Enabled = true;
                        btnSave.Enabled = false;
                        break;
                    case LoadFileReturnValue.NotExist:
                        lblItems_730Bin.ForeColor = Color.Red;
                        lblItems_730Bin.Text = @"File does not exist!";
                        btnReloadInv.Enabled = true;
                        btnSave.Enabled = false;
                        break;
                    default:
                        break;
                }
            }

            clbInventories.Items.Clear();

            if (_kvFileReader.IsValid && _inventoryFileLoader.FileLoadResult == LoadFileReturnValue.ValidAndUseable)
            {
                _invRetriever = new InventoryRetriever(_kvFileReader, _inventoryFileLoader);

                foreach (var item in _invRetriever.GetAllInventories())
                {
                    clbInventories.Items.Add(item);
                }
                clbInventories.SelectedIndex = 0;

                foreach (var item in _kvFileReader.GetItemSets())
                {
                    clbItemSets.Items.Add(item);
                }

                foreach (var item in _kvFileReader.GetOfficialItems())
                {
                    lvItem = new ListViewItem();
                    lvItem.Text = item.Item1.CodedName;
                    lvItem.SubItems.Add(item.Item2.Name);
                    lvItem.SubItems.Add(item.Item2.Rarity);
                    lvItem.Checked = false;
                    lvRecognizedOfficialItems.Items.Add(lvItem);
                }
            }
        }
示例#3
0
        private void btnBrowseItems730_Click(object sender, EventArgs e)
        {
            if (ofdFileBin.ShowDialog() == DialogResult.OK)
            {
                txtItems_730Bin.Text = ofdFileBin.FileName;

                _inventoryFileLoader = new InventoryFileLoader(ofdFileBin.FileName);

                switch (_inventoryFileLoader.FileLoadResult)
                {
                    case LoadFileReturnValue.ValidAndUseable:
                        lblItems_730Bin.ForeColor = Color.Green;
                        lblItems_730Bin.Text = @"Correct file";

                        break;
                    case LoadFileReturnValue.ReadOnly:
                        lblItems_730Bin.ForeColor = Color.Red;
                        lblItems_730Bin.Text = @"File is readonly!";
                        break;
                    case LoadFileReturnValue.ValidHeaderBrokenInside:
                        lblItems_730Bin.ForeColor = Color.Red;
                        lblItems_730Bin.Text = @"File is unsupported/wrong file!";
                        break;
                    case LoadFileReturnValue.NotValid:
                        lblItems_730Bin.ForeColor = Color.Red;
                        lblItems_730Bin.Text = @"Invalid file!";
                        break;
                    case LoadFileReturnValue.NotExist:
                        lblItems_730Bin.ForeColor = Color.Red;
                        lblItems_730Bin.Text = @"File does not exist!";
                        break;
                    default:
                        break;
                }
            }
        }