Skip to content

Commit 7bef94f

Browse files
Add RegionSelectorSettings and persist BrushColor
Co-authored-by: toniolo.luca <toniolo.luca@outlook.com>
1 parent 3f30565 commit 7bef94f

3 files changed

Lines changed: 32 additions & 2 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Drawing;
2+
3+
namespace Captura
4+
{
5+
public class RegionSelectorSettings : PropertyStore
6+
{
7+
public Color BrushColor
8+
{
9+
get => Get(Color.FromArgb(27, 27, 27));
10+
set => Set(value);
11+
}
12+
}
13+
}

src/Captura.Core/Settings/Settings.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ public bool Save()
115115

116116
public WindowsSettings WindowsSettings { get; }
117117

118+
public RegionSelectorSettings RegionSelector { get; } = new RegionSelectorSettings();
119+
118120
public int PreStartCountdown
119121
{
120122
get => Get(0);

src/Captura/ViewModels/RegionSelectorViewModel.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ namespace Captura.ViewModels
1414
// ReSharper disable once ClassNeverInstantiated.Global
1515
public class RegionSelectorViewModel : NotifyPropertyChanged
1616
{
17+
readonly Settings _settings;
18+
1719
int _left = 50,
1820
_top = 50,
1921
_width = 500,
@@ -25,8 +27,21 @@ public class RegionSelectorViewModel : NotifyPropertyChanged
2527

2628
public const int BorderSize = 3;
2729

28-
public RegionSelectorViewModel()
30+
public RegionSelectorViewModel(Settings Settings)
2931
{
32+
_settings = Settings;
33+
34+
// Initialize BrushColor from settings
35+
var savedColor = _settings.RegionSelector.BrushColor;
36+
BrushColor = new ReactiveProperty<Color>(Color.FromRgb(savedColor.R, savedColor.G, savedColor.B));
37+
38+
// Subscribe to BrushColor changes to save to settings
39+
BrushColor.Subscribe(color =>
40+
{
41+
var drawingColor = System.Drawing.Color.FromArgb(color.R, color.G, color.B);
42+
_settings.RegionSelector.BrushColor = drawingColor;
43+
});
44+
3045
MoveLeftCommand = new ReactiveCommand()
3146
.WithSubscribe(() => Left -= KeyMoveDelta);
3247
MoveRightCommand = new ReactiveCommand()
@@ -58,7 +73,7 @@ public RegionSelectorViewModel()
5873

5974
public IReactiveProperty<int> BrushSize { get; } = new ReactiveProperty<int>(10);
6075

61-
public IReactiveProperty<Color> BrushColor { get; } = new ReactiveProperty<Color>(Color.FromRgb(27, 27, 27));
76+
public IReactiveProperty<Color> BrushColor { get; }
6277

6378
public int Left
6479
{

0 commit comments

Comments
 (0)