예제 #1
0
        private void GridTroopsTemplates_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (e.RowIndex >= 0)
                {
                    var troopsTemplateName = GridTroopsTemplates.Rows[e.RowIndex].Cells[1].Value.ToString();

                    var troopsTemplate = _plemionaToolLocalData.TroopsTemplates.Single(tt => tt.Name == troopsTemplateName);

                    using (var frmTroopsTemplate = new FrmTroopsTemplate(_plemionaToolLocalData.TroopsTemplates.Select(tt => tt.Name), troopsTemplate))
                    {
                        var dialogResult = frmTroopsTemplate.ShowDialog();

                        if (dialogResult == DialogResult.OK)
                        {
                            if (frmTroopsTemplate.Deletetion)
                            {
                                _plemionaToolLocalData.TroopsTemplates.Remove(troopsTemplate);
                                GridTroopsTemplates.Rows.RemoveAt(e.RowIndex);
                                FixGridNumbers(GridTroopsTemplates);
                            }
                            else
                            {
                                GridTroopsTemplates.Rows[e.RowIndex].Cells[1].Value = troopsTemplate.Name;
                            }

                            _plemionaToolLocalDataService.Save(_plemionaToolLocalData);
                        }
                    }
                }
            }
        }
예제 #2
0
        private void BtnShowTroopsTemplate_MouseClick(object sender, MouseEventArgs e)
        {
            var selectedTroopsTemplate = _troopsTemplates.Single(tt => tt.Name == CbxTroopsTemplate.Text);

            using (var frmTroopsTemplate = new FrmTroopsTemplate(selectedTroopsTemplate))
            {
                frmTroopsTemplate.ShowDialog();
            }
        }
예제 #3
0
        private void BtnCheckRequiredTroops_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                var requiredTroopsTemplate = new TroopsTemplate
                {
                    Name   = "Troops required to perform order",
                    Troops = _requiredTroops
                };

                using (var frmTroopsTemplate = new FrmTroopsTemplate(requiredTroopsTemplate))
                {
                    frmTroopsTemplate.ShowDialog();
                }
            }
        }
예제 #4
0
        private void BtnAddTroopsTemplate_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                using (var frmTroopsTemplate = new FrmTroopsTemplate(_plemionaToolLocalData.TroopsTemplates.Select(tt => tt.Name)))
                {
                    var dialogResult = frmTroopsTemplate.ShowDialog();

                    if (dialogResult == DialogResult.OK)
                    {
                        var troopsTemplate = frmTroopsTemplate.TroopsTemplate;

                        _plemionaToolLocalData.TroopsTemplates.Add(troopsTemplate);

                        GridTroopsTemplates.Rows.Add(GridTroopsTemplates.RowCount + 1, troopsTemplate.Name);
                    }
                }
            }
        }