1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
|
string flowImage; public string FlowImage { get { return flowImage; } set { SetProperty(ref flowImage, value); } }
void drawFlowImage(List<ZLTASKSTEP> stepLst, int curStep) { var imageInfo = new SKImageInfo( width: stepLst.Count * L + L / 2, height: L * 10 / 9, colorType: SKColorType.Rgba8888, alphaType: SKAlphaType.Premul); var surface = SKSurface.Create(imageInfo); var canvas = surface.Canvas; SKColor sKColor_Done = new SKColor(140, 182, 40); SKColor sKColor_Doing = new SKColor(50, 130, 170); SKColor sKColor_NotDone = new SKColor(192, 192, 192);
for (int i = 0; i < stepLst.Count; i++) { SKColor sKColor_Cur; if (stepLst[i].F_STEP_NUM == curStep) sKColor_Cur = sKColor_Doing; else sKColor_Cur = stepLst[i].F_STEP_NUM < curStep ? sKColor_Done : sKColor_NotDone; SKPaint sKPaint_Cur_Poly = new SKPaint() { Color = sKColor_Cur, IsAntialias = true, Style = SKPaintStyle.Fill }; SKPaint sKPaint_Cur_Line = new SKPaint() { Color = new SKColor(255, 255, 255), StrokeWidth = 3, IsAntialias = true, Style = SKPaintStyle.Stroke }; SKPoint[] sKPoints_Cur = getGeomPnts(i + 1); SKPath sKPath_Cur_Poly = new SKPath(); sKPath_Cur_Poly.AddPoly(sKPoints_Cur); SKPath sKPath_Cur_Line = new SKPath(); sKPath_Cur_Line.AddPoly(sKPoints_Cur); canvas.DrawPath(sKPath_Cur_Poly, sKPaint_Cur_Poly); canvas.DrawPath(sKPath_Cur_Line, sKPaint_Cur_Line); } for (int i = 0; i < stepLst.Count; i++) { SKPaint sKPaint_Cur_Text = new SKPaint() { TextSize = 45.0f, IsAntialias = true, Color = new SKColor(255, 255, 255), TextAlign = SKTextAlign.Center, Style = SKPaintStyle.Fill, TextEncoding = SKTextEncoding.Utf8, Typeface = SKTypeface.FromFamilyName("宋体"), FakeBoldText= true }; float x = L * (3 / 2 + i)-10; float y = 180; canvas.DrawText(stepLst[i].F_STEP_NAME, x, y, sKPaint_Cur_Text); }
using (SKImage image = surface.Snapshot()) using (SKData data = image.Encode()) { try {
if (!Directory.Exists(Config.InitlizeConfig.FlowImgTempPath)) Directory.CreateDirectory(Config.InitlizeConfig.FlowImgTempPath); string tempFlowImgFilePath = Config.InitlizeConfig.FlowImgTempPath + Guid.NewGuid() + ".png"; using (var stream = File.Create(tempFlowImgFilePath)) { stream.Write(data.ToArray(), 0, data.ToArray().Length); } if (File.Exists(tempFlowImgFilePath)) FlowImage = tempFlowImgFilePath; } catch(Exception ex) { MessageDialogHelper.ShowErrorDialogOK(ex.Message); } } }
SKPoint[] getGeomPnts(int x) { return new SKPoint[] { new SKPoint(0 + L * (x - 1), 0), new SKPoint(L + L * (x - 1), 0), new SKPoint(L * 3 / 2 + L * (x - 1), L*10/9/2), new SKPoint(L + L * (x - 1), L*10/9), new SKPoint(0 + L * (x - 1), L*10/9), new SKPoint(L/2 * (x - 1 == 0 ? 0 : 1) + L * (x - 1), L*10/9/2), new SKPoint(0 + L * (x - 1), 0) }; }
|