Exemplo n.º 1
0
        private void AddUnitClick(object sender, RoutedEventArgs e)
        {
            if (SelectedCell.UnitStack != null)
            {
                if (SelectedPlayer.UnitStacks.Contains(SelectedCell.UnitStack))
                {
                    var addUnitWindow = new AddUnitWindow();

                    if (addUnitWindow.ShowDialog() == false)
                    {
                        return;
                    }

                    AddUnitFromWidnowContext(addUnitWindow);

                    var remUnit = SelectedCell.UnitStack;
                    SelectedPlayer.UnitStacks.Remove(remUnit);
                }
            }
            else
            {
                var addUnitWindow = new AddUnitWindow();

                if (addUnitWindow.ShowDialog() == false)
                {
                    return;
                }

                AddUnitFromWidnowContext(addUnitWindow);
            }
        }
Exemplo n.º 2
0
        public void OnAddUnit(Object obj, EventArgs args)
        {
            // Quickly build the array of strings\
            int tempCount = MainVM.UnitEditor.NameList.Count;

            string[] tempNames = new string[tempCount];
            for (int i = 0; i < tempCount; i++)
            {
                tempNames[i] = MainVM.UnitEditor.NameList[i].ViewName;
            }

            AddUnitWindow addDlg = new AddUnitWindow(tempNames);

            // And don't forget to pass along the ValidationRules!
            //addDlg.NameRules.SetUnitList(MainVM.UnitEditor.NameList);

            bool?addRes = addDlg.ShowDialog();

            // Push results if the user hit "Okay"
            if (addRes == true)
            {
                MainVM.AddUnit(addDlg.UnitIndex, addDlg.NewUnitName);
            }
        }