public override void Draw() { VG.vgSetfv(VGParamType.VG_CLEAR_COLOR, 4, new[] { 0.0f, 1.0f, 0.0f, 0.50f }); VG.vgClear(0, 60, Width, Height); VG.vgFinish(); Text.Label(null, "Hello", 50, 10, 20, Width, 50, Align.Center, Palette.DarkSlateGray)[0].Draw(); mPath.Update(); }
public new void Update() { //Console.WriteLine("->> {1}: draw: {0}", Name, DateTime.Now.ToString("mm:ss.fff")); Redraw(); VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_PATH_USER_TO_SURFACE); VG.vgLoadIdentity(); VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_IMAGE_USER_TO_SURFACE); VG.vgLoadIdentity(); VG.vgSetfv(VGParamType.VG_CLEAR_COLOR, 4, new[] { 1.0f, 1.0f, 0.0f, 0.0f }); VG.vgClear(0, 0, Width, Height); VG.vgFinish(); //Console.WriteLine("<<- {1}: draw: {0}", Name, DateTime.Now.ToString("mm:ss.fff")); //Console.WriteLine("->> {1}: update: {0}", Name, DateTime.Now.ToString("mm:ss.fff")); base.Update(); //Console.WriteLine("<<- {1}: update: {0}", Name, DateTime.Now.ToString("mm:ss.fff")); #region Popup window ModalWindow popup = null; lock (mModalWindows) { if (mVisibleModal != null) { if (mVisibleModal.IsVisible) { popup = mVisibleModal; } } if (popup == null) { foreach (var modalWindow in mModalWindows.Where(modalWindow => modalWindow.IsVisible)) { mVisibleModal = modalWindow; popup = mVisibleModal; } } } if (popup == null) { return; } // отрисовываем модальное окно popup.Update(); #endregion }
protected override void Draw() { // draw bg if (Background != null) { VG.vgSetfv(VGParamType.VG_CLEAR_COLOR, 4, Background.Value); VG.vgClear(X, Y, Width, Height); } if (Grid != null) { Grid.Update(); } if (Arrows != null) { Arrows.Update(); } // draw line if (mGrapihcs.Count > 0) { foreach (var data in from data in mGrapihcs where data != null where data.Data != null where data.Data.Length > 0 select data) { VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_PATH_USER_TO_SURFACE); VG.vgLoadIdentity(); VG.vgTranslate(X + data.Position.X, Y + data.Position.Y); // (40, 20) VG.vgSetf(VGParamType.VG_STROKE_LINE_WIDTH, data.StrokeWidth); VG.vgSetParameterfv(mPaint, (int)VGPaintParamType.VG_PAINT_COLOR, 4, data.Color != null ? data.Color.Value : Palette.Black.Value); VG.vgSetPaint(mPaint, VGPaintMode.VG_STROKE_PATH); VG.vgClearPath(mPath, VGPathCapabilities.VG_PATH_CAPABILITY_ALL); var size = (data.Data.Length - 1) > (Width - data.Position.X) ? (Width - data.Position.X) : (data.Data.Length - 1); for (var i = 0; i < size; i++) { VGU.vguLine(mPath, i, data.Data[i], i + 1, data.Data[i + 1]); } VG.vgDrawPath(mPath, VGPaintMode.VG_STROKE_PATH); } } }
/// <summary> /// Реальная физическая перерисовка, если виджет имеет ширину и высоту и помечен к перерисовке /// </summary> public void Redraw(bool force = false) { if (Height != 0 && Width != 0 && IsDirty) { //Console.WriteLine("{1}: redraw: {0}", Name, DateTime.Now.ToString("mm:ss.fff")); VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_PATH_USER_TO_SURFACE); VG.vgLoadIdentity(); VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_IMAGE_USER_TO_SURFACE); VG.vgLoadIdentity(); VG.vgSetfv(VGParamType.VG_CLEAR_COLOR, 4, new[] { 1.0f, 1.0f, 1.0f, 0.0f }); VG.vgClear(0, 0, Width, Height); VG.vgFinish(); // TODO: swap debug only if (SwapDebug) { mApplication.Swap(); } Draw(); VG.vgFinish(); // TODO: swap debug only if (SwapDebug) { mApplication.Swap(); } mRenderBuffer.Copy(); // TODO: вместо mRenderBuffer.Activate(); IsDirty = false; } foreach (var widget in mChilds) { ((Widget)widget).Redraw(); } }
protected override void Draw() { if (Background != null) { VG.vgSetfv(VGParamType.VG_CLEAR_COLOR, 4, Background.Value); VG.vgClear(0, 0, Width, Height); VG.vgFinish(); } #region calibrate lines { /* * VG.vgLoadIdentity(); * VG.vgSetParameteri(mPanelBorderColor, (int)VGPaintParamType.VG_PAINT_TYPE, (int)VGPaintType.VG_PAINT_TYPE_COLOR); * VG.vgSetParameterfv(mPanelBorderColor, (int)VGPaintParamType.VG_PAINT_COLOR, 4, new[] { 1.0f, 1.0f, 1.0f, 1.0f }); * * VG.vgSetPaint(mPanelBorderColor, VGPaintMode.VG_STROKE_PATH); * VG.vgClearPath(mPath, VGPathCapabilities.VG_PATH_CAPABILITY_ALL); * * const float kLineSize = 1.0f; * VG.vgSetf(VGParamType.VG_STROKE_LINE_WIDTH, kLineSize); * VG.vgSeti(VGParamType.VG_STROKE_CAP_STYLE, (int)VGCapStyle.VG_CAP_BUTT); * VG.vgSeti(VGParamType.VG_STROKE_JOIN_STYLE, (int)VGJoinStyle.VG_JOIN_BEVEL); * * VGU.vguLine(mPath, 10, 0, 10, Height); * VGU.vguLine(mPath, Width - 10, 0, Width - 10, Height); * * VGU.vguLine(mPath, 0, 10, Width, 10); * VGU.vguLine(mPath, 0, Height - 10, Width, Height - 10); * * * VG.vgDrawPath(mPath, VGPaintMode.VG_STROKE_PATH); * VG.vgFinish(); */ } #endregion }
protected override void Draw() { if (!IsVisible) { return; } if (OnPaint != null) { OnPaint(this); } //var position = ScreenPosition; #region fill default background if (mNormaLineColor != null) { VG.vgSetfv(VGParamType.VG_CLEAR_COLOR, 4, mNormaLineColor.Value); VG.vgClear(0, 0, Width, Height); VG.vgFinish(); } #endregion #region fill active cells if (mActiveLineColor != null) { VG.vgSetfv(VGParamType.VG_CLEAR_COLOR, 4, mActiveLineColor.Value); if (ActiveLine != null) { VG.vgClear(ActiveLine.X, ActiveLine.Y, ActiveLine.Width, ActiveLine.Height); } else if (ActiveCell != null) { VG.vgClear(ActiveCell.X, ActiveCell.Y, ActiveCell.Width, ActiveCell.Height); } VG.vgFinish(); } #endregion VG.vgFinish(); #region draw grid if (mBorderWidth != 0) { VG.vgSetf(VGParamType.VG_STROKE_LINE_WIDTH, mBorderWidth); 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.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_PATH_USER_TO_SURFACE); VG.vgLoadIdentity(); //VG.vgTranslate(position.X, position.Y); VG.vgSetPaint(mPaint, VGPaintMode.VG_STROKE_PATH); VG.vgDrawPath(mPath, VGPaintMode.VG_STROKE_PATH); VG.vgFinish(); } #endregion VG.vgFinish(); }
public override void Draw() { if (!IsVisible) { return; } // draw bg if (Background != null) { VG.vgSetfv(VGParamType.VG_CLEAR_COLOR, 4, Background.Value); VG.vgClear(X, Y, Width, Height); VG.vgFinish(); } if (Arrows != null) { Arrows.Update(X, Y); } VG.vgSetf(VGParamType.VG_STROKE_LINE_WIDTH, 1.0f); VG.vgSetfv(VGParamType.VG_STROKE_DASH_PATTERN, 0, null); VG.vgSetParameterfv(mStrokePaint, (int)VGPaintParamType.VG_PAINT_COLOR, 4, new Color(0x575959FF).Value); VG.vgSetPaint(mStrokePaint, VGPaintMode.VG_STROKE_PATH); switch (Type) { case VisializationType.Realtime: { //mApplication.DebugTimeToConsole("realtime"); #region Realtime if (Grid != null) { Grid.Update(X, Y); } VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_PATH_USER_TO_SURFACE); // draw rectangles if (mGrapihcs.Count > 0) { lock (mGrapihcs) foreach (var data in from data in mGrapihcs where data != null where data.Data != null where data.Data.Length > 0 select data) { VG.vgLoadIdentity(); VG.vgTranslate(X + data.Position.X, Y + data.Position.Y); // (40, 20) var size = (data.Data.Length - 1) > (((uint)(kOxWidht)) - data.Position.X) ? (((uint)(kOxWidht)) - data.Position.X) : (data.Data.Length - 1); for (var i = 0; i < size; i++) { VG.vgClearPath(mPath, VGPathCapabilities.VG_PATH_CAPABILITY_ALL); var maxY = data.Data[i] < 5 ? 5 : data.Data[i]; // минимальное значение - 5 единиц, чтобы было видно секции maxY = data.Data[i] == ushort.MaxValue ? 5 : maxY; // проверяем флаг на наличие датчика maxY /= 2; VGU.vguRect(mPath, i * (kOxWidht / 177f), 0, (kOxWidht / 177f), maxY); var color = (data.Data[i] == ushort.MaxValue) ? Palette.White : new Color(GetColor(data.Data[i])); VG.vgSetParameterfv(mFillPaint, (int)VGPaintParamType.VG_PAINT_COLOR, 4, color.Value); VG.vgSetPaint(mFillPaint, VGPaintMode.VG_FILL_PATH); VG.vgDrawPath(mPath, VGPaintMode.VG_FILL_PATH); VG.vgDrawPath(mPath, VGPaintMode.VG_STROKE_PATH); } } } #endregion } break; case VisializationType.History: { if (HistoryReports != null) { if (HistoryReports.Length > 0) { //Console.WriteLine("history: {0}", HistoryReports.Length); VG.vgSeti(VGParamType.VG_MATRIX_MODE, (int)VGMatrixMode.VG_MATRIX_PATH_USER_TO_SURFACE); VG.vgLoadIdentity(); VG.vgTranslate(X + 40, Y + 20); // (40, 20) foreach (var label in mVHistoryLabels) { label.Text = ""; } var depth = 0; for (var j = 0; j < HistoryReports.Length; j++) { var data = HistoryReports[j].Restore(); if (j % 5 == 0) { //Console.WriteLine("history: {0}", j); var index = j / 5; var date = HistoryReports[j].Time; mVHistoryLabels[2 * index].Text = date.ToString("HH:mm"); mVHistoryLabels[2 * index + 1].Text = date.ToString("dd") + "/" + date.ToString("MM"); } if (data != null) { var size = (data.Length - 1); for (var i = 0; i < size; i++) { if (data[i] == ushort.MaxValue) { continue; } VG.vgClearPath(mPath, VGPathCapabilities.VG_PATH_CAPABILITY_ALL); const int kRectHeight = 12; VGU.vguRect(mPath, i * (kOxWidht / 177f), depth * kRectHeight, (kOxWidht / 177f), kRectHeight); VG.vgSetParameterfv(mFillPaint, (int)VGPaintParamType.VG_PAINT_COLOR, 4, new Color(GetColor(data[i])).Value); VG.vgSetPaint(mFillPaint, VGPaintMode.VG_FILL_PATH); VG.vgDrawPath(mPath, VGPaintMode.VG_FILL_PATH); VG.vgDrawPath(mPath, VGPaintMode.VG_STROKE_PATH); } } else { Console.WriteLine("oooops"); } depth++; } } } } break; } //base.Update(); }