public void PolygonCmd(ScreanDrawOption option, Point[] points) { // 描画先 var buffers = TargetImages(option); // 描画領域 if (option.DrawOption != ScreanDrawMode.Background) { GUI.IsPictureVisible = true; } using (var pen = GetPen(option)) using (var brush = GetBrush(option)) { foreach (var buffer in buffers) { using (var g = Graphics.FromImage(buffer)) { if (option.FillStyle != FillStyle.VbFSTransparent) { g.FillPolygon(brush, points); } g.DrawPolygon(pen, points); } } } }
public void ArcCmd(ScreanDrawOption option, int x1, int y1, int rad, float start_angle, float end_angle) { // 描画先 var buffers = TargetImages(option); // 描画領域 if (option.DrawOption != ScreanDrawMode.Background) { GUI.IsPictureVisible = true; } using (var pen = GetPen(option)) using (var brush = GetBrush(option)) { foreach (var buffer in buffers) { using (var g = Graphics.FromImage(buffer)) { // GraphicsのインタフェースとSRCのインタフェースで回転方向が逆 if (option.FillStyle != FillStyle.VbFSTransparent) { g.FillPie(brush, GetCircleRect(x1, y1, rad), -start_angle, -(end_angle - start_angle)); } g.DrawArc(pen, GetCircleRect(x1, y1, rad), -start_angle, -(end_angle - start_angle)); } } } }
public void OvalCmd(ScreanDrawOption option, int x1, int y1, int rad, float oval_ratio) { // 描画先 var buffers = TargetImages(option); // 描画領域 if (option.DrawOption != ScreanDrawMode.Background) { GUI.IsPictureVisible = true; } var rect = GetCircleRect(x1, y1, rad, oval_ratio); using (var pen = GetPen(option)) using (var brush = GetBrush(option)) { foreach (var buffer in buffers) { using (var g = Graphics.FromImage(buffer)) { if (option.FillStyle != FillStyle.VbFSTransparent) { g.FillEllipse(brush, rect); } g.DrawEllipse(pen, rect); } } } }
public void BoxCmd(ScreanDrawOption option, int x1, int y1, int x2, int y2) { // 描画先 var buffers = TargetImages(option); // 描画領域 if (option.DrawOption != ScreanDrawMode.Background) { GUI.IsPictureVisible = true; } var w = x2 - x1; var h = y2 - y1; using (var pen = GetPen(option)) using (var brush = GetBrush(option)) { foreach (var buffer in buffers) { using (var g = Graphics.FromImage(buffer)) { if (option.FillStyle != FillStyle.VbFSTransparent) { g.FillRectangle(brush, x1, y1, w, h); } g.DrawRectangle(pen, x1, y1, w, h); } } } }
private IEnumerable <Image> TargetImages(ScreanDrawOption option) { switch (option.DrawOption) { case ScreanDrawMode.Background: return(new Image[] { BackgroundBuffer }); case ScreanDrawMode.Preserve: return(new Image[] { MainBuffer, MainBufferBack }); default: return(new Image[] { MainBuffer }); } }
public void LineCmd(ScreanDrawOption option, int x1, int y1, int x2, int y2) { // 描画先 var buffers = TargetImages(option); // 描画領域 if (option.DrawOption != ScreanDrawMode.Background) { GUI.IsPictureVisible = true; } using (var pen = GetPen(option)) { foreach (var buffer in buffers) { using (var g = Graphics.FromImage(buffer)) { g.DrawLine(pen, x1, y1, x2, y2); } } } }
protected override int ExecInternal() { if (ArgNum < 5) { throw new EventErrorException(this, "Lineコマンドの引数の数が違います"); } var x1 = (GetArgAsLong(2) + Event.BaseX); var y1 = (GetArgAsLong(3) + Event.BaseY); var x2 = (GetArgAsLong(4) + Event.BaseX); var y2 = (GetArgAsLong(5) + Event.BaseY); GUI.SaveScreen(); var dtype = ""; var clr = Event.ObjColor; for (var i = 6; i <= ArgNum; i++) { var opt = GetArgAsString(i); if (Strings.Asc(opt) == 35) // # { if (!ColorExtension.TryFromHexString(opt, out clr)) { throw new EventErrorException(this, "色指定が不正です"); } } else { if (opt != "B" && opt != "BF") { throw new EventErrorException(this, "Lineコマンドに不正なオプション「" + opt + "」が使われています"); } dtype = opt; } } var drawOpt = new ScreanDrawOption(Event, clr); switch (dtype ?? "") { case "B": // Box SRC.GUIScrean.BoxCmd(drawOpt, x1, y1, x2, y2); break; case "BF": // Box Fill drawOpt.FillStyle = FillStyle.VbFSSolid; drawOpt.FillColor = drawOpt.ForeColor; SRC.GUIScrean.BoxCmd(drawOpt, x1, y1, x2, y2); break; default: // Line SRC.GUIScrean.LineCmd(drawOpt, x1, y1, x2, y2); break; } return(EventData.NextID); }
public void CircleCmd(ScreanDrawOption option, int x1, int y1, int rad) { OvalCmd(option, x1, y1, rad, 1f); }
private Brush GetBrush(ScreanDrawOption option) { //TODO FillStyle return(new SolidBrush(option.FillColor)); }
private Pen GetPen(ScreanDrawOption option) { return(new Pen(option.ForeColor, option.DrawWidth)); }