private void DrawingArea_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { if (sender == null || !(sender is Canvas)) { throw new ArgumentException("expected only Canvas", "sender"); } //Status = "ready"; var canvas = (Canvas)sender; if (!keyIsDown) { return; } switch (tool) { case Tools.Filtering: { ReinitializeMask(); DrawingBrush.Visibility = Visibility.Hidden; } break; case Tools.Line: { double x = e.GetPosition(canvas).X; double y = e.GetPosition(canvas).Y; int startX = (int)currentLineStart.X; int startY = (int)currentLineStart.Y; int endX = (int)x; int endY = (int)y; bitmapArray.CopyArea(bitmapArrayTemp); if (bitmapArrayWithoutLines == null) { bitmapArrayWithoutLines = new FastBitmapArray(bitmapArray); } if (multisamplingForNewLines) { int scaling = 2; bitmapArrayWithoutLines = bitmapArrayWithoutLines.ScaleUp(scaling); var l = new Line(scaling * startX, scaling * startY, scaling * endX, scaling * endY, lineColor.ScR, lineColor.ScG, lineColor.ScB, scaling * (int)lineThickness); bitmapArrayWithoutLines.DrawLine(l); bitmapArrayWithoutLines = bitmapArrayWithoutLines.ScaleDown(scaling); SetBitmapArray(bitmapArrayWithoutLines); } else { var l = new Line(startX, startY, endX, endY, lineColor.ScR, lineColor.ScG, lineColor.ScB, (int)lineThickness); bitmapArray.DrawLine(l); bitmapArray.RefreshBitmap(Mask.Disabled); Lines.Add(l); } bitmapArrayTemp = null; //LineAdd.IsEnabled = true; //LineUpdate.IsEnabled = true; } break; } if (canvas.IsMouseCaptured) { canvas.ReleaseMouseCapture(); } if (keyIsDown) { keyIsDown = false; } }