public GameSettingsControl() { foreach (UInt16 frequency in EnumerateAudioSettings()) { _validSamplingFrequency.Add(frequency); } SetCols(2); SetRows(9); Width = 200; VerticalAlignment = VerticalAlignment.Top; HorizontalAlignment = HorizontalAlignment.Left; Margin = new Thickness(5); DataContext = this; LinearGradientBrush backgroundStroke = new LinearGradientBrush { EndPoint = new Point(0.5, 1), StartPoint = new Point(0.5, 0), RelativeTransform = new RotateTransform(115, 0.5, 0.5), GradientStops = new GradientStopCollection { new GradientStop(Color.FromArgb(0xff, 0x61, 0x61, 0x61), 0), new GradientStop(Color.FromArgb(0xff, 0xF2, 0xF2, 0xF2), 0.504), new GradientStop(Color.FromArgb(0xff, 0xAE, 0xB1, 0xB1), 1) } }; backgroundStroke.Freeze(); LinearGradientBrush backgroundFill = new LinearGradientBrush { MappingMode = BrushMappingMode.RelativeToBoundingBox, StartPoint = new Point(0.5, 1.0), EndPoint = new Point(0.5, -0.4), GradientStops = new GradientStopCollection { new GradientStop(Color.FromArgb(0xBB, 0x44, 0x71, 0xc1), 0), new GradientStop(Color.FromArgb(0xBB, 0x28, 0x36, 0x65), 1) } }; backgroundFill.Freeze(); Rectangle backround = AddUiElement(new Rectangle { Stroke = backgroundStroke, Fill = backgroundFill, StrokeThickness = 5 }, 0, 0, 9, 2); Thickness rowMargin = new Thickness(0, 8, 0, 3); AddUiElement(UiTextBlockFactory.Create(Lang.Settings.ActiveMonitor), row: 0, col: 0, colSpan: 2).Margin = rowMargin; UiComboBox monitor = AddUiElement(UiComboBoxFactory.Create(), row: 1, col: 0, rowSpan: 0, colSpan: 2); monitor.ItemsSource = GetAvailableMonitors(); monitor.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(ActiveMonitor)) { Mode = BindingMode.TwoWay }); monitor.Margin = rowMargin; AddUiElement(UiTextBlockFactory.Create(Lang.Settings.Resolution), row: 2, col: 0).Margin = rowMargin; UiComboBox resolution = AddUiElement(UiComboBoxFactory.Create(), row: 3, col: 0); resolution.ItemsSource = EnumerateDisplaySettings().ToArray(); resolution.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(ScreenResolution)) { Mode = BindingMode.TwoWay }); resolution.Margin = rowMargin; UiCheckBox windowedCheckBox = AddUiElement(UiCheckBoxFactory.Create(Lang.Settings.Windowed, null), row: 3, col: 1); windowedCheckBox.Margin = rowMargin; windowedCheckBox.SetBinding(ToggleButton.IsCheckedProperty, new Binding(nameof(Windowed)) { Mode = BindingMode.TwoWay }); AddUiElement(UiTextBlockFactory.Create(Lang.Settings.AudioSamplingFrequency), 4, 0, 0, 2).Margin = rowMargin; UiComboBox audio = AddUiElement(UiComboBoxFactory.Create(), 5, 0, 0, 2); audio.ItemStringFormat = Lang.Settings.AudioSamplingFrequencyFormat; audio.ItemsSource = EnumerateAudioSettings().ToArray(); audio.SetBinding(Selector.SelectedItemProperty, new Binding(nameof(AudioFrequency)) { Mode = BindingMode.TwoWay }); audio.SetBinding(Selector.IsEnabledProperty, new Binding(nameof(AudioFrequencyEnabled)) { Mode = BindingMode.TwoWay }); audio.Margin = rowMargin; UiCheckBox x64 = AddUiElement(UiCheckBoxFactory.Create("X64", null), 6, 0); x64.Margin = rowMargin; x64.SetBinding(ToggleButton.IsCheckedProperty, new Binding(nameof(IsX64)) { Mode = BindingMode.TwoWay }); x64.SetBinding(ToggleButton.IsEnabledProperty, new Binding(nameof(IsX64Enabled)) { Mode = BindingMode.TwoWay }); UiCheckBox debuggableCheckBox = AddUiElement(UiCheckBoxFactory.Create(Lang.Settings.Debuggable, null), 6, 1); debuggableCheckBox.Margin = rowMargin; debuggableCheckBox.SetBinding(ToggleButton.IsCheckedProperty, new Binding(nameof(IsDebugMode)) { Mode = BindingMode.TwoWay }); UiCheckBox checkUpdates = AddUiElement(UiCheckBoxFactory.Create(Lang.Settings.CheckUpdates, null), 7, 0, 0, 2); checkUpdates.Margin = new Thickness(0, 8, 0, 8); checkUpdates.SetBinding(ToggleButton.IsCheckedProperty, new Binding(nameof(CheckUpdates)) { Mode = BindingMode.TwoWay }); foreach (FrameworkElement child in Children) { if (!ReferenceEquals(child, backround)) { child.Margin = new Thickness(child.Margin.Left + 8, child.Margin.Top, child.Margin.Right + 8, child.Margin.Bottom); } TextBlock textblock = child as TextBlock; if (textblock != null) { textblock.Foreground = Brushes.WhiteSmoke; textblock.FontWeight = FontWeight.FromOpenTypeWeight(500); continue; } Control control = child as Control; if (control != null && !(control is ComboBox)) { control.Foreground = Brushes.WhiteSmoke; } } LoadSettings(); }
public GameSettingsControl() { SetCols(2); SetRows(5); Width = 200; VerticalAlignment = VerticalAlignment.Top; HorizontalAlignment = HorizontalAlignment.Left; Margin = new Thickness(5); DataContext = this; LinearGradientBrush backgroundStroke = new LinearGradientBrush { EndPoint = new Point(0.5, 1), StartPoint = new Point(0.5, 0), RelativeTransform = new RotateTransform(115, 0.5, 0.5), GradientStops = new GradientStopCollection { new GradientStop(Color.FromArgb(0xff, 0x61, 0x61, 0x61), 0), new GradientStop(Color.FromArgb(0xff, 0xF2, 0xF2, 0xF2), 0.504), new GradientStop(Color.FromArgb(0xff, 0xAE, 0xB1, 0xB1), 1) } }; backgroundStroke.Freeze(); LinearGradientBrush backgroundFill = new LinearGradientBrush { MappingMode = BrushMappingMode.RelativeToBoundingBox, StartPoint = new Point(0.5, 1.0), EndPoint = new Point(0.5, -0.4), GradientStops = new GradientStopCollection { new GradientStop(Color.FromArgb(0xBB, 0x44, 0x71, 0xc1), 0), new GradientStop(Color.FromArgb(0xBB, 0x28, 0x36, 0x65), 1) } }; backgroundFill.Freeze(); Rectangle backround = AddUiElement(new Rectangle { Stroke = backgroundStroke, Fill = backgroundFill, StrokeThickness = 5 }, 0, 0, 9, 2); Thickness rowMargin = new Thickness(0, 8, 0, 3); AddUiElement(UiTextBlockFactory.Create("Resolution:"), 0, 0).Margin = rowMargin; UiComboBox resolution = AddUiElement(UiComboBoxFactory.Create(), 1, 0); resolution.ItemsSource = EnumerateDisplaySettings().ToArray(); resolution.SetBinding(Selector.SelectedItemProperty, new Binding("ScreenResolution") { Mode = BindingMode.TwoWay }); resolution.Margin = rowMargin; UiCheckBox windowedCheckBox = AddUiElement(UiCheckBoxFactory.Create("Windowed", null), 1, 1); windowedCheckBox.Margin = rowMargin; windowedCheckBox.SetBinding(ToggleButton.IsCheckedProperty, new Binding(nameof(Windowed)) { Mode = BindingMode.TwoWay }); UiCheckBox x64 = AddUiElement(UiCheckBoxFactory.Create("X64", null), 2, 0); x64.Margin = rowMargin; x64.SetBinding(ToggleButton.IsCheckedProperty, new Binding(nameof(IsX64)) { Mode = BindingMode.TwoWay }); x64.SetBinding(ToggleButton.IsEnabledProperty, new Binding(nameof(IsX64Enabled)) { Mode = BindingMode.TwoWay }); UiCheckBox debuggableCheckBox = AddUiElement(UiCheckBoxFactory.Create("Debuggable", null), 2, 1); debuggableCheckBox.Margin = new Thickness(0, 8, 0, 8); debuggableCheckBox.SetBinding(ToggleButton.IsCheckedProperty, new Binding(nameof(IsDebugMode)) { Mode = BindingMode.TwoWay }); foreach (FrameworkElement child in Children) { if (!ReferenceEquals(child, backround)) { child.Margin = new Thickness(child.Margin.Left + 8, child.Margin.Top, child.Margin.Right + 8, child.Margin.Bottom); } TextBlock textblock = child as TextBlock; if (textblock != null) { textblock.Foreground = Brushes.WhiteSmoke; textblock.FontWeight = FontWeight.FromOpenTypeWeight(500); continue; } Control control = child as Control; if (control != null && !(control is ComboBox)) { control.Foreground = Brushes.WhiteSmoke; } } LoadSettings(); }
public GameSettingsControl() { SetCols(2); SetRows(9); Width = 250; VerticalAlignment = VerticalAlignment.Top; HorizontalAlignment = HorizontalAlignment.Left; Margin = new Thickness(5); DataContext = this; _info = InteractionService.LocalizatorEnvironment.Provide(); InteractionService.LocalizatorEnvironment.InfoProvided += OnLocalizatorEnvironmentProvided; LinearGradientBrush backgroundStroke = new LinearGradientBrush { EndPoint = new Point(0.5, 1), StartPoint = new Point(0.5, 0), RelativeTransform = new RotateTransform(115, 0.5, 0.5), GradientStops = new GradientStopCollection { new GradientStop(Color.FromArgb(0xff, 0x61, 0x61, 0x61), 0), new GradientStop(Color.FromArgb(0xff, 0xF2, 0xF2, 0xF2), 0.504), new GradientStop(Color.FromArgb(0xff, 0xAE, 0xB1, 0xB1), 1) } }; backgroundStroke.Freeze(); LinearGradientBrush backgroundFill = new LinearGradientBrush { MappingMode = BrushMappingMode.RelativeToBoundingBox, StartPoint = new Point(0.5, 1.0), EndPoint = new Point(0.5, -0.4), GradientStops = new GradientStopCollection { new GradientStop(Color.FromArgb(0xBB, 0x44, 0x71, 0xc1), 0), new GradientStop(Color.FromArgb(0xBB, 0x28, 0x36, 0x65), 1) } }; backgroundFill.Freeze(); Rectangle backround = AddUiElement(new Rectangle { Stroke = backgroundStroke, Fill = backgroundFill, StrokeThickness = 5 }, 0, 0, 9, 2); InverseBoolConverter inverseBoolConverter = new InverseBoolConverter(); Thickness rowMargin = new Thickness(0, 8, 0, 3); const string screenGroup = "Отображение:"; AddUiElement(UiTextBlockFactory.Create(screenGroup), 0, 0, 0, 2).Margin = rowMargin; AddUiElement(UiRadioButtonFactory.Create(screenGroup, "Экран", true), 1, 0).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullScreen") { Mode = BindingMode.TwoWay }); AddUiElement(UiRadioButtonFactory.Create(screenGroup, "Окно", false), 1, 1).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullScreen") { Mode = BindingMode.TwoWay, Converter = inverseBoolConverter }); const string resolutionGroup = "Разрешение:"; AddUiElement(UiTextBlockFactory.Create(resolutionGroup), 2, 0, 0, 2).Margin = rowMargin; AddUiElement(UiRadioButtonFactory.Create(resolutionGroup, "1920x1080", true), 3, 0).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullHd") { Mode = BindingMode.TwoWay }); AddUiElement(UiRadioButtonFactory.Create(resolutionGroup, "1280x720", false), 3, 1).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsFullHd") { Mode = BindingMode.TwoWay, Converter = inverseBoolConverter }); const string voiceGroup = "Озвучка:"; AddUiElement(UiTextBlockFactory.Create(voiceGroup), 4, 0, 0, 2).Margin = rowMargin; AddUiElement(UiRadioButtonFactory.Create(voiceGroup, "Японская", true), 5, 0).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsNihonVoice") { Mode = BindingMode.TwoWay }); AddUiElement(UiRadioButtonFactory.Create(voiceGroup, "Английская", false), 5, 1).SetBinding(ToggleButton.IsCheckedProperty, new Binding("IsNihonVoice") { Mode = BindingMode.TwoWay, Converter = inverseBoolConverter }); UiCheckBox switchButtons = AddUiElement(UiCheckBoxFactory.Create("Поменять кнопки X/O", null), 6, 0, 0, 2); switchButtons.Margin = rowMargin; switchButtons.IsThreeState = true; switchButtons.SetBinding(ToggleButton.IsCheckedProperty, new Binding("SwitchButtons") { Mode = BindingMode.TwoWay }); AddUiElement(UiTextBlockFactory.Create("MSAA:"), 7, 0).Margin = rowMargin; UiComboBox antiAliasing = AddUiElement(UiComboBoxFactory.Create(), 8, 0); antiAliasing.ItemStringFormat = "x{0}"; antiAliasing.ItemsSource = new[] { 2, 4, 8, 16 }; antiAliasing.SelectedIndex = 3; antiAliasing.SetBinding(Selector.SelectedItemProperty, new Binding("AntiAliasing") { Mode = BindingMode.TwoWay }); antiAliasing.Margin = new Thickness(0, 0, 0, 8); AddUiElement(UiTextBlockFactory.Create("Тени:"), 7, 1).Margin = rowMargin; UiComboBox shadows = AddUiElement(UiComboBoxFactory.Create(), 8, 1); shadows.ItemStringFormat = "{0}x{0}"; shadows.ItemsSource = new[] { 512, 1024, 2048, 4096, 8192 }; shadows.SelectedIndex = 1; shadows.SetBinding(Selector.SelectedItemProperty, new Binding("ShadowResolution") { Mode = BindingMode.TwoWay }); shadows.Margin = new Thickness(0, 0, 0, 8); foreach (FrameworkElement child in Children) { if (!ReferenceEquals(child, backround)) { child.Margin = new Thickness(child.Margin.Left + 8, child.Margin.Top, child.Margin.Right + 8, child.Margin.Bottom); } TextBlock textblock = child as TextBlock; if (textblock != null) { textblock.Foreground = Brushes.WhiteSmoke; textblock.FontWeight = FontWeight.FromOpenTypeWeight(500); continue; } Control control = child as Control; if (control != null && !(control is ComboBox)) { control.Foreground = Brushes.WhiteSmoke; } } }