Пример #1
0
        public UiRectPositionControl()
        {
            UiGrid grid = new UiGrid();

            grid.SetCols(4);
            grid.ColumnDefinitions[0].Width = GridLength.Auto;
            grid.ColumnDefinitions[2].Width = GridLength.Auto;

            TextBlock xLabel = grid.AddUiElement(new TextBlock {
                Text = "x:"
            }, 0, 0);

            xLabel.Margin = new Thickness(3, 3, 5, 3);

            _relative               = grid.AddUiElement(new SingleUpDown(), 0, 1);
            _relative.Value         = 0;
            _relative.Increment     = 0.1f;
            _relative.FormatString  = "F3";
            _relative.ValueChanged += RelativeChanged;
            _relative.Margin        = new Thickness(3);

            TextBlock yLabel = grid.AddUiElement(new TextBlock {
                Text = "y:"
            }, 0, 2);

            yLabel.Margin = new Thickness(10, 3, 5, 3);

            _absolute               = grid.AddUiElement(new IntegerUpDown(), 0, 3);
            _absolute.Value         = 0;
            _absolute.Increment     = 1;
            _absolute.FormatString  = "F3";
            _absolute.ValueChanged += AbsoluteChanged;
            _absolute.Margin        = new Thickness(3);

            this.Content = grid;
        }
Пример #2
0
        public Vector2Control()
        {
            UiGrid grid = new UiGrid();

            grid.SetCols(4);
            grid.ColumnDefinitions[0].Width = GridLength.Auto;
            grid.ColumnDefinitions[2].Width = GridLength.Auto;

            TextBlock xLabel = grid.AddUiElement(new TextBlock {
                Text = "x:"
            }, 0, 0);

            xLabel.Margin = new Thickness(3, 3, 5, 3);

            _x               = grid.AddUiElement(new SingleUpDown(), 0, 1);
            _x.Value         = 0;
            _x.Increment     = 0.5f;
            _x.FormatString  = "F3";
            _x.ValueChanged += XChanged;
            _x.Margin        = new Thickness(3);

            TextBlock yLabel = grid.AddUiElement(new TextBlock {
                Text = "y:"
            }, 0, 2);

            yLabel.Margin = new Thickness(10, 3, 5, 3);

            _y               = grid.AddUiElement(new SingleUpDown(), 0, 3);
            _y.Value         = 0;
            _y.Increment     = 0.5f;
            _y.FormatString  = "F3";
            _y.ValueChanged += YChanged;
            _y.Margin        = new Thickness(3);

            this.Content = grid;
        }
Пример #3
0
        public QuaternionControl()
        {
            UiGrid grid = new UiGrid();

            grid.SetCols(8);
            grid.ColumnDefinitions[0].Width = GridLength.Auto;
            grid.ColumnDefinitions[2].Width = GridLength.Auto;
            grid.ColumnDefinitions[4].Width = GridLength.Auto;
            grid.ColumnDefinitions[6].Width = GridLength.Auto;

            TextBlock xLabel = grid.AddUiElement(new TextBlock {
                Text = "x:"
            }, 0, 0);

            xLabel.Margin = new Thickness(3, 3, 5, 3);

            _x               = grid.AddUiElement(new SingleUpDown(), 0, 1);
            _x.Value         = 0;
            _x.Increment     = 0.5f;
            _x.FormatString  = "F3";
            _x.ValueChanged += XChanged;
            _x.Margin        = new Thickness(3);

            TextBlock yLabel = grid.AddUiElement(new TextBlock {
                Text = "y:"
            }, 0, 2);

            yLabel.Margin = new Thickness(10, 3, 5, 3);

            _y               = grid.AddUiElement(new SingleUpDown(), 0, 3);
            _y.Value         = 0;
            _y.Increment     = 0.5f;
            _y.FormatString  = "F3";
            _y.ValueChanged += YChanged;
            _y.Margin        = new Thickness(3);

            TextBlock zLabel = grid.AddUiElement(new TextBlock {
                Text = "z:"
            }, 0, 4);

            zLabel.Margin = new Thickness(10, 3, 5, 3);

            _z               = grid.AddUiElement(new SingleUpDown(), 0, 5);
            _z.Value         = 0;
            _z.Increment     = 0.5f;
            _z.FormatString  = "F3";
            _z.ValueChanged += ZChanged;
            _z.Margin        = new Thickness(3);

            TextBlock wLabel = grid.AddUiElement(new TextBlock {
                Text = "w:"
            }, 0, 6);

            wLabel.Margin = new Thickness(10, 3, 5, 3);

            _w               = grid.AddUiElement(new SingleUpDown(), 0, 7);
            _w.Value         = 0;
            _w.Increment     = 0.5f;
            _w.FormatString  = "F3";
            _w.ValueChanged += WChanged;
            _w.Margin        = new Thickness(3);

            this.Content = grid;
        }
Пример #4
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
        }