//creates the panel for a new route private void createRoutePanel() { panelRouteInfo.Children.Clear(); ListBox lbRouteInfo = new ListBox(); lbRouteInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbRouteInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelRouteInfo.Children.Add(lbRouteInfo); WrapPanel panelDestination1 = new WrapPanel(); cbDestination1 = createDestinationComboBox(); panelDestination1.Children.Add(cbDestination1); txtDestination1Gates = new TextBlock(); txtDestination1Gates.Margin = new Thickness(5, 0, 0, 0); txtDestination1Gates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelDestination1.Children.Add(txtDestination1Gates); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "202"), panelDestination1)); WrapPanel panelDestination2 = new WrapPanel(); cbDestination2 = createDestinationComboBox(); panelDestination2.Children.Add(cbDestination2); txtDestination2Gates = new TextBlock(); txtDestination2Gates.Margin = new Thickness(5, 0, 0, 0); txtDestination2Gates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelDestination2.Children.Add(txtDestination2Gates); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "203"), panelDestination2)); ucStopover1 = new ucStopover(); ucStopover1.ValueChanged += ucStopover_OnValueChanged; lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1003"), ucStopover1)); ucStopover2 = new ucStopover(); ucStopover2.ValueChanged += ucStopover_OnValueChanged; lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1003"), ucStopover2)); txtRoute = UICreator.CreateTextBlock(""); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1004"), txtRoute)); txtDistance = UICreator.CreateTextBlock("-"); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "204"), txtDistance)); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "205"), UICreator.CreateTextBlock(string.Format("{0:0} {1}", new NumberToUnitConverter().Convert(this.MaxDistance), new StringToLanguageConverter().Convert("km."))))); if (this.RouteType == Route.RouteType.Mixed || this.RouteType == Route.RouteType.Passenger) { this.Classes.Clear(); foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType))) { RouteAirlinerClass rClass = new RouteAirlinerClass(type, RouteAirlinerClass.SeatingType.Reserved_Seating, 1); foreach (RouteFacility.FacilityType ftype in Enum.GetValues(typeof(RouteFacility.FacilityType))) { if (GameObject.GetInstance().GameTime.Year >= (int)ftype) rClass.addFacility(RouteFacilities.GetBasicFacility(ftype)); } this.Classes.Add(type, rClass); WrapPanel panelClassButtons = new WrapPanel(); Button btnEdit = new Button(); btnEdit.Background = Brushes.Transparent; btnEdit.Tag = type; btnEdit.Click += new RoutedEventHandler(btnEdit_Click); Image imgEdit = new Image(); imgEdit.Width = 16; imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEdit.Content = imgEdit; panelClassButtons.Children.Add(btnEdit); Image imgInfo = new Image(); imgInfo.Width = 16; imgInfo.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute)); imgInfo.Margin = new Thickness(5, 0, 0, 0); imgInfo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; RenderOptions.SetBitmapScalingMode(imgInfo, BitmapScalingMode.HighQuality); Border brdToolTip = new Border(); brdToolTip.Margin = new Thickness(-4, 0, -4, -3); brdToolTip.Padding = new Thickness(5); brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2"); ContentControl lblClass = new ContentControl(); lblClass.SetResourceReference(ContentControl.ContentTemplateProperty, "RouteAirlinerClassItem"); lblClass.Content = rClass; brdToolTip.Child = lblClass; imgInfo.ToolTip = brdToolTip; panelClassButtons.Children.Add(imgInfo); lbRouteInfo.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(type, null, null, null).ToString(), panelClassButtons)); } } if (this.RouteType == Route.RouteType.Mixed || this.RouteType == Route.RouteType.Cargo) { WrapPanel panelCargo = new WrapPanel(); txtCargo = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.CargoPrice).ToString()); txtCargo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelCargo.Children.Add(txtCargo); Button btnEditCargo = new Button(); btnEditCargo.Margin = new Thickness(5, 0, 0, 0); btnEditCargo.Background = Brushes.Transparent; btnEditCargo.Click += new RoutedEventHandler(btnEditCargo_Click); Image imgEdit = new Image(); imgEdit.Width = 16; imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEditCargo.Content = imgEdit; panelCargo.Children.Add(btnEditCargo); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1007"), panelCargo)); } txtInvalidRoute = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PanelNewRoute", "1001")); txtInvalidRoute.Foreground = Brushes.DarkRed; txtInvalidRoute.Visibility = System.Windows.Visibility.Collapsed; panelRouteInfo.Children.Add(txtInvalidRoute); WrapPanel panelButtons = new WrapPanel(); panelButtons.Margin = new Thickness(0, 5, 0, 0); panelRouteInfo.Children.Add(panelButtons); btnSave = new Button(); btnSave.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnSave.Height = Double.NaN; btnSave.Width = Double.NaN; btnSave.Content = Translator.GetInstance().GetString("General", "113"); btnSave.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnSave.Click += new RoutedEventHandler(btnSave_Click); btnSave.IsEnabled = false; panelButtons.Children.Add(btnSave); btnLoad = new Button(); btnLoad.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnLoad.Height = Double.NaN; btnLoad.Width = Double.NaN; btnLoad.Content = Translator.GetInstance().GetString("General", "115"); btnLoad.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnLoad.IsEnabled = false; btnLoad.Click += new RoutedEventHandler(btnLoad_Click); btnLoad.Margin = new Thickness(5, 0, 0, 0); btnLoad.Visibility = this.RouteType == Route.RouteType.Cargo ? Visibility.Collapsed : Visibility.Visible; panelButtons.Children.Add(btnLoad); }
//creates the panel for a new route private void createRoutePanel() { panelRouteInfo.Children.Clear(); ListBox lbRouteInfo = new ListBox(); lbRouteInfo.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbRouteInfo.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelRouteInfo.Children.Add(lbRouteInfo); WrapPanel panelDestination1 = new WrapPanel(); cbDestination1 = createDestinationComboBox(); panelDestination1.Children.Add(cbDestination1); txtDestination1Gates = new TextBlock(); txtDestination1Gates.Margin = new Thickness(5, 0, 0, 0); txtDestination1Gates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelDestination1.Children.Add(txtDestination1Gates); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "202"), panelDestination1)); WrapPanel panelDestination2 = new WrapPanel(); cbDestination2 = createDestinationComboBox(); panelDestination2.Children.Add(cbDestination2); txtDestination2Gates = new TextBlock(); txtDestination2Gates.Margin = new Thickness(5, 0, 0, 0); txtDestination2Gates.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelDestination2.Children.Add(txtDestination2Gates); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "203"), panelDestination2)); ucStopover1 = new ucStopover(); ucStopover1.ValueChanged += ucStopover_OnValueChanged; lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1003"), ucStopover1)); ucStopover2 = new ucStopover(); ucStopover2.ValueChanged += ucStopover_OnValueChanged; lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1003"), ucStopover2)); txtRoute = UICreator.CreateTextBlock(""); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1004"), txtRoute)); txtDistance = UICreator.CreateTextBlock("-"); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "204"), txtDistance)); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "205"), UICreator.CreateTextBlock(string.Format("{0:0} {1}", new NumberToUnitConverter().Convert(this.MaxDistance), new StringToLanguageConverter().Convert("km."))))); if (this.RouteType == Route.RouteType.Mixed || this.RouteType == Route.RouteType.Passenger) { this.Classes.Clear(); foreach (AirlinerClass.ClassType type in Enum.GetValues(typeof(AirlinerClass.ClassType))) { RouteAirlinerClass rClass = new RouteAirlinerClass(type, RouteAirlinerClass.SeatingType.Reserved_Seating, 1); foreach (RouteFacility.FacilityType ftype in Enum.GetValues(typeof(RouteFacility.FacilityType))) { if (GameObject.GetInstance().GameTime.Year >= (int)ftype) { rClass.addFacility(RouteFacilities.GetBasicFacility(ftype)); } } this.Classes.Add(type, rClass); WrapPanel panelClassButtons = new WrapPanel(); Button btnEdit = new Button(); btnEdit.Background = Brushes.Transparent; btnEdit.Tag = type; btnEdit.Click += new RoutedEventHandler(btnEdit_Click); Image imgEdit = new Image(); imgEdit.Width = 16; imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEdit.Content = imgEdit; panelClassButtons.Children.Add(btnEdit); Image imgInfo = new Image(); imgInfo.Width = 16; imgInfo.Source = new BitmapImage(new Uri(@"/Data/images/info.png", UriKind.RelativeOrAbsolute)); imgInfo.Margin = new Thickness(5, 0, 0, 0); imgInfo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; RenderOptions.SetBitmapScalingMode(imgInfo, BitmapScalingMode.HighQuality); Border brdToolTip = new Border(); brdToolTip.Margin = new Thickness(-4, 0, -4, -3); brdToolTip.Padding = new Thickness(5); brdToolTip.SetResourceReference(Border.BackgroundProperty, "HeaderBackgroundBrush2"); ContentControl lblClass = new ContentControl(); lblClass.SetResourceReference(ContentControl.ContentTemplateProperty, "RouteAirlinerClassItem"); lblClass.Content = rClass; brdToolTip.Child = lblClass; imgInfo.ToolTip = brdToolTip; panelClassButtons.Children.Add(imgInfo); lbRouteInfo.Items.Add(new QuickInfoValue(new TextUnderscoreConverter().Convert(type, null, null, null).ToString(), panelClassButtons)); } } if (this.RouteType == Route.RouteType.Mixed || this.RouteType == Route.RouteType.Cargo) { WrapPanel panelCargo = new WrapPanel(); txtCargo = UICreator.CreateTextBlock(new ValueCurrencyConverter().Convert(this.CargoPrice).ToString()); txtCargo.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelCargo.Children.Add(txtCargo); Button btnEditCargo = new Button(); btnEditCargo.Margin = new Thickness(5, 0, 0, 0); btnEditCargo.Background = Brushes.Transparent; btnEditCargo.Click += new RoutedEventHandler(btnEditCargo_Click); Image imgEdit = new Image(); imgEdit.Width = 16; imgEdit.Source = new BitmapImage(new Uri(@"/Data/images/edit.png", UriKind.RelativeOrAbsolute)); RenderOptions.SetBitmapScalingMode(imgEdit, BitmapScalingMode.HighQuality); btnEditCargo.Content = imgEdit; panelCargo.Children.Add(btnEditCargo); lbRouteInfo.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PanelNewRoute", "1007"), panelCargo)); } txtInvalidRoute = UICreator.CreateTextBlock(Translator.GetInstance().GetString("PanelNewRoute", "1001")); txtInvalidRoute.Foreground = Brushes.DarkRed; txtInvalidRoute.Visibility = System.Windows.Visibility.Collapsed; panelRouteInfo.Children.Add(txtInvalidRoute); WrapPanel panelButtons = new WrapPanel(); panelButtons.Margin = new Thickness(0, 5, 0, 0); panelRouteInfo.Children.Add(panelButtons); btnSave = new Button(); btnSave.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnSave.Height = Double.NaN; btnSave.Width = Double.NaN; btnSave.Content = Translator.GetInstance().GetString("General", "113"); btnSave.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnSave.Click += new RoutedEventHandler(btnSave_Click); btnSave.IsEnabled = false; panelButtons.Children.Add(btnSave); btnLoad = new Button(); btnLoad.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnLoad.Height = Double.NaN; btnLoad.Width = Double.NaN; btnLoad.Content = Translator.GetInstance().GetString("General", "115"); btnLoad.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); btnLoad.IsEnabled = false; btnLoad.Click += new RoutedEventHandler(btnLoad_Click); btnLoad.Margin = new Thickness(5, 0, 0, 0); btnLoad.Visibility = this.RouteType == Route.RouteType.Cargo ? Visibility.Collapsed : Visibility.Visible; panelButtons.Children.Add(btnLoad); }