Пример #1
0
        protected void OnExpose(object sender, ExposeEventArgs args)
        {
            using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) {
                var left   = Allocation.Left;
                var width  = Allocation.Width;
                var top    = Allocation.Top;
                var bottom = Allocation.Bottom;
                var height = Allocation.Height;

                TouchGlobal.DrawRoundedRectangle(cr, left, top, width, height, 4.0);

                var outlineColor = new TouchColor(buttonColor);
                outlineColor.ModifyColor(0.5);
                var highlightColor = new TouchColor(buttonColor);
                highlightColor.ModifyColor(1.4);
                var lowlightColor = new TouchColor(buttonColor);
                lowlightColor.ModifyColor(0.75);

                using (var grad = new LinearGradient(left, top, left, bottom)) {
                    grad.AddColorStop(0, highlightColor.ToCairoColor());
                    grad.AddColorStop(0.2, buttonColor.ToCairoColor());
                    grad.AddColorStop(0.85, lowlightColor.ToCairoColor());
                    cr.SetSource(grad);
                    cr.FillPreserve();
                }

                outlineColor.SetSource(cr);
                cr.LineWidth = 1;
                cr.Stroke();

                render.Render(this, left + 3, top, width - 6, height);
            }
        }
Пример #2
0
        protected void OnExpose(object sender, ExposeEventArgs args)
        {
            using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) {
                int left   = Allocation.Left;
                int top    = Allocation.Top;
                int width  = Allocation.Width;
                int height = Allocation.Height;

                TouchGlobal.DrawRoundedRectangle(cr, left + 4, top + 4, width - 1, height - 1, 3);
                var shadowColor = new TouchColor(backgroundColor);
                shadowColor.ModifyColor(0.5);
                shadowColor.A = 0.4;
                shadowColor.SetSource(cr);
                cr.Fill();

                TouchGlobal.DrawRoundedRectangle(cr, left, top, width, height, 3);
                backgroundColor.SetSource(cr);
                cr.FillPreserve();

                TouchColor.SetSource(cr, "grey0");
                cr.LineWidth = 1;
                cr.Stroke();

                textRender.Render(this, left + 3, top, width - 6, height);
            }
        }
Пример #3
0
        protected void OnExpose(object sender, ExposeEventArgs args)
        {
            using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) {
                int left   = Allocation.Left;
                int top    = Allocation.Top;
                int width  = Allocation.Width;
                int height = Allocation.Height;

                radius = orientation == TouchOrientation.Vertical ? width / 2 : height / 2;

                TouchGlobal.DrawRoundedRectangle(cr, left, top, width, height, radius);
                colorBackground.SetSource(cr);
                cr.Fill();

                DrawProgressBar(cr, _currentProgress, colorProgress);
            }
        }
        protected void OnExpose(object sender, ExposeEventArgs args)
        {
            using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) {
                int left  = Allocation.Left + 1;
                int top   = Allocation.Top;
                int width = Allocation.Width - 2;

                if (listDropdown)
                {
                    int listHeight;

                    if (comboList.Count > maxListHeight)
                    {
                        listHeight       = (maxListHeight + 1) * height;
                        includeScrollBar = true;
                    }
                    else if (comboList.Count > 0)
                    {
                        listHeight = (comboList.Count + 1) * height;
                    }
                    else
                    {
                        listHeight = 2 * height;
                    }

                    HeightRequest = listHeight + 2;

                    int radius = height / 2;
                    cr.MoveTo(left, top + radius);
                    cr.Arc(left + radius, top + radius, radius, Math.PI, -Math.PI / 2);
                    cr.LineTo(left + width - radius, top);
                    cr.Arc(left + width - radius, top + radius, radius, -Math.PI / 2, 0);
                    cr.LineTo(left + width, top + listHeight);
                    cr.LineTo(left, top + listHeight);
                    cr.ClosePath();
                    TouchColor.SetSource(cr, "grey4");
                    cr.FillPreserve();
                    TouchColor.SetSource(cr, "black");
                    cr.LineWidth = 1;
                    cr.Stroke();

                    DrawDownButton(cr, left, top, width);

                    if (includeScrollBar)
                    {
                        if (listOffset + maxListHeight > comboList.Count)
                        {
                            listOffset = 0;
                        }

                        int x = left + width - height;
                        listHeight -= height;

                        cr.Rectangle(x, top + height, height, listHeight);
                        TouchColor.SetSource(cr, "grey3");
                        cr.Fill();

                        cr.Rectangle(x, top + height, height, height);
                        TouchColor buttonColor  = "grey1";
                        var        outlineColor = new TouchColor(buttonColor);
                        outlineColor.ModifyColor(0.5);
                        var highlightColor = new TouchColor(buttonColor);
                        highlightColor.ModifyColor(1.4);
                        var lowlightColor = new TouchColor(buttonColor);
                        lowlightColor.ModifyColor(0.75);
                        using (var grad = new LinearGradient(x, top + height, x, top + 2 * height)) {
                            grad.AddColorStop(0.0, buttonColor.ToCairoColor());
                            grad.AddColorStop(0.85, lowlightColor.ToCairoColor());
                            cr.SetSource(grad);
                            cr.FillPreserve();
                        }
                        outlineColor.SetSource(cr);
                        cr.LineWidth = 1;
                        cr.Stroke();

                        var buttonTop = top + listHeight;
                        cr.Rectangle(x, buttonTop, height, height);
                        using (var grad = new LinearGradient(x, buttonTop, x, buttonTop + height)) {
                            grad.AddColorStop(0, highlightColor.ToCairoColor());
                            grad.AddColorStop(0.2, buttonColor.ToCairoColor());
                            grad.AddColorStop(0.85, lowlightColor.ToCairoColor());
                            cr.SetSource(grad);
                            cr.FillPreserve();
                        }
                        outlineColor.SetSource(cr);
                        cr.LineWidth = 1;
                        cr.Stroke();

                        scrollBarHeight = (listHeight - 2 * height) / comboList.Count;
                        var scrollBarActualHeight = scrollBarHeight * maxListHeight;
                        var scrollBarTop          = top + (2 * height) + (scrollBarHeight * listOffset);

                        TouchGlobal.DrawRoundedRectangle(cr, x, scrollBarTop, height, scrollBarActualHeight, height / 3);
                        buttonColor  = "grey2";
                        outlineColor = new TouchColor(buttonColor);
                        outlineColor.ModifyColor(0.5);
                        highlightColor = new TouchColor(buttonColor);
                        highlightColor.ModifyColor(1.3);
                        lowlightColor = new TouchColor(buttonColor);
                        lowlightColor.ModifyColor(0.75);
                        using (var grad = new LinearGradient(x, scrollBarTop, x, scrollBarTop + scrollBarActualHeight)) {
                            grad.AddColorStop(0, highlightColor.ToCairoColor());
                            grad.AddColorStop(0.1, buttonColor.ToCairoColor());
                            grad.AddColorStop(0.85, lowlightColor.ToCairoColor());
                            cr.SetSource(grad);
                            cr.FillPreserve();
                        }
                        outlineColor.SetSource(cr);
                        cr.LineWidth = 1;
                        cr.Stroke();

                        int triOffset = 7;
                        int triSize   = height - 12;
                        int y         = top + height + triOffset + triSize;
                        x += (triOffset - 1);

                        cr.MoveTo(x, y);
                        cr.LineTo(x + triSize, y);
                        cr.LineTo(x + (triSize / 2), y - triSize);
                        cr.ClosePath();
                        if (scrollBarUpClicked)
                        {
                            TouchColor.SetSource(cr, "pri");
                        }
                        else
                        {
                            TouchColor.SetSource(cr, "grey2");
                        }
                        cr.Fill();

                        y = top + listHeight + triOffset;
                        cr.MoveTo(x, y);
                        cr.LineTo(x + triSize, y);
                        cr.LineTo(x + triSize / 2, y + triSize);
                        cr.ClosePath();
                        if (scrollBarDownClicked)
                        {
                            TouchColor.SetSource(cr, "pri");
                        }
                        else
                        {
                            TouchColor.SetSource(cr, "grey2");
                        }
                        cr.Fill();
                    }

                    if (highlighted != -1)
                    {
                        var highlightedWidth = width - 2;
                        if (includeScrollBar)
                        {
                            highlightedWidth -= height;
                        }
                        var y = top + height + (height * highlighted);
                        cr.Rectangle(left + 1, y + 1, highlightedWidth, height - 2);
                        TouchColor.SetSource(cr, "pri");
                        cr.Fill();
                    }

                    var textRender = new TouchText();
                    textRender.font.color = "black";
                    if (includeScrollBar)
                    {
                        for (int i = 0; i < maxListHeight; ++i)
                        {
                            textRender.text = comboList[i + listOffset];
                            int y = top + height + 6 + (height * i);
                            textRender.Render(this, left + 10, y, width - height);
                        }
                    }
                    else
                    {
                        for (int i = 0; i < comboList.Count; ++i)
                        {
                            textRender.text = comboList[i];
                            int y = top + height + 6 + (height * i);
                            textRender.Render(this, left + 10, y, width - height);
                        }
                    }
                }
                else
                {
                    HeightRequest = height;

                    TouchGlobal.DrawRoundedRectangle(cr, left, top, width - 2, height, height / 2);
                    TouchColor.SetSource(cr, "grey4");
                    cr.FillPreserve();
                    cr.LineWidth = 1;
                    TouchColor.SetSource(cr, "black");
                    cr.Stroke();

                    DrawDownButton(cr, left, top, width);
                }

                bool writeStringCond1 = nonActiveMessage.IsNotEmpty() && (activeIndex == -1);
                bool writeStringCond2 = (comboList.Count > 0) && (activeIndex >= 0);

                if (writeStringCond1 || writeStringCond2)
                {
                    string text = writeStringCond1 ? nonActiveMessage : comboList[activeIndex];
                    var    t    = new TouchText(text);
                    t.textWrap   = TouchTextWrap.Shrink;
                    t.font.color = "black";
                    var w = width - height - 10;
                    t.Render(this, left + 10, top, w, height);
                }
            }
        }
Пример #5
0
        protected void OnExpose(object sender, ExposeEventArgs args)
        {
            using (Context cr = Gdk.CairoHelper.Create(GdkWindow)) {
                var left   = Allocation.Left;
                var top    = Allocation.Top;
                var width  = Allocation.Width;
                var height = Allocation.Height;
                var radius = barWidth / 2;
                int bigRadius;

                double fudgeFactor = -0.0125 * radius;

                if (curveStyle == CurveStyle.HalfCurve)
                {
                    bigRadius = height - radius - 2;
                    int originX = left + (width / 2);
                    int originY = top + height - radius;

                    cr.MoveTo(originX - bigRadius + barWidth, originY);
                    cr.Arc(originX - bigRadius + radius, originY, radius, 0, Math.PI);
                    cr.Arc(originX, originY, bigRadius, Math.PI, 0);
                    cr.Arc(originX + bigRadius - radius, originY, radius, 0, Math.PI);
                    cr.ArcNegative(originX, originY, bigRadius - barWidth + fudgeFactor, 0, Math.PI);
                    cr.ClosePath();
                    backgroundColor.SetSource(cr);
                    cr.Fill();

                    double r  = ((1 - _progress) * -180.0).ToRadians();
                    double x2 = TouchGlobal.CalcX(originX, bigRadius - radius, r);
                    double y2 = TouchGlobal.CalcY(originY, bigRadius - radius, r);

                    cr.MoveTo(originX - bigRadius + barWidth, originY);
                    cr.Arc(originX - bigRadius + radius, originY, radius, 0, Math.PI);
                    cr.Arc(originX, originY, bigRadius, Math.PI, r);
                    cr.Arc(x2, y2, radius, r, r + Math.PI);
                    cr.ArcNegative(originX, originY, bigRadius - barWidth + fudgeFactor, r, Math.PI);
                    cr.LineTo(left, originY);
                    cr.ClosePath();
                    progressColor.SetSource(cr);
                    cr.Fill();
                }
                else if (curveStyle == CurveStyle.ThreeQuarterCurve)
                {
                    int below = (0.45 * height).ToInt();
                    bigRadius = height - below - 2;
                    int originX = left + (width / 2);
                    int originY = top + height - below;

                    double x2 = TouchGlobal.CalcX(originX, bigRadius - radius, 3 * Math.PI / 4);
                    double y2 = TouchGlobal.CalcY(originY, bigRadius - radius, 3 * Math.PI / 4);

                    cr.MoveTo(x2, y2);
                    cr.Arc(x2, y2, radius, 7 * Math.PI / 4, 3 * Math.PI / 4);
                    cr.Arc(originX, originY, bigRadius, 3 * Math.PI / 4, Math.PI / 4);
                    x2 = TouchGlobal.CalcX(originX, bigRadius - radius, Math.PI / 4);
                    y2 = TouchGlobal.CalcY(originY, bigRadius - radius, Math.PI / 4);
                    cr.Arc(x2, y2, radius, Math.PI / 4, (-135.0).ToRadians());
                    cr.ArcNegative(originX, originY, bigRadius - barWidth + fudgeFactor, Math.PI / 4, 3 * Math.PI / 4);
                    cr.ClosePath();
                    backgroundColor.SetSource(cr);
                    cr.Fill();

                    double r = (_progress * 270.0 + 135.0).ToRadians();

                    x2 = TouchGlobal.CalcX(originX, bigRadius - radius, 3 * Math.PI / 4);
                    y2 = TouchGlobal.CalcY(originY, bigRadius - radius, 3 * Math.PI / 4);
                    cr.Arc(x2, y2, radius, 7 * Math.PI / 4, 3 * Math.PI / 4);
                    cr.Arc(originX, originY, bigRadius, 3 * Math.PI / 4, r);
                    x2 = TouchGlobal.CalcX(originX, bigRadius - radius, r);
                    y2 = TouchGlobal.CalcY(originY, bigRadius - radius, r);
                    cr.Arc(x2, y2, radius, r, r + Math.PI);
                    cr.ArcNegative(originX, originY, bigRadius - barWidth + fudgeFactor, r, 3 * Math.PI / 4);

                    var outlineColor = new TouchColor(progressColor);
                    outlineColor.ModifyColor(0.5);
                    var highlightColor = new TouchColor(progressColor);
                    highlightColor.ModifyColor(1.4);
                    var lowlightColor = new TouchColor(progressColor);
                    lowlightColor.ModifyColor(0.75);

                    var colorOriginX = TouchGlobal.CalcX(originX, bigRadius - 5, 11 * Math.PI / 8);
                    var colorOriginY = TouchGlobal.CalcY(originY, bigRadius - 5, 11 * Math.PI / 8);
                    using (var grad = new RadialGradient(colorOriginX, colorOriginY, 0, colorOriginX, colorOriginY, (bigRadius - 5) * 2)) {
                        grad.AddColorStop(0, highlightColor.ToCairoColor());
                        grad.AddColorStop(0.35, progressColor.ToCairoColor());
                        grad.AddColorStop(0.75, lowlightColor.ToCairoColor());
                        cr.SetSource(grad);
                        cr.FillPreserve();
                    }

                    outlineColor.SetSource(cr);
                    cr.LineWidth = 1;
                    cr.Stroke();
                }
            }
        }
Пример #6
0
        protected void OnExpose(object sender, ExposeEventArgs args)
        {
            using (Context cr = Gdk.CairoHelper.Create(this.GdkWindow)) {
                int height = Allocation.Height;
                int width  = Allocation.Width;
                int top    = Allocation.Top;
                int left   = Allocation.Left;

                int seperation, sliderWidth, sliderLength, sliderMax, x, y;

                if (orientation == TouchOrientation.Horizontal)
                {
                    if (sliderSize == MySliderSize.Small)
                    {
                        sliderWidth = height;
                    }
                    else
                    {
                        sliderWidth  = width / selectionCount;
                        sliderWidth += (selectionCount - 2) * 8;
                    }

                    sliderLength = width - sliderWidth;
                    sliderMax    = left + sliderLength;

                    seperation = sliderLength / (selectionCount - 1);

                    seperation *= currentSelected;

                    if (clicked)
                    {
                        seperation += (click2 - click1);
                    }

                    x = left + seperation;
                    if (x < left)
                    {
                        x = left;
                    }
                    if (x > sliderMax)
                    {
                        x = sliderMax;
                    }
                    y = top;
                }
                else
                {
                    if (sliderSize == MySliderSize.Small)
                    {
                        sliderWidth = width;
                    }
                    else
                    {
                        sliderWidth  = height / selectionCount;
                        sliderWidth += (selectionCount - 2) * 8;
                    }

                    sliderLength = height - sliderWidth;
                    sliderMax    = top + sliderLength;

                    seperation = sliderLength / (selectionCount - 1);

                    seperation *= currentSelected;

                    if (clicked)
                    {
                        seperation += click2 - click1;
                    }

                    y = top + seperation;
                    if (y < top)
                    {
                        y = top;
                    }
                    if (y > sliderMax)
                    {
                        y = sliderMax;
                    }
                    x = left;
                }

                // Background
                if (orientation == TouchOrientation.Horizontal)
                {
                    TouchGlobal.DrawRoundedRectangle(cr, left, top, width, height, height / 2);
                }
                else
                {
                    TouchGlobal.DrawRoundedRectangle(cr, left, top, width, height, width / 2);
                }
                TouchColor.SetSource(cr, "grey0");
                cr.FillPreserve();

                TouchColor.SetSource(cr, "black");
                cr.LineWidth = 1;
                cr.Stroke();

                // Slider
                double sliderLeft, sliderTop, sliderBottom;
                if (orientation == TouchOrientation.Horizontal)
                {
                    sliderLeft   = x;
                    sliderTop    = y;
                    sliderBottom = y + height;

                    TouchGlobal.DrawRoundedRectangle(cr, x, y, sliderWidth, height, height / 2);
                }
                else
                {
                    sliderLeft   = x;
                    sliderTop    = y;
                    sliderBottom = y + sliderWidth;

                    TouchGlobal.DrawRoundedRectangle(cr, x, y, width, sliderWidth, width / 2);
                }

                var sliderColor  = sliderColorOptions[currentSelected];
                var outlineColor = new TouchColor(sliderColor);
                outlineColor.ModifyColor(0.5);
                var highlightColor = new TouchColor(sliderColor);
                highlightColor.ModifyColor(1.4);
                var lowlightColor = new TouchColor(sliderColor);
                lowlightColor.ModifyColor(0.75);

                using (var grad = new LinearGradient(sliderLeft, sliderTop, sliderLeft, sliderBottom)) {
                    grad.AddColorStop(0, highlightColor.ToCairoColor());
                    grad.AddColorStop(0.2, sliderColor.ToCairoColor());
                    grad.AddColorStop(0.85, lowlightColor.ToCairoColor());
                    cr.SetSource(grad);
                    cr.FillPreserve();
                }

                outlineColor.SetSource(cr);
                cr.LineWidth = 0.9;
                cr.Stroke();

                // Text Labels
                var render = new TouchText();
                render.textWrap  = TouchTextWrap.Shrink;
                render.alignment = TouchAlignment.Center;

                seperation = Allocation.Width / selectionCount;
                x          = Allocation.Left;
                for (int i = 0; i < selectionCount; ++i)
                {
                    if (!string.IsNullOrWhiteSpace(textOptions[i]))
                    {
                        render.font.color = i == currentSelected ? selectedTextColorOptions[i] : backgoundTextColorOptions[i];
                        render.text       = textOptions[i];
                        render.Render(this, x, Allocation.Top + 4, seperation);
                    }

                    x += seperation;
                }
            }
        }