Esempio n. 1
0
            protected void AddTextWithShadow(CanvasRenderer renderer, string text, Vector2 position, EHorizontalAlignment horizontalAlign,
                                             EVerticalAlignment verticalAlign, ColorValue color, double shadowOffsetInPixels)
            {
                Vector2 shadowOffset = shadowOffsetInPixels / Owner.ViewportControl.Viewport.SizeInPixels.ToVector2();

                renderer.AddText(null, GetFontSize(), text, position + shadowOffset, horizontalAlign, verticalAlign, new ColorValue(0, 0, 0, color.Alpha / 2.5f));
                renderer.AddText(null, GetFontSize(), text, position, horizontalAlign, verticalAlign, color);
            }
Esempio n. 2
0
        /////////////////////////////////////////

        protected override void OnRenderWindow(UIWindow control, CanvasRenderer renderer)
        {
            var rect = control.GetScreenRectangle();

            renderer.AddQuad(rect, new ColorValue(0.05, 0.05, 0.25));

            var rect2 = rect;

            rect2.Expand(-control.GetScreenOffsetByValue(new UIMeasureValueVector2(UIMeasure.Units, 4, 4)));

            var color = new ColorValue(0.25, 0.25, 0.75);

            renderer.AddQuad(new Rectangle(rect.Left, rect.Top, rect2.Left, rect.Bottom), color);
            renderer.AddQuad(new Rectangle(rect2.Left, rect.Top, rect2.Right, rect2.Top), color);
            renderer.AddQuad(new Rectangle(rect2.Right, rect.Top, rect.Right, rect.Bottom), color);
            renderer.AddQuad(new Rectangle(rect.Left, rect2.Bottom, rect2.Right, rect.Bottom), color);

            if (control.TitleBar.Value)
            {
                double titleBarHeight = 30;
                double screenY        = rect.Top + control.GetScreenOffsetByValue(new UIMeasureValueVector2(UIMeasure.Units, 0, titleBarHeight)).Y;
                double screenY2       = screenY + control.GetScreenOffsetByValue(new UIMeasureValueVector2(UIMeasure.Units, 0, 4)).Y;

                var rect3 = new Rectangle(rect2.Left, rect2.Top, rect2.Right, screenY2);
                renderer.AddQuad(rect3, color);

                if (!string.IsNullOrEmpty(control.Text))
                {
                    var pos = new Vector2(rect.GetCenter().X, (rect2.Top + screenY) / 2);
                    renderer.AddText(control.Text, pos, EHorizontalAlignment.Center, EVerticalAlignment.Center, new ColorValue(1, 1, 1));
                }
            }
        }
Esempio n. 3
0
        protected override void OnRenderButton(UIButton control, CanvasRenderer renderer)
        {
            var styleColor = ColorValue.Zero;

            switch (control.State)
            {
            case UIButton.StateEnum.Normal: styleColor = new ColorValue(0.1, 0.1, 0.6); break;

            case UIButton.StateEnum.Hover: styleColor = new ColorValue(0.175, 0.175, 0.75); break;

            case UIButton.StateEnum.Pushed: styleColor = new ColorValue(0.25, 0.25, 0.9); break;

            case UIButton.StateEnum.Highlighted: styleColor = new ColorValue(0.6, 0.6, 0); break;

            case UIButton.StateEnum.Disabled: styleColor = new ColorValue(0.5, 0.5, 0.5); break;
            }

            control.GetScreenRectangle(out var rect);
            var color = styleColor.GetSaturate();

            if (color.Alpha > 0)
            {
                renderer.AddQuad(rect, color);

                var center = rect.GetCenter() + new Vector2(0, renderer.DefaultFontSize / 10);
                renderer.AddText(control.Text, center, EHorizontalAlignment.Center, EVerticalAlignment.Center, new ColorValue(1, 1, 1));
            }
        }
Esempio n. 4
0
        protected override void OnRenderButton(UIButton control, CanvasRenderer renderer)
        {
            if (control.Parent as UIContextMenu != null)
            {
                //context menu button

                var styleColor = ColorValue.Zero;
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: styleColor = new ColorValue(0.1, 0.1, 0.7); break;

                case UIButton.StateEnum.Hover: styleColor = new ColorValue(0.175, 0.175, 0.75); break;

                case UIButton.StateEnum.Pushed: styleColor = new ColorValue(0.25, 0.25, 0.9); break;

                case UIButton.StateEnum.Highlighted: styleColor = new ColorValue(0.6, 0.6, 0); break;

                case UIButton.StateEnum.Disabled: styleColor = new ColorValue(0.1, 0.1, 0.7); break;                  //new ColorValue( 0.5, 0.5, 0.5 ); break;
                }

                control.GetScreenRectangle(out var rect);
                var color = styleColor.GetSaturate();
                if (color.Alpha > 0)
                {
                    //back
                    renderer.AddQuad(rect, color);

                    //!!!!image

                    //text
                    var position  = new Vector2(rect.Left + control.GetScreenOffsetByValueX(new UIMeasureValueDouble(UIMeasure.Units, 10)), rect.GetCenter().Y) + new Vector2(0, renderer.DefaultFontSize / 10);
                    var textColor = control.State == UIButton.StateEnum.Disabled ? new ColorValue(0.7, 0.7, 0.7) : new ColorValue(1, 1, 1);
                    renderer.AddText(control.Text, position, EHorizontalAlignment.Left, EVerticalAlignment.Center, textColor);
                }
            }
            else
            {
                //usual button

                var styleColor = ColorValue.Zero;
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: styleColor = new ColorValue(0.1, 0.1, 0.6); break;

                case UIButton.StateEnum.Hover: styleColor = new ColorValue(0.175, 0.175, 0.75); break;

                case UIButton.StateEnum.Pushed: styleColor = new ColorValue(0.25, 0.25, 0.9); break;

                case UIButton.StateEnum.Highlighted: styleColor = new ColorValue(0.6, 0.6, 0); break;

                case UIButton.StateEnum.Disabled: styleColor = new ColorValue(0.5, 0.5, 0.5); break;
                }

                control.GetScreenRectangle(out var rect);
                var color = styleColor.GetSaturate();
                if (color.Alpha > 0)
                {
                    //back
                    renderer.AddQuad(rect, color);

                    //image
                    if (control.Image.Value != null)
                    {
                        var image = control.Image.Value;
                        if (control.ReadOnly && control.ImageDisabled.Value != null)
                        {
                            image = control.ImageDisabled.Value;
                        }

                        var imageRect = rect;
                        imageRect.Expand(-control.GetScreenOffsetByValue(new UIMeasureValueVector2(UIMeasure.Units, 4, 4)));
                        renderer.AddQuad(imageRect, new Rectangle(0, 0, 1, 1), image, new ColorValue(1, 1, 1), true);
                    }

                    //text
                    var position  = rect.GetCenter() + new Vector2(0, renderer.DefaultFontSize / 10);
                    var textColor = control.State == UIButton.StateEnum.Disabled ? new ColorValue(0.7, 0.7, 0.7) : new ColorValue(1, 1, 1);
                    renderer.AddText(control.Text, position, EHorizontalAlignment.Center, EVerticalAlignment.Center, textColor);
                }
            }
        }
Esempio n. 5
0
        protected override void OnRenderButton(UIButton control, CanvasRenderer renderer)
        {
            //!!!!context menu

            //if( control.Parent as UIContextMenu != null )
            //{
            //	//context menu button
            //}
            //else
            //{
            //	//usual button
            //}

            //!!!!
            //RenderButtonTextImage( control, renderer, new ColorValue( 1, 1, 1 ), new ColorValue( 1, 1, 1 ) );

            control.GetScreenRectangle(out var rect);

            //back
            {
                var color = new ColorByte();
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: color = DarkTheme ? new ColorByte(60, 60, 60) : new ColorByte(253, 253, 253); break;

                case UIButton.StateEnum.Hover: color = DarkTheme ? new ColorByte(80, 80, 80) : new ColorByte(205, 230, 247); break;

                case UIButton.StateEnum.Pushed: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(204, 228, 247); break;

                case UIButton.StateEnum.Highlighted: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(204, 228, 247); break;

                case UIButton.StateEnum.Disabled: color = DarkTheme ? new ColorByte(50, 50, 50) : new ColorByte(250, 250, 250); break;
                }

                renderer.AddQuad(rect, color.ToColorValue());
            }

            //text
            {
                var color = new ColorByte();
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(59, 59, 59); break;

                case UIButton.StateEnum.Hover: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(0, 0, 0); break;

                case UIButton.StateEnum.Pushed: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(0, 0, 0); break;

                case UIButton.StateEnum.Highlighted: color = DarkTheme ? new ColorByte(230, 230, 230) : new ColorByte(0, 0, 0); break;

                case UIButton.StateEnum.Disabled: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(167, 167, 167); break;
                }

                var center = rect.GetCenter() + new Vector2(0, renderer.DefaultFontSize / 10);
                renderer.AddText(control.Text, center, EHorizontalAlignment.Center, EVerticalAlignment.Center, color.ToColorValue());
            }

            //border
            {
                var color = new ColorByte();
                switch (control.State)
                {
                case UIButton.StateEnum.Normal: color = DarkTheme ? new ColorByte(90, 90, 90) : new ColorByte(170, 170, 170); break;

                case UIButton.StateEnum.Hover: color = DarkTheme ? new ColorByte(130, 130, 130) : new ColorByte(95, 168, 226); break;

                case UIButton.StateEnum.Pushed: color = DarkTheme ? new ColorByte(150, 150, 150) : new ColorByte(0, 120, 215); break;

                case UIButton.StateEnum.Highlighted: color = DarkTheme ? new ColorByte(150, 150, 150) : new ColorByte(0, 120, 215); break;

                case UIButton.StateEnum.Disabled: color = DarkTheme ? new ColorByte(60, 60, 60) : new ColorByte(180, 180, 180); break;
                }

                renderer.AddRectangle(rect, color.ToColorValue());
            }
        }