示例#1
0
        private void InitBackground()
        {
            if (mInitialized)
            {
                return;
            }

            const int kRound = 10;

            mPath = VGPath.OpenVGPath();
            VGU.vguRoundRect(mPath, 0, 0, Width, Height, kRound, kRound);

            mCircle = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);

            mInitialized = true;
        }
示例#2
0
        public Button(string aName, int x, int y, int width, int height, float round)
            : base(null, aName)
        {
            X = x;
            Y = y;

            Width  = width;
            Height = height;

            mRound = round;

            const float kColor = 252f / 256f;

            PressColor = new Color {
                R = kColor, G = kColor, B = kColor
            };

            mPath  = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);
            mPaint = VG.vgCreatePaint();
        }
示例#3
0
        public SparcButton(string aName, int x, int y, int width, int height, float round, string url)
            : base(null, aName)
        {
            X = x;
            Y = y;

            Width  = width;
            Height = height;

            mRound = round;

            //const float kColor = 252f / 256f;
            //PressColor = new Color { R = kColor, G = kColor, B = kColor };

            mPath  = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);
            mPaint = VG.vgCreatePaint();

            mCache = VG.vgCreateImage(PixelFormat, Width + 2, Height + 2, VGImageQuality.VG_IMAGE_QUALITY_NONANTIALIASED);

            mIsRealUpdate = true;
            IsVisible     = true;
        }
示例#4
0
        public override void Update()
        {
            // render table
            {
                VG.vgSeti(VGParamType.VG_BLEND_MODE, (int)VGBlendMode.VG_BLEND_SRC_OVER);
                VG.vgSeti(VGParamType.VG_FILL_RULE, (int)VGFillRule.VG_NON_ZERO);
                VG.vgSetfv(VGParamType.VG_STROKE_DASH_PATTERN, 0, null);

                // create some paths
                var path0 = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);

                // create and set a paint for fill
                var fillPaint   = VG.vgCreatePaint();
                var strokePaint = VG.vgCreatePaint();

                // set model view matrix
                VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_PATH_USER_TO_SURFACE);
                VG.vgLoadIdentity();

                #region draw border
                if (Border)
                {
                    VG.vgSetf(VGParamType.VG_STROKE_LINE_WIDTH, 5.0f);
                    VG.vgSeti(VGParamType.VG_STROKE_CAP_STYLE, (int)VGCapStyle.VG_CAP_BUTT);
                    VG.vgSeti(VGParamType.VG_STROKE_JOIN_STYLE, (int)VGJoinStyle.VG_JOIN_BEVEL);

                    VG.vgSetParameteri(strokePaint, (int)VGPaintParamType.VG_PAINT_TYPE, (int)VGPaintType.VG_PAINT_TYPE_COLOR);
                    const float kGreyColor = 192f / 256f;
                    VG.vgSetParameterfv(strokePaint, (int)VGPaintParamType.VG_PAINT_COLOR, 4, new[] { kGreyColor, kGreyColor, kGreyColor, 1.0f });
                    VG.vgSetPaint(strokePaint, VGPaintMode.VG_STROKE_PATH);

                    var tableLenght = 0;
                    for (var i = 0; i < mLenghtX.Length; i++)
                    {
                        tableLenght += mLenghtX[i];
                    }


                    VGU.vguRect(path0, (mX - 2.5f), (mY - 2.5f), tableLenght + 5, GetLenght(mLenghtY.Length, mLenghtY) + 5.0f);
                    VG.vgDrawPath(path0, VGPaintMode.VG_STROKE_PATH);
                }
                #endregion

                #region fill cells
                if (CellFill)
                {
                    for (var i = 0; i < mLenghtX.Length; i++)
                    {
                        for (var j = 0; j < mLenghtY.Length; j++)
                        {
                            VG.vgSetParameteri(fillPaint, (int)VGPaintParamType.VG_PAINT_TYPE, (int)VGPaintType.VG_PAINT_TYPE_COLOR);
                            VG.vgSetParameterfv(fillPaint, (int)VGPaintParamType.VG_PAINT_COLOR, 4, CellColors[i, j].Value);
                            VG.vgSetPaint(fillPaint, VGPaintMode.VG_FILL_PATH);

                            VG.vgClearPath(path0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);
                            VGU.vguRect(path0, mX + GetLenght(i, mLenghtX), mY + GetLenght(j, mLenghtY), mLenghtX[i], mLenghtY[j]);
                            VG.vgDrawPath(path0, VGPaintMode.VG_FILL_PATH);
                        }
                    }
                }
                #endregion

                #region draw cells borders
                if (CellBorder)
                {
                    VG.vgSetParameteri(strokePaint, (int)VGPaintParamType.VG_PAINT_TYPE, (int)VGPaintType.VG_PAINT_TYPE_COLOR);
                    VG.vgSetParameterfv(strokePaint, (int)VGPaintParamType.VG_PAINT_COLOR, 4, new[] { 0.0f, 0.0f, 0.0f, 1.0f });
                    VG.vgSetPaint(strokePaint, VGPaintMode.VG_STROKE_PATH);

                    VG.vgClearPath(path0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);

                    VG.vgSetf(VGParamType.VG_STROKE_LINE_WIDTH, 1.0f);
                    VG.vgSeti(VGParamType.VG_STROKE_CAP_STYLE, (int)VGCapStyle.VG_CAP_BUTT);
                    VG.vgSeti(VGParamType.VG_STROKE_JOIN_STYLE, (int)VGJoinStyle.VG_JOIN_BEVEL);


                    for (var i = 0; i < mLenghtX.Length; i++)
                    {
                        for (var j = 0; j < mLenghtY.Length; j++)
                        {
                            VGU.vguRect(path0, mX + GetLenght(i, mLenghtX), mY + GetLenght(j, mLenghtY), mLenghtX[i], mLenghtY[j]);
                        }
                    }

                    VG.vgDrawPath(path0, VGPaintMode.VG_STROKE_PATH);
                }
                #endregion

                VG.vgDestroyPath(path0);
                VG.vgDestroyPaint(strokePaint);
            }

            base.Update();
        }
示例#5
0
 public VGPath(IOpenVGPaint stroke, IOpenVGPaint fill)
 {
     //mPath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_F, 1.0f, 0.0f, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);
     mPath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);
     Initialize(mPath, stroke, fill);
 }
示例#6
0
        public static Window ShowWindow()
        {
            var window = new Window("show", kWidth, kHeight)
            {
                Description = "Шеф-повар \"Сибовар\""
            };

            var line = new TableLine(25);

            line.AddColumn(80);
            line.AddColumn(80);
            line.AddColumn(70);

            line.Text[0].Text = "HgjloGreen";
            line.Text[0].SetFont(Palette.Lime, 20);
            line.Text[0].SetAlign(Align.Left, new GfxPoint(0, 3));
            line.Text[1].Text = "HelloRed";
            line.Text[1].SetFont(Palette.Red, 15);
            line.Text[1].SetAlign(Align.Center);
            line.Text[2].Text = "HgelloBlue";
            line.Text[2].SetFont(Palette.PaleTurquoise, 30);
            line.Text[2].SetAlign(Align.Left, new GfxPoint(0, 4));

            line.Name = "line";


            var table = new Table(window)
            {
                Name = "table"
            };

            table.Move(10, 50);
            table.AddLine(new TableLine(line));
            table.AddLine(new TableLine(line));
            table.AddLine(new TableLine(line));
            table.SetBackground(Palette.Red, Palette.White);
            table.SetBorder(1, Palette.Lime);
            table.OnPress += caller =>
            {
                var rv = table.GetLineByCell(caller);
                if (rv == null)
                {
                    return;
                }

                table.ActiveLine   = rv;
                window.Description = rv.Name;
            };


            var text = new TextArea(window, 10, 180, 325, 50);

            text.SetFont("i260c", Palette.PaleTurquoise, 50);
            text.Text = "0123456789:";

            text.OnPress += caller => window.Description = "Text.Pressed";

            var bar = new ProgressBar(window, 40, 30, 200, 15, 15)
            {
                Percent = 10, Status = { Text = "hello" }
            };

            bar.Status.SetAlign(Align.Center, new GfxPoint(3, 3));
            bar.Status.SetFont(Palette.White, 14);
            bar.Rotate(70);

            text.OnRelease += caller =>
            {
                window.Description = "Text.Released";
                //mApplication.SetFocusedWindow("1");
                line.Move(line.X - 3, line.Y - 3);
                table.ActiveLine = null;
                bar.Percent     -= 1;
            };

            window.OnPaint += delegate { Debug.Print(DateTime.Now.ToString("HH:mm:ss") + ":\tHome update"); };

            var activePath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);

            VGU.vguRoundRect(activePath, 0, 0, 60, 100, 20, 20);

            var normalPath = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);

            VGU.vguRoundRect(normalPath, 0, 0, 100, 50, 20, 20);
            VGU.vguRoundRect(normalPath, 10, 50, 80, 70, 20, 20);



            var activeButton = new VGSolidColor(new Color(0xFF0000FF));
            //var normalButton = new VGSolidColor(new Color(0x00FF00FF));
            var normalButton = new VGLinearGradient(0, 0, 100, 120);

            normalButton.AddColor(0, new Color(0xFF0000FF));
            normalButton.AddColor(100, new Color(0x00FF00FF));

            var button = new Button(window, new VGPath(activePath, null, activeButton), new VGPath(normalPath, null, normalButton));

            button.IsCached = true;
            button.Move(250, 50);
            button.OnPress += delegate { Console.WriteLine("button.OnPress"); };


            var image = new Image(window, 25, 10);

            image.Load("splash.raw");
            image.Scale(0.5f, 0.5f);
            image.RotateCenter = new GfxPoint(image.Width / 2, image.Height / 2);
            //image.Hide();

            window.OnPaint += caller =>
            {
                image.Rotate(mImageRotate);
                mImageRotate += 5;
            };

            var graphicArea = new GraphicArea(window, 200, 200);

            graphicArea.Move(70, 20);
            graphicArea.Background = new Color(0xF0F0F0FF);


            graphicArea.Grid   = new VGPath(activePath, activeButton, null);
            graphicArea.Arrows = new VGPath(normalPath, new VGSolidColor(Palette.PaleTurquoise), null);

            var graphicData1 = new GraphicsData
            {
                Data =
                    new byte[]
                {
                    0, 15, 25, 50, 40, 35, 12, 10, 15, 17, 30, 32, 35, 35, 35, 35, 35, 40,
                    45, 57, 25, 23, 20, 18, 12, 12, 12, 30, 32, 35, 35, 35, 35, 35, 40, 45
                }
            };

            var graphicData2 = new GraphicsData(graphicData1)
            {
                Color = Palette.Lime, Position = new GfxPoint(10, 10)
            };

            graphicArea.AddGrapic(graphicData1);
            graphicArea.AddGrapic(graphicData2);

            return(window);
        }
示例#7
0
        private void Init()
        {
            mTimer = new Timer(ProcessTimerEvent, null, Timeout.Infinite, Timeout.Infinite);

            mPath        = VG.vgCreatePath(0, VGPathDatatype.VG_PATH_DATATYPE_S_16, 1, 0, 0, 0, VGPathCapabilities.VG_PATH_CAPABILITY_ALL);
            mFillPaint   = VG.vgCreatePaint();
            mStrokePaint = VG.vgCreatePaint();

            mGrapihcs = new List <GraphicsData>();

            var color = new VGSolidColor(new Color(0xD1D3D4FF));

            #region Lines & arrows
            {
                var path = VGPath.OpenVGPath();
                VG.vgLoadIdentity();

                const float kXBias = 3f;
                const float kYBias = 12f;

                VGU.vguLine(path, 0, 0, Width - 60, 0);          // OX
                //VGU.vguLine(path, 0, 0, 0, Height - 40); // OY
                VGU.vguLine(path, 0, 0, 0, Height - kYBias - 1); // OY



                var yArroyBias = Height - kYBias - 1;
                //var yArroyBias = Height - 40f;

                var pathData = new float[16];
                pathData[0] = -kXBias;
                pathData[1] = yArroyBias;          //0f;
                pathData[2] = 0f;
                pathData[3] = yArroyBias + kYBias; // kYBias;
                pathData[4] = kXBias;
                pathData[5] = yArroyBias;          //0f;
                VGU.vguPolygon(path, pathData, 3, VGboolean.VG_TRUE);

                var xArroyBias = Width - 60f;
                pathData[0] = xArroyBias;
                pathData[1] = -kXBias;
                pathData[2] = xArroyBias + kYBias;
                pathData[3] = 0f;
                pathData[4] = xArroyBias;
                pathData[5] = kXBias;
                VGU.vguPolygon(path, pathData, 3, VGboolean.VG_TRUE);

                var vgPath = new VGPath(path, color, color);
                vgPath.Move(35, 15);
                Arrows = vgPath;
            }

            #endregion

            #region Grid

            {
                var path = VGPath.OpenVGPath();
                VGU.vguLine(path, 0, 0, Width - 60, 0); // OX

                var vgPath = new VGPath(path, null, null);
                //vgPath.SetStroke(color);
                vgPath.SetStroke(color, new[] { 2.0f, 2.0f });
                vgPath.StrokeWidth = 0.5f;
                vgPath.Move(40, 20 + 180);

                Grid = vgPath;
            }

            #endregion

            #region childs
            mHLabels = new[]
            {
                new TextArea(this, 15, 0, 36, 18)
                {
                    Text = "1"
                },
                new TextArea(this, (int)(kOxWidht * 50 / 177), 0, 36, 18)
                {
                    Text = "50"
                },
                new TextArea(this, (int)(kOxWidht * 100 / 177), 0, 36, 18)
                {
                    Text = "100"
                },
                new TextArea(this, (int)(kOxWidht * 150 / 177), 0, 36, 18)
                {
                    Text = "150"
                }
            };

            var oyLabel = new TextArea(this, -10, Height, 60, 18)
            {
                Text = "P, бар"
            };
            mVRuntimeLabels = new[]
            {
                oyLabel,
                new TextArea(this, -10, 10, 36, 18)
                {
                    Text = "0"
                },

                new TextArea(this, -10, Height * 50 / kHeight, 36, 18)
                {
                    Text = "100"
                },
                new TextArea(this, -10, Height * 100 / kHeight, 36, 18)
                {
                    Text = "200"
                },
                new TextArea(this, -10, Height * 150 / kHeight, 36, 18)
                {
                    Text = "300"
                },
                new TextArea(this, -10, Height * 200 / kHeight, 36, 18)
                {
                    Text = "400"
                },
                new TextArea(this, -10, Height * 250 / kHeight, 36, 18)
                {
                    Text = "500"
                }
            };


            mVHistoryLabels = new[]
            {
                new TextArea(this, -15, Height * 10 / kHeight, 45, 18)
                {
                    Text = ""
                },
                new TextArea(this, -15, Height * 25 / kHeight, 45, 18)
                {
                    Text = ""
                },

                new TextArea(this, -15, Height * 60 / kHeight, 45, 18)
                {
                    Text = ""
                },
                new TextArea(this, -15, Height * 75 / kHeight, 45, 18)
                {
                    Text = ""
                },

                new TextArea(this, -15, Height * 110 / kHeight, 45, 18)
                {
                    Text = ""
                },
                new TextArea(this, -15, Height * 125 / kHeight, 45, 18)
                {
                    Text = ""
                },

                new TextArea(this, -15, Height * 160 / kHeight, 45, 18)
                {
                    Text = ""
                },
                new TextArea(this, -15, Height * 175 / kHeight, 45, 18)
                {
                    Text = ""
                },

                new TextArea(this, -15, Height * 210 / kHeight, 45, 18)
                {
                    Text = ""
                },
                new TextArea(this, -15, Height * 225 / kHeight, 45, 18)
                {
                    Text = ""
                }
            };

            foreach (var label in mHLabels)
            {
                label.SetFont(new Color(0xD1D3D4FF), 20);
                label.SetAlign(Align.Right);
            }


            foreach (var label in mVRuntimeLabels)
            {
                label.SetFont(new Color(0xD1D3D4FF), 20);
                label.SetAlign(Align.Right);
            }


            foreach (var label in mVHistoryLabels)
            {
                label.SetFont(new Color(0xD1D3D4FF), 20);
                label.SetAlign(Align.Right);
                label.Hide();
            }

            //mVRuntimeLabels[mVRuntimeLabels.Length - 2].SetFont(new Color(0x5EE82CFF), 20);// "180"

            var oxLabel = new TextArea(this, Width - 20, 0, 60, 18)
            {
                Text = "N"
            };
            oxLabel.SetFont(new Color(0xD1D3D4FF), 20);


            oyLabel.SetFont(new Color(0xD1D3D4FF), 20);
            oyLabel.SetAlign(Align.Left, new GfxPoint(0, 5));
            #endregion

            Move(170, 310);

            //ImageCacheBorder = 50; // work

            Type = VisializationType.Realtime;
        }