/// <summary> /// Creates a button. /// </summary> /// <param name="imageSource">Image to use.</param> /// <param name="toolTipReference">Reference where to find the ToolTip resource.</param> /// <returns>The created button.</returns> private static Button CreateButton(string imageSource, string toolTipReference) { var button = new Button(); button.HorizontalAlignment = HorizontalAlignment.Right; button.VerticalAlignment = VerticalAlignment.Top; button.Width = 20; button.Height = 20; var img = new Image(); img.SetResourceReference(Image.SourceProperty, imageSource); button.Content = img; var toolTipText = new TextBlock(); toolTipText.SetResourceReference(TextBlock.TextProperty, toolTipReference); toolTipText.SetResourceReference(TextBlock.ForegroundProperty, "BackBrush"); var toolTip = new ToolTip(); toolTip.Content = toolTipText; button.ToolTip = toolTip; return(button); }
/// <summary> /// This is used to get the content to add to the quick info by looking up the given topic ID to get its /// title and filename if possible. /// </summary> /// <param name="elementName">The element name for which to create content</param> /// <param name="id">The ID to look up if necessary</param> /// <returns>The content to add to the quick info (a text block element containing the additional info /// about the element)</returns> private UIElement CreateInfoText(string elementName, string id) { if(String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id)) return null; var textBlock = new TextBlock(); switch(elementName) { case "conceptualLink": var projectFileSearcher = new ProjectFileSearcher(serviceProvider, null); string title, filename, relativePath; bool found = projectFileSearcher.GetInfoFor(ProjectFileSearcher.IdType.Link, id, out title, out filename, out relativePath); textBlock.Inlines.AddRange(new Inline[] { new Bold(new Run("Title: ")), new Run(title), new LineBreak(), new Bold(new Run("Filename: ")), new Run(relativePath) }); if(found && ctrlClickEnabled) textBlock.Inlines.AddRange(new Inline[] { new LineBreak(), new Run("Ctrl+Click to open the file") }); break; case "cref": if(!ctrlClickEnabled) return null; if(!IntelliSense.RoslynHacks.RoslynUtilities.IsFinalRoslyn) textBlock.Inlines.Add(new Run("Ctrl+Click to go to definition (within solution only)")); else textBlock.Inlines.Add(new Run("Ctrl+Click to go to definition")); break; default: if(!ctrlClickEnabled) return null; textBlock.Inlines.Add(new Run("Ctrl+Click to open the containing file")); break; } // Set the styles in order to support other themes textBlock.SetResourceReference(TextBlock.BackgroundProperty, EnvironmentColors.ToolTipBrushKey); textBlock.SetResourceReference(TextBlock.ForegroundProperty, EnvironmentColors.ToolTipTextBrushKey); return textBlock; }
/// <summary> /// This is used to get the content to add to the quick info by looking up the given topic ID to get its /// title and filename if possible. /// </summary> /// <param name="elementName">The element name for which to create content</param> /// <param name="id">The ID to look up if necessary</param> /// <returns>The content to add to the quick info (a text block element containing the additional info /// about the element)</returns> private UIElement CreateInfoText(string elementName, string id) { if (String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id)) { return(null); } var textBlock = new TextBlock(); switch (elementName) { case "conceptualLink": var projectFileSearcher = new ProjectFileSearcher(serviceProvider, null); string title, filename, relativePath; #pragma warning disable VSTHRD010 bool found = projectFileSearcher.GetInfoFor(ProjectFileSearcher.IdType.Link, id, out title, out filename, out relativePath); #pragma warning restore VSTHRD010 textBlock.Inlines.AddRange(new Inline[] { new Bold(new Run("Title: ")), new Run(title), new LineBreak(), new Bold(new Run("Filename: ")), new Run(relativePath) }); if (found && ctrlClickEnabled) { textBlock.Inlines.AddRange(new Inline[] { new LineBreak(), new Run("Ctrl+Click to open the file") }); } break; default: if (!ctrlClickEnabled) { return(null); } textBlock.Inlines.Add(new Run("Ctrl+Click to open the containing file")); break; } // Set the styles in order to support other themes textBlock.SetResourceReference(TextBlock.BackgroundProperty, EnvironmentColors.ToolTipBrushKey); textBlock.SetResourceReference(TextBlock.ForegroundProperty, EnvironmentColors.ToolTipTextBrushKey); return(textBlock); }
/// <summary> /// This is used to get the content to add to the quick info by looking up the given topic ID to get its /// title and filename if possible. /// </summary> /// <param name="elementName">The element name for which to create content</param> /// <param name="id">The ID to look up if necessary</param> /// <returns>The content to add to the quick info (a text block element containing the additional info /// about the element)</returns> private UIElement CreateInfoText(string elementName, string id) { if (String.IsNullOrWhiteSpace(elementName) || String.IsNullOrWhiteSpace(id)) { return(null); } var textBlock = new TextBlock(); switch (elementName) { case "image": case "link": case "topic": var projectFileSearcher = new ProjectFileSearcher(serviceProvider, null); string title, filename, relativePath; bool found = projectFileSearcher.GetInfoFor(elementName == "image" ? ProjectFileSearcher.IdType.Image : ProjectFileSearcher.IdType.Link, id, out title, out filename, out relativePath); textBlock.Inlines.AddRange(new Inline[] { new Bold(new Run(elementName == "image" ? "Alternate Text: " : "Title: ")), new Run(title), new LineBreak(), new Bold(new Run("Filename: ")), new Run(relativePath) }); break; case "codeEntityReference": break; default: break; } // Set the styles in order to support other themes in VS 2012 and later object themeKey = Utility.GetThemeKey("ToolTipBrushKey", SystemColors.ControlLightBrushKey); if (themeKey != null) { textBlock.SetResourceReference(TextBlock.BackgroundProperty, themeKey); textBlock.SetResourceReference(TextBlock.ForegroundProperty, Utility.GetThemeKey("ToolTipTextBrushKey", SystemColors.ControlTextBrushKey)); } return(textBlock); }
protected override void OnInitialized(EventArgs e) { _checkbox = new CheckBox(); _checkbox.IsChecked = IsChecked(); _checkbox.Visibility = Visibility.Hidden; _checkbox.Padding = new Thickness(0, 0, 4, 0); _checkbox.Checked += CheckedChanged; _checkbox.Unchecked += CheckedChanged; Children.Add(_checkbox); var img = new Image(); img.Source = ToBitmap(_icon, 14); img.SetValue(RenderOptions.BitmapScalingModeProperty, BitmapScalingMode.HighQuality); var border = new Border(); border.BorderBrush = Brushes.Transparent; border.BorderThickness = new Thickness(1); border.Child = img; Children.Add(border); _text = new TextBlock(); _text.Width = 30; _text.Padding = new Thickness(4, 0, 0, 0); _text.SetResourceReference(Control.ForegroundProperty, VsBrushes.CaptionTextKey); _text.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.Aliased); _text.SetValue(TextOptions.TextFormattingModeProperty, TextFormattingMode.Ideal); Children.Add(_text); }
private void SeriesNameInput_TextChanged(object sender, TextChangedEventArgs e) { Panel.Children.Clear(); string text = SeriesNameInput.Text.ToLower(); if (!String.IsNullOrEmpty(text)) { foreach (var series in allSeries) { if (series.seriesName.ToLower() == text) { Clicked(series); break; } if (series.seriesName.ToLower().Contains(text)) { TextBlock textBlock = new TextBlock(); textBlock.Text = series.seriesName; textBlock.Margin = new Thickness(5, 10, 0, 0); textBlock.Height = 30; textBlock.MouseLeftButtonUp += (s, ev) => { SeriesNameInput.Text = series.seriesName; }; textBlock.FontSize = 16; textBlock.SetResourceReference(ForegroundProperty, "TextColor"); Panel.Children.Add(textBlock); } } } }
//creates the panel for the manufacturer contract private StackPanel createManufacturerContractPanel() { StackPanel panelContract = new StackPanel(); panelContract.Margin = new Thickness(5, 10, 10, 10); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1014"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.TextAlignment = TextAlignment.Left; txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageAirline", txtHeader.Uid); panelContract.Children.Add(txtHeader); ListBox lbContract = new ListBox(); lbContract.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbContract.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelContract.Children.Add(lbContract); lbContract.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1015"), UICreator.CreateTextBlock(this.Airline.Contract.Manufacturer.Name))); lbContract.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1016"), UICreator.CreateTextBlock(this.Airline.Contract.SigningDate.ToShortDateString()))); lbContract.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1017"), UICreator.CreateTextBlock(this.Airline.Contract.ExpireDate.ToShortDateString()))); lbContract.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1018"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", this.Airline.Contract.Discount)))); lbContract.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirline", "1019"), UICreator.CreateTextBlock(string.Format("{0} / {1}", this.Airline.Contract.PurchasedAirliners, this.Airline.Contract.Airliners)))); return(panelContract); }
//creates the training aircrafts panel private StackPanel createTrainingAircraftsPanel() { StackPanel panelAircrafts = new StackPanel(); panelAircrafts.Margin = new Thickness(0, 5, 0, 0); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1009"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PanelFlightSchool", txtHeader.Uid); panelAircrafts.Children.Add(txtHeader); lbTrainingAircrafts = new ListBox(); lbTrainingAircrafts.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbTrainingAircrafts.ItemTemplate = this.Resources["TrainingAircraftItem"] as DataTemplate; lbTrainingAircrafts.MaxHeight = (GraphicsHelpers.GetContentHeight() - 100) / 6; panelAircrafts.Children.Add(lbTrainingAircrafts); return(panelAircrafts); }
public PageHeader() { Brush brush = new SolidColorBrush(Colors.DarkGray); brush.Opacity = 0.60; this.Background = brush; Border frameBorder = new Border(); frameBorder.BorderBrush = Brushes.Gray; frameBorder.BorderThickness = new Thickness(2); DockPanel panelMain = new DockPanel(); panelMain.Margin = new Thickness(5, 5, 5, 5); panelMain.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; txtText = new TextBlock(); txtText.FontSize = 32; txtText.Margin = new Thickness(5, 0, 0, 0); txtText.SetResourceReference(TextBlock.ForegroundProperty, "HeaderTextColor"); txtText.VerticalAlignment = System.Windows.VerticalAlignment.Bottom; panelMain.Children.Add(txtText); frameBorder.Child = panelMain; this.Content = frameBorder; }
public static void Add(Grid grid, string label, Binding value, int row, string labelStyle, string inputStyle, int startColumn) { int column = startColumn; if (label != "") { TextBlock labelElement = new TextBlock(); labelElement.Style = App.Instance.Resources[labelStyle] as Style; labelElement.SetResourceReference(TextBlock.TextProperty, label); labelElement.VerticalAlignment = VerticalAlignment.Center; labelElement.Margin = new Thickness(column > 0 ? 5 : 0, 0, 0, 5); grid.Children.Add(labelElement); Grid.SetColumn(labelElement, column); Grid.SetRow(labelElement, row); column += 1; } System.Windows.Controls.CheckBox inputElement = new System.Windows.Controls.CheckBox(); inputElement.HorizontalAlignment = HorizontalAlignment.Stretch; inputElement.Margin = new Thickness(column > 0 ? 5 : 0, 0, 0, 5); if (inputStyle != "") { Style s = App.Instance.Resources[inputStyle] as Style;; if (s.TargetType == typeof(System.Windows.Controls.CheckBox)) { inputElement.Style = s; } } inputElement.SetBinding(System.Windows.Controls.CheckBox.IsCheckedProperty, value); grid.Children.Add(inputElement); Grid.SetColumn(inputElement, column); Grid.SetRow(inputElement, row); }
public static void Add(Grid grid, string label, Binding value, int row, string labelStyle, string inputStyle, int startColumn) { int column = startColumn; if (label != "") { TextBlock labelElement = new TextBlock(); labelElement.Style = App.Instance.Resources[labelStyle] as Style; labelElement.SetResourceReference(TextBlock.TextProperty, label); labelElement.VerticalAlignment = VerticalAlignment.Center; labelElement.Margin = new Thickness(column > 0 ? 5 : 0, 0, 0, 5); grid.Children.Add(labelElement); Grid.SetColumn(labelElement, column); Grid.SetRow(labelElement, row); column += 1; } TextBlock inputElement = new TextBlock(); inputElement.HorizontalAlignment = HorizontalAlignment.Center; inputElement.VerticalAlignment = VerticalAlignment.Center; inputElement.Margin = new Thickness(column > 0 ? 5 : 0, 0, 0, 5); inputElement.Style = App.Instance.Resources["HeaderLabel"] as Style; inputElement.SetBinding(System.Windows.Controls.TextBlock.TextProperty, value); grid.Children.Add(inputElement); Grid.SetColumn(inputElement, column); Grid.SetRow(inputElement, row); }
//creates the weather forecast panel private StackPanel createWeatherForecastPanel() { StackPanel panelForecast = new StackPanel(); panelForecast.Margin = new Thickness(0, 5, 0, 0); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1003"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.TextAlignment = TextAlignment.Left; txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageAirportWeather", txtHeader.Uid); panelForecast.Children.Add(txtHeader); WrapPanel panelDays = new WrapPanel(); for (int i = 1; i < this.Airport.Weather.Length; i++) { ccWeather[i] = new ContentControl(); ccWeather[i].ContentTemplate = this.Resources["WeatherForecastItem"] as DataTemplate; ccWeather[i].Content = this.Airport.Weather[i]; ccWeather[i].Margin = new Thickness(10, 0, 0, 0); panelDays.Children.Add(ccWeather[i]); } panelForecast.Children.Add(panelDays); return(panelForecast); }
//creates the panel for the human statistics private StackPanel createHumanStatisticsPanel() { StackPanel panelHumanStatistics = new StackPanel(); panelHumanStatistics.Margin = new Thickness(0, 10, 0, 0); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1005"; txtHeader.Margin = new Thickness(0, 0, 0, 0); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageAirlineStatistics", txtHeader.Uid); panelHumanStatistics.Children.Add(txtHeader); ListBox lbHumanStats = new ListBox(); lbHumanStats.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbHumanStats.SetResourceReference(ListBox.ItemTemplateProperty, "QuickInfoItem"); panelHumanStatistics.Children.Add(lbHumanStats); lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1006"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", StatisticsHelpers.GetHumanOnTime())))); lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1007"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", StatisticsHelpers.GetHumanFillAverage() * 100)))); lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1008"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", Ratings.GetCustomerHappiness(GameObject.GetInstance().HumanAirline))))); lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1009"), UICreator.CreateTextBlock(string.Format("{0:0.00}", StatisticsHelpers.GetHumanAvgTicketPPD())))); lbHumanStats.Items.Add(new QuickInfoValue(Translator.GetInstance().GetString("PageAirlineStatistics", "1012"), UICreator.CreateTextBlock(string.Format("{0:0.00} %", Ratings.GetEmployeeHappiness(GameObject.GetInstance().HumanAirline))))); return(panelHumanStatistics); }
protected virtual FrameworkElement CreateSelector() { var textBlock = new TextBlock(); textBlock.Text = "Select Component"; textBlock.IsHitTestVisible = false; textBlock.HorizontalAlignment = HorizontalAlignment.Left; textBlock.VerticalAlignment = VerticalAlignment.Center; textBlock.Margin = new Thickness(8, 0, 40, 0); textBlock.SetResourceReference( TextBlock.ForegroundProperty, "TextBrush" ); var selector = new UIComponentSelector(); selector.HorizontalAlignment = HorizontalAlignment.Stretch; selector.VerticalAlignment = VerticalAlignment.Center; selector.SetBinding( UIComponentSelector.ComponentProperty, new Binding() { Source = this, Path = new PropertyPath("Component") } ); var grid = new Grid(); grid.Children.Add(selector); grid.Children.Add(textBlock); return(grid); }
//creates the fleet route details private StackPanel createDetailedPanel() { StackPanel panelDetailed = new StackPanel(); TextBlock txtFleetHeader = new TextBlock(); txtFleetHeader.Uid = "1011"; txtFleetHeader.Margin = new Thickness(0, 0, 0, 0); txtFleetHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtFleetHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtFleetHeader.FontWeight = FontWeights.Bold; txtFleetHeader.Text = Translator.GetInstance().GetString("PageAirlineFleet", txtFleetHeader.Uid); panelDetailed.Children.Add(txtFleetHeader); lvRouteFleet = new ListView(); lvRouteFleet.Background = Brushes.Transparent; lvRouteFleet.SetResourceReference(ListView.ItemContainerStyleProperty, "ListViewItemStyle"); lvRouteFleet.MaxHeight = 400; lvRouteFleet.BorderThickness = new Thickness(0); lvRouteFleet.View = this.Resources["FleetRouteViewItem"] as GridView; panelDetailed.Children.Add(lvRouteFleet); List <FleetAirliner> fAirliners = this.Airline.Fleet; lvRouteFleet.ItemsSource = this.FleetDelivered; return(panelDetailed); }
/// <summary> /// 添加标题和值 /// </summary> public Border GetTexeBlock(String textContent, bool isResourceReference) { Border border = new Border(); border.Margin = new Thickness(5, 0, 0, 0); border.BorderThickness = new Thickness(2); border.HorizontalAlignment = HorizontalAlignment.Stretch; border.Background = new SolidColorBrush(Color.FromRgb(43, 43, 43)); border.BorderBrush = new SolidColorBrush(Color.FromRgb(31, 31, 31)); TextBlock tbContent = new TextBlock(); tbContent.Margin = new Thickness(5, 2, 5, 2); tbContent.FontSize = 16; tbContent.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); if (isResourceReference) { tbContent.SetResourceReference(TextBlock.TextProperty, textContent); } else { tbContent.Text = textContent; } border.Child = tbContent; return(border); }
/// <summary> /// 隐藏控制 - 新建或者打开之前隐藏界面 /// </summary> public void HideControl() { //隐藏内部容器 mainView.Children[0].Visibility = Visibility.Collapsed; if (spHint == null) { //隐藏容器 spHint = new StackPanel { HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, Orientation = Orientation.Horizontal }; //提示 TextBlock tbOr = new TextBlock { Foreground = new SolidColorBrush(Colors.White), FontSize = 20, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(20) }; tbOr.SetResourceReference(TextBlock.TextProperty, "NoFileWasOpened"); //容器添加控件 spHint.Children.Add(tbOr); //总容器添加隐藏容器 mainView.Children.Add(spHint); } else { spHint.Visibility = Visibility.Visible; } }
private void ButtonDeselect(Button button, Rectangle rectangle, TextBlock textBlock, Border border) { button.SetResourceReference(Button.StyleProperty, "EffectButton"); rectangle.SetResourceReference(Rectangle.FillProperty, "DefaultColorBrushFF"); textBlock.SetResourceReference(TextBlock.ForegroundProperty, "DefaultColorBrushAA"); border.SetResourceReference(Border.BorderBrushProperty, "DefaultColorBrushAA"); }
//creates the panel for restrictions private StackPanel createRestrictionsPanel() { StackPanel panelRestrictions = new StackPanel(); panelRestrictions.Margin = new Thickness(0, 10, 0, 0); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1002"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageRoutes", txtHeader.Uid); panelRestrictions.Children.Add(txtHeader); ListBox lbRestrictions = new ListBox(); lbRestrictions.MaxHeight = GraphicsHelpers.GetContentHeight() / 5; lbRestrictions.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbRestrictions.ItemTemplate = this.Resources["RestrictionItem"] as DataTemplate; lbRestrictions.ItemsSource = FlightRestrictions.GetRestrictions().FindAll(r => r.StartDate <GameObject.GetInstance().GameTime&& r.EndDate> GameObject.GetInstance().GameTime); panelRestrictions.Children.Add(lbRestrictions); return(panelRestrictions); }
public PageAirportsStatistics() { InitializeComponent(); StackPanel panelStatistics = new StackPanel(); panelStatistics.Margin = new Thickness(0, 10, 50, 0); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageAirportsStatistics", txtHeader.Uid); panelStatistics.Children.Add(txtHeader); lbAirports = new ListBox(); lbAirports.ItemTemplate = this.Resources["AirportItem"] as DataTemplate; lbAirports.Height = 500; lbAirports.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); panelStatistics.Children.Add(lbAirports); //GameTimer.GetInstance().OnTimeChanged += new GameTimer.TimeChanged(PageAirportsStatistics_OnTimeChanged); //this.Unloaded += new RoutedEventHandler(PageAirportsStatistics_Unloaded); this.Content = panelStatistics; showAirports(); }
//shows the facilities private void showFacilities() { panelClassFacilities.Children.Clear(); foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes) { TextBlock txtHeader = new TextBlock(); txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush"); txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = string.Format("{0} ({1} seats)", new TextUnderscoreConverter().Convert(aClass.Type, null, null, null), aClass.SeatingCapacity); panelClassFacilities.Children.Add(txtHeader); foreach (AirlinerFacility.FacilityType type in Enum.GetValues(typeof(AirlinerFacility.FacilityType))) { AirlinerFacility facility = aClass.getFacility(type); ListBox lbFacilities = new ListBox(); lbFacilities.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbFacilities.ItemTemplate = this.Resources["FleetFacilityItem"] as DataTemplate; panelClassFacilities.Children.Add(lbFacilities); lbFacilities.Items.Add(new AirlinerFacilityItem(this.Airliner.Airliner.Airline, aClass, facility)); } panelClassFacilities.Children.Add(new Separator()); } }
public PageAirportWeather(Airport airport) { this.Airport = airport; ccWeather = new ContentControl[this.Airport.Weather.Length]; InitializeComponent(); StackPanel panelWeather = new StackPanel(); panelWeather.Margin = new Thickness(0, 10, 50, 0); TextBlock txtHeader = new TextBlock(); txtHeader.Uid = "1001"; txtHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtHeader.TextAlignment = TextAlignment.Left; txtHeader.FontWeight = FontWeights.Bold; txtHeader.Text = Translator.GetInstance().GetString("PageAirportWeather", txtHeader.Uid); panelWeather.Children.Add(txtHeader); panelWeather.Children.Add(createCurrentWeatherPanel()); panelWeather.Children.Add(createWeatherForecastPanel()); this.Content = panelWeather; // GameTimer.GetInstance().OnTimeChanged += new GameTimer.TimeChanged(PageAirportWeather_OnTimeChanged); }
private void _initializeSubComponent() { /* サブウィンドウ用タイトルの描画 */ // メインタイトルを非表示 title.Visibility = Visibility.Hidden; // サブウィンドウ用タイトルを描画 var titleBlock = new TextBlock { Text = "Reseacher Aurora", TextTrimming = TextTrimming.CharacterEllipsis, FontFamily = new FontFamily("Segoe UI Light"), FontSize = 16, VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(5, 0, 0, 0), }; titleBlock.SetResourceReference(ForegroundProperty, "ForegroundBrushKey"); CaptionBarArea.Children.Add(titleBlock); /* システムボタンの描画 */ CaptionBarArea.Children.Add(_systemButtons); /* メインコンテンツの描画 */ ContentArea.Children.Add(new DragablzControl()); }
//creates a popup with a text //creates the splash window private Border createSplashWindow(string text) { Border brdSplasInner = new Border(); brdSplasInner.BorderBrush = Brushes.Black; brdSplasInner.BorderThickness = new Thickness(2, 2, 0, 0); Border brdSplashOuter = new Border(); brdSplashOuter.BorderBrush = Brushes.White; brdSplashOuter.BorderThickness = new Thickness(0, 0, 2, 2); brdSplasInner.Child = brdSplashOuter; TextBlock txtSplash = UICreator.CreateTextBlock(text); txtSplash.Width = 200; txtSplash.Height = 100; txtSplash.TextAlignment = TextAlignment.Center; txtSplash.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtSplash.FontWeight = FontWeights.Bold; brdSplashOuter.Child = txtSplash; return(brdSplasInner); }
private void UpdateFileExtensions(ICollection <string> extensions) { if (extensions.Count == 0) { PanelFileExtensions.Visibility = Visibility.Collapsed; return; } PanelFileExtensions.Visibility = Visibility.Visible; WrapPanelFileExtensions.Children.Clear(); foreach (var ext in extensions.OrderBy(i => i).Select(i => i.TrimStart('.'))) { var checkbox = new CheckBox { Tag = ext, IsChecked = _playerConfig.FileExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase), Margin = new Thickness(0, 0, 30, 10) }; var textBlock = new TextBlock(); textBlock.SetResourceReference(TextBlock.StyleProperty, "SmallTextBlockStyle"); textBlock.Text = ext; checkbox.Content = textBlock; WrapPanelFileExtensions.Children.Add(checkbox); } }
private void DetectScreens() { var monitors = Monitor.AllMonitorsGranular(); _minLeft = monitors.Min(m => m.NativeBounds.Left); _minTop = monitors.Min(m => m.NativeBounds.Top); _maxRight = monitors.Max(m => m.NativeBounds.Right); _maxBottom = monitors.Max(m => m.NativeBounds.Bottom); MainCanvas.Children.Clear(); foreach (var monitor in monitors) { var rect = new Rectangle { Width = monitor.NativeBounds.Width, Height = monitor.NativeBounds.Height, StrokeThickness = 6 }; rect.SetResourceReference(Shape.StrokeProperty, "Element.Foreground"); rect.SetResourceReference(Shape.FillProperty, monitor.AdapterName == Monitor.AdapterName ? "Element.Background.Checked" : "Element.Background.Hover"); var textBlock = new TextBlock { Text = monitor.AdapterName, TextAlignment = TextAlignment.Center, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, FontSize = 26, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(15) }; textBlock.SetResourceReference(TextBlock.ForegroundProperty, "Element.Foreground"); var viewbox = new Viewbox { Child = textBlock, Width = monitor.NativeBounds.Width, Height = monitor.NativeBounds.Height, }; MainCanvas.Children.Add(rect); MainCanvas.Children.Add(viewbox); Canvas.SetLeft(rect, monitor.NativeBounds.Left); Canvas.SetTop(rect, monitor.NativeBounds.Top); Canvas.SetLeft(viewbox, monitor.NativeBounds.Left); Canvas.SetTop(viewbox, monitor.NativeBounds.Top); Panel.SetZIndex(rect, 1); Panel.SetZIndex(viewbox, 2); } MainCanvas.Width = Math.Abs(_minLeft) + Math.Abs(_maxRight); MainCanvas.Height = Math.Abs(_minTop) + Math.Abs(_maxBottom); MainCanvas.Measure(new Size(MainCanvas.Width, MainCanvas.Height)); MainCanvas.Arrange(new Rect(MainCanvas.DesiredSize)); SetViewPort(_minLeft, _maxRight, _minTop, _maxBottom); }
public static StackPanel GetSizeInStrWPF(long bytes) { StackPanel sp = new StackPanel(); sp.Orientation = Orientation.Horizontal; TextBlock tbSize = new TextBlock(); TextBlock tbAttr = new TextBlock(); tbAttr.Margin = new System.Windows.Thickness(5, 0, 0, 0); sp.Children.Add(tbSize); sp.Children.Add(tbAttr); const int scale = 1024; OneLanguage lang = LanguagesManager.GetCurrLanguage(); string[] orders = new string[] { "SFISGB", "SFISMB", "SFISKB", "SFISBytes" }; long max = (long)Math.Pow(scale, orders.Length - 1); foreach (string order in orders) { if (bytes > max) { tbSize.Text = string.Format("{0:##.##}", decimal.Divide(bytes, max)); //tbAttr.Text = order; tbAttr.SetResourceReference(TextBlock.TextProperty, order); return(sp); } max /= scale; } tbSize.Text = "0"; tbAttr.SetResourceReference(TextBlock.TextProperty, "SFISBytes"); //tbAttr.Text = lang.SFISBytes; return(sp); //return "0 " + lang.SFISBytes; }
protected override FrameworkElement BuildElementInternal() { var buildElementInternal = new TextBlock { TextWrapping = TextWrapping.Wrap, Text = Text, Margin = new Thickness(0, 5, 0, 5) }; buildElementInternal.SetResourceReference(FrameworkContentElement.StyleProperty, "H2"); return(buildElementInternal); }
public PageAirlineSubsidiaries(Airline airline, StandardPage parent) { this.PageParent = parent; this.Airline = airline; InitializeComponent(); StackPanel panelSubsidiaries = new StackPanel(); panelSubsidiaries.Margin = new Thickness(0, 10, 50, 0); TextBlock txtSubsidiariesHeader = new TextBlock(); txtSubsidiariesHeader.Uid = "1001"; txtSubsidiariesHeader.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; txtSubsidiariesHeader.SetResourceReference(TextBlock.BackgroundProperty, "HeaderBackgroundBrush2"); txtSubsidiariesHeader.FontWeight = FontWeights.Bold; txtSubsidiariesHeader.Text = Translator.GetInstance().GetString("PageAirlineSubsidiaries", txtSubsidiariesHeader.Uid); panelSubsidiaries.Children.Add(txtSubsidiariesHeader); lbSubsidiaryAirline = new ListBox(); lbSubsidiaryAirline.ItemTemplate = this.Resources["SubsidiaryItem"] as DataTemplate; lbSubsidiaryAirline.ItemContainerStyleSelector = new ListBoxItemStyleSelector(); lbSubsidiaryAirline.MaxHeight = GraphicsHelpers.GetContentHeight() - 100; showSubsidiaries(); panelSubsidiaries.Children.Add(lbSubsidiaryAirline); WrapPanel panelButtons = new WrapPanel(); panelButtons.Visibility = this.Airline.IsHuman && !(this.Airline is SubsidiaryAirline) && this.Airline.Money > 100000 ? Visibility.Visible : Visibility.Collapsed; panelButtons.Margin = new Thickness(0, 5, 0, 0); panelSubsidiaries.Children.Add(panelButtons); Button btnCreate = new Button(); btnCreate.Uid = "200"; btnCreate.SetResourceReference(Button.StyleProperty, "RoundedButton"); btnCreate.Height = Double.NaN; btnCreate.Width = Double.NaN; btnCreate.Content = Translator.GetInstance().GetString("PageAirlineSubsidiaries", btnCreate.Uid); btnCreate.Click += new RoutedEventHandler(btnCreate_Click); btnCreate.SetResourceReference(Button.BackgroundProperty, "ButtonBrush"); panelButtons.Children.Add(btnCreate); if (this.Airline.IsHuman) { panelSubsidiaries.Children.Add(createTransferFundsPanel()); } this.Content = panelSubsidiaries; }
/// <summary> /// 添加头部提示文本 /// </summary> public void AddTopHintTextBlock(String textName) { TextBlock tb = new TextBlock(); tb.FontSize = 14; tb.Foreground = new SolidColorBrush(Color.FromArgb(255, 240, 240, 240)); tb.Margin = new Thickness(0, 20, 0, 0); tb.SetResourceReference(TextBlock.TextProperty, textName); _UI.Add(tb); }
private static System.Collections.ObjectModel.ObservableCollection<object> Get_e_24_Items() { System.Collections.ObjectModel.ObservableCollection<object> items = new System.Collections.ObjectModel.ObservableCollection<object>(); // e_25 element TabItem e_25 = new TabItem(); e_25.Name = "e_25"; e_25.HorizontalContentAlignment = HorizontalAlignment.Stretch; e_25.SetResourceReference(TabItem.HeaderProperty, "GameText"); // e_26 element Grid e_26 = new Grid(); e_25.Content = e_26; e_26.Name = "e_26"; e_26.Margin = new Thickness(10F, 10F, 10F, 10F); RowDefinition row_e_26_0 = new RowDefinition(); row_e_26_0.Height = new GridLength(1F, GridUnitType.Auto); e_26.RowDefinitions.Add(row_e_26_0); RowDefinition row_e_26_1 = new RowDefinition(); row_e_26_1.Height = new GridLength(1F, GridUnitType.Auto); e_26.RowDefinitions.Add(row_e_26_1); RowDefinition row_e_26_2 = new RowDefinition(); row_e_26_2.Height = new GridLength(1F, GridUnitType.Auto); e_26.RowDefinitions.Add(row_e_26_2); RowDefinition row_e_26_3 = new RowDefinition(); row_e_26_3.Height = new GridLength(1F, GridUnitType.Auto); e_26.RowDefinitions.Add(row_e_26_3); RowDefinition row_e_26_4 = new RowDefinition(); row_e_26_4.Height = new GridLength(1F, GridUnitType.Auto); e_26.RowDefinitions.Add(row_e_26_4); ColumnDefinition col_e_26_0 = new ColumnDefinition(); col_e_26_0.Width = new GridLength(58F, GridUnitType.Star); e_26.ColumnDefinitions.Add(col_e_26_0); ColumnDefinition col_e_26_1 = new ColumnDefinition(); col_e_26_1.Width = new GridLength(134F, GridUnitType.Star); e_26.ColumnDefinitions.Add(col_e_26_1); ColumnDefinition col_e_26_2 = new ColumnDefinition(); col_e_26_2.Width = new GridLength(193F, GridUnitType.Star); e_26.ColumnDefinitions.Add(col_e_26_2); ColumnDefinition col_e_26_3 = new ColumnDefinition(); col_e_26_3.Width = new GridLength(192F, GridUnitType.Star); e_26.ColumnDefinitions.Add(col_e_26_3); ColumnDefinition col_e_26_4 = new ColumnDefinition(); col_e_26_4.Width = new GridLength(193F, GridUnitType.Star); e_26.ColumnDefinitions.Add(col_e_26_4); // e_27 element TextBlock e_27 = new TextBlock(); e_26.Children.Add(e_27); e_27.Name = "e_27"; e_27.Margin = new Thickness(0F, 6F, 0F, 5F); e_27.VerticalAlignment = VerticalAlignment.Center; e_27.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); Grid.SetColumnSpan(e_27, 2); e_27.SetResourceReference(TextBlock.TextProperty, "DifficultyText"); // cbDifficulty element ComboBox cbDifficulty = new ComboBox(); e_26.Children.Add(cbDifficulty); cbDifficulty.Name = "cbDifficulty"; cbDifficulty.Margin = new Thickness(2F, 2F, 2F, 3F); cbDifficulty.VerticalAlignment = VerticalAlignment.Center; cbDifficulty.ItemsSource = Get_cbDifficulty_Items(); Grid.SetColumn(cbDifficulty, 2); Binding binding_cbDifficulty_SelectedIndex = new Binding("Difficulty"); cbDifficulty.SetBinding(ComboBox.SelectedIndexProperty, binding_cbDifficulty_SelectedIndex); // e_31 element TextBlock e_31 = new TextBlock(); e_26.Children.Add(e_31); e_31.Name = "e_31"; e_31.Margin = new Thickness(0F, 6F, 0F, 5F); e_31.VerticalAlignment = VerticalAlignment.Center; e_31.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); Grid.SetRow(e_31, 1); Grid.SetColumnSpan(e_31, 2); e_31.SetResourceReference(TextBlock.TextProperty, "LanguageText"); // cbLanguage element ComboBox cbLanguage = new ComboBox(); e_26.Children.Add(cbLanguage); cbLanguage.Name = "cbLanguage"; cbLanguage.Margin = new Thickness(2F, 3F, 2F, 2F); cbLanguage.VerticalAlignment = VerticalAlignment.Center; cbLanguage.ItemsSource = Get_cbLanguage_Items(); Grid.SetColumn(cbLanguage, 2); Grid.SetRow(cbLanguage, 1); Binding binding_cbLanguage_SelectedIndex = new Binding("Language"); cbLanguage.SetBinding(ComboBox.SelectedIndexProperty, binding_cbLanguage_SelectedIndex); items.Add(e_25); // e_36 element TabItem e_36 = new TabItem(); e_36.Name = "e_36"; e_36.SetResourceReference(TabItem.HeaderProperty, "VideoText"); // e_37 element Grid e_37 = new Grid(); e_36.Content = e_37; e_37.Name = "e_37"; e_37.Margin = new Thickness(10F, 10F, 10F, 10F); RowDefinition row_e_37_0 = new RowDefinition(); row_e_37_0.Height = new GridLength(1F, GridUnitType.Auto); e_37.RowDefinitions.Add(row_e_37_0); RowDefinition row_e_37_1 = new RowDefinition(); row_e_37_1.Height = new GridLength(1F, GridUnitType.Auto); e_37.RowDefinitions.Add(row_e_37_1); RowDefinition row_e_37_2 = new RowDefinition(); row_e_37_2.Height = new GridLength(1F, GridUnitType.Auto); e_37.RowDefinitions.Add(row_e_37_2); RowDefinition row_e_37_3 = new RowDefinition(); row_e_37_3.Height = new GridLength(1F, GridUnitType.Auto); e_37.RowDefinitions.Add(row_e_37_3); RowDefinition row_e_37_4 = new RowDefinition(); row_e_37_4.Height = new GridLength(1F, GridUnitType.Auto); e_37.RowDefinitions.Add(row_e_37_4); ColumnDefinition col_e_37_0 = new ColumnDefinition(); e_37.ColumnDefinitions.Add(col_e_37_0); ColumnDefinition col_e_37_1 = new ColumnDefinition(); e_37.ColumnDefinitions.Add(col_e_37_1); ColumnDefinition col_e_37_2 = new ColumnDefinition(); e_37.ColumnDefinitions.Add(col_e_37_2); ColumnDefinition col_e_37_3 = new ColumnDefinition(); e_37.ColumnDefinitions.Add(col_e_37_3); // e_38 element TextBlock e_38 = new TextBlock(); e_37.Children.Add(e_38); e_38.Name = "e_38"; e_38.VerticalAlignment = VerticalAlignment.Center; e_38.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); e_38.SetResourceReference(TextBlock.TextProperty, "ResolutionText"); // cbResolution element ComboBox cbResolution = new ComboBox(); e_37.Children.Add(cbResolution); cbResolution.Name = "cbResolution"; cbResolution.Margin = new Thickness(2F, 2F, 2F, 2F); cbResolution.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(cbResolution, 1); Binding binding_cbResolution_ItemsSource = new Binding("AvailableResolutions"); cbResolution.SetBinding(ComboBox.ItemsSourceProperty, binding_cbResolution_ItemsSource); Binding binding_cbResolution_SelectedIndex = new Binding("ResolutionSelectedIndex"); cbResolution.SetBinding(ComboBox.SelectedIndexProperty, binding_cbResolution_SelectedIndex); // e_39 element TextBlock e_39 = new TextBlock(); e_37.Children.Add(e_39); e_39.Name = "e_39"; e_39.VerticalAlignment = VerticalAlignment.Center; e_39.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); Grid.SetRow(e_39, 1); e_39.SetResourceReference(TextBlock.TextProperty, "DisplayModeText"); // cbDisplayMode element ComboBox cbDisplayMode = new ComboBox(); e_37.Children.Add(cbDisplayMode); cbDisplayMode.Name = "cbDisplayMode"; cbDisplayMode.Margin = new Thickness(2F, 2F, 2F, 2F); cbDisplayMode.VerticalAlignment = VerticalAlignment.Center; cbDisplayMode.ItemsSource = Get_cbDisplayMode_Items(); Grid.SetColumn(cbDisplayMode, 1); Grid.SetRow(cbDisplayMode, 1); Binding binding_cbDisplayMode_SelectedIndex = new Binding("DisplayModeSelectedIndex"); cbDisplayMode.SetBinding(ComboBox.SelectedIndexProperty, binding_cbDisplayMode_SelectedIndex); // e_43 element TextBlock e_43 = new TextBlock(); e_37.Children.Add(e_43); e_43.Name = "e_43"; e_43.VerticalAlignment = VerticalAlignment.Center; e_43.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); Grid.SetRow(e_43, 2); e_43.SetResourceReference(TextBlock.TextProperty, "VerticalSyncText"); // chkVerticalSync element CheckBox chkVerticalSync = new CheckBox(); e_37.Children.Add(chkVerticalSync); chkVerticalSync.Name = "chkVerticalSync"; chkVerticalSync.Margin = new Thickness(5F, 5F, 5F, 5F); chkVerticalSync.HorizontalAlignment = HorizontalAlignment.Center; chkVerticalSync.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(chkVerticalSync, 1); Grid.SetRow(chkVerticalSync, 2); Binding binding_chkVerticalSync_IsChecked = new Binding("VerticalSyncEnabled"); chkVerticalSync.SetBinding(CheckBox.IsCheckedProperty, binding_chkVerticalSync_IsChecked); // e_44 element TextBlock e_44 = new TextBlock(); e_37.Children.Add(e_44); e_44.Name = "e_44"; e_44.Margin = new Thickness(10F, 0F, 0F, 0F); e_44.VerticalAlignment = VerticalAlignment.Center; e_44.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); Grid.SetColumn(e_44, 2); e_44.SetResourceReference(TextBlock.TextProperty, "GammaText"); // slGamma element Slider slGamma = new Slider(); e_37.Children.Add(slGamma); slGamma.Name = "slGamma"; slGamma.VerticalAlignment = VerticalAlignment.Center; slGamma.Minimum = 0F; slGamma.Maximum = 1F; Grid.SetColumn(slGamma, 3); Binding binding_slGamma_Value = new Binding("Gamma"); slGamma.SetBinding(Slider.ValueProperty, binding_slGamma_Value); // e_45 element TextBlock e_45 = new TextBlock(); e_37.Children.Add(e_45); e_45.Name = "e_45"; e_45.Margin = new Thickness(10F, 0F, 0F, 0F); e_45.VerticalAlignment = VerticalAlignment.Center; e_45.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); Grid.SetColumn(e_45, 2); Grid.SetRow(e_45, 1); e_45.SetResourceReference(TextBlock.TextProperty, "AntialiasingText"); // chAntialiasing element CheckBox chAntialiasing = new CheckBox(); e_37.Children.Add(chAntialiasing); chAntialiasing.Name = "chAntialiasing"; chAntialiasing.Margin = new Thickness(5F, 5F, 5F, 5F); chAntialiasing.HorizontalAlignment = HorizontalAlignment.Center; chAntialiasing.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(chAntialiasing, 3); Grid.SetRow(chAntialiasing, 1); Binding binding_chAntialiasing_IsChecked = new Binding("AntialiasingEnabled"); chAntialiasing.SetBinding(CheckBox.IsCheckedProperty, binding_chAntialiasing_IsChecked); items.Add(e_36); // e_46 element TabItem e_46 = new TabItem(); e_46.Name = "e_46"; e_46.SetResourceReference(TabItem.HeaderProperty, "AudioText"); // e_47 element Grid e_47 = new Grid(); e_46.Content = e_47; e_47.Name = "e_47"; e_47.Margin = new Thickness(10F, 10F, 10F, 10F); RowDefinition row_e_47_0 = new RowDefinition(); row_e_47_0.Height = new GridLength(1F, GridUnitType.Auto); e_47.RowDefinitions.Add(row_e_47_0); RowDefinition row_e_47_1 = new RowDefinition(); row_e_47_1.Height = new GridLength(1F, GridUnitType.Auto); e_47.RowDefinitions.Add(row_e_47_1); RowDefinition row_e_47_2 = new RowDefinition(); row_e_47_2.Height = new GridLength(1F, GridUnitType.Auto); e_47.RowDefinitions.Add(row_e_47_2); RowDefinition row_e_47_3 = new RowDefinition(); row_e_47_3.Height = new GridLength(1F, GridUnitType.Auto); e_47.RowDefinitions.Add(row_e_47_3); RowDefinition row_e_47_4 = new RowDefinition(); row_e_47_4.Height = new GridLength(1F, GridUnitType.Auto); e_47.RowDefinitions.Add(row_e_47_4); ColumnDefinition col_e_47_0 = new ColumnDefinition(); e_47.ColumnDefinitions.Add(col_e_47_0); ColumnDefinition col_e_47_1 = new ColumnDefinition(); e_47.ColumnDefinitions.Add(col_e_47_1); ColumnDefinition col_e_47_2 = new ColumnDefinition(); e_47.ColumnDefinitions.Add(col_e_47_2); ColumnDefinition col_e_47_3 = new ColumnDefinition(); e_47.ColumnDefinitions.Add(col_e_47_3); // e_48 element TextBlock e_48 = new TextBlock(); e_47.Children.Add(e_48); e_48.Name = "e_48"; e_48.VerticalAlignment = VerticalAlignment.Center; e_48.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); e_48.SetResourceReference(TextBlock.TextProperty, "MasterVolumeText"); // masterVolume element Slider masterVolume = new Slider(); e_47.Children.Add(masterVolume); masterVolume.Name = "masterVolume"; masterVolume.Margin = new Thickness(5F, 5F, 5F, 5F); masterVolume.VerticalAlignment = VerticalAlignment.Center; masterVolume.Minimum = 0F; masterVolume.Maximum = 100F; Grid.SetColumn(masterVolume, 1); Binding binding_masterVolume_Value = new Binding("MasterVolume"); masterVolume.SetBinding(Slider.ValueProperty, binding_masterVolume_Value); // e_49 element TextBlock e_49 = new TextBlock(); e_47.Children.Add(e_49); e_49.Name = "e_49"; e_49.VerticalAlignment = VerticalAlignment.Center; e_49.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); Grid.SetRow(e_49, 1); e_49.SetResourceReference(TextBlock.TextProperty, "MusicVolumeText"); // musicVolume element Slider musicVolume = new Slider(); e_47.Children.Add(musicVolume); musicVolume.Name = "musicVolume"; musicVolume.Margin = new Thickness(5F, 5F, 5F, 5F); musicVolume.VerticalAlignment = VerticalAlignment.Center; musicVolume.Minimum = 0F; musicVolume.Maximum = 100F; Grid.SetColumn(musicVolume, 1); Grid.SetRow(musicVolume, 1); Binding binding_musicVolume_Value = new Binding("MusicVolume"); musicVolume.SetBinding(Slider.ValueProperty, binding_musicVolume_Value); // e_50 element TextBlock e_50 = new TextBlock(); e_47.Children.Add(e_50); e_50.Name = "e_50"; e_50.VerticalAlignment = VerticalAlignment.Center; e_50.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); Grid.SetRow(e_50, 2); e_50.SetResourceReference(TextBlock.TextProperty, "SoundsVolumeText"); // soundsVolume element Slider soundsVolume = new Slider(); e_47.Children.Add(soundsVolume); soundsVolume.Name = "soundsVolume"; soundsVolume.Margin = new Thickness(5F, 5F, 5F, 5F); soundsVolume.VerticalAlignment = VerticalAlignment.Center; soundsVolume.Minimum = 0F; soundsVolume.Maximum = 100F; Grid.SetColumn(soundsVolume, 1); Grid.SetRow(soundsVolume, 2); Binding binding_soundsVolume_Value = new Binding("SoundsVolume"); soundsVolume.SetBinding(Slider.ValueProperty, binding_soundsVolume_Value); items.Add(e_46); // e_51 element TabItem e_51 = new TabItem(); e_51.Name = "e_51"; e_51.SetResourceReference(TabItem.HeaderProperty, "ControlsText"); // e_52 element Grid e_52 = new Grid(); e_51.Content = e_52; e_52.Name = "e_52"; e_52.Margin = new Thickness(10F, 10F, 10F, 10F); RowDefinition row_e_52_0 = new RowDefinition(); row_e_52_0.Height = new GridLength(1F, GridUnitType.Auto); e_52.RowDefinitions.Add(row_e_52_0); RowDefinition row_e_52_1 = new RowDefinition(); row_e_52_1.Height = new GridLength(1F, GridUnitType.Auto); e_52.RowDefinitions.Add(row_e_52_1); RowDefinition row_e_52_2 = new RowDefinition(); row_e_52_2.Height = new GridLength(1F, GridUnitType.Auto); e_52.RowDefinitions.Add(row_e_52_2); RowDefinition row_e_52_3 = new RowDefinition(); row_e_52_3.Height = new GridLength(1F, GridUnitType.Auto); e_52.RowDefinitions.Add(row_e_52_3); RowDefinition row_e_52_4 = new RowDefinition(); row_e_52_4.Height = new GridLength(1F, GridUnitType.Auto); e_52.RowDefinitions.Add(row_e_52_4); ColumnDefinition col_e_52_0 = new ColumnDefinition(); e_52.ColumnDefinitions.Add(col_e_52_0); ColumnDefinition col_e_52_1 = new ColumnDefinition(); e_52.ColumnDefinitions.Add(col_e_52_1); ColumnDefinition col_e_52_2 = new ColumnDefinition(); e_52.ColumnDefinitions.Add(col_e_52_2); ColumnDefinition col_e_52_3 = new ColumnDefinition(); e_52.ColumnDefinitions.Add(col_e_52_3); // e_53 element TextBlock e_53 = new TextBlock(); e_52.Children.Add(e_53); e_53.Name = "e_53"; e_53.VerticalAlignment = VerticalAlignment.Center; e_53.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); e_53.SetResourceReference(TextBlock.TextProperty, "SensitivityText"); // sensitivity element Slider sensitivity = new Slider(); e_52.Children.Add(sensitivity); sensitivity.Name = "sensitivity"; sensitivity.Margin = new Thickness(5F, 5F, 5F, 5F); sensitivity.VerticalAlignment = VerticalAlignment.Center; sensitivity.Minimum = 0F; sensitivity.Maximum = 100F; Grid.SetColumn(sensitivity, 1); Binding binding_sensitivity_Value = new Binding("Sensitivity"); sensitivity.SetBinding(Slider.ValueProperty, binding_sensitivity_Value); // e_54 element TextBlock e_54 = new TextBlock(); e_52.Children.Add(e_54); e_54.Name = "e_54"; e_54.VerticalAlignment = VerticalAlignment.Center; e_54.Foreground = new SolidColorBrush(new ColorW(255, 255, 255, 255)); Grid.SetRow(e_54, 1); e_54.SetResourceReference(TextBlock.TextProperty, "InvertVerticalText"); // chkInvert element CheckBox chkInvert = new CheckBox(); e_52.Children.Add(chkInvert); chkInvert.Name = "chkInvert"; chkInvert.Margin = new Thickness(5F, 5F, 5F, 5F); chkInvert.HorizontalAlignment = HorizontalAlignment.Center; chkInvert.VerticalAlignment = VerticalAlignment.Center; Grid.SetColumn(chkInvert, 1); Grid.SetRow(chkInvert, 1); Binding binding_chkInvert_IsChecked = new Binding("InvertVertical"); chkInvert.SetBinding(CheckBox.IsCheckedProperty, binding_chkInvert_IsChecked); items.Add(e_51); return items; }
protected void VersionsChanged(object sender, EventArgs e) { if (versions.Count == 0) return; for (int i = 0; i < _Versions.Count; i++) { ListViewItem item = _Versions[i]; Mod mod = ((ModVersionViewModel)item.DataContext).mod; if (!versions.Values.Contains(mod)) { _Versions.RemoveAt(i); i--; } } List<int> versionKeys = versions.Keys.ToList(); versionKeys.Sort(); versionKeys.Reverse(); ListViewItem[] old = _Versions.ToArray(); _Versions = new ObservableCollection<ListViewItem>(); foreach (int n in versionKeys) { Mod mod = versions[n]; bool add = true; /*foreach (ListViewItem item in _Versions) { if (item.DataContext == mod) { add = false; break; } }*/ if (add) { ListViewItem newItem = new ListViewItem(); StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Vertical; newItem.DataContext = new ModVersionViewModel(mod); TextBlock label = new TextBlock(); label.SetBinding(TextBlock.TextProperty, "Version"); StackPanel panel2 = new StackPanel(); panel2.Orientation = Orientation.Horizontal; TextBlock compatibleLabel = new TextBlock(); compatibleLabel.SetResourceReference(TextBlock.TextProperty, "Lang.Mods.Labels.Compatible"); compatibleLabel.FontSize = 14; compatibleLabel.Margin = new Thickness(0, 0, 5, 0); TextBlock label2 = new TextBlock(); label2.SetBinding(TextBlock.TextProperty, "Compatible"); label2.FontSize = 14; panel2.Children.Add(compatibleLabel); panel2.Children.Add(label2); panel.Children.Add(label); panel.Children.Add(panel2); newItem.Content = panel; _Versions.Add(newItem); } } OnPropertyChanged("Versions"); if (_Initialized) { DontSaveVersion = true; int versionToPrefer = Configuration.GetInt("Mods." + versions[versions.Keys.ToArray()[0]].Game.GameConfiguration.ID + "." + versions[versions.Keys.ToArray()[0]].ID + ".Version"); bool found = false; foreach (ListViewItem item in _Versions) { Mod mod = ((ModVersionViewModel)item.DataContext).mod; int build = Mod.Header.ParseModVersion(mod.header.GetVersion()); if (build == versionToPrefer) { SelectedVersion = item; found = true; } } if (!found) { if (_Versions.Count > 0) SelectedVersion = _Versions[0]; else SelectedVersion = null; } DontSaveVersion = false; OnPropertyChanged("SelectedVersion"); OnPropertyChanged("Name"); OnPropertyChanged("Description"); OnPropertyChanged("Version"); } }
protected void AddLanguageButton(string LangCode) { Button newButton = new Button(); newButton.Style = Application.Current.FindResource("NormalButton") as Style; newButton.DataContext = LangCode; newButton.Click += RemoveLanguage; newButton.Margin = new Thickness(0, 0, 10, 0); StackPanel panel = new StackPanel(); panel.Orientation = Orientation.Horizontal; Image image = new Image(); image.Height = 20; BitmapImage source = new BitmapImage(); source.BeginInit(); source.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/Lang_" + LangCode + ".png"); source.EndInit(); image.Source = source; image.Margin = new Thickness(0, 0, 5, 0); panel.Children.Add(image); Image image2 = new Image(); image2.Height = 24; BitmapImage source2 = new BitmapImage(); source2.BeginInit(); source2.UriSource = new Uri("pack://application:,,,/ModAPI;component/resources/textures/Icons/Icon_Delete.png"); source2.EndInit(); image2.Source = source2; image2.Margin = new Thickness(5, 0, 0, 0); TextBlock label = new TextBlock(); label.SetResourceReference(TextBlock.TextProperty, "Lang.Languages." + LangCode); panel.Children.Add(label); panel.Children.Add(image2); newButton.Content = panel; _LanguageButtons.Add(newButton); _Languages.Add(LangCode); }