Пример #1
0
        public override void InitElements()
        {
            _name.SetWidthPolicy(SizePolicy.Fixed);
            _name.SetWidth(150);

            _speed.SetWidthPolicy(SizePolicy.Fixed);
            _speed.SetWidth(30);
            _speed.SetTextAlignment(ItemAlignment.Left, ItemAlignment.VCenter);

            _slider.SetIgnoreStep(false);
            _slider.Handler.SetShadow(5, 0, 2, Palette.Shadow);
            _slider.SetMaxValue(10);
            _slider.SetMinValue(1);
            _slider.SetStep(1);
            _slider.EventValueChanged += (sender) =>
            {
                _speed.SetText("x" + (int)_slider.GetCurrentValue());
                EventValueChanged?.Invoke();
            };

            AddItems(
                _name,
                _slider,
                _speed
                );

            SetSpeed(3);
        }
Пример #2
0
        public override void InitWindow()
        {
            SetParameters(this.GetType().Name, this.GetType().Name, 800, 800, false);
            IsCentered = true;

            TitleBar titleBar = new TitleBar(this.GetType().Name);

            OpenGLLayer ogl = new OpenGLLayer();

            ogl.SetMargin(0, titleBar.GetHeight(), 0, 0);

            HorizontalStack toolbar = Items.GetToolbarLayout();

            ImagedButton btnRotateLeft  = Items.GetImagedButton(EmbeddedImage.ArrowUp, -90);
            ImagedButton btnRotateRight = Items.GetImagedButton(EmbeddedImage.ArrowUp, 90);

            HorizontalSlider zoom = Items.GetSlider();

            ImagedButton btnRestoreView = Items.GetImagedButton(EmbeddedImage.Refresh, 0);

            // adding
            AddItems(titleBar, ogl);
            ogl.AddItems(toolbar);
            toolbar.AddItems(btnRotateLeft, btnRotateRight, zoom, btnRestoreView);

            // assign events
            btnRestoreView.EventMousePress += (sender, args) =>
            {
                ogl.RestoreView();
            };

            btnRotateLeft.EventMousePress += (sender, args) =>
            {
                ogl.Rotate(KeyCode.Left);
            };

            btnRotateRight.EventMousePress += (sender, args) =>
            {
                ogl.Rotate(KeyCode.Right);
            };

            zoom.EventValueChanged += (sender) =>
            {
                ogl.SetZoom(zoom.GetCurrentValue());
            };

            // Set focus
            ogl.SetFocus();
            zoom.SetCurrentValue(3);
        }