void DrawChangeSymbol(Cairo.Context ctx, double x, int width, BlockInfo block) { if (!IsChangeBlock(block.Type)) { return; } Gdk.Color color = block.Type == BlockType.Added ? baseAddColor : baseRemoveColor; int ssize = 8; int barSize = 3; if (ssize - 2 > lineHeight) { ssize = lineHeight - 2; } if (ssize <= 0) { return; } double inSize = (ssize / 2) - (barSize / 2); double py = block.YStart + ((block.YEnd - block.YStart) / 2 - ssize / 2) + 0.5; double px = x + (LeftPaddingBlock / 2) - (ssize / 2) + 0.5; if (block.Type == BlockType.Added) { ctx.MoveTo(px + inSize, py); ctx.RelLineTo(barSize, 0); ctx.RelLineTo(0, inSize); ctx.RelLineTo(inSize, 0); ctx.RelLineTo(0, barSize); ctx.RelLineTo(-inSize, 0); ctx.RelLineTo(0, inSize); ctx.RelLineTo(-barSize, 0); ctx.RelLineTo(0, -inSize); ctx.RelLineTo(-inSize, 0); ctx.RelLineTo(0, -barSize); ctx.RelLineTo(inSize, 0); ctx.RelLineTo(0, -inSize); ctx.ClosePath(); } else { ctx.MoveTo(px, py + inSize); ctx.RelLineTo(ssize, 0); ctx.RelLineTo(0, barSize); ctx.RelLineTo(-ssize, 0); ctx.RelLineTo(0, -barSize); ctx.ClosePath(); } ctx.Color = color.ToCairoColor(); ctx.FillPreserve(); ctx.Color = color.AddLight(-0.2).ToCairoColor();; ctx.LineWidth = 1; ctx.Stroke(); }
public ImageCanvas(string fileName, List <BarierPoint> shapeListPoint) { this.fileName = fileName; if (shapeListPoint != null) { this.shapeListPoint = shapeListPoint; } else { shapeListPoint = new List <BarierPoint>(); } if (MainClass.Settings.ImageEditors == null) { MainClass.Settings.ImageEditors = new Option.Settings.ImageEditorSetting(); MainClass.Settings.ImageEditors.LineWidth = 3; MainClass.Settings.ImageEditors.PointWidth = 5; MainClass.Settings.ImageEditors.LineColor = new Option.Settings.BackgroundColors(10, 10, 255, 32767); MainClass.Settings.ImageEditors.PointColor = new Option.Settings.BackgroundColors(10, 10, 255, 32767); MainClass.Settings.ImageEditors.SelectPointColor = new Option.Settings.BackgroundColors(255, 10, 10, 32767); } lineWitdth = MainClass.Settings.ImageEditors.LineWidth; pointWidth = MainClass.Settings.ImageEditors.PointWidth; Gdk.Color gdkLineColor = new Gdk.Color(MainClass.Settings.ImageEditors.LineColor.Red, MainClass.Settings.ImageEditors.LineColor.Green, MainClass.Settings.ImageEditors.LineColor.Blue); Gdk.Color gdkPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.PointColor.Red, MainClass.Settings.ImageEditors.PointColor.Green, MainClass.Settings.ImageEditors.PointColor.Blue); Gdk.Color gdkSelPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.SelectPointColor.Red, MainClass.Settings.ImageEditors.SelectPointColor.Green, MainClass.Settings.ImageEditors.SelectPointColor.Blue); colorLine = gdkLineColor.ToCairoColor(MainClass.Settings.ImageEditors.LineColor.Alpha); colorPoint = gdkPointColor.ToCairoColor(MainClass.Settings.ImageEditors.PointColor.Alpha); colorSelectPoint = gdkSelPointColor.ToCairoColor(MainClass.Settings.ImageEditors.SelectPointColor.Alpha); Gdk.Pixbuf bg; try{ using (var fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open)) bg = new Gdk.Pixbuf(fs); bg = bg.ApplyEmbeddedOrientation(); this.HeightImage = bg.Height; this.WidthImage = bg.Width; }catch (Exception ex) { Tool.Logger.Error(ex.Message, null); } }
public ImageCanvas(string fileName, List<BarierPoint> shapeListPoint) { this.fileName = fileName; if (shapeListPoint != null) this.shapeListPoint = shapeListPoint; else shapeListPoint = new List<BarierPoint>(); if(MainClass.Settings.ImageEditors == null){ MainClass.Settings.ImageEditors = new Option.Settings.ImageEditorSetting(); MainClass.Settings.ImageEditors.LineWidth = 3; MainClass.Settings.ImageEditors.PointWidth = 5; MainClass.Settings.ImageEditors.LineColor = new Option.Settings.BackgroundColors(10,10,255,32767); MainClass.Settings.ImageEditors.PointColor = new Option.Settings.BackgroundColors(10,10,255,32767); MainClass.Settings.ImageEditors.SelectPointColor = new Option.Settings.BackgroundColors(255,10,10,32767); } lineWitdth = MainClass.Settings.ImageEditors.LineWidth; pointWidth = MainClass.Settings.ImageEditors.PointWidth; Gdk.Color gdkLineColor = new Gdk.Color(MainClass.Settings.ImageEditors.LineColor.Red, MainClass.Settings.ImageEditors.LineColor.Green,MainClass.Settings.ImageEditors.LineColor.Blue); Gdk.Color gdkPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.PointColor.Red, MainClass.Settings.ImageEditors.PointColor.Green,MainClass.Settings.ImageEditors.PointColor.Blue); Gdk.Color gdkSelPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.SelectPointColor.Red, MainClass.Settings.ImageEditors.SelectPointColor.Green,MainClass.Settings.ImageEditors.SelectPointColor.Blue); colorLine = gdkLineColor.ToCairoColor(MainClass.Settings.ImageEditors.LineColor.Alpha); colorPoint = gdkPointColor.ToCairoColor(MainClass.Settings.ImageEditors.PointColor.Alpha); colorSelectPoint = gdkSelPointColor.ToCairoColor(MainClass.Settings.ImageEditors.SelectPointColor.Alpha); Gdk.Pixbuf bg; try{ using (var fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open)) bg = new Gdk.Pixbuf(fs); bg = bg.ApplyEmbeddedOrientation(); this.HeightImage = bg.Height; this.WidthImage= bg.Width; }catch(Exception ex){ Tool.Logger.Error(ex.Message,null); } }
public void RefreshSetting() { lineWitdth = MainClass.Settings.ImageEditors.LineWidth; pointWidth = MainClass.Settings.ImageEditors.PointWidth; Gdk.Color gdkLineColor = new Gdk.Color(MainClass.Settings.ImageEditors.LineColor.Red, MainClass.Settings.ImageEditors.LineColor.Green, MainClass.Settings.ImageEditors.LineColor.Blue); Gdk.Color gdkPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.PointColor.Red, MainClass.Settings.ImageEditors.PointColor.Green, MainClass.Settings.ImageEditors.PointColor.Blue); Gdk.Color gdkSelPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.SelectPointColor.Red, MainClass.Settings.ImageEditors.SelectPointColor.Green, MainClass.Settings.ImageEditors.SelectPointColor.Blue); colorLine = gdkLineColor.ToCairoColor(MainClass.Settings.ImageEditors.LineColor.Alpha); colorPoint = gdkPointColor.ToCairoColor(MainClass.Settings.ImageEditors.PointColor.Alpha); colorSelectPoint = gdkSelPointColor.ToCairoColor(MainClass.Settings.ImageEditors.SelectPointColor.Alpha); try{ GdkWindow.InvalidateRect(new Gdk.Rectangle(drawOffsetX, drawOffsetY, width, height), false); } catch {} }
public void RefreshSetting() { lineWitdth = MainClass.Settings.ImageEditors.LineWidth; pointWidth = MainClass.Settings.ImageEditors.PointWidth; Gdk.Color gdkLineColor = new Gdk.Color(MainClass.Settings.ImageEditors.LineColor.Red, MainClass.Settings.ImageEditors.LineColor.Green,MainClass.Settings.ImageEditors.LineColor.Blue); Gdk.Color gdkPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.PointColor.Red, MainClass.Settings.ImageEditors.PointColor.Green,MainClass.Settings.ImageEditors.PointColor.Blue); Gdk.Color gdkSelPointColor = new Gdk.Color(MainClass.Settings.ImageEditors.SelectPointColor.Red, MainClass.Settings.ImageEditors.SelectPointColor.Green,MainClass.Settings.ImageEditors.SelectPointColor.Blue); colorLine = gdkLineColor.ToCairoColor(MainClass.Settings.ImageEditors.LineColor.Alpha); colorPoint = gdkPointColor.ToCairoColor(MainClass.Settings.ImageEditors.PointColor.Alpha); colorSelectPoint = gdkSelPointColor.ToCairoColor(MainClass.Settings.ImageEditors.SelectPointColor.Alpha); try{ GdkWindow.InvalidateRect(new Gdk.Rectangle(drawOffsetX, drawOffsetY, width, height), false); } catch{} }