/// <summary> /// Resets the image cache(s) /// </summary> public void ClearImageCache() { DrawItem.DumpImages(); DrawItem.DumpOpacityImages(); FireLayoutRenderUpdatedEvent(); Logger.AddLogLine("Cleared Image Cache"); }
public override bool Render(ProjectLayoutElement zElement, Graphics zGraphics) { if (zElement.height < (TargetRect.Y + TargetRect.Height)) { // too tall, completely end the draw return(false); } // draw border (debugging) if (CardMakerInstance.DrawFormattedTextBorder) { zGraphics.DrawRectangle(Pens.Green, TargetRect.X + m_fXOffset, TargetRect.Y + m_fYOffset, TargetRect.Width, TargetRect.Height); } // already null checked in the ProcessMarkup var zBmp = DrawItem.LoadImageFromCache(m_sImageFile); zGraphics.DrawImage(zBmp, TargetRect.X + m_fXOffset, TargetRect.Y + m_fYOffset, TargetRect.Width, TargetRect.Height); if (CardMakerInstance.DrawFormattedTextBorder) { zGraphics.FillRectangle(new SolidBrush(Color.FromArgb(32, 255, 0, 0)), TargetRect.X, TargetRect.Y, TargetRect.Width, TargetRect.Height); } return(true); }
private void frmDetails_Load(object sender, EventArgs e) { drawNote = new DrawItem(); txtboxName.Text = filename; txtboxLink.Text = link; txtBoxID.Text = ID; }
public override bool Render(ProjectLayoutElement zElement, Graphics zGraphics) { var zFormat = new StringFormat { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Near, }; // indicate any text being cut off if (zElement.height < TargetRect.Y + TargetRect.Height) { // completely end the draw return(false); } // NOTE: when rendering there is no need for a target rect as that information has already been processed float targetX = TargetRect.X + m_fXOffset; float targetY = TargetRect.Y + m_fYOffset; // draw border (debugging) if (CardMakerInstance.DrawFormattedTextBorder) { zGraphics.DrawRectangle(Pens.Green, targetX, targetY, TargetRect.Width, TargetRect.Height); } // when a string is measured there is a bit of an offset to where it renders (into the target rect a few pixels right ---->) targetX -= m_rectMeasuredRectangle.X; if (0 == zElement.outlinethickness) { try { zGraphics.DrawString(m_sVariable, m_zFont, m_zFontBrush, targetX, targetY, zFormat); } catch (Exception) { Logger.AddLogLine("Unable to render text (font issue?)"); } } else { // prepare to draw text var zPath = new GraphicsPath(); try { zPath.AddString(m_sVariable, m_zFont.FontFamily, (int)m_zFont.Style, m_fFontOutlineSize, new PointF(targetX, targetY), zFormat); DrawItem.DrawOutline(zElement, zGraphics, zPath); } catch (Exception) { Logger.AddLogLine("Unable to render text (font issue?)"); } // fill in the outline zGraphics.FillPath(m_zFontBrush, zPath); } return(true); }
protected override void OnPaint(PaintEventArgs pe) { pe.Graphics.FillRectangle(Brushes.White, this.ClientRectangle); int startPoint = -(offsetPosition % ItemDirectionalSize); Rectangle area = new Rectangle(); for (int index = offsetPosition / ItemDirectionalSize; startPoint < OffsetPosition + DirectionSize; index++) { System.Diagnostics.Debug.WriteLine(index); if (HorizontalMode) { area = new Rectangle(startPoint, 0, ItemDirectionalSize, this.Height); if (DrawItemHorizontal != null) { DrawItemHorizontal.Invoke(this, new DrawItemEventArgs( pe.Graphics, this.Font, area, index, SelectedIndex == index ? DrawItemState.Selected : DrawItemState.None)); } } else { area = new Rectangle(0, startPoint, this.Width, ItemDirectionalSize); if (DrawItem != null) { DrawItem.Invoke(this, new DrawItemEventArgs( pe.Graphics, this.Font, area, index, SelectedIndex == index ? DrawItemState.Selected : DrawItemState.None)); } } startPoint += ItemDirectionalSize; } }
private void OnDrawItem(ref DrawItem drawItem) { if (drawItem.CtlType != OwnerDrawControlType.Menu) { throw new COMException("CtlType is not menu"); } GetMenuItem((int)(drawItem.itemID - startCommandId)).CustomMenuHandler.Draw(ref drawItem); }
public static void PerformMirrorOperation(DrawItem tmpItem, float canvasWidth) { float midPoint = canvasWidth / 2.0f; float drawMidXPoint = tmpItem.Path.Bounds.MidX; float x = (midPoint - drawMidXPoint) * 2; SKMatrix translateXaxis = SKMatrix.CreateTranslation(x, 0); tmpItem.Path.Transform(translateXaxis); }
public DrawItem GetDrawItemFromCache() { if (m_drawItemsCache.Count > 0) { DrawItem result = m_drawItemsCache[m_drawItemsCache.Count - 1]; m_drawItemsCache.RemoveAt(m_drawItemsCache.Count - 1); return(result); } return(new DrawItem()); }
public void ValidateMarkupTranslation(string input, Type[] expectedTypes) { var markups = DrawItem.GetMarkups(input); Assert.AreEqual(expectedTypes.Length, markups.Count); for (var i = 0; i < expectedTypes.Length; i++) { Assert.AreEqual(expectedTypes[i], markups[i].GetType()); } }
public void CollateDrawItems(Widget widget, Rectangle scissorRectangle) { if (!widget.IsVisible || !widget.IsDrawEnabled) { return; } bool flag = widget.GlobalBounds.Intersection(new BoundingRectangle(scissorRectangle.Left, scissorRectangle.Top, scissorRectangle.Right, scissorRectangle.Bottom)); Rectangle?scissorRectangle2 = null; if (widget.ClampToBounds && flag) { scissorRectangle2 = scissorRectangle; int num = (int)MathUtils.Floor(widget.GlobalBounds.Min.X - 0.5f); int num2 = (int)MathUtils.Floor(widget.GlobalBounds.Min.Y - 0.5f); int num3 = (int)MathUtils.Ceiling(widget.GlobalBounds.Max.X - 0.5f); int num4 = (int)MathUtils.Ceiling(widget.GlobalBounds.Max.Y - 0.5f); scissorRectangle = Rectangle.Intersection(new Rectangle(num, num2, num3 - num, num4 - num2), scissorRectangle2.Value); DrawItem drawItemFromCache = GetDrawItemFromCache(); drawItemFromCache.ScissorRectangle = scissorRectangle; m_drawItems.Add(drawItemFromCache); } if (widget.IsDrawRequired && flag) { DrawItem drawItemFromCache2 = GetDrawItemFromCache(); drawItemFromCache2.Widget = widget; m_drawItems.Add(drawItemFromCache2); } if (flag || !widget.ClampToBounds) { ContainerWidget containerWidget = widget as ContainerWidget; if (containerWidget != null) { foreach (Widget child in containerWidget.Children) { CollateDrawItems(child, scissorRectangle); } } } if (widget.IsOverdrawRequired && flag) { DrawItem drawItemFromCache3 = GetDrawItemFromCache(); drawItemFromCache3.Widget = widget; drawItemFromCache3.IsOverdraw = true; m_drawItems.Add(drawItemFromCache3); } if (scissorRectangle2.HasValue) { DrawItem drawItemFromCache4 = GetDrawItemFromCache(); drawItemFromCache4.ScissorRectangle = scissorRectangle2; m_drawItems.Add(drawItemFromCache4); } widget.WidgetsHierarchyInput?.Draw(this); }
void Mirror_Button_Clicked(System.Object sender, System.EventArgs e) { if (completedPaths.Count > 0) { DrawItem tmpItem = DrawHelper.CopyLastDrawPathListItem(completedPaths); DrawHelper.PerformMirrorOperation(tmpItem, canvasView.CanvasSize.Width); DrawHelper.InvertBoundBrushPaths(tmpItem.Path); completedPaths.Add(tmpItem); canvasView.InvalidateSurface(); } }
public override bool Render(ProjectLayoutElement zElement, Graphics zGraphics) { // already null checked in the ProcessMarkup var zBmp = DrawItem.LoadImageFromCache(m_sImageFile); zGraphics.DrawImage(zBmp, TargetRect.X + m_fXOffset, TargetRect.Y + m_fYOffset, m_nWidth, m_nHeight); if (CardMakerInstance.DrawFormattedTextBorder) { zGraphics.FillRectangle(new SolidBrush(Color.FromArgb(32, 0, 255, 0)), TargetRect.X, TargetRect.Y, m_nWidth, m_nHeight); } return(true); }
public static List<Revision> GetRevisions(DrawItem drawItem) { var db = new Data1.CloudCoreDB(drawItem.ConnectionString); var revisions = from pv in db.Cloudcoremodel_ProcessRevision select new Revision { ID = pv.ProcessRevisionId, Name = pv.ProcessRevision.ToString(), ProcessID = pv.ProcessModelId, Date = String.Format("{0:dd MMMM yyyy}", pv.Changed), User = pv.UserId.ToString() }; return revisions.ToList(); }
public static List<Process> GetProcesses(DrawItem drawItem) { var db = new Data1.CloudCoreDB(drawItem.ConnectionString); var processes = from pm in db.Cloudcoremodel_ProcessModel where pm.ProcessModelId != 0 select new Process(drawItem) { Id = pm.ProcessModelId, Title = pm.ProcessName }; return processes.ToList(); }
/// <summary> /// メモリに読みこんだグラフィックの描画 /// </summary> /// <param name="x"></param> /// <param name="y"></param> /// <param name="GrHandle"></param> private static void DrawGraph(int x, int y, int GrHandle, EnumPriority priority, EnumBLEND blend, int blendparam) { DrawItem d = new DrawItem(); d.xy.X = x; d.xy.Y = y; d.gh = GrHandle; d.priority = priority; d.blend = blend; d.blendparam = blendparam; d.drawmode = EnumDraw.DrawGraph; d.index = lstDrawObject.Count(); lstDrawObject.Add(d); }
public static DrawItem CopyLastDrawPathListItem(List <DrawItem> drawItems) { drawItems.Reverse(); DrawItem tmpItem = new DrawItem() { Path = new SKPath(drawItems[0].Path), Paint = drawItems[0].Paint, Area = drawItems[0].Area, Name = drawItems[0].Name }; drawItems.Reverse(); return(tmpItem); }
/// <summary> /// 通用绘图方式 /// </summary> /// <param name="item">绘制项目</param> /// <param name="name">绘图名称</param> /// <param name="type">绘制类型</param> private void Draw(DrawItem item, object type, object obj) { switch (item) { case DrawItem.POINT: PointDrawer.Draw(type, obj, graph); // 空缺处可以是PointDrawer 也可以是PointDrawer[] break; case DrawItem.ROUTE: RouteDrawer.Draw(type, obj, graph); // 空缺处可以是RouteDrawer 也可以是RouteDrawer[] break; case DrawItem.TEXT: break; } }
/// <summary> /// Processes the image markup and if the image is valid associates it with the current process data. /// </summary> /// <param name="zElement"></param> /// <param name="zData"></param> /// <param name="zProcessData"></param> /// <param name="zGraphics"></param> /// <returns>false - The BackgroundImageMarkup.Render is called as part of a TextMarkup</returns> public override bool ProcessMarkup(ProjectLayoutElement zElement, FormattedTextData zData, FormattedTextProcessData zProcessData, Graphics zGraphics) { var arrayComponents = m_sVariable.Split(new char[] { ';' }); if (1 > arrayComponents.Length) { return(false); } StringAlignment = zProcessData.CurrentStringAlignment; LineNumber = zProcessData.CurrentLine; m_sImageFile = arrayComponents[0]; var zBmp = DrawItem.LoadImageFromCache(m_sImageFile); m_fXOffset = zProcessData.CurrentXOffset; m_fYOffset = zProcessData.CurrentYOffset; if (null != zBmp) { switch (arrayComponents.Length) { case 1: m_nWidth = zBmp.Width; m_nHeight = zBmp.Height; TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, 0, 0); return(true); case 5: { if (ParseUtil.ParseFloat(arrayComponents[1], out m_fXOffset) && ParseUtil.ParseFloat(arrayComponents[2], out m_fYOffset) && int.TryParse(arrayComponents[3], out m_nWidth) && int.TryParse(arrayComponents[4], out m_nHeight)) { TargetRect = new RectangleF(zProcessData.CurrentX, zProcessData.CurrentY, 0, 0); return(true); } } break; } } return(false); }
private void ChangePlayFieldData(List <Point> pointList, DrawItem drawItem) { /* "pointList" contains a list of cartesian coordiantes that should be changed. * This can be one point for the apple or 100 points for snakes body. * * The "drawItem" defines the change kind. * This information defines finally the color to use. */ for (int i = 0; i < pointList.Count; i++) { switch (drawItem) { case DrawItem.PlayField: PlayFieldData[pointList[i].X, pointList[i].Y].Color = ColorPlayField; break; case DrawItem.Apple: PlayFieldData[pointList[i].X, pointList[i].Y].Color = ColorApple; break; case DrawItem.Snake: if (i == 0) { PlayFieldData[pointList[i].X, pointList[i].Y].Color = ColorSnakeHead; } else if (i == pointList.Count - 1) { PlayFieldData[pointList[i].X, pointList[i].Y].Color = ColorSnakeTail; } else { PlayFieldData[pointList[i].X, pointList[i].Y].Color = ColorSnakeBody; } break; case DrawItem.HamiltonianCycle: PlayFieldData[pointList[i].X, pointList[i].Y].Color = ColorHamiltonianCycle; break; default: break; } } }
protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (graphics == null) { return; } graphics.Clear(BackColor); graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias; // Draw items via user-code if (DrawItem != null) { if (Items != null) { for (int i = 0; i < Items.Count; i++) { int yPos = (i * (rowHeight + rowDistance)) + scrollAmount + rowDistance; if (yPos >= -rowHeight && yPos < this.Height) { DrawItem?.Invoke(i == selected ? DrawItemState.Selected : DrawItemState.Default, graphics, i, GetItemBounds(i)); } } } } else // Draw default items { if (Items != null) { for (int i = 0; i < Items.Count; i++) { int yPos = (i * (rowHeight + rowDistance)) + scrollAmount + rowDistance; if (yPos >= -rowHeight && yPos < this.Height) { OnDrawItem(i == selected ? DrawItemState.Selected : DrawItemState.Default, graphics, i, GetItemBounds(i)); } } } } e.Graphics.DrawImageUnscaled(buffer, Point.Empty); }
/// <summary> /// メモリに読みこんだグラフィックの自由変形描画 /// </summary> /// <param name="x1"></param> /// <param name="y1"></param> /// <param name="x2"></param> /// <param name="y2"></param> /// <param name="x3"></param> /// <param name="y3"></param> /// <param name="x4"></param> /// <param name="y4"></param> /// <param name="GrHandle"></param> /// <returns></returns> private static void DrawModiGraph(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4, int GrHandle, EnumPriority priority, EnumBLEND blend, int blendparam) { DrawItem d = new DrawItem(); d.xy.X = x1; d.xy.Y = y1; d.xy2.X = x2; d.xy2.Y = y2; d.xy3.X = x3; d.xy3.Y = y3; d.xy4.X = x4; d.xy4.Y = y4; d.gh = GrHandle; d.priority = priority; d.blend = blend; d.blendparam = blendparam; d.drawmode = EnumDraw.DrawModiGraph; d.index = lstDrawObject.Count(); lstDrawObject.Add(d); }
public void AssignDrawItemsLayers() { for (int i = 0; i < m_drawItems.Count; i++) { DrawItem drawItem = m_drawItems[i]; for (int j = i + 1; j < m_drawItems.Count; j++) { DrawItem drawItem2 = m_drawItems[j]; if (drawItem.ScissorRectangle.HasValue || drawItem2.ScissorRectangle.HasValue) { drawItem2.Layer = MathUtils.Max(drawItem2.Layer, drawItem.Layer + 1); } else if (TestOverlap(drawItem.Widget, drawItem2.Widget)) { drawItem2.Layer = MathUtils.Max(drawItem2.Layer, drawItem.Layer + 1); } } } m_drawItems.Sort(); }
private async void shuffle(RunningState state) { Interval = new Duration(TimeSpan.FromMilliseconds(600)); this.DrawRunningState = state; while (this.DrawRunningState != RunningState.Stopped) { VisualStateManager.GoToState(this, "Hide", this.DrawRunningState != RunningState.Stopped); await Task.Delay(Interval.TimeSpan); var list = DataModel.DrawData.Instance.DrawItems; if (list.Count > 0) { var next = RandomUtil.Instance.Next(list.Count); LastPickedDrawItem = list[next]; this.NameBlock.Text = LastPickedDrawItem.DisplayName; } else { Stop(); } VisualStateManager.GoToState(this, "Show", this.DrawRunningState != RunningState.Stopped); await Task.Delay(Interval.TimeSpan); if (Interval.TimeSpan.TotalMilliseconds > 200) { Interval = new Duration(Interval.TimeSpan - TimeSpan.FromMilliseconds(100)); } else { RandomUtil.Instance.Reset(); this.DrawRunningState = RunningState.Running; } } }
/// <summary> /// グラフィックの指定矩形部分のみを描画 /// </summary> /// <param name="DestX">画面上の位置</param> /// <param name="DestY"></param> /// <param name="SrcX">グラフィックのどこの部分を描く?(左上座標)</param> /// <param name="SrcY"></param> /// <param name="Width">描画するグラフィックのサイズ</param> /// <param name="Height"></param> /// <param name="GraphHandle"></param> /// <returns></returns> private static void DrawRectGraph(int DestX, int DestY, int SrcX, int SrcY, int Width, int Height, int GrHandle, EnumPriority priority, EnumBLEND blend, int blendparam) { DrawItem d = new DrawItem(); d.xy.X = DestX; d.xy.Y = DestY; d.xy2.X = SrcX; d.xy2.Y = SrcY; d.wh.X = Width; d.wh.Y = Height; d.gh = GrHandle; d.priority = priority; d.blend = blend; d.blendparam = blendparam; d.drawmode = EnumDraw.DrawRectGraph; d.index = lstDrawObject.Count(); lstDrawObject.Add(d); }
private void btnSetSizeToImage_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(txtElementVariable.Text)) { var zBmp = DrawItem.LoadImageFromCache(txtElementVariable.Text); if (null == zBmp) { var zElement = ElementManager.Instance.GetSelectedElement(); if (null != zElement) { var zElementString = LayoutManager.Instance.ActiveDeck.GetStringFromTranslationCache(zElement.name); if (null != zElementString.String) { zBmp = DrawItem.LoadImageFromCache(zElementString.String); } } } if (null != zBmp) { numericElementW.Value = zBmp.Width; numericElementH.Value = zBmp.Height; } } }
private void clearCacheToolStripMenuItem_Click(object sender, EventArgs e) { DrawItem.DumpImages(); DrawItem.DumpOpacityImages(); LayoutManager.Instance.FireLayoutRenderUpdatedEvent(); }
/// <summary> /// Called by the OS when the item must be draw. /// </summary> public virtual void Draw(ref DrawItem drawItem) { }
/// <summary> /// Raises the <see cref="E:DrawItem"/> event. /// </summary> /// <param name="e">The <see cref="DrawStepListItemEventArgs"/> instance containing the event data.</param> protected virtual void OnDrawItem(DrawStepListItemEventArgs e) { DrawItem?.Invoke(this, e); }
public Process(DrawItem drawItem) { this.drawItem = drawItem; }
public void SetGcodeRenderBeans(List <GcodeRenderBean> gcodeRenderBeanList) { if (gcodeRenderBeanList == null || gcodeRenderBeanList.Count == 0) { Debug.LogWarning("gcodeRenderBeanList is empty" + "\n"); return; } _gcodeRenderBeanList = gcodeRenderBeanList; //1.release VectorLine.Destroy(_vectorLineList_types.ToArray()); VectorLine.Destroy(_vectorLineList_topLayer.ToArray()); //types _drawItemList_types.Clear(); _vectorLineList_types.Clear(); _colorsDic_types = null; //top layer _colors_topLayer = GcodeTypeColor.Top_Layer; _active_topLayer = false; _drawItemList_topLayer.Clear(); _vectorLineList_topLayer.Clear(); _vectorsList_layer.Clear(); //2.separate gcodeRenderPoints by 16383 //per vectorLine is assigned 16383 Vector3 for (int i = 0; i < Mathf.CeilToInt(_gcodeRenderBeanList.Count / (float)_pointCountLimit); i++) { List <GcodeRenderBean> gcodeRenderPointBuffer_line = null; List <Vector3> vectorsItem_line = new List <Vector3> (); if (_gcodeRenderBeanList.Count >= i * _pointCountLimit + _pointCountLimit) { gcodeRenderPointBuffer_line = _gcodeRenderBeanList.GetRange(i * _pointCountLimit, _pointCountLimit); } else { gcodeRenderPointBuffer_line = _gcodeRenderBeanList.GetRange(i * _pointCountLimit, _gcodeRenderBeanList.Count - i * _pointCountLimit); } foreach (GcodeRenderBean gcodePoint in gcodeRenderPointBuffer_line) { //Attention : switch y <====> z Vector3 vec3 = new Vector3(gcodePoint.vector3.x, gcodePoint.vector3.z, gcodePoint.vector3.y); vectorsItem_line.Add(vec3); } VectorLine vectorLine = new VectorLine("line_" + i, vectorsItem_line, null, _lineWidth, LineType.Continuous, Joins.None); vectorLine.active = true; DrawItem drawItem = new DrawItem(); drawItem.vectorLine = vectorLine; drawItem.gcodeRenderPointList = gcodeRenderPointBuffer_line; _drawItemList_types.Add(drawItem); } foreach (DrawItem item in _drawItemList_types) { _vectorLineList_types.Add(item.vectorLine); } //3.separate all Vector3 by layer index //if the point count of 1 layer is less than 16383, draw them by 1 vectorLine instance //else draw them by more than 1 vectorLine instance List <GcodeRenderBean> gcodeRenderPointBuffer_layer = new List <GcodeRenderBean> (); gcodeRenderPointBuffer_layer.Add(_gcodeRenderBeanList [0]); List <Vector3> vectorsItem_layer = new List <Vector3> (); for (int i = 1; i < _gcodeRenderBeanList.Count; i++) { GcodeRenderBean pointNew = _gcodeRenderBeanList [i]; GcodeRenderBean pointLast = gcodeRenderPointBuffer_layer [gcodeRenderPointBuffer_layer.Count - 1]; if (pointNew.layerIndex == pointLast.layerIndex) { gcodeRenderPointBuffer_layer.Add(pointNew); } else { foreach (GcodeRenderBean temp in gcodeRenderPointBuffer_layer) { //Attention : switch y <====> z Vector3 vec3 = new Vector3(temp.vector3.x, temp.vector3.z, temp.vector3.y); vectorsItem_layer.Add(vec3); } //vectorsItem_layer will clear, so need deep copy _vectorsList_layer.Add(new List <Vector3> (vectorsItem_layer)); vectorsItem_layer.Clear(); gcodeRenderPointBuffer_layer.Clear(); gcodeRenderPointBuffer_layer.Add(pointNew); } } //attention : there still are points in buff foreach (GcodeRenderBean gcodePoint in gcodeRenderPointBuffer_layer) { //Attention : switch y <====> z Vector3 vec3 = new Vector3(gcodePoint.vector3.x, gcodePoint.vector3.z, gcodePoint.vector3.y); vectorsItem_layer.Add(vec3); } //vectorsItem_layer will clear, so need deep copy _vectorsList_layer.Add(new List <Vector3> (vectorsItem_layer)); vectorsItem_layer.Clear(); gcodeRenderPointBuffer_layer.Clear(); int pointCountMax_layer = 0; foreach (List <Vector3> list in _vectorsList_layer) { pointCountMax_layer = list.Count > pointCountMax_layer ? list.Count : pointCountMax_layer; } for (int i = 0; i < Mathf.CeilToInt(pointCountMax_layer / (float)_pointCountLimit); i++) { VectorLine vectorLine = new VectorLine("line_top_" + i, new List <Vector3>(), null, _lineWidth, LineType.Continuous, Joins.None); vectorLine.active = true; _vectorLineList_topLayer.Add(vectorLine); } }
public void SetColor_types(Dictionary <GcodeType, Color32> colorsDic) { if (colorsDic.Count == 0) { return; } _colorsDic_types = colorsDic; //change colors Color32 color_WALL_INNER = colorsDic [GcodeType.WALL_INNER]; Color32 color_WALL_OUTER = colorsDic [GcodeType.WALL_OUTER]; Color32 color_SKIN = colorsDic [GcodeType.SKIN]; Color32 color_SKIRT = colorsDic [GcodeType.SKIRT]; Color32 color_SUPPORT = colorsDic [GcodeType.SUPPORT]; Color32 color_FILL = colorsDic [GcodeType.FILL]; Color32 color_UNKNOWN = colorsDic [GcodeType.UNKNOWN]; Color32 color_Travel = colorsDic [GcodeType.Travel]; for (int i = 0; i < _drawItemList_types.Count; i++) { DrawItem item = _drawItemList_types [i]; item.colorList.Clear(); for (int k = 0; k < item.gcodeRenderPointList.Count; k++) { GcodeRenderBean point = item.gcodeRenderPointList [k]; Color32 color32 = GcodeTypeColor.UNKNOWN; switch (point.type) { case GcodeType.WALL_INNER: color32 = color_WALL_INNER; break; case GcodeType.WALL_OUTER: color32 = color_WALL_OUTER; break; case GcodeType.SKIN: color32 = color_SKIN; break; case GcodeType.SKIRT: color32 = color_SKIRT; break; case GcodeType.SUPPORT: color32 = color_SUPPORT; break; case GcodeType.FILL: color32 = color_FILL; break; case GcodeType.UNKNOWN: color32 = color_UNKNOWN; break; case GcodeType.Travel: color32 = color_Travel; break; } item.colorList.Add(color32); } item.colorList.RemoveAt(0); item.vectorLine.SetColors(item.colorList); } }
public static void HandleShapeRender(Graphics zGraphics, string sShapeInfo, ProjectLayoutElement zElement) { if (s_regexShapes.IsMatch(sShapeInfo)) { var zMatch = s_regexShapes.Match(sShapeInfo); ShapeInfo zInfo = null; var bParse = false; var arraySplit = zMatch.Groups[3].ToString().Split(new char[] { ';' }); var sShapeName = arraySplit[(int)AbstractShape.ShapeInformationIndex.Name]; AbstractShape zShape; if (s_dictionaryShapeByName.TryGetValue(sShapeName, out zShape)) { // allow any shapes with extended settings to read in the values (ShapeInformationIndex extension) zShape.InitializeItem(sShapeInfo); if ((int)AbstractShape.ShapeInformationIndex.BasicShapeInformation < arraySplit.Length) { int nThickness; var nOverrideWidth = int.MinValue; var nOverrideHeight = int.MinValue; bParse = int.TryParse(arraySplit[(int)AbstractShape.ShapeInformationIndex.Thickness], out nThickness); if (!arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideWidth].Equals(AbstractShape.NO_SIZE_OVERRIDE)) { bParse &= int.TryParse(arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideWidth], out nOverrideWidth); } if (!arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideHeight].Equals(AbstractShape.NO_SIZE_OVERRIDE)) { bParse &= int.TryParse(arraySplit[(int)AbstractShape.ShapeInformationIndex.OverrideHeight], out nOverrideHeight); } zInfo = new ShapeInfo(nThickness, nOverrideWidth, nOverrideHeight, arraySplit); } if (!bParse) { return; // invalid (error?) } var previousTransform = zGraphics.Transform; var zPath = new GraphicsPath(); var targetRect = new Rectangle(0, 0, zElement.width - 1, zElement.height - 1); // internally int.MinValue indicates no override if (int.MinValue != zInfo.OverrideWidth || int.MinValue != zInfo.OverrideHeight) { var nOverrideWidth = int.MinValue == zInfo.OverrideWidth ? zElement.width : zInfo.OverrideWidth; var nOverrideHeight = int.MinValue == zInfo.OverrideHeight ? zElement.height : zInfo.OverrideHeight; if (0 == nOverrideWidth || 0 == nOverrideHeight) { // nothing to draw return; } targetRect = GetZeroRectangle(nOverrideWidth, nOverrideHeight); zGraphics.TranslateTransform(targetRect.X, targetRect.Y); targetRect = new Rectangle(0, 0, Math.Abs(nOverrideWidth), Math.Abs(nOverrideHeight)); } zShape.DrawShape(zPath, targetRect, zInfo); DrawItem.DrawOutline(zElement, zGraphics, zPath); if (0 == zInfo.Thickness) { var zShapeBrush = 255 != zElement.opacity ? new SolidBrush(Color.FromArgb(zElement.opacity, zElement.GetElementColor())) : new SolidBrush(zElement.GetElementColor()); zGraphics.FillPath(zShapeBrush, zPath); } else { var zShapePen = 255 != zElement.opacity ? new Pen(Color.FromArgb(zElement.opacity, zElement.GetElementColor()), zInfo.Thickness) : new Pen(zElement.GetElementColor(), zInfo.Thickness); zGraphics.DrawPath(zShapePen, zPath); } zGraphics.Transform = previousTransform; } } }
private void OnDrawItem(object sender, DrawItemEventArgs e) { DrawItem?.Invoke(this, e); }