private int CalculateCompletePercent() { int remainingPixels = AreaToCut.Count((color, point) => color.A != 0); double cutPixels = PixelsToCut - remainingPixels; double percent = (cutPixels / PixelsToCut) * 100; return((int)Math.Round(percent, 0)); }
public void Dispose() { IsDisposed = true; DisposePropertyChangedEvent(); EditorThread.Abort(); EditActions.Dispose(); Hair.Dispose(); AreaToCut.Dispose(); FailedCuts.Dispose(); }
public void Cut(IEnumerable <Point> points) { EditActions.Add(() => { points = points.Where(point => { bool isOutOfBounds = point.X < 0 || point.X >= Hair.Width || point.Y < 0 || point.Y >= Hair.Height; return(!isOutOfBounds && Hair.GetPixel(point).A != 0); }).ToList(); if (points.Count() == 0) { return; } IEnumerable <Point> pointsOutsideArea = points.Where(point => AreaToCut.GetPixel(point).A == 0).ToList(); HairNeedsRender = true; AreaToCutNeedsRender = true; Hair.Lock(); AreaToCut.Lock(); foreach (var point in points) { Hair.ModifyImage(point, Color.FromArgb(0, 0, 0, 0)); AreaToCut.ModifyImage(point, Color.FromArgb(0, 0, 0, 0)); } Hair.Unlock(); AreaToCut.Unlock(); if (pointsOutsideArea.Count() == 0) { return; } FailedCutsNeedsRender = true; FailedCuts.Lock(); foreach (var point in pointsOutsideArea) { FailedCuts.ModifyImage(point, Color.FromArgb(200, 255, 0, 0)); } FailedCuts.Unlock(); }); }