Пример #1
0
        protected override void Draw()
        {
            //VG.vgSetfv(VGParamType.VG_CLEAR_COLOR, 4, new[] { 0.0f, 1.0f, 0.0f, 0.5f });
            //VG.vgClear(0, 0, Width, Height);
            //VG.vgFinish();

            VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_PATH_USER_TO_SURFACE);
            VG.vgLoadIdentity();

            #region draw text

            if (Text == null)
            {
                return;
            }

            VG.vgSetParameteri(mPaint, (int)VGPaintParamType.VG_PAINT_TYPE, (int)VGPaintType.VG_PAINT_TYPE_COLOR);
            VG.vgSetParameterfv(mPaint, (int)VGPaintParamType.VG_PAINT_COLOR, 4, FontColor.Value);
            VG.vgSetPaint(mPaint, VGPaintMode.VG_FILL_PATH);

            float[] glyphOrigin = { 0.0f, 0.0f };

            // set glyph matrices
            VG.vgSetfv(VGParamType.VG_GLYPH_ORIGIN, 2, glyphOrigin);
            VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_GLYPH_USER_TO_SURFACE);
            VG.vgLoadIdentity();

            var widthText = (TextWidth > Width) ? Width : TextWidth;
            switch (TextAlign)
            {
            case Align.Left:
                VG.vgTranslate(TextOffset.X, TextOffset.Y);
                break;

            case Align.Center:
                VG.vgTranslate((Width - widthText + TextOffset.X) / 2f, TextOffset.Y);
                break;

            case Align.Right:
                VG.vgTranslate((Width - widthText - TextOffset.X), TextOffset.Y);
                break;
            }

            VG.vgTranslate(RotateCenter.X, RotateCenter.Y);
            VG.vgRotate(mRotate);
            VG.vgTranslate(-RotateCenter.X, -RotateCenter.Y);

            VG.vgScale(FontSize, FontSize);

            mFontRender.RenderText(Text);
            VG.vgFinish();

            #endregion
        }
Пример #2
0
        public override void Update(GfxRect updateArea)
        {
            if (!IsVisible)
            {
                return;
            }

            if (OnPaint != null)
            {
                OnPaint(this);
            }

            //Console.WriteLine("->> {1}: to surface: {0}", Name, DateTime.Now.ToString("mm:ss.fff"));

            var position = ScreenPosition;

            VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_IMAGE_USER_TO_SURFACE);

            VG.vgLoadIdentity();
            VG.vgTranslate(position.X, position.Y);

            if (mRotate != 0)
            {
                VG.vgTranslate(RotateCenter.X, RotateCenter.Y);
                VG.vgRotate(mRotate);
                VG.vgTranslate(-RotateCenter.X, -RotateCenter.Y);
            }

            if (mScaleX != kAccuratePoint || mScaleY != kAccuratePoint)
            {
                var sx = mScaleX / (kAccuratePoint * 1.0f);
                var sy = mScaleY / (kAccuratePoint * 1.0f);
                VG.vgScale(sx, sy);
            }

            mRenderBuffer.ToSurface();

            Console.WriteLine("<<- {1}: to surface: {0}", Name, DateTime.Now.ToString("mm:ss.fff"));

            foreach (var widget in mChilds.Where(widget => !(widget is ModalWindow)))
            {
                widget.Update();
            }
        }
Пример #3
0
        public override void Update()
        {
            VG.vgSeti(VGParamType.VG_IMAGE_MODE, (int)VGImageMode.VG_DRAW_IMAGE_NORMAL);
            VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_IMAGE_USER_TO_SURFACE);

            VG.vgLoadIdentity();
            VG.vgTranslate(X, Y);

            // draw bg
            int width, height;
            var image = CopyImageToVgBuffer(File.ReadAllBytes(Path.Combine(mRootImageDirUrl, @"generic/progressbar/bg.raw")), out width, out height);

            VG.vgDrawImage(image);
            VG.vgDestroyImage(image);

            // draw left border
            if (Percent > 0)
            {
                image = CopyImageToVgBuffer(File.ReadAllBytes(Path.Combine(mRootImageDirUrl, @"generic/progressbar/left.raw")), out width, out height);
                VG.vgDrawImage(image);
                VG.vgDestroyImage(image);
            }

            // draw right border
            VG.vgTranslate(300, 0);
            if (Percent == 100)
            {
                image = CopyImageToVgBuffer(File.ReadAllBytes(Path.Combine(mRootImageDirUrl, @"generic/progressbar/right.raw")), out width, out height);
                VG.vgDrawImage(image);
                VG.vgDestroyImage(image);
            }

            if (Percent > 0)
            {
                VG.vgTranslate(-293, 1);
                VG.vgScale(1.465f * Percent, 1.0f);
                image = CopyImageToVgBuffer(File.ReadAllBytes(Path.Combine(mRootImageDirUrl, @"generic/progressbar/1.raw")), out width, out height);
                VG.vgDrawImage(image);
                VG.vgDestroyImage(image);
            }

            mTextArea.Update();
        }
Пример #4
0
        public override void Update()
        {
            VG.vgSeti(VGParamType.VG_IMAGE_MODE, (int)VGImageMode.VG_DRAW_IMAGE_NORMAL);
            VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_IMAGE_USER_TO_SURFACE);
            VG.vgLoadIdentity();


            if (State == ButtonState.Released)
            {
                VG.vgTranslate(X, Y);
                VG.vgScale(mScaleX, mScaleY);
            }
            else
            {
                if (EffectToLeft)
                {
                    VG.vgTranslate(X - ((Width / mScaleX) - Width), Y);
                }
                else
                {
                    VG.vgTranslate(X, Y);
                }
            }

            /*
             * int width;
             * int height;
             * var image = CopyImageToVgBuffer(File.ReadAllBytes(mImageUrl), out width, out height);
             * if (image != IntPtr.Zero)
             * {
             *  VG.vgDrawImage(image);
             *  VG.vgDestroyImage(image);
             * }
             */

            base.Update();
        }
Пример #5
0
        public void Update()
        {
            VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_PATH_USER_TO_SURFACE);
            VG.vgLoadIdentity();

            if (mStrokePaint != null)
            {
                mStrokePaint.SetPaint(VGPaintMode.VG_STROKE_PATH);

                VG.vgSetf(VGParamType.VG_STROKE_LINE_WIDTH, StrokeWidth);
                VG.vgSeti(VGParamType.VG_STROKE_CAP_STYLE, mCapStyle);
                VG.vgSeti(VGParamType.VG_STROKE_JOIN_STYLE, mJoinStyle);
                VG.vgSetfv(VGParamType.VG_STROKE_DASH_PATTERN, mDashPattern != null ? mDashPattern.Length : 0, mDashPattern);
            }
            else
            {
                VG.vgSetf(VGParamType.VG_STROKE_LINE_WIDTH, 0);
            }

            if (mFillPaint != null)
            {
                mFillPaint.SetPaint(VGPaintMode.VG_FILL_PATH);
            }

            //Parse("M30.0, 0.0c-6.512-8.236-10.411-18.633-10.411-29.948 c0-26.692,21.639-48.331,48.331-48.331s48.331,21.639,48.331,48.331c0,11.503-4.024,22.063-10.735,30.359l10.688,8.629 c8.615-10.655,13.779-24.218,13.779-38.988c0-34.275-27.786-62.062-62.063-62.062c-34.275,0-62.062,27.786-62.062,62.062 c0,14.53,4.995,27.892,13.357,38.467L30.0, 0.0z");
            //Parse("M676.364,484.481c0,6.627-5.372,12-12,12H526.357c-6.628,0-12-5.373-12-12V357.351c0-6.627,5.372-12,12-12h138.007c6.628,0,12,5.373,12,12V484.481z");

            VG.vgTranslate(X, Y);                 // offset at screen

            VG.vgScale(Scale, Scale);             // scale
            VG.vgTranslate(-Bounds.X, -Bounds.Y); // translate to screen coordinates (0;0)

            VG.vgDrawPath(mPath, (mFillPaint != null ? VGPaintMode.VG_FILL_PATH : 0) | (mStrokePaint != null ? VGPaintMode.VG_STROKE_PATH : 0));

            VG.vgFinish();
        }