Skip to content

Commit

Permalink
add the last steps
Browse files Browse the repository at this point in the history
  • Loading branch information
LoneWandererProductions committed Dec 8, 2024
1 parent c24d07e commit 56b4e1c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 38 deletions.
4 changes: 2 additions & 2 deletions SlimControls/ToolOptions.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public sealed partial class ToolOptions
public static readonly DependencyProperty SliderValueProperty =
DependencyProperty.Register(
nameof(SliderValue),
typeof(double),
typeof(int),
typeof(ToolOptions),
new PropertyMetadata(1.0)); // Default slider value

Expand Down Expand Up @@ -75,7 +75,7 @@ public string SliderCaption
/// </value>
public double SliderValue
{
get => (double)GetValue(SliderValueProperty);
get => (int)GetValue(SliderValueProperty);
set => SetValue(SliderValueProperty, value);
}
}
Expand Down
42 changes: 18 additions & 24 deletions SlimViews/ImageProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ internal static void ConvertGifAction(List<string> images, string filePath)
/// <param name="btm">The bitmap.</param>
/// <param name="point">The point.</param>
/// <param name="color">The color.</param>
/// <param name="frame">The optional frame.</param>
internal static Bitmap SetPixel(Bitmap btm, Point point, Color color, SelectionFrame frame = null)
/// <param name="radius">The optional radius.</param>
internal static Bitmap SetPixel(Bitmap btm, Point point, Color color, int radius = 1)
{
return Render.SetPixel(btm, point, color);
return Render.SetPixel(btm, point, color, radius);
}

/// <summary>
Expand Down Expand Up @@ -373,27 +373,6 @@ internal static void ExportString(Bitmap bitmap)
Clipboard.SetText(str);
}

/// <summary>
/// Cuts the image.
/// </summary>
/// <param name="frame">The selection frame.</param>
/// <param name="btm">The bitmap.</param>
/// <returns>Changed bitmap or in case of error the original</returns>
internal static Bitmap CutImage(SelectionFrame frame, Bitmap btm)
{
try
{
btm = Render.CutBitmap(btm, frame.X, frame.Y, frame.Height, frame.Width);
}
catch (ArgumentNullException ex)
{
Trace.WriteLine(ex);
_ = MessageBox.Show(ex.ToString(), string.Concat(ViewResources.ErrorMessage, nameof(CutImage)));
}

return btm;
}

/// <summary>
/// Erases part of the image.
/// </summary>
Expand All @@ -415,6 +394,21 @@ internal static Bitmap EraseImage(SelectionFrame frame, Bitmap btm)
return btm;
}

public static Bitmap FillArea(Bitmap btm, SelectionFrame frame, Color color)
{
throw new NotImplementedException();
}

public static Bitmap FillTexture(Bitmap btm, SelectionFrame frame, ImageFilters currentFilter)
{
throw new NotImplementedException();
}

public static Bitmap FillFilter(Bitmap btm, SelectionFrame frame, TextureType currentTexture)
{
throw new NotImplementedException();
}

/// <summary>
/// Rotates the image.
/// </summary>
Expand Down
27 changes: 15 additions & 12 deletions SlimViews/ImageView.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public sealed class ImageView : ViewModelBase
/// <summary>
/// The brush size
/// </summary>
private double _brushSize;
private int _brushSize;

/// <summary>
/// The erase radius
Expand Down Expand Up @@ -435,7 +435,7 @@ public sealed class ImageView : ViewModelBase
/// <summary>
/// The tolerance
/// </summary>
private double _tolerance;
private int _tolerance;

/// <summary>
/// The tool changed command
Expand Down Expand Up @@ -564,7 +564,7 @@ public ImageTools SelectedTool
/// <value>
/// The size of the brush.
/// </value>
public double BrushSize
public int BrushSize
{
get => _brushSize;
set => SetProperty(ref _brushSize, value, nameof(BrushSize));
Expand All @@ -588,7 +588,7 @@ public double EraseRadius
/// <value>
/// The tolerance.
/// </value>
public double Tolerance
public int Tolerance
{
get => _tolerance;
set => SetProperty(ref _tolerance, value, nameof(Tolerance));
Expand Down Expand Up @@ -1383,9 +1383,6 @@ private void ThumbImageClickedAction(ImageEventArgs obj)
/// <param name="wPoint">The w point.</param>
private void SelectedPointAction(Point wPoint)
{
if (ImageZoomTool != ImageZoomTools.Trace)
return;

var point = new System.Drawing.Point((int)wPoint.X, (int)wPoint.Y);

switch (ToolCode)
Expand All @@ -1395,22 +1392,21 @@ private void SelectedPointAction(Point wPoint)

var color = Color.GetDrawingColor();

Btm = ImageProcessor.SetPixel(Btm, point, color);
Btm = ImageProcessor.SetPixel(Btm, point, color, BrushSize);

Bmp = Btm.ToBitmapImage();
return;

case EnumTools.ColorSelect:
Color = ImageProcessor.GetPixel(Btm, point);
Color = ImageProcessor.GetPixel(Btm, point, Tolerance);
Picker.SetColors(Color.R, Color.G, Color.B, Color.A);
Color = Picker.Colors;
return;
case EnumTools.Move:
break;
case EnumTools.Erase:
case EnumTools.SolidColor:
case EnumTools.Filter:
break;
default:
throw new ArgumentOutOfRangeException();
}
}

Expand All @@ -1435,10 +1431,17 @@ private void SelectedFrameAction(SelectionFrame frame)
case EnumTools.Move:
break;
case EnumTools.SolidColor:
if (Color == null) return;

var color = Color.GetDrawingColor();

Btm = ImageProcessor.FillArea(Btm, frame, color);
break;
case EnumTools.Texture:
Btm = ImageProcessor.FillTexture(Btm, frame, CurrentFilter);
break;
case EnumTools.Filter:
Btm = ImageProcessor.FillFilter(Btm, frame, CurrentTexture);
break;
default:
throw new ArgumentOutOfRangeException();
Expand Down

0 comments on commit 56b4e1c

Please sign in to comment.