Esempio n. 1
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;
                }
            }
        }
Esempio n. 2
0
        public UiEncodingWindow()
        {
            #region Construct

            WindowStartupLocation = WindowStartupLocation.CenterScreen;
            ResizeMode            = ResizeMode.CanMinimize;
            Width  = 1024;
            Height = 768;

            UiGrid root = UiGridFactory.Create(4, 1);
            {
                root.RowDefinitions[0].Height = GridLength.Auto;
                root.RowDefinitions[2].Height = GridLength.Auto;
                root.RowDefinitions[3].Height = GridLength.Auto;

                _comboBox = UiComboBoxFactory.Create();
                {
                    _comboBox.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    _comboBox.Margin            = new Thickness(3);
                    _comboBox.DisplayMemberPath = "DisplayName";
                    _comboBox.SelectionChanged += OnComboBoxItemChanged;
                    root.AddUiElement(_comboBox, 0, 0);
                }

                _editViewport = new UiDxViewport();
                {
                    _editViewport.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                    _editViewport.VerticalAlignment   = VerticalAlignment.Stretch;

                    _editViewport.DrawSprites    += OnEditViewportDrawSprites;
                    _editViewport.DrawPrimitives += OnEditViewportDrawPrimitives;

                    _editViewport.DxControl.Control.MouseDown += OnDxControlElementMouseDown;
                    _editViewport.DxControl.Control.MouseUp   += OnDxControlElementMouseUp;
                    _editViewport.DxControl.Control.MouseMove += OnDxControlElementMouseMove;

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

                UiGrid previewGroup = UiGridFactory.Create(2, 2);
                {
                    previewGroup.RowDefinitions[0].Height   = GridLength.Auto;
                    previewGroup.ColumnDefinitions[1].Width = GridLength.Auto;

                    _previewViewport = new UiDxViewport();
                    {
                        _previewViewport.Height = 200;
                        _previewViewport.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch;
                        _previewViewport.VerticalAlignment   = VerticalAlignment.Stretch;

                        _previewViewport.DrawSprites += OnPreviewViewportDraw;
                        _previewViewport.DxControl.RenderContainer.BackBuffer.BackgroundColor = Colors.Black;

                        previewGroup.AddUiElement(_previewViewport, 0, 0, 2);
                    }

                    UiEncodingLabeledNumber scale = new UiEncodingLabeledNumber("Масштаб:", 200, 100, 400, OnScaleValueChanged);
                    {
                        scale.Value = 100;
                        scale.NumberControl.Increment = 25;
                        previewGroup.AddUiElement(scale, 0, 1);
                    }

                    UiTextBox textBox = UiTextBoxFactory.Create();
                    {
                        textBox.Text         = _previewText;
                        textBox.TextChanged += OnPreviewTextChanged;
                        previewGroup.AddUiElement(textBox, 1, 1);
                    }

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

                _charactersControl = new UiEncodingCharactersControl();
                {
                    root.AddUiElement(_charactersControl, 3, 0);
                }

                UiButton button = UiButtonFactory.Create("OK");
                {
                    button.Width  = 70;
                    button.Margin = new Thickness(3);
                    button.HorizontalAlignment = System.Windows.HorizontalAlignment.Right;
                    button.Click += (s, a) => DialogResult = true;
                    root.AddUiElement(button, 3, 0);
                }
            }
            Content = root;

            _editViewport.DxControl.RenderContainer.Reseted += ResetBurshes;
            ResetBurshes(_editViewport.DxControl.RenderContainer);

            Thread movingThread = new Thread(MovingThread);
            movingThread.Start();

            Activated += OnWindowActivated;
            Closing   += (s, e) => ClosingEvent.Set();
            Closing   += OnWindowClosing;

            #endregion
        }