Ejemplo n.º 1
0
        public UiProgressWindow(string title)
        {
            #region Construct

            Height = 72;
            Width  = 320;
            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            WindowStyle           = WindowStyle.None;

            UiGrid root = UiGridFactory.Create(3, 1);
            root.SetRowsHeight(GridLength.Auto);
            root.Margin = new Thickness(5);

            UiTextBlock titleTextBlock = UiTextBlockFactory.Create(title);
            {
                titleTextBlock.VerticalAlignment   = VerticalAlignment.Center;
                titleTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
                root.AddUiElement(titleTextBlock, 0, 0);
            }

            _progressBar = UiProgressBarFactory.Create();
            {
                root.AddUiElement(_progressBar, 1, 0);
            }

            _progressTextBlock = UiTextBlockFactory.Create("100%");
            {
                _progressTextBlock.VerticalAlignment   = VerticalAlignment.Center;
                _progressTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
                root.AddUiElement(_progressTextBlock, 1, 0);
            }

            _elapsedTextBlock = UiTextBlockFactory.Create(Lang.Measurement.Elapsed + ": 00:00");
            {
                _elapsedTextBlock.HorizontalAlignment = HorizontalAlignment.Left;
                root.AddUiElement(_elapsedTextBlock, 2, 0);
            }

            _processedTextBlock = UiTextBlockFactory.Create("0 / 0");
            {
                _processedTextBlock.HorizontalAlignment = HorizontalAlignment.Center;
                root.AddUiElement(_processedTextBlock, 2, 0);
            }

            _remainingTextBlock = UiTextBlockFactory.Create(Lang.Measurement.Remaining + ": 00:00");
            {
                _remainingTextBlock.HorizontalAlignment = HorizontalAlignment.Right;
                root.AddUiElement(_remainingTextBlock, 2, 0);
            }

            Content = root;

            #endregion

            Loaded  += OnLoaded;
            Closing += OnClosing;

            _timer          = new System.Timers.Timer(500);
            _timer.Elapsed += OnTimer;
        }
Ejemplo 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();
        }
Ejemplo n.º 3
0
        public DonationControl()
        {
            SetCols(2);
            SetRows(5);

            Width                      = 250;
            VerticalAlignment          = VerticalAlignment.Top;
            HorizontalAlignment        = HorizontalAlignment.Left;
            Margin                     = new Thickness(5);
            DataContext                = this;
            ColumnDefinitions[0].Width = GridLength.Auto;

            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);

            UiTextBlock title = AddUiElement(UiTextBlockFactory.Create("Пожертвования"), 0, 0, 0, 2);

            title.FontSize            = 18;
            title.HorizontalAlignment = HorizontalAlignment.Center;
            title.Margin = new Thickness(0, 4, 0, 0);

            AddUiElement(UiTextBoxFactory.Create("Яндекс: "), 1, 0);
            AddUiElement(UiTextBoxFactory.Create("410013254932482"), 1, 1);
            AddUiElement(UiTextBoxFactory.Create("WMR: "), 2, 0);
            AddUiElement(UiTextBoxFactory.Create("R255847965836"), 2, 1);
            AddUiElement(UiTextBoxFactory.Create("WMZ: "), 3, 0);
            AddUiElement(UiTextBoxFactory.Create("Z321220468886 "), 3, 1);
            AddUiElement(UiTextBoxFactory.Create("WME: "), 4, 0);
            AddUiElement(UiTextBoxFactory.Create("E223137827385"), 4, 1).Margin = new Thickness(0, 0, 0, 5);

            foreach (FrameworkElement child in Children)
            {
                if (!ReferenceEquals(child, backround))
                {
                    child.Margin = GetColumn(child) == 0
                        ? new Thickness(child.Margin.Left + 8, child.Margin.Top, child.Margin.Right, child.Margin.Bottom)
                        : new Thickness(child.Margin.Left, 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;
                }

                TextBox textBox = child as TextBox;
                if (textBox != null)
                {
                    textBox.Foreground      = Brushes.WhiteSmoke;
                    textBox.FontWeight      = FontWeight.FromOpenTypeWeight(500);
                    textBox.Background      = Brushes.Transparent;
                    textBox.BorderThickness = new Thickness(0);
                    textBox.IsReadOnly      = true;
                }
            }
        }
Ejemplo 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();
        }