Exemplo n.º 1
0
        private void btnCars_Click(object sender, EventArgs e)
        {
            try
            {                
                _toolbuildteam = new ToolBuildTeam((AccountInfo)cmbAccount.SelectedItem);
                _toolbuildteam.MessageChanged += new KaixinBase.MessageChangedEventHandler(_toolbuildteam_MessageChanged);
                _toolbuildteam.ValidateCodeNeeded += new KaixinBase.ValidateCodeNeededEventHandler(_toolbuildteam_ValidateCodeNeeded);
                _toolbuildteam.MyCarFetched += new GamePark.MyCarFetchedEventHandler(_toolbuildteam_MyCarFetched);

                if (cmbAccount.Items.Count <= 0 || cmbAccount.SelectedIndex < 0)
                {
                    MessageBox.Show("请选择账号!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cmbAccount.Select();
                    return;
                }

                _account = cmbAccount.Items[cmbAccount.SelectedIndex] as AccountInfo;

                if (_account == null)
                    return;

                SetControlStatus(false);
                
                _toolbuildteam.GetMyCarsByThread();
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("FrmBuildTeam", ex);
            }
        }
Exemplo n.º 2
0
        private void btnBuildTeam_Click(object sender, EventArgs e)
        {
            try
            {
                _toolbuildteam = new ToolBuildTeam((AccountInfo)cmbAccount.SelectedItem);
                _toolbuildteam.MessageChanged += new KaixinBase.MessageChangedEventHandler(_toolbuildteam_MessageChanged);
                _toolbuildteam.ValidateCodeNeeded += new KaixinBase.ValidateCodeNeededEventHandler(_toolbuildteam_ValidateCodeNeeded);
                _toolbuildteam.BuildTeamFinished += new GamePark.BuildTeamFinishedEventHandler(_toolbuildteam_BuildTeamFinished);

                if (cmbAccount.Items.Count <= 0 || cmbAccount.SelectedIndex < 0)
                {
                    MessageBox.Show("请选择账号!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cmbAccount.Select();
                    return;
                }

                if (lstViewCarsInMarket.SelectedItems.Count == 0)
                {
                    MessageBox.Show("请在市场上的汽车列表里选择你需要组建的车队车型!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    lstViewCarsInMarket.Select();
                    return;
                }

                if (cmbMaxCarCount.Items.Count <= 0 || cmbMaxCarCount.SelectedIndex < 0)
                {
                    MessageBox.Show("请选择汽车数量!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    cmbMaxCarCount.Select();
                    return;
                }

                _account = cmbAccount.Items[cmbAccount.SelectedIndex] as AccountInfo;

                if (_account == null)
                    return;

                _modelcar = new NewCarInfo();
                ListViewItem item = lstViewCarsInMarket.SelectedItems[0];
                if (item != null)
                {
                    _modelcar.CarId = DataConvert.GetInt32(item.SubItems[3].Text);
                    _modelcar.CarName = item.SubItems[1].Text;
                    _modelcar.CarPrice = DataConvert.GetInt32(item.SubItems[2].Text);
                }

                if (_modelcar.CarPrice < 70000)
                {
                    MessageBox.Show("按规则70000元以下的车型,同一款车只能拥有一辆!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    lstViewCarsInMarket.Select();
                    return;
                }
                if (_modelcar.CarPrice < 200000)
                {
                    if (MessageBox.Show("根据游戏规则,不能组建汽车单价低于200000的车队!是否继续?", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                    {
                        lstViewCarsInMarket.Select();
                        return;
                    }
                }

                _maxcarcount = DataConvert.GetInt32(cmbMaxCarCount.Items[cmbMaxCarCount.SelectedIndex].ToString());
                _exchange = ExchangeCar.Stop;
                if (rdbExpensive.Checked)
                    _exchange = ExchangeCar.Expensive;
                else if (rdbCheap.Checked)
                    _exchange = ExchangeCar.Cheap;

                SetControlStatus(false);
                
                _toolbuildteam._account = _account;
                _toolbuildteam._modelcar = _modelcar;
                _toolbuildteam._maxcarcount = _maxcarcount;
                _toolbuildteam._exchange = _exchange;
                _toolbuildteam._carsInMarket = _carsInMarket;
                _toolbuildteam.BuildTeamByThread();
            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("FrmBuildTeam", ex);
            }
        }
Exemplo n.º 3
0
        private void btnCarsInMarket_Click(object sender, EventArgs e)
        {
            try
            {
                _toolbuildteam = new ToolBuildTeam((AccountInfo)cmbAccount.SelectedItem);
                _toolbuildteam.MessageChanged += new KaixinBase.MessageChangedEventHandler(_toolbuildteam_MessageChanged);
                _toolbuildteam.ValidateCodeNeeded += new KaixinBase.ValidateCodeNeededEventHandler(_toolbuildteam_ValidateCodeNeeded);
                _toolbuildteam.AllCarsInMarketFetched += new GamePark.AllCarsInMarketFetchedEventHandler(_toolbuildteam_AllCarsInMarketFetched);

                if (cmbAccount.SelectedIndex >= 0)
                    _account = cmbAccount.Items[cmbAccount.SelectedIndex] as AccountInfo;
                else
                {
                    Collection<AccountInfo> accounts = ConfigCtrl.GetAccounts("");
                    if (accounts == null || accounts.Count == 0)
                    {
                        MessageBox.Show("没有有效的账号,无法刷新!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        cmbAccount.Select();
                        return;
                    }
                    if (accounts[0] == null)
                    {
                        MessageBox.Show("没有有效的账号,无法刷新!", MainConstants.MESSAGEBOX_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        cmbAccount.Select();
                        return;
                    }

                    _account = accounts[0];
                }

                SetControlStatus(false);

                _toolbuildteam.GetAllCarsInMarketByThread();

            }
            catch (Exception ex)
            {
                Program.ShowMessageBox("FrmBuildTeam", ex);
            }
        }