public PopUpDifficulty(DifficultyLevel level) { this.Level = level; InitializeComponent(); this.Uid = "1000"; this.Title = Translator.GetInstance().GetString("PopUpDifficulty", this.Uid); this.Width = 400; this.Height = 210; this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; StackPanel mainPanel = new StackPanel(); mainPanel.Margin = new Thickness(10, 10, 10, 10); ListBox lbContent = new ListBox(); lbContent.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbContent.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); mainPanel.Children.Add(lbContent); DifficultyLevel easyLevel = DifficultyLevels.GetDifficultyLevel("Easy"); DifficultyLevel normalLevel = DifficultyLevels.GetDifficultyLevel("Normal"); DifficultyLevel hardLevel = DifficultyLevels.GetDifficultyLevel("Hard"); slMoney = createDifficultySlider(easyLevel.MoneyLevel, normalLevel.MoneyLevel, hardLevel.MoneyLevel, level.MoneyLevel); slLoan = createDifficultySlider(easyLevel.LoanLevel, normalLevel.LoanLevel, hardLevel.LoanLevel, level.LoanLevel); slAI = createDifficultySlider(easyLevel.AILevel, normalLevel.AILevel, hardLevel.AILevel, level.AILevel); slPassengers = createDifficultySlider(easyLevel.PassengersLevel, normalLevel.PassengersLevel, hardLevel.PassengersLevel, level.PassengersLevel); slPrice = createDifficultySlider(easyLevel.PriceLevel, normalLevel.PriceLevel, hardLevel.PriceLevel, level.PriceLevel); slStartData = createDifficultySlider(easyLevel.StartDataLevel, normalLevel.StartDataLevel, hardLevel.StartDataLevel, level.StartDataLevel); lbContent.Items.Add(new QuickInfoValue("", createIndicator())); lbContent.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpDifficulty", "200"), slMoney)); lbContent.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpDifficulty", "201"), slPrice)); lbContent.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpDifficulty", "202"), slLoan)); lbContent.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpDifficulty", "203"), slPassengers)); lbContent.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpDifficulty", "204"), slAI)); lbContent.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PopUpDifficulty", "205"), slStartData)); mainPanel.Children.Add(createButtonsPanel()); this.Content = mainPanel; }
public PageCreateDifficulty() { this.Difficulties = new List <DifficultyMVVM>(); DifficultyLevel easyLevel = DifficultyLevels.GetDifficultyLevel("Easy"); DifficultyLevel normalLevel = DifficultyLevels.GetDifficultyLevel("Normal"); DifficultyLevel hardLevel = DifficultyLevels.GetDifficultyLevel("Hard"); this.Difficulties.Add(new DifficultyMVVM("money", Translator.GetInstance().GetString("PageCreateDifficulty", "1000"), easyLevel.MoneyLevel, normalLevel.MoneyLevel, hardLevel.MoneyLevel)); this.Difficulties.Add(new DifficultyMVVM("price", Translator.GetInstance().GetString("PageCreateDifficulty", "1001"), easyLevel.PriceLevel, normalLevel.PriceLevel, hardLevel.PriceLevel)); this.Difficulties.Add(new DifficultyMVVM("loan", Translator.GetInstance().GetString("PageCreateDifficulty", "1002"), easyLevel.LoanLevel, normalLevel.LoanLevel, hardLevel.LoanLevel)); this.Difficulties.Add(new DifficultyMVVM("passengers", Translator.GetInstance().GetString("PageCreateDifficulty", "1003"), easyLevel.PassengersLevel, normalLevel.PassengersLevel, hardLevel.PassengersLevel)); this.Difficulties.Add(new DifficultyMVVM("AI", Translator.GetInstance().GetString("PageCreateDifficulty", "1004"), easyLevel.AILevel, normalLevel.AILevel, hardLevel.AILevel)); this.Difficulties.Add(new DifficultyMVVM("startdata", Translator.GetInstance().GetString("PageCreateDifficulty", "1005"), easyLevel.StartDataLevel, normalLevel.StartDataLevel, hardLevel.StartDataLevel)); InitializeComponent(); }
private void btnAddDifficulty_Click(object sender, RoutedEventArgs e) { object o = PopUpDifficulty.ShowPopUp((DifficultyLevel)cbDifficulty.SelectedItem); if (o != null && o is DifficultyLevel) { DifficultyLevel level = (DifficultyLevel)o; if (DifficultyLevels.GetDifficultyLevel("Custom") != null) { DifficultyLevel customLevel = DifficultyLevels.GetDifficultyLevel("Custom"); DifficultyLevels.RemoveDifficultyLevel(customLevel); cbDifficulty.Items.Remove(customLevel); } DifficultyLevels.AddDifficultyLevel(level); cbDifficulty.Items.Add(level); cbDifficulty.SelectedItem = level; } }
//create the slider indicator private Grid createIndicator() { Grid grdIndicator = UICreator.CreateGrid(3); grdIndicator.Width = 200; TextBlock txtEasy = UICreator.CreateTextBlock(DifficultyLevels.GetDifficultyLevel("Easy").Name); TextBlock txtNormal = UICreator.CreateTextBlock(DifficultyLevels.GetDifficultyLevel("Normal").Name); TextBlock txtHard = UICreator.CreateTextBlock(DifficultyLevels.GetDifficultyLevel("Hard").Name); Grid.SetColumn(txtEasy, 0); grdIndicator.Children.Add(txtEasy); txtNormal.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; Grid.SetColumn(txtNormal, 1); grdIndicator.Children.Add(txtNormal); Grid.SetColumn(txtHard, 2); txtHard.HorizontalAlignment = System.Windows.HorizontalAlignment.Right; grdIndicator.Children.Add(txtHard); return(grdIndicator); }