|
@@ -42,24 +42,34 @@ namespace PixiEditorDotNetCore3.Models.Tools
|
|
|
private void LoopTimer_Elapsed(object sender, ElapsedEventArgs e)
|
|
|
{
|
|
|
Application.Current.Dispatcher.Invoke(() =>
|
|
|
- {
|
|
|
- if(_clonedBitmap != null)
|
|
|
+ {
|
|
|
+ _layer.LayerBitmap.Lock();
|
|
|
+
|
|
|
+ if (_clonedBitmap != null)
|
|
|
{
|
|
|
- _layer.LayerBitmap.Clear();
|
|
|
- _layer.LayerBitmap.Blit(new Rect(new Size(_layer.Width, _layer.Height)), _clonedBitmap, new Rect(new Size(_layer.Width, _layer.Height)), WriteableBitmapExtensions.BlendMode.Additive);
|
|
|
+ RestoreLastBitmap();
|
|
|
}
|
|
|
+
|
|
|
BitmapPixelChanges changes = SelectedTool.Use(_layer, _startCoordinates, _color, _toolSzie);
|
|
|
|
|
|
if (!SelectedTool.ExecutesItself)
|
|
|
{
|
|
|
_layer.ApplyPixels(changes, changes.PixelsColor);
|
|
|
}
|
|
|
+ _layer.LayerBitmap.Unlock();
|
|
|
+
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ private void RestoreLastBitmap()
|
|
|
+ {
|
|
|
+ _layer.LayerBitmap.Clear();
|
|
|
+ _layer.LayerBitmap.Blit(new Rect(new Size(_layer.Width, _layer.Height)), _clonedBitmap, new Rect(new Size(_layer.Width, _layer.Height)), WriteableBitmapExtensions.BlendMode.Additive);
|
|
|
+ }
|
|
|
+
|
|
|
public void SetTool(ToolType tool)
|
|
|
{
|
|
|
- SelectedTool = Tools.Find(x => x.ToolType == tool);
|
|
|
+ SelectedTool = Tools.Find(x => x.ToolType == tool);
|
|
|
}
|
|
|
|
|
|
public void StopExectuingTool()
|
|
@@ -79,7 +89,7 @@ namespace PixiEditorDotNetCore3.Models.Tools
|
|
|
{
|
|
|
if (SelectedTool.GetType().BaseType == typeof(ShapeTool))
|
|
|
{
|
|
|
- _clonedBitmap = _layer.LayerBitmap.Clone();
|
|
|
+ _clonedBitmap = _layer.LayerBitmap.Clone();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -97,7 +107,7 @@ namespace PixiEditorDotNetCore3.Models.Tools
|
|
|
if (toolSize < 1)
|
|
|
return;
|
|
|
|
|
|
- if(_toolRecievedData == false || (_toolRecievedData == true && SelectedTool.GetType().BaseType != typeof(ShapeTool)))
|
|
|
+ if (_toolRecievedData == false || (_toolRecievedData == true && SelectedTool.GetType().BaseType != typeof(ShapeTool)))
|
|
|
{
|
|
|
_startCoordinates = startingCoords;
|
|
|
_layer = layer;
|