Exemplo n.º 1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            SpriteFont font = Content.Load <SpriteFont>("file");

            UiProgressBar progressbar = new UiProgressBar(this, new Vector2(0, 200), 51, font);
            UiTextbox     textbox     = new UiTextbox(this, new Vector2(0, -100), font);
            UiRadio       radio       = new UiRadio(this, new Vector2(0, -200), "hejsan", font);
            UiCheckBox    box         = new UiCheckBox(this, new Vector2(0, 0), "textbox visible", font);

            UiButton btn = new UiButton(this, new Vector2(0, 100), "Hej", font,
                                        delegate(object sender, EventArgs args)
            {
                progressbar.Procent += (MoveUp ? 2 : -3);

                switch (progressbar.Procent)
                {
                case 100:
                    MoveUp = false;
                    break;

                case 0:
                    MoveUp = true;
                    break;
                }
                if (box.IsChecked)
                {
                    textbox.IsVisible = false;
                }
                else
                {
                    textbox.IsVisible = true;
                }
            });

            Menu1 = new Menu();
            Menu1.Add(btn);
            Menu1.Add(textbox);
            Menu1.Add(radio);
            Menu1.Add(box);
            Menu1.Add(progressbar);
        }
Exemplo n.º 2
0
        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 UiGameFileCommanderSettingsWindow(bool isExtracting)
        {
            #region Construct

            SizeToContent = SizeToContent.WidthAndHeight;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            WindowStyle = WindowStyle.None;

            UiGrid root = UiGridFactory.Create(3, 1);
            {
                Thickness margin = new Thickness(3);

                UiStackPanel maskPanel = UiStackPanelFactory.Create(Orientation.Horizontal);
                {
                    UiTextBlock maskLabel = UiTextBlockFactory.Create("Маска: ");
                    {
                        maskLabel.Margin = margin;
                        maskLabel.VerticalAlignment = VerticalAlignment.Center;
                        maskPanel.AddUiElement(maskLabel);
                    }

                    _wildcardBox = UiTextBoxFactory.Create("*");
                    {
                        _wildcardBox.Width = 300;
                        _wildcardBox.Margin = margin;
                        maskPanel.AddUiElement(_wildcardBox);
                    }

                    root.AddUiElement(maskPanel, 0, 0);
                }

                UiStackPanel settingsPanel = UiStackPanelFactory.Create(Orientation.Horizontal);
                {
                    if (!isExtracting)
                    {
                        _compressBox = UiCheckBoxFactory.Create("Сжать", false);
                        {
                            _compressBox.Margin = margin;
                            _compressBox.IsThreeState = true;
                            _compressBox.IsChecked = null;
                            settingsPanel.AddUiElement(_compressBox);
                        }
                    }

                    _convertBox = UiCheckBoxFactory.Create("Конвертировать", false);
                    {
                        _convertBox.Margin = margin;
                        _convertBox.IsThreeState = true;
                        _convertBox.IsChecked = null;
                        settingsPanel.AddUiElement(_convertBox);
                    }

                    root.AddUiElement(settingsPanel, 1, 0);
                }

                UiStackPanel buttonsPanel = UiStackPanelFactory.Create(Orientation.Horizontal);
                {
                    buttonsPanel.HorizontalAlignment = HorizontalAlignment.Right;

                    UiButton okButton = UiButtonFactory.Create("OK");
                    {
                        okButton.Width = 100;
                        okButton.Margin = margin;
                        okButton.Click += OnOkButtonClick;
                        buttonsPanel.AddUiElement(okButton);
                    }

                    UiButton cancelButton = UiButtonFactory.Create("Отмена");
                    {
                        cancelButton.Width = 100;
                        cancelButton.Margin = margin;
                        cancelButton.Click += OnCancelButtonClick;
                        buttonsPanel.AddUiElement(cancelButton);
                    }

                    root.AddUiElement(buttonsPanel, 2, 0);
                }
            }

            Content = root;

            #endregion
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        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;
                }
            }
        }