From 9ca090513a99f5663ee524be41f7671d879d6d97 Mon Sep 17 00:00:00 2001
From: FaithBeam <32502411+FaithBeam@users.noreply.github.com>
Date: Fri, 6 Dec 2024 06:51:56 -0500
Subject: [PATCH 01/39] wip
---
.../Repositories/ButtonMappingRepository.cs | 2 +-
.../Repositories/ProfileRepository.cs | 2 +-
.../Repositories/SettingRepository.cs | 2 +-
.../Repositories/ThemeRepository.cs | 2 +-
.../GlobalSettingsDialogViewModel.cs | 1 -
.../YMouseButtonControl.Core.csproj | 19 +-
.../Context/YMouseButtonControlDbContext.cs | 219 +++++++++---------
.../Queries/BaseQueries.cs | 21 --
.../Queries/ButtonMappingQueries.cs | 26 ---
.../Queries/ProfileQueries.cs | 27 ---
.../Queries/SettingQueries.cs | 20 --
.../Queries/ThemeQueries.cs | 19 --
...YMouseButtonControl.Infrastructure.csproj} | 6 +-
.../Models/ButtonMapping.cs | 2 +-
.../Models/Profile.cs | 4 +-
.../Models/Setting.cs | 2 +-
.../Models/SimulatedKeystrokeType.cs | 2 +-
.../Models/Theme.cs | 2 +-
.../YMouseButtonControl.Domain.csproj | 9 +
YMouseButtonControl.sln | 14 +-
YMouseButtonControl/App.axaml.cs | 2 +-
.../YMouseButtonControl.csproj | 1 -
22 files changed, 162 insertions(+), 242 deletions(-)
delete mode 100644 YMouseButtonControl.DataAccess/Queries/BaseQueries.cs
delete mode 100644 YMouseButtonControl.DataAccess/Queries/ButtonMappingQueries.cs
delete mode 100644 YMouseButtonControl.DataAccess/Queries/ProfileQueries.cs
delete mode 100644 YMouseButtonControl.DataAccess/Queries/SettingQueries.cs
delete mode 100644 YMouseButtonControl.DataAccess/Queries/ThemeQueries.cs
rename YMouseButtonControl.DataAccess/{YMouseButtonControl.DataAccess.csproj => YMouseButtonControl.Infrastructure.csproj} (65%)
rename {YMouseButtonControl.DataAccess => YMouseButtonControl.Domain}/Models/ButtonMapping.cs (95%)
rename {YMouseButtonControl.DataAccess => YMouseButtonControl.Domain}/Models/Profile.cs (80%)
rename {YMouseButtonControl.DataAccess => YMouseButtonControl.Domain}/Models/Setting.cs (89%)
rename {YMouseButtonControl.DataAccess => YMouseButtonControl.Domain}/Models/SimulatedKeystrokeType.cs (87%)
rename {YMouseButtonControl.DataAccess => YMouseButtonControl.Domain}/Models/Theme.cs (79%)
create mode 100644 YMouseButtonControl.Domain/YMouseButtonControl.Domain.csproj
diff --git a/YMouseButtonControl.Core/Repositories/ButtonMappingRepository.cs b/YMouseButtonControl.Core/Repositories/ButtonMappingRepository.cs
index f9db682..154c1fe 100644
--- a/YMouseButtonControl.Core/Repositories/ButtonMappingRepository.cs
+++ b/YMouseButtonControl.Core/Repositories/ButtonMappingRepository.cs
@@ -5,9 +5,9 @@
using Dapper;
using YMouseButtonControl.Core.Mappings;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Context;
using YMouseButtonControl.DataAccess.Models;
using YMouseButtonControl.DataAccess.Queries;
+using YMouseButtonControl.Infrastructure.Context;
namespace YMouseButtonControl.Core.Repositories;
diff --git a/YMouseButtonControl.Core/Repositories/ProfileRepository.cs b/YMouseButtonControl.Core/Repositories/ProfileRepository.cs
index b1c04ac..3726ff1 100644
--- a/YMouseButtonControl.Core/Repositories/ProfileRepository.cs
+++ b/YMouseButtonControl.Core/Repositories/ProfileRepository.cs
@@ -5,9 +5,9 @@
using Dapper;
using YMouseButtonControl.Core.Mappings;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Context;
using YMouseButtonControl.DataAccess.Models;
using YMouseButtonControl.DataAccess.Queries;
+using YMouseButtonControl.Infrastructure.Context;
namespace YMouseButtonControl.Core.Repositories;
diff --git a/YMouseButtonControl.Core/Repositories/SettingRepository.cs b/YMouseButtonControl.Core/Repositories/SettingRepository.cs
index 7c42ed2..626de1d 100644
--- a/YMouseButtonControl.Core/Repositories/SettingRepository.cs
+++ b/YMouseButtonControl.Core/Repositories/SettingRepository.cs
@@ -6,9 +6,9 @@
using Dapper;
using YMouseButtonControl.Core.Mappings;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Context;
using YMouseButtonControl.DataAccess.Models;
using YMouseButtonControl.DataAccess.Queries;
+using YMouseButtonControl.Infrastructure.Context;
using static Dapper.SqlMapper;
namespace YMouseButtonControl.Core.Repositories;
diff --git a/YMouseButtonControl.Core/Repositories/ThemeRepository.cs b/YMouseButtonControl.Core/Repositories/ThemeRepository.cs
index e34083a..a5554ef 100644
--- a/YMouseButtonControl.Core/Repositories/ThemeRepository.cs
+++ b/YMouseButtonControl.Core/Repositories/ThemeRepository.cs
@@ -6,9 +6,9 @@
using Dapper;
using YMouseButtonControl.Core.Mappings;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Context;
using YMouseButtonControl.DataAccess.Models;
using YMouseButtonControl.DataAccess.Queries;
+using YMouseButtonControl.Infrastructure.Context;
namespace YMouseButtonControl.Core.Repositories;
diff --git a/YMouseButtonControl.Core/ViewModels/MainWindow/GlobalSettingsDialogViewModel.cs b/YMouseButtonControl.Core/ViewModels/MainWindow/GlobalSettingsDialogViewModel.cs
index 0653252..8ab7720 100644
--- a/YMouseButtonControl.Core/ViewModels/MainWindow/GlobalSettingsDialogViewModel.cs
+++ b/YMouseButtonControl.Core/ViewModels/MainWindow/GlobalSettingsDialogViewModel.cs
@@ -10,7 +10,6 @@
using YMouseButtonControl.Core.Services.StartMenuInstaller;
using YMouseButtonControl.Core.Services.Theme;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
namespace YMouseButtonControl.Core.ViewModels.MainWindow;
diff --git a/YMouseButtonControl.Core/YMouseButtonControl.Core.csproj b/YMouseButtonControl.Core/YMouseButtonControl.Core.csproj
index 77da661..8587cba 100644
--- a/YMouseButtonControl.Core/YMouseButtonControl.Core.csproj
+++ b/YMouseButtonControl.Core/YMouseButtonControl.Core.csproj
@@ -18,22 +18,21 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
diff --git a/YMouseButtonControl.DataAccess/Context/YMouseButtonControlDbContext.cs b/YMouseButtonControl.DataAccess/Context/YMouseButtonControlDbContext.cs
index da048ff..395fd5f 100644
--- a/YMouseButtonControl.DataAccess/Context/YMouseButtonControlDbContext.cs
+++ b/YMouseButtonControl.DataAccess/Context/YMouseButtonControlDbContext.cs
@@ -1,117 +1,128 @@
using System.Data;
using Dapper;
using Microsoft.Data.Sqlite;
+using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
+using YMouseButtonControl.Domain.Models;
-namespace YMouseButtonControl.DataAccess.Context;
+namespace YMouseButtonControl.Infrastructure.Context;
-public class YMouseButtonControlDbContext(IConfigurationRoot? configuration)
+public class YMouseButtonControlDbContext(DbContextOptions opts)
+ : DbContext(opts)
{
- public IConfigurationRoot? Configuration { get; } = configuration;
+ public DbSet Profiles { get; set; } = null!;
+ public DbSet Settings { get; set; } = null!;
+ public DbSet SettingBools { get; set; } = null!;
+ public DbSet SettingStrings { get; set; } = null!;
+ public DbSet SettingInts { get; set; } = null!;
+ public DbSet Themes { get; set; } = null!;
+ public DbSet ButtonMappings { get; set; } = null!;
+ public DbSet DisabledMappings { get; set; } = null!;
+ public DbSet NothingMappings { get; set; } = null!;
+ public DbSet SimulatedKeystrokeMappings { get; set; } = null!;
+ public DbSet RightClickMappings { get; set; } = null!;
- public IDbConnection CreateConnection()
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
{
- return new SqliteConnection(
- Configuration?.GetConnectionString("YMouseButtonControlContext")
- );
- }
-
- public void Init()
- {
- using var conn = CreateConnection();
- InitProfiles();
- InitSettings();
- InitThemes();
- InitButtonMappings();
- return;
-
- void InitProfiles()
- {
- const string sql = """
- CREATE TABLE IF NOT EXISTS
- Profiles (
- Id INTEGER PRIMARY KEY AUTOINCREMENT,
- IsDefault BOOLEAN,
- Checked BOOLEAN,
- DisplayPriority INTEGER,
- Name TEXT NOT NULL,
- Description TEXT NOT NULL,
- WindowCaption TEXT NOT NULL,
- Process TEXT NOT NULL,
- WindowClass TEXT NOT NULL,
- ParentClass TEXT NOT NULL,
- MatchType TEXT NOT NULL
- );
- INSERT OR IGNORE INTO Profiles (
- Id, IsDefault, Checked, Name, Description, WindowCaption, Process, WindowClass, ParentClass, MatchType)
- VALUES ('1', '1', '1', 'Default', 'Default description', 'N/A', '*', 'N/A', 'N/A', 'N/A');
- """;
- conn.Execute(sql);
- }
-
- void InitSettings()
- {
- const string sql = """
- CREATE TABLE IF NOT EXISTS
- Settings (
- Id INTEGER PRIMARY KEY AUTOINCREMENT,
- Name TEXT NOT NULL,
- BoolValue BOOLEAN,
- StringValue TEXT,
- IntValue INTEGER,
- SettingType INTEGER NOT NULL
- );
- INSERT OR IGNORE INTO Settings (Id, Name, BoolValue, SettingType) VALUES ('1', 'StartMinimized', 0, '1');
- INSERT OR IGNORE INTO Settings (Id, Name, IntValue, SettingType) VALUES ('2', 'Theme', '1', '3');
- """;
- conn.Execute(sql);
- }
+ modelBuilder
+ .Entity()
+ .HasData(
+ new Profile
+ {
+ Id = 1,
+ IsDefault = true,
+ Checked = true,
+ DisplayPriority = 1,
+ Name = "Default",
+ Description = "Default description",
+ WindowCaption = "N/A",
+ Process = "*",
+ MatchType = "N/A",
+ ParentClass = "N/A",
+ WindowClass = "N/A",
+ }
+ );
- void InitThemes()
- {
- const string sql = """
- CREATE TABLE IF NOT EXISTS
- Themes (
- Id INTEGER PRIMARY KEY AUTOINCREMENT,
- Name TEXT NOT NULL,
- Background TEXT NOT NULL,
- Highlight TEXT NOT NULL
- );
- INSERT OR IGNORE INTO Themes (Id, Name, Background, Highlight) VALUES ('1', 'Default', 'SystemAltHighColor','SystemAccentColor');
- INSERT OR IGNORE INTO Themes (Id, Name, Background, Highlight) VALUES ('2', 'Light', 'White', 'Yellow');
- INSERT OR IGNORE INTO Themes (Id, Name, Background, Highlight) VALUES ('3', 'Dark', 'Black', '#3700b3');
- """;
- conn.Execute(sql);
- }
+ modelBuilder
+ .Entity()
+ .HasData(
+ [
+ new NothingMapping
+ {
+ Id = 1,
+ MouseButton = MouseButton.Mb1,
+ ProfileId = 1,
+ },
+ new NothingMapping
+ {
+ Id = 2,
+ MouseButton = MouseButton.Mb2,
+ ProfileId = 1,
+ },
+ new NothingMapping
+ {
+ Id = 3,
+ MouseButton = MouseButton.Mb3,
+ ProfileId = 1,
+ },
+ new NothingMapping
+ {
+ Id = 4,
+ MouseButton = MouseButton.Mb4,
+ ProfileId = 1,
+ },
+ new NothingMapping
+ {
+ Id = 5,
+ MouseButton = MouseButton.Mb5,
+ ProfileId = 1,
+ },
+ new NothingMapping
+ {
+ Id = 6,
+ MouseButton = MouseButton.Mwu,
+ ProfileId = 1,
+ },
+ new NothingMapping
+ {
+ Id = 7,
+ MouseButton = MouseButton.Mwd,
+ ProfileId = 1,
+ },
+ new NothingMapping
+ {
+ Id = 8,
+ MouseButton = MouseButton.Mwl,
+ ProfileId = 1,
+ },
+ new NothingMapping
+ {
+ Id = 9,
+ MouseButton = MouseButton.Mwr,
+ ProfileId = 1,
+ },
+ ]
+ );
- void InitButtonMappings()
- {
- const string sql = """
- CREATE TABLE IF NOT EXISTS
- ButtonMappings (
- Id INTEGER PRIMARY KEY AUTOINCREMENT,
- Keys TEXT,
- MouseButton INTEGER NOT NULL,
- ProfileId INTEGER NOT NULL,
- SimulatedKeystrokeType INTEGER,
- Selected BOOLEAN,
- BlockOriginalMouseInput BOOLEAN,
- AutoRepeatDelay INTEGER,
- AutoRepeatRandomizeDelayEnabled BOOLEAN,
- ButtonMappingType INTEGER NOT NULL,
- FOREIGN KEY (ProfileId) REFERENCES Profiles (Id) ON DELETE CASCADE
- );
- INSERT OR IGNORE INTO ButtonMappings (Id, MouseButton, ProfileId, ButtonMappingType) VALUES ('1', '0', '1', '1');
- INSERT OR IGNORE INTO ButtonMappings (Id, MouseButton, ProfileId, ButtonMappingType) VALUES ('2', '1', '1', '1');
- INSERT OR IGNORE INTO ButtonMappings (Id, MouseButton, ProfileId, ButtonMappingType) VALUES ('3', '2', '1', '1');
- INSERT OR IGNORE INTO ButtonMappings (Id, MouseButton, ProfileId, ButtonMappingType) VALUES ('4', '3', '1', '1');
- INSERT OR IGNORE INTO ButtonMappings (Id, MouseButton, ProfileId, ButtonMappingType) VALUES ('5', '4', '1', '1');
- INSERT OR IGNORE INTO ButtonMappings (Id, MouseButton, ProfileId, ButtonMappingType) VALUES ('6', '5', '1', '1');
- INSERT OR IGNORE INTO ButtonMappings (Id, MouseButton, ProfileId, ButtonMappingType) VALUES ('7', '6', '1', '1');
- INSERT OR IGNORE INTO ButtonMappings (Id, MouseButton, ProfileId, ButtonMappingType) VALUES ('8', '7', '1', '1');
- INSERT OR IGNORE INTO ButtonMappings (Id, MouseButton, ProfileId, ButtonMappingType) VALUES ('9', '8', '1', '1');
- """;
- conn.Execute(sql);
- }
+ modelBuilder
+ .Entity()
+ .HasData(
+ new SettingBool
+ {
+ Id = 1,
+ Name = "StartMinimized",
+ BoolValue = false,
+ }
+ );
+ modelBuilder
+ .Entity()
+ .HasData(
+ new SettingInt
+ {
+ Id = 2,
+ Name = "Theme",
+ IntValue = 3,
+ }
+ );
}
}
diff --git a/YMouseButtonControl.DataAccess/Queries/BaseQueries.cs b/YMouseButtonControl.DataAccess/Queries/BaseQueries.cs
deleted file mode 100644
index 37f6cfa..0000000
--- a/YMouseButtonControl.DataAccess/Queries/BaseQueries.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-namespace YMouseButtonControl.DataAccess.Queries;
-
-public abstract class BaseQueries
-{
- public abstract string Add();
-
- public virtual string GetByName(string tblName) =>
- $"""
- SELECT * FROM {tblName}
- WHERE Name = @Name
- LIMIT 1;
- """;
-
- public virtual string GetAll(string tblName) => $"SELECT * FROM {tblName};";
-
- public virtual string GetById(string tblName) => $"SELECT * FROM {tblName} WHERE Id = @Id;";
-
- public abstract string Update();
-
- public virtual string DeleteById(string tblName) => $"DELETE FROM {tblName} WHERE Id = @Id;";
-}
diff --git a/YMouseButtonControl.DataAccess/Queries/ButtonMappingQueries.cs b/YMouseButtonControl.DataAccess/Queries/ButtonMappingQueries.cs
deleted file mode 100644
index f7f56c6..0000000
--- a/YMouseButtonControl.DataAccess/Queries/ButtonMappingQueries.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-namespace YMouseButtonControl.DataAccess.Queries;
-
-public class ButtonMappingQueries : BaseQueries
-{
- public string GetByProfileId() => "SELECT * FROM ButtonMappings WHERE ProfileId = @Id;";
-
- public override string Add() =>
- """
- INSERT INTO ButtonMappings
- (Keys, MouseButton, ProfileId, SimulatedKeystrokeType, Selected, BlockOriginalMouseInput, ButtonMappingType, AutoRepeatDelay, AutoRepeatRandomizeDelayEnabled)
- VALUES (@Keys, @MouseButton, @ProfileId, @SimulatedKeystrokeType, @Selected, @BlockOriginalMouseInput, @ButtonMappingType, @AutoRepeatDelay, @AutoRepeatRandomizeDelayEnabled);
- """;
-
- public override string Update() =>
- """
- UPDATE ButtonMappings
- SET Keys = @Keys,
- MouseButton = @MouseButton,
- ProfileId = @ProfileId,
- SimulatedKeystrokeType = @SimulatedKeystrokeType,
- Selected = @Selected,
- AutoRepeatDelay = @AutoRepeatDelay,
- AutoRepeatRandomizeDelayEnabled = @AutoRepeatRandomizeDelayEnabled,
- BlockOriginalMouseInput = @BlockOriginalMouseInput;
- """;
-}
diff --git a/YMouseButtonControl.DataAccess/Queries/ProfileQueries.cs b/YMouseButtonControl.DataAccess/Queries/ProfileQueries.cs
deleted file mode 100644
index 2f5fe9c..0000000
--- a/YMouseButtonControl.DataAccess/Queries/ProfileQueries.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-namespace YMouseButtonControl.DataAccess.Queries;
-
-public class ProfileQueries : BaseQueries
-{
- public override string Add() =>
- """
- INSERT INTO Profiles
- (Id, IsDefault, Checked, DisplayPriority, Name, Description, WindowCaption, Process, WindowClass, ParentClass, MatchType)
- VALUES (@Id, @IsDefault, @Checked, @DisplayPriority, @Name, @Description, @WindowCaption, @Process, @WindowClass, @ParentClass, @MatchType);
- SELECT SEQ from sqlite_sequence WHERE name='Profiles';
- """;
-
- public override string Update() =>
- """
- UPDATE Profiles
- SET IsDefault = @IsDefault,
- Checked = @Checked,
- DisplayPriority = @DisplayPriority,
- Name = @Name,
- Description = @Description,
- WindowCaption = @WindowCaption,
- Process = @Process,
- WindowClass = @WindowClass,
- ParentClass = @ParentClass,
- MatchType = @MatchType;
- """;
-}
diff --git a/YMouseButtonControl.DataAccess/Queries/SettingQueries.cs b/YMouseButtonControl.DataAccess/Queries/SettingQueries.cs
deleted file mode 100644
index 02e6532..0000000
--- a/YMouseButtonControl.DataAccess/Queries/SettingQueries.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace YMouseButtonControl.DataAccess.Queries;
-
-public class SettingQueries : BaseQueries
-{
- public override string Add() =>
- """
- INSERT INTO Settings (Id, Name, BoolValue, StringValue, IntValue)
- VALUES (@Id, @Name, @BoolValue, @StringValue, @IntValue);
- """;
-
- public override string Update() =>
- """
- UPDATE Settings
- SET Name = @Name,
- BoolValue = @BoolValue,
- StringValue = @StringValue,
- IntValue = @IntValue
- WHERE Id = @Id;
- """;
-}
diff --git a/YMouseButtonControl.DataAccess/Queries/ThemeQueries.cs b/YMouseButtonControl.DataAccess/Queries/ThemeQueries.cs
deleted file mode 100644
index 45e9cff..0000000
--- a/YMouseButtonControl.DataAccess/Queries/ThemeQueries.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-namespace YMouseButtonControl.DataAccess.Queries;
-
-public class ThemeQueries : BaseQueries
-{
- public override string Add() =>
- """
- INSERT INTO Themes (Id, Name, Background, Highlight)
- VALUES (@Id, @Name, @Background, @Highlight);
- """;
-
- public override string Update() =>
- """
- UPDATE Themes
- SET Name = @Name,
- Background = @Background,
- Highlight = @Highlight
- Where Id = @Id,
- """;
-}
diff --git a/YMouseButtonControl.DataAccess/YMouseButtonControl.DataAccess.csproj b/YMouseButtonControl.DataAccess/YMouseButtonControl.Infrastructure.csproj
similarity index 65%
rename from YMouseButtonControl.DataAccess/YMouseButtonControl.DataAccess.csproj
rename to YMouseButtonControl.DataAccess/YMouseButtonControl.Infrastructure.csproj
index bc46183..c4ca276 100644
--- a/YMouseButtonControl.DataAccess/YMouseButtonControl.DataAccess.csproj
+++ b/YMouseButtonControl.DataAccess/YMouseButtonControl.Infrastructure.csproj
@@ -7,9 +7,13 @@
-
+
+
+
+
+
diff --git a/YMouseButtonControl.DataAccess/Models/ButtonMapping.cs b/YMouseButtonControl.Domain/Models/ButtonMapping.cs
similarity index 95%
rename from YMouseButtonControl.DataAccess/Models/ButtonMapping.cs
rename to YMouseButtonControl.Domain/Models/ButtonMapping.cs
index 16cefea..c38817e 100644
--- a/YMouseButtonControl.DataAccess/Models/ButtonMapping.cs
+++ b/YMouseButtonControl.Domain/Models/ButtonMapping.cs
@@ -1,4 +1,4 @@
-namespace YMouseButtonControl.DataAccess.Models;
+namespace YMouseButtonControl.Domain.Models;
public enum MouseButton
{
diff --git a/YMouseButtonControl.DataAccess/Models/Profile.cs b/YMouseButtonControl.Domain/Models/Profile.cs
similarity index 80%
rename from YMouseButtonControl.DataAccess/Models/Profile.cs
rename to YMouseButtonControl.Domain/Models/Profile.cs
index 43e06c8..aa465ea 100644
--- a/YMouseButtonControl.DataAccess/Models/Profile.cs
+++ b/YMouseButtonControl.Domain/Models/Profile.cs
@@ -1,4 +1,4 @@
-namespace YMouseButtonControl.DataAccess.Models;
+namespace YMouseButtonControl.Domain.Models;
public class Profile
{
@@ -14,5 +14,5 @@ public class Profile
public required string ParentClass { get; set; }
public required string MatchType { get; set; }
- public virtual ICollection? ButtonMappings { get; set; }
+ public virtual ICollection ButtonMappings { get; set; } = [];
}
diff --git a/YMouseButtonControl.DataAccess/Models/Setting.cs b/YMouseButtonControl.Domain/Models/Setting.cs
similarity index 89%
rename from YMouseButtonControl.DataAccess/Models/Setting.cs
rename to YMouseButtonControl.Domain/Models/Setting.cs
index 943e649..329638a 100644
--- a/YMouseButtonControl.DataAccess/Models/Setting.cs
+++ b/YMouseButtonControl.Domain/Models/Setting.cs
@@ -1,4 +1,4 @@
-namespace YMouseButtonControl.DataAccess.Models;
+namespace YMouseButtonControl.Domain.Models;
public abstract class Setting
{
diff --git a/YMouseButtonControl.DataAccess/Models/SimulatedKeystrokeType.cs b/YMouseButtonControl.Domain/Models/SimulatedKeystrokeType.cs
similarity index 87%
rename from YMouseButtonControl.DataAccess/Models/SimulatedKeystrokeType.cs
rename to YMouseButtonControl.Domain/Models/SimulatedKeystrokeType.cs
index 6d32881..332b730 100644
--- a/YMouseButtonControl.DataAccess/Models/SimulatedKeystrokeType.cs
+++ b/YMouseButtonControl.Domain/Models/SimulatedKeystrokeType.cs
@@ -1,4 +1,4 @@
-namespace YMouseButtonControl.DataAccess.Models;
+namespace YMouseButtonControl.Domain.Models;
public enum SimulatedKeystrokeType
{
diff --git a/YMouseButtonControl.DataAccess/Models/Theme.cs b/YMouseButtonControl.Domain/Models/Theme.cs
similarity index 79%
rename from YMouseButtonControl.DataAccess/Models/Theme.cs
rename to YMouseButtonControl.Domain/Models/Theme.cs
index c2090a1..b91c248 100644
--- a/YMouseButtonControl.DataAccess/Models/Theme.cs
+++ b/YMouseButtonControl.Domain/Models/Theme.cs
@@ -1,4 +1,4 @@
-namespace YMouseButtonControl.DataAccess.Models;
+namespace YMouseButtonControl.Domain.Models;
public class Theme
{
diff --git a/YMouseButtonControl.Domain/YMouseButtonControl.Domain.csproj b/YMouseButtonControl.Domain/YMouseButtonControl.Domain.csproj
new file mode 100644
index 0000000..3a63532
--- /dev/null
+++ b/YMouseButtonControl.Domain/YMouseButtonControl.Domain.csproj
@@ -0,0 +1,9 @@
+
+
+
+ net8.0
+ enable
+ enable
+
+
+
diff --git a/YMouseButtonControl.sln b/YMouseButtonControl.sln
index 996cabb..aa7e3fd 100644
--- a/YMouseButtonControl.sln
+++ b/YMouseButtonControl.sln
@@ -1,10 +1,13 @@
Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 17
+VisualStudioVersion = 17.12.35527.113 d17.12
+MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YMouseButtonControl.Core.Tests", "YMouseButtonControl.Core.Tests\YMouseButtonControl.Core.Tests.csproj", "{0F770391-A4A1-611D-4FBA-125A6EB42834}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YMouseButtonControl.Core", "YMouseButtonControl.Core\YMouseButtonControl.Core.csproj", "{CEB84FCC-DB49-6456-7173-1F508E465D31}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YMouseButtonControl.DataAccess", "YMouseButtonControl.DataAccess\YMouseButtonControl.DataAccess.csproj", "{A4C2C9B9-43FA-ACCF-4C5B-E79ECC6F61BA}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YMouseButtonControl.Infrastructure", "YMouseButtonControl.DataAccess\YMouseButtonControl.Infrastructure.csproj", "{A4C2C9B9-43FA-ACCF-4C5B-E79ECC6F61BA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YMouseButtonControl.Linux.Tests", "YMouseButtonControl.Linux.Tests\YMouseButtonControl.Linux.Tests.csproj", "{BD4EFA4F-A2CD-2BDE-BAA5-C55B4B220A84}"
EndProject
@@ -18,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YMouseButtonControl.Windows
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YMouseButtonControl", "YMouseButtonControl\YMouseButtonControl.csproj", "{9E275480-14AB-A39F-C3FB-ED2FDB97361F}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "YMouseButtonControl.Domain", "YMouseButtonControl.Domain\YMouseButtonControl.Domain.csproj", "{4DE55456-2875-4979-BB42-8D57B0FDE353}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -60,5 +65,12 @@ Global
{9E275480-14AB-A39F-C3FB-ED2FDB97361F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9E275480-14AB-A39F-C3FB-ED2FDB97361F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9E275480-14AB-A39F-C3FB-ED2FDB97361F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {4DE55456-2875-4979-BB42-8D57B0FDE353}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {4DE55456-2875-4979-BB42-8D57B0FDE353}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {4DE55456-2875-4979-BB42-8D57B0FDE353}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {4DE55456-2875-4979-BB42-8D57B0FDE353}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
diff --git a/YMouseButtonControl/App.axaml.cs b/YMouseButtonControl/App.axaml.cs
index 946bfe7..2d457b1 100644
--- a/YMouseButtonControl/App.axaml.cs
+++ b/YMouseButtonControl/App.axaml.cs
@@ -18,8 +18,8 @@
using YMouseButtonControl.Core.ViewModels.MainWindow;
using YMouseButtonControl.Core.ViewModels.Models;
using YMouseButtonControl.Core.Views;
-using YMouseButtonControl.DataAccess.Context;
using YMouseButtonControl.DependencyInjection;
+using YMouseButtonControl.Infrastructure.Context;
using ILogger = Microsoft.Extensions.Logging.ILogger;
using LogLevel = Microsoft.Extensions.Logging.LogLevel;
diff --git a/YMouseButtonControl/YMouseButtonControl.csproj b/YMouseButtonControl/YMouseButtonControl.csproj
index e93bb78..3b855d5 100644
--- a/YMouseButtonControl/YMouseButtonControl.csproj
+++ b/YMouseButtonControl/YMouseButtonControl.csproj
@@ -75,7 +75,6 @@
-
From 7cd32e63551e8a590320757894c0a370de802193 Mon Sep 17 00:00:00 2001
From: FaithBeam <32502411+FaithBeam@users.noreply.github.com>
Date: Sat, 7 Dec 2024 14:45:32 -0500
Subject: [PATCH 02/39] wip
---
.../Mappings/ButtonMappingMapper.cs | 2 +-
.../Mappings/ProfileMapper.cs | 2 +-
.../Mappings/SettingMapper.cs | 2 +-
.../Mappings/ThemeMapper.cs | 2 +-
.../Repositories/ButtonMappingRepository.cs | 86 ++--
.../Repositories/IRepository.cs | 5 -
.../Repositories/ProfileRepository.cs | 135 ++-----
.../Repositories/SettingRepository.cs | 159 ++------
.../Repositories/ThemeRepository.cs | 76 ++--
.../Services/Profiles/ProfilesService.cs | 78 +++-
.../Services/Settings/SettingsService.cs | 2 +-
.../Services/Theme/ThemeService.cs | 4 +-
.../LayerViewModel/LayerViewModel.cs | 2 +-
.../LayerViewModel/MouseComboViewModel.cs | 3 +-
.../MouseComboViewModelFactory.cs | 2 +-
.../ShowSimulatedKeystrokesDialogService.cs | 2 +-
.../SimulatedKeystrokesDialogViewModel.cs | 2 +-
.../Features/Apply/ApplyProfiles.cs | 44 ++-
.../GlobalSettingsDialogViewModel.cs | 2 -
.../MainWindow/MainWindowViewModel.cs | 59 +--
.../ViewModels/Models/BaseButtonMappingVm.cs | 2 +-
.../ViewModels/Models/ProfileVm.cs | 2 +-
.../ProcessSelectorDialogViewModel.cs | 2 +-
.../YMouseButtonControl.Core.csproj | 3 +-
.../Context/YMouseButtonControlDbContext.cs | 38 +-
.../20241207140626_Initial.Designer.cs | 349 ++++++++++++++++
.../Migrations/20241207140626_Initial.cs | 150 +++++++
.../20241207141716_AddThemes.Designer.cs | 372 ++++++++++++++++++
.../Migrations/20241207141716_AddThemes.cs | 45 +++
...tDefaultProfileDisplayPriority.Designer.cs | 372 ++++++++++++++++++
...35_CorrectDefaultProfileDisplayPriority.cs | 32 ++
...ouseButtonControlDbContextModelSnapshot.cs | 369 +++++++++++++++++
YMouseButtonControl/App.axaml.cs | 8 +-
.../DataAccessBootstrapper.cs | 7 +-
.../ViewModelsBootstrapper.cs | 2 +-
.../YMouseButtonControl.csproj | 7 +
36 files changed, 1993 insertions(+), 436 deletions(-)
create mode 100644 YMouseButtonControl.DataAccess/Migrations/20241207140626_Initial.Designer.cs
create mode 100644 YMouseButtonControl.DataAccess/Migrations/20241207140626_Initial.cs
create mode 100644 YMouseButtonControl.DataAccess/Migrations/20241207141716_AddThemes.Designer.cs
create mode 100644 YMouseButtonControl.DataAccess/Migrations/20241207141716_AddThemes.cs
create mode 100644 YMouseButtonControl.DataAccess/Migrations/20241207142135_CorrectDefaultProfileDisplayPriority.Designer.cs
create mode 100644 YMouseButtonControl.DataAccess/Migrations/20241207142135_CorrectDefaultProfileDisplayPriority.cs
create mode 100644 YMouseButtonControl.DataAccess/Migrations/YMouseButtonControlDbContextModelSnapshot.cs
diff --git a/YMouseButtonControl.Core/Mappings/ButtonMappingMapper.cs b/YMouseButtonControl.Core/Mappings/ButtonMappingMapper.cs
index 46fd134..65a4254 100644
--- a/YMouseButtonControl.Core/Mappings/ButtonMappingMapper.cs
+++ b/YMouseButtonControl.Core/Mappings/ButtonMappingMapper.cs
@@ -1,7 +1,7 @@
using System;
using Riok.Mapperly.Abstractions;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.Mappings;
diff --git a/YMouseButtonControl.Core/Mappings/ProfileMapper.cs b/YMouseButtonControl.Core/Mappings/ProfileMapper.cs
index 681b35d..87e76e0 100644
--- a/YMouseButtonControl.Core/Mappings/ProfileMapper.cs
+++ b/YMouseButtonControl.Core/Mappings/ProfileMapper.cs
@@ -2,7 +2,7 @@
using System.Linq;
using Riok.Mapperly.Abstractions;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.Mappings;
diff --git a/YMouseButtonControl.Core/Mappings/SettingMapper.cs b/YMouseButtonControl.Core/Mappings/SettingMapper.cs
index 4173c2e..86f6221 100644
--- a/YMouseButtonControl.Core/Mappings/SettingMapper.cs
+++ b/YMouseButtonControl.Core/Mappings/SettingMapper.cs
@@ -1,6 +1,6 @@
using Riok.Mapperly.Abstractions;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.Mappings;
diff --git a/YMouseButtonControl.Core/Mappings/ThemeMapper.cs b/YMouseButtonControl.Core/Mappings/ThemeMapper.cs
index 97be0c3..a63b067 100644
--- a/YMouseButtonControl.Core/Mappings/ThemeMapper.cs
+++ b/YMouseButtonControl.Core/Mappings/ThemeMapper.cs
@@ -1,6 +1,6 @@
using Riok.Mapperly.Abstractions;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.Mappings;
diff --git a/YMouseButtonControl.Core/Repositories/ButtonMappingRepository.cs b/YMouseButtonControl.Core/Repositories/ButtonMappingRepository.cs
index 154c1fe..cda6f08 100644
--- a/YMouseButtonControl.Core/Repositories/ButtonMappingRepository.cs
+++ b/YMouseButtonControl.Core/Repositories/ButtonMappingRepository.cs
@@ -1,25 +1,20 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
-using System.Threading.Tasks;
-using Dapper;
using YMouseButtonControl.Core.Mappings;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
-using YMouseButtonControl.DataAccess.Queries;
+using YMouseButtonControl.Domain.Models;
using YMouseButtonControl.Infrastructure.Context;
namespace YMouseButtonControl.Core.Repositories;
-public class ButtonMappingRepository(YMouseButtonControlDbContext ctx, ButtonMappingQueries queries)
+public class ButtonMappingRepository(YMouseButtonControlDbContext ctx)
: IRepository
{
private readonly YMouseButtonControlDbContext _ctx = ctx;
- private const string TblName = "ButtonMappings";
public int Add(BaseButtonMappingVm vm)
{
- using var conn = _ctx.CreateConnection();
var ent = ButtonMappingMapper.Map(vm);
ent.ButtonMappingType = ent switch
{
@@ -29,67 +24,56 @@ public int Add(BaseButtonMappingVm vm)
RightClick => ButtonMappingType.RightClick,
_ => throw new System.NotImplementedException(),
};
- return conn.Execute(queries.Add(), ent);
- }
-
- public async Task AddAsync(BaseButtonMappingVm vm)
- {
- using var conn = _ctx.CreateConnection();
- return await conn.ExecuteAsync(queries.Add(), vm);
+ var id = _ctx.ButtonMappings.Add(ent).Entity.Id;
+ _ctx.SaveChanges();
+ return id;
}
public BaseButtonMappingVm? GetById(int id)
{
- using var conn = _ctx.CreateConnection();
- return ButtonMappingMapper.Map(
- conn.QueryFirstOrDefault(queries.GetById(TblName), id)
- );
- }
-
- public async Task GetByIdAsync(int id)
- {
- using var conn = _ctx.CreateConnection();
- return ButtonMappingMapper.Map(
- await conn.QueryFirstOrDefaultAsync(queries.GetById(TblName), id)
- );
+ return ButtonMappingMapper.Map(_ctx.ButtonMappings.Find(id));
}
public IEnumerable GetAll()
{
- using var conn = _ctx.CreateConnection();
- return conn.Query(queries.GetAll(TblName)).Select(ButtonMappingMapper.Map);
- }
-
- public async Task> GetAllAsync()
- {
- using var conn = _ctx.CreateConnection();
- return (await conn.QueryAsync(queries.GetAll(TblName))).Select(
- ButtonMappingMapper.Map
- );
+ return _ctx.ButtonMappings.Select(ButtonMappingMapper.Map);
}
public int Update(BaseButtonMappingVm vm)
{
- using var conn = _ctx.CreateConnection();
- return conn.Execute(queries.Update(), vm);
- }
-
- public async Task UpdateAsync(BaseButtonMappingVm vm)
- {
- using var conn = _ctx.CreateConnection();
- return await conn.ExecuteAsync(queries.Update(), vm);
+ var ent = _ctx.ButtonMappings.Find(vm.Id);
+ if (ent is not null)
+ {
+ ent.MouseButton = vm.MouseButton;
+ ent.Keys = vm.Keys;
+ ent.Selected = vm.Selected;
+ ent.ProfileId = vm.ProfileId;
+ ent.BlockOriginalMouseInput = vm.BlockOriginalMouseInput;
+ ent.AutoRepeatDelay = vm.AutoRepeatDelay;
+ ent.AutoRepeatRandomizeDelayEnabled = vm.AutoRepeatRandomizeDelayEnabled;
+ ent.ButtonMappingType = ent.ButtonMappingType = ent switch
+ {
+ DisabledMapping => ButtonMappingType.Disabled,
+ NothingMapping => ButtonMappingType.Nothing,
+ SimulatedKeystroke => ButtonMappingType.SimulatedKeystroke,
+ RightClick => ButtonMappingType.RightClick,
+ _ => throw new System.NotImplementedException(),
+ };
+ _ctx.SaveChanges();
+ }
+ return ent?.Id ?? -1;
}
public int Delete(BaseButtonMappingVm vm)
{
- using var conn = _ctx.CreateConnection();
- return conn.Execute(queries.DeleteById(TblName), vm.Id);
- }
+ var ent = _ctx.ButtonMappings.Find(vm.Id);
+ if (ent is not null)
+ {
+ _ctx.ButtonMappings.Remove(ent);
+ _ctx.SaveChanges();
+ }
- public Task DeleteAsync(BaseButtonMappingVm vm)
- {
- using var conn = _ctx.CreateConnection();
- return conn.ExecuteAsync(queries.DeleteById(TblName), vm.Id);
+ return ent?.Id ?? -1;
}
public BaseButtonMappingVm? GetByName(string name)
diff --git a/YMouseButtonControl.Core/Repositories/IRepository.cs b/YMouseButtonControl.Core/Repositories/IRepository.cs
index 4a12ded..8b4a100 100644
--- a/YMouseButtonControl.Core/Repositories/IRepository.cs
+++ b/YMouseButtonControl.Core/Repositories/IRepository.cs
@@ -6,14 +6,9 @@ namespace YMouseButtonControl.Core.Repositories;
public interface IRepository
{
int Add(TVm vm);
- Task AddAsync(TVm vm);
TVm? GetByName(string name);
TVm? GetById(int id);
- Task GetByIdAsync(int id);
IEnumerable GetAll();
- Task> GetAllAsync();
int Update(TVm vm);
- Task UpdateAsync(TVm vm);
int Delete(TVm vm);
- Task DeleteAsync(TVm vm);
}
diff --git a/YMouseButtonControl.Core/Repositories/ProfileRepository.cs b/YMouseButtonControl.Core/Repositories/ProfileRepository.cs
index 3726ff1..087637e 100644
--- a/YMouseButtonControl.Core/Repositories/ProfileRepository.cs
+++ b/YMouseButtonControl.Core/Repositories/ProfileRepository.cs
@@ -1,140 +1,73 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using System.Threading.Tasks;
-using Dapper;
+using Microsoft.EntityFrameworkCore;
using YMouseButtonControl.Core.Mappings;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
-using YMouseButtonControl.DataAccess.Queries;
+using YMouseButtonControl.Domain.Models;
using YMouseButtonControl.Infrastructure.Context;
namespace YMouseButtonControl.Core.Repositories;
-public class ProfileRepository(
- YMouseButtonControlDbContext ctx,
- ProfileQueries queries,
- ButtonMappingQueries btnMappingQueries
-) : IRepository
+public class ProfileRepository(YMouseButtonControlDbContext ctx) : IRepository
{
private readonly YMouseButtonControlDbContext _ctx = ctx;
- private const string TblName = "Profiles";
public int Add(ProfileVm vm)
{
- using var conn = _ctx.CreateConnection();
- return conn.Query(queries.Add(), vm).Single();
- }
-
- public async Task AddAsync(ProfileVm vm)
- {
- using var conn = _ctx.CreateConnection();
- return await conn.ExecuteAsync(queries.Add(), vm);
- }
-
- public ProfileVm? GetById(int id)
- {
- using var conn = _ctx.CreateConnection();
- var profile = conn.QueryFirstOrDefault(queries.GetById(TblName), new { Id = id });
- if (profile == null)
+ var ent = ProfileMapper.Map(vm);
+ if (ent is not null)
{
- return null;
+ _ctx.Profiles.Add(ent);
+ _ctx.SaveChanges();
}
- profile.ButtonMappings = GetButtonMappingsForProfileId(id);
- return ProfileMapper.Map(profile);
+ return ent?.Id ?? -1;
}
- public async Task GetByIdAsync(int id)
+ public ProfileVm? GetById(int id)
{
- using var conn = _ctx.CreateConnection();
- return ProfileMapper.Map(
- await conn.QueryFirstOrDefaultAsync(queries.GetById(TblName), id)
- );
+ var ent = _ctx.Profiles.Find(id);
+ return ent is null ? null : ProfileMapper.Map(ent);
}
public IEnumerable GetAll()
{
- using var conn = _ctx.CreateConnection();
- return conn.Query(queries.GetAll(TblName))
- .Select(p =>
- {
- p.ButtonMappings = GetButtonMappingsForProfileId(p.Id);
- return ProfileMapper.Map(p);
- });
- }
-
- public async Task> GetAllAsync()
- {
- using var conn = _ctx.CreateConnection();
- return (await conn.QueryAsync(queries.GetAll(TblName))).Select(ProfileMapper.Map);
+ return _ctx.Profiles.Include(x => x.ButtonMappings).Select(x => ProfileMapper.Map(x));
}
public int Update(ProfileVm vm)
{
- using var conn = _ctx.CreateConnection();
- return conn.Execute(queries.Update(), vm);
- }
-
- public async Task UpdateAsync(ProfileVm vm)
- {
- using var conn = _ctx.CreateConnection();
- return await conn.ExecuteAsync(queries.Update(), vm);
+ var ent = _ctx.Profiles.Find(vm.Id);
+ if (ent is not null)
+ {
+ ent.Checked = vm.Checked;
+ ent.Description = vm.Description;
+ ent.DisplayPriority = vm.DisplayPriority;
+ ent.IsDefault = vm.IsDefault;
+ ent.MatchType = vm.MatchType;
+ ent.Name = vm.Name;
+ ent.ParentClass = vm.ParentClass;
+ ent.Process = vm.Process;
+ ent.WindowCaption = vm.WindowCaption;
+ ent.WindowClass = vm.WindowClass;
+ _ctx.SaveChanges();
+ }
+ return ent?.Id ?? -1;
}
public int Delete(ProfileVm vm)
{
- using var conn = _ctx.CreateConnection();
- return conn.Execute(queries.DeleteById(TblName), vm);
- }
-
- public Task DeleteAsync(ProfileVm vm)
- {
- using var conn = _ctx.CreateConnection();
- return conn.ExecuteAsync(queries.DeleteById(TblName), vm);
- }
-
- private List GetButtonMappingsForProfileId(int id)
- {
- using var conn = _ctx.CreateConnection();
- using var reader = conn.ExecuteReader(btnMappingQueries.GetByProfileId(), new { Id = id });
- var nothingParser = reader.GetRowParser();
- var disabledParser = reader.GetRowParser();
- var simulatedKeystrokeParser = reader.GetRowParser();
- var rightClickParser = reader.GetRowParser();
-
- var buttonMappings = new List();
-
- while (reader.Read())
+ var ent = _ctx.Profiles.Find(vm.Id);
+ if (ent is not null)
{
- var discriminator = (ButtonMappingType)
- reader.GetInt32(reader.GetOrdinal("ButtonMappingType"));
- switch (discriminator)
- {
- case ButtonMappingType.Disabled:
- buttonMappings.Add(disabledParser(reader));
- break;
- case ButtonMappingType.Nothing:
- buttonMappings.Add(nothingParser(reader));
- break;
- case ButtonMappingType.SimulatedKeystroke:
- buttonMappings.Add(simulatedKeystrokeParser(reader));
- break;
- case ButtonMappingType.RightClick:
- buttonMappings.Add(rightClickParser(reader));
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
+ _ctx.Profiles.Remove(ent);
+ _ctx.SaveChanges();
}
-
- return buttonMappings;
+ return ent?.Id ?? -1;
}
public ProfileVm? GetByName(string name)
{
- using var conn = _ctx.CreateConnection();
- return ProfileMapper.Map(
- conn.QuerySingleOrDefault(queries.GetByName(TblName), name)
- );
+ return ProfileMapper.Map(_ctx.Profiles.Find(name));
}
}
diff --git a/YMouseButtonControl.Core/Repositories/SettingRepository.cs b/YMouseButtonControl.Core/Repositories/SettingRepository.cs
index 626de1d..ee9d726 100644
--- a/YMouseButtonControl.Core/Repositories/SettingRepository.cs
+++ b/YMouseButtonControl.Core/Repositories/SettingRepository.cs
@@ -3,160 +3,75 @@
using System.Data;
using System.Linq;
using System.Threading.Tasks;
-using Dapper;
using YMouseButtonControl.Core.Mappings;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
-using YMouseButtonControl.DataAccess.Queries;
+using YMouseButtonControl.Domain.Models;
using YMouseButtonControl.Infrastructure.Context;
-using static Dapper.SqlMapper;
namespace YMouseButtonControl.Core.Repositories;
-public class SettingRepository(YMouseButtonControlDbContext ctx, SettingQueries queries)
+public class SettingRepository(YMouseButtonControlDbContext ctx)
: IRepository
{
private readonly YMouseButtonControlDbContext _ctx = ctx;
- private const string TblName = "Settings";
public int Add(BaseSettingVm vm)
{
- using var conn = _ctx.CreateConnection();
- return conn.Execute(queries.Add(), vm);
- }
-
- public async Task AddAsync(BaseSettingVm vm)
- {
- using var conn = _ctx.CreateConnection();
- return await conn.ExecuteAsync(queries.Add(), vm);
+ var ent = SettingMapper.Map(vm);
+ if (ent is not null)
+ {
+ _ctx.Add(ent);
+ _ctx.SaveChanges();
+ }
+ return ent?.Id ?? -1;
}
public BaseSettingVm? GetById(int id)
{
- using var conn = _ctx.CreateConnection();
- return SettingMapper.Map(conn.QueryFirstOrDefault(queries.GetById(TblName), id));
- }
-
- public async Task GetByIdAsync(int id)
- {
- using var conn = _ctx.CreateConnection();
- return SettingMapper.Map(
- await conn.QueryFirstOrDefaultAsync(queries.GetById(TblName), id)
- );
+ return SettingMapper.Map(_ctx.Settings.Find(id));
}
public IEnumerable GetAll()
{
- using var conn = _ctx.CreateConnection();
- using var reader = conn.ExecuteReader(queries.GetAll(TblName));
- var settings = new List();
- var settingBoolParser = reader.GetRowParser();
- var settingIntParser = reader.GetRowParser();
- var settingStringParser = reader.GetRowParser();
- while (reader.Read())
- {
- var discriminator = (SettingType)
- reader.GetInt32(reader.GetOrdinal(nameof(SettingType)));
- switch (discriminator)
- {
- case SettingType.SettingBool:
- settings.Add(settingBoolParser(reader));
- break;
- case SettingType.SettingString:
- settings.Add(settingStringParser(reader));
- break;
- case SettingType.SettingInt:
- settings.Add(settingIntParser(reader));
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
- }
- return settings.Select(SettingMapper.Map);
+ return _ctx.Settings.Select(x => SettingMapper.Map(x));
}
public BaseSettingVm? GetByName(string name)
{
- using var conn = _ctx.CreateConnection();
- using var reader = conn.ExecuteReader(queries.GetByName(TblName), new { Name = name });
- var settingBoolParser = reader.GetRowParser();
- var settingIntParser = reader.GetRowParser();
- var settingStringParser = reader.GetRowParser();
- reader.Read();
- var discriminator = (SettingType)reader.GetInt32(reader.GetOrdinal(nameof(SettingType)));
- return discriminator switch
- {
- SettingType.SettingBool => SettingMapper.Map(settingBoolParser(reader)),
- SettingType.SettingString => SettingMapper.Map(settingStringParser(reader)),
- SettingType.SettingInt => SettingMapper.Map(settingIntParser(reader)),
- _ => throw new ArgumentOutOfRangeException(),
- };
- }
-
- public async Task> GetAllAsync()
- {
- using var conn = _ctx.CreateConnection();
- return (await conn.QueryAsync(queries.GetAll(TblName))).Select(SettingMapper.Map);
+ return SettingMapper.Map(_ctx.Settings.First(x => x.Name == name));
}
public int Update(BaseSettingVm vm)
{
- using var conn = _ctx.CreateConnection();
- var ent = SettingMapper.Map(vm);
- return ent switch
+ var ent = _ctx.Settings.Find(vm.Id);
+ if (ent is not null)
{
- SettingBool t => conn.Execute(
- queries.Update(),
- new
- {
- ent.Id,
- ent.Name,
- t.BoolValue,
- StringValue = (string?)null,
- IntValue = (int?)null,
- }
- ),
- SettingString t => conn.Execute(
- queries.Update(),
- new
- {
- ent.Id,
- ent.Name,
- BoolValue = (bool?)null,
- t.StringValue,
- IntValue = (int?)null,
- }
- ),
- SettingInt t => conn.Execute(
- queries.Update(),
- new
- {
- ent.Id,
- ent.Name,
- BoolValue = (bool?)null,
- StringValue = (string?)null,
- t.IntValue,
- }
- ),
- _ => throw new NotImplementedException(),
- };
- }
-
- public async Task UpdateAsync(BaseSettingVm vm)
- {
- using var conn = _ctx.CreateConnection();
- return await conn.ExecuteAsync(queries.Update(), vm);
+ ent.Name = vm.Name;
+ if (ent is SettingBool sb)
+ {
+ sb.BoolValue = ((SettingBoolVm)vm).BoolValue;
+ }
+ else if (ent is SettingInt si)
+ {
+ si.IntValue = ((SettingIntVm)vm).IntValue;
+ }
+ else if (ent is SettingString ss)
+ {
+ ss.StringValue = ((SettingStringVm)vm).StringValue;
+ }
+ _ctx.SaveChanges();
+ }
+ return ent?.Id ?? -1;
}
public int Delete(BaseSettingVm vm)
{
- using var conn = _ctx.CreateConnection();
- return conn.Execute(queries.DeleteById(TblName), vm.Id);
- }
-
- public Task DeleteAsync(BaseSettingVm vm)
- {
- using var conn = _ctx.CreateConnection();
- return conn.ExecuteAsync(queries.DeleteById(TblName), vm.Id);
+ var ent = _ctx.Settings.Find(vm.Id);
+ if (ent is not null)
+ {
+ _ctx.Settings.Remove(ent);
+ _ctx.SaveChanges();
+ }
+ return ent?.Id ?? -1;
}
}
diff --git a/YMouseButtonControl.Core/Repositories/ThemeRepository.cs b/YMouseButtonControl.Core/Repositories/ThemeRepository.cs
index a5554ef..a74d482 100644
--- a/YMouseButtonControl.Core/Repositories/ThemeRepository.cs
+++ b/YMouseButtonControl.Core/Repositories/ThemeRepository.cs
@@ -2,83 +2,63 @@
using System.Collections.Generic;
using System.Data;
using System.Linq;
-using System.Threading.Tasks;
-using Dapper;
using YMouseButtonControl.Core.Mappings;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
-using YMouseButtonControl.DataAccess.Queries;
+using YMouseButtonControl.Domain.Models;
using YMouseButtonControl.Infrastructure.Context;
namespace YMouseButtonControl.Core.Repositories;
-public class ThemeRepository(YMouseButtonControlDbContext ctx, ThemeQueries queries)
- : IRepository
+public class ThemeRepository(YMouseButtonControlDbContext ctx) : IRepository
{
- private const string TblName = "Themes";
-
public int Add(ThemeVm vm)
{
- using var conn = ctx.CreateConnection();
- return conn.Query(queries.Add(), ThemeMapper.Map(vm)).Single();
- }
-
- public Task AddAsync(ThemeVm vm)
- {
- throw new NotImplementedException();
+ var ent = ThemeMapper.Map(vm);
+ if (ent is not null)
+ {
+ ctx.Themes.Add(ent);
+ ctx.SaveChanges();
+ }
+ return ent?.Id ?? -1;
}
public int Delete(ThemeVm vm)
{
- using var conn = ctx.CreateConnection();
- return conn.Execute(queries.DeleteById(TblName), new { ThemeMapper.Map(vm).Id });
- }
+ var ent = ctx.Themes.Find(vm.Id);
+ if (ent is not null)
+ {
+ ctx.Themes.Remove(ent);
+ ctx.SaveChanges();
+ }
- public Task DeleteAsync(ThemeVm vm)
- {
- throw new NotImplementedException();
+ return ent?.Id ?? -1;
}
public IEnumerable GetAll()
{
- using var conn = ctx.CreateConnection();
- return conn.Query(queries.GetAll(TblName)).Select(ThemeMapper.Map);
- }
-
- public Task> GetAllAsync()
- {
- throw new NotImplementedException();
+ return ctx.Themes.Select(ThemeMapper.Map);
}
public ThemeVm? GetById(int id)
{
- using var conn = ctx.CreateConnection();
- return ThemeMapper.Map(
- conn.QueryFirstOrDefault(queries.GetById(TblName), new { Id = id })
- );
- }
-
- public Task GetByIdAsync(int id)
- {
- throw new NotImplementedException();
+ return ThemeMapper.Map(ctx.Themes.Find(id));
}
public ThemeVm? GetByName(string name)
{
- using var conn = ctx.CreateConnection();
- return ThemeMapper.Map(
- conn.QuerySingleOrDefault(queries.GetByName(TblName), new { Name = name })
- );
+ return ThemeMapper.Map(ctx.Themes.Find(name));
}
public int Update(ThemeVm vm)
{
- using var conn = ctx.CreateConnection();
- return conn.Execute(queries.Update(), ThemeMapper.Map(vm));
- }
-
- public Task UpdateAsync(ThemeVm vm)
- {
- throw new NotImplementedException();
+ var ent = ctx.Themes.Find(vm.Id);
+ if (ent is not null)
+ {
+ ent.Background = vm.Background;
+ ent.Highlight = vm.Highlight;
+ ent.Name = vm.Name;
+ ctx.SaveChanges();
+ }
+ return ent?.Id ?? -1;
}
}
diff --git a/YMouseButtonControl.Core/Services/Profiles/ProfilesService.cs b/YMouseButtonControl.Core/Services/Profiles/ProfilesService.cs
index c8e364c..132aaaf 100644
--- a/YMouseButtonControl.Core/Services/Profiles/ProfilesService.cs
+++ b/YMouseButtonControl.Core/Services/Profiles/ProfilesService.cs
@@ -4,15 +4,14 @@
using System.IO;
using System.Linq;
using System.Reactive.Linq;
-using Avalonia.Media.TextFormatting.Unicode;
using DynamicData;
-using DynamicData.Binding;
using Newtonsoft.Json;
using ReactiveUI;
+using YMouseButtonControl.Core.Mappings;
using YMouseButtonControl.Core.Repositories;
using YMouseButtonControl.Core.Services.Profiles.Exceptions;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.Services.Profiles;
@@ -20,6 +19,8 @@ public interface IProfilesService
{
ProfileVm? CurrentProfile { get; set; }
ReadOnlyObservableCollection Profiles { get; }
+ bool Dirty { get; set; }
+
IObservable> Connect();
ProfileVm CopyProfile(ProfileVm p);
void WriteProfileToFile(ProfileVm p, string path);
@@ -30,6 +31,7 @@ public interface IProfilesService
void MoveProfileDown(ProfileVm p);
void RemoveProfile(ProfileVm profileVm);
void AddOrUpdate(ProfileVm profileVm);
+ void CheckForDirty();
}
public class ProfilesService : ReactiveObject, IProfilesService, IDisposable
@@ -38,6 +40,7 @@ public class ProfilesService : ReactiveObject, IProfilesService, IDisposable
private ProfileVm? _currentProfile;
private readonly SourceCache _profiles;
private readonly ReadOnlyObservableCollection _profilesObsCol;
+ private bool _dirty;
public ProfilesService(IRepository profileRepository)
{
@@ -48,10 +51,77 @@ public ProfilesService(IRepository profileRepository)
.AutoRefresh()
.SortBy(x => x.DisplayPriority)
.Bind(out _profilesObsCol)
- .Subscribe();
+ .Subscribe(IsDirty);
_profiles.AddOrUpdate(profileRepository.GetAll().ToList());
}
+ private void IsDirty(IChangeSet set)
+ {
+ foreach (var cs in set.Where(x => x.Reason != ChangeReason.Refresh))
+ {
+ if (cs.Reason == ChangeReason.Add)
+ {
+ if (_profileRepository.GetById(cs.Current.Id) is null)
+ {
+ Dirty = true;
+ return;
+ }
+ }
+ else if (cs.Reason == ChangeReason.Update)
+ {
+ var ent =
+ _profileRepository.GetById(cs.Current.Id)
+ ?? throw new Exception("Null entity on update reason");
+ var mapped = ProfileMapper.Map(cs.Current);
+ if (!ent.Equals(mapped))
+ {
+ Dirty = true;
+ return;
+ }
+ }
+ else if (cs.Reason == ChangeReason.Remove)
+ {
+ if (_profileRepository.GetById(cs.Current.Id) is null)
+ {
+ Dirty = false;
+ }
+ else
+ {
+ Dirty = true;
+ return;
+ }
+ }
+ }
+ }
+
+ public void CheckForDirty()
+ {
+ var dbProfiles = _profileRepository.GetAll();
+ foreach (var dbProf in dbProfiles)
+ {
+ if (_profilesObsCol.All(x => !x.Equals(dbProf)))
+ {
+ Dirty = true;
+ return;
+ }
+ }
+ foreach (var prof in _profilesObsCol)
+ {
+ if (dbProfiles.All(x => !x.Equals(prof)))
+ {
+ Dirty = true;
+ return;
+ }
+ }
+ Dirty = false;
+ }
+
+ public bool Dirty
+ {
+ get => _dirty;
+ set => this.RaiseAndSetIfChanged(ref _dirty, value);
+ }
+
///
/// Read only collection of profiles
///
diff --git a/YMouseButtonControl.Core/Services/Settings/SettingsService.cs b/YMouseButtonControl.Core/Services/Settings/SettingsService.cs
index cadb738..8f0c705 100644
--- a/YMouseButtonControl.Core/Services/Settings/SettingsService.cs
+++ b/YMouseButtonControl.Core/Services/Settings/SettingsService.cs
@@ -1,7 +1,7 @@
using ReactiveUI;
using YMouseButtonControl.Core.Repositories;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.Services.Settings;
diff --git a/YMouseButtonControl.Core/Services/Theme/ThemeService.cs b/YMouseButtonControl.Core/Services/Theme/ThemeService.cs
index 60ab85b..270fd7b 100644
--- a/YMouseButtonControl.Core/Services/Theme/ThemeService.cs
+++ b/YMouseButtonControl.Core/Services/Theme/ThemeService.cs
@@ -21,7 +21,7 @@ public interface IThemeService
public class ThemeService : ReactiveObject, IThemeService
{
- private readonly IRepository _themeRepo;
+ private readonly IRepository _themeRepo;
private readonly SettingIntVm _themeSetting;
private readonly ThemeVm _themeVm;
private IBrush _background;
@@ -29,7 +29,7 @@ public class ThemeService : ReactiveObject, IThemeService
private readonly ThemeVariant _themeVariant;
public ThemeService(
- IRepository themeRepo,
+ IRepository themeRepo,
ISettingsService settingsService
)
{
diff --git a/YMouseButtonControl.Core/ViewModels/LayerViewModel/LayerViewModel.cs b/YMouseButtonControl.Core/ViewModels/LayerViewModel/LayerViewModel.cs
index e8ef2de..6a598ac 100644
--- a/YMouseButtonControl.Core/ViewModels/LayerViewModel/LayerViewModel.cs
+++ b/YMouseButtonControl.Core/ViewModels/LayerViewModel/LayerViewModel.cs
@@ -1,7 +1,7 @@
using System;
using ReactiveUI;
using YMouseButtonControl.Core.Services.Profiles;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.ViewModels.LayerViewModel;
diff --git a/YMouseButtonControl.Core/ViewModels/LayerViewModel/MouseComboViewModel.cs b/YMouseButtonControl.Core/ViewModels/LayerViewModel/MouseComboViewModel.cs
index 933d26b..a88a0be 100644
--- a/YMouseButtonControl.Core/ViewModels/LayerViewModel/MouseComboViewModel.cs
+++ b/YMouseButtonControl.Core/ViewModels/LayerViewModel/MouseComboViewModel.cs
@@ -9,12 +9,11 @@
using DynamicData;
using ReactiveUI;
using YMouseButtonControl.Core.Services.KeyboardAndMouse.Enums;
-using YMouseButtonControl.Core.Services.KeyboardAndMouse.EventArgs;
using YMouseButtonControl.Core.Services.KeyboardAndMouse.Implementations;
using YMouseButtonControl.Core.Services.Profiles;
using YMouseButtonControl.Core.Services.Theme;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.ViewModels.LayerViewModel;
diff --git a/YMouseButtonControl.Core/ViewModels/LayerViewModel/MouseComboViewModelFactory.cs b/YMouseButtonControl.Core/ViewModels/LayerViewModel/MouseComboViewModelFactory.cs
index 746aeac..1dfe687 100644
--- a/YMouseButtonControl.Core/ViewModels/LayerViewModel/MouseComboViewModelFactory.cs
+++ b/YMouseButtonControl.Core/ViewModels/LayerViewModel/MouseComboViewModelFactory.cs
@@ -1,7 +1,7 @@
using YMouseButtonControl.Core.Services.KeyboardAndMouse.Implementations;
using YMouseButtonControl.Core.Services.Profiles;
using YMouseButtonControl.Core.Services.Theme;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.ViewModels.LayerViewModel;
diff --git a/YMouseButtonControl.Core/ViewModels/LayerViewModel/ShowSimulatedKeystrokesDialogService.cs b/YMouseButtonControl.Core/ViewModels/LayerViewModel/ShowSimulatedKeystrokesDialogService.cs
index 37e5fa9..28c3850 100644
--- a/YMouseButtonControl.Core/ViewModels/LayerViewModel/ShowSimulatedKeystrokesDialogService.cs
+++ b/YMouseButtonControl.Core/ViewModels/LayerViewModel/ShowSimulatedKeystrokesDialogService.cs
@@ -4,7 +4,7 @@
using YMouseButtonControl.Core.Services.KeyboardAndMouse.Implementations;
using YMouseButtonControl.Core.Services.Theme;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.ViewModels.LayerViewModel;
diff --git a/YMouseButtonControl.Core/ViewModels/LayerViewModel/SimulatedKeystrokesDialogViewModel.cs b/YMouseButtonControl.Core/ViewModels/LayerViewModel/SimulatedKeystrokesDialogViewModel.cs
index 014b494..958cf3a 100644
--- a/YMouseButtonControl.Core/ViewModels/LayerViewModel/SimulatedKeystrokesDialogViewModel.cs
+++ b/YMouseButtonControl.Core/ViewModels/LayerViewModel/SimulatedKeystrokesDialogViewModel.cs
@@ -8,7 +8,7 @@
using YMouseButtonControl.Core.Services.KeyboardAndMouse.Implementations;
using YMouseButtonControl.Core.Services.Theme;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.ViewModels.LayerViewModel;
diff --git a/YMouseButtonControl.Core/ViewModels/MainWindow/Features/Apply/ApplyProfiles.cs b/YMouseButtonControl.Core/ViewModels/MainWindow/Features/Apply/ApplyProfiles.cs
index 11a6a80..2ed9939 100644
--- a/YMouseButtonControl.Core/ViewModels/MainWindow/Features/Apply/ApplyProfiles.cs
+++ b/YMouseButtonControl.Core/ViewModels/MainWindow/Features/Apply/ApplyProfiles.cs
@@ -1,8 +1,9 @@
-using System.Transactions;
+using System.Linq;
+using System.Transactions;
using YMouseButtonControl.Core.Repositories;
using YMouseButtonControl.Core.Services.Profiles;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.ViewModels.MainWindow.Features.Apply;
@@ -13,29 +14,30 @@ public interface IApply
public class Apply(
IRepository profileRepository,
- IRepository buttonMappingRepository,
+ //IRepository buttonMappingRepository,
IProfilesService profilesService
) : IApply
{
public void ApplyProfiles()
{
- using var trn = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
- foreach (var dbVm in profileRepository.GetAll())
- {
- profileRepository.Delete(dbVm);
- }
- foreach (var vm in profilesService.Profiles)
- {
- var profileId = profileRepository.Add(vm);
- foreach (var bm in vm.ButtonMappings)
- {
- if (bm.ProfileId <= 0)
- {
- bm.ProfileId = profileId;
- }
- buttonMappingRepository.Add(bm);
- }
- }
- trn.Complete();
+ var dbProfiles = profileRepository.GetAll();
+
+ // delete profiles
+ dbProfiles
+ .Where(x => !profilesService.Profiles.Any(y => y.Id == x.Id))
+ .ToList()
+ .ForEach(x => profileRepository.Delete(x));
+
+ // update profiles
+ profilesService
+ .Profiles.Where(x => dbProfiles.Any(y => y.Id == x.Id))
+ .ToList()
+ .ForEach(x => profileRepository.Update(x));
+
+ // add profiles
+ profilesService
+ .Profiles.Where(x => !dbProfiles.Any(y => y.Id == x.Id))
+ .ToList()
+ .ForEach(x => profileRepository.Add(x));
}
}
diff --git a/YMouseButtonControl.Core/ViewModels/MainWindow/GlobalSettingsDialogViewModel.cs b/YMouseButtonControl.Core/ViewModels/MainWindow/GlobalSettingsDialogViewModel.cs
index 8ab7720..cc13947 100644
--- a/YMouseButtonControl.Core/ViewModels/MainWindow/GlobalSettingsDialogViewModel.cs
+++ b/YMouseButtonControl.Core/ViewModels/MainWindow/GlobalSettingsDialogViewModel.cs
@@ -104,10 +104,8 @@ IThemeService themeService
}
}
- using var trn = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled);
settingsService.UpdateSetting(StartMinimized);
settingsService.UpdateSetting(ThemeSetting);
- trn.Complete();
},
canSave
);
diff --git a/YMouseButtonControl.Core/ViewModels/MainWindow/MainWindowViewModel.cs b/YMouseButtonControl.Core/ViewModels/MainWindow/MainWindowViewModel.cs
index 3ac7004..a22ccc1 100644
--- a/YMouseButtonControl.Core/ViewModels/MainWindow/MainWindowViewModel.cs
+++ b/YMouseButtonControl.Core/ViewModels/MainWindow/MainWindowViewModel.cs
@@ -1,25 +1,19 @@
using System;
using System.Collections.ObjectModel;
-using System.Diagnostics;
-using System.Linq;
using System.Reactive;
using System.Reactive.Linq;
using System.Threading.Tasks;
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using DynamicData;
-using DynamicData.Binding;
using ReactiveUI;
-using YMouseButtonControl.Core.Repositories;
using YMouseButtonControl.Core.Services.Profiles;
-using YMouseButtonControl.Core.Services.Settings;
using YMouseButtonControl.Core.Services.Theme;
using YMouseButtonControl.Core.ViewModels.LayerViewModel;
using YMouseButtonControl.Core.ViewModels.MainWindow.Features.Apply;
using YMouseButtonControl.Core.ViewModels.Models;
using YMouseButtonControl.Core.ViewModels.ProfilesInformationViewModel;
using YMouseButtonControl.Core.ViewModels.ProfilesList;
-using YMouseButtonControl.DataAccess.Models;
namespace YMouseButtonControl.Core.ViewModels.MainWindow;
@@ -40,14 +34,11 @@ public class MainWindowViewModel : ViewModelBase, IMainWindowViewModel
{
#region Fields
- private readonly IRepository _profileRepository;
private readonly IProfilesService _ps;
private readonly IThemeService _themeService;
private readonly IProfilesListViewModel _profilesListViewModel;
private readonly IGlobalSettingsDialogViewModel _globalSettingsDialogViewModel;
- private readonly ObservableAsPropertyHelper? _isExecutingSave;
private readonly ReadOnlyObservableCollection _profileVms;
- private bool _canSave;
#endregion
@@ -60,11 +51,9 @@ public MainWindowViewModel(
IProfilesListViewModel profilesListViewModel,
IProfilesInformationViewModel profilesInformationViewModel,
IGlobalSettingsDialogViewModel globalSettingsDialogViewModel,
- IApply apply,
- IRepository profileRepository
+ IApply apply
)
{
- _profileRepository = profileRepository;
_profilesListViewModel = profilesListViewModel;
_globalSettingsDialogViewModel = globalSettingsDialogViewModel;
_ps = ps;
@@ -88,50 +77,16 @@ is IClassicDesktopStyleApplicationLifetime lifetime
.RefCount()
.Bind(out _profileVms)
.DisposeMany()
- .Subscribe(CanSaveHelper);
- var isExecutingObservable = this.WhenAnyValue(x => x.IsExecutingSave)
- .Subscribe(_ => CanSave = false);
- var canSaveCmd = this.WhenAnyValue(x => x.CanSave);
- ApplyCommand = ReactiveCommand.Create(apply.ApplyProfiles, canSaveCmd);
- _isExecutingSave = ApplyCommand.IsExecuting.ToProperty(this, x => x.IsExecutingSave);
- }
-
- private void CanSaveHelper(IChangeSet changeSet)
- {
- foreach (var cs in changeSet)
- {
- var entity = _profileRepository.GetById(cs.Current.Id);
- switch (cs.Reason)
- {
- case ChangeReason.Add:
- CanSave = entity is null;
- break;
- case ChangeReason.Update:
- CanSave = !entity?.Equals(cs.Current) ?? true;
- break;
- case ChangeReason.Remove:
- CanSave = entity is not null;
- break;
- case ChangeReason.Refresh:
- CanSave = !entity?.Equals(cs.Current) ?? true;
- break;
- case ChangeReason.Moved:
- break;
- default:
- throw new ArgumentOutOfRangeException();
- }
- }
+ .Subscribe();
+ var canExecuteApply = this.WhenAnyValue(x => x._ps.Dirty);
+ ApplyCommand = ReactiveCommand.Create(apply.ApplyProfiles, canExecuteApply);
+ var isExecutingObservable = this.WhenAnyObservable(x => x.ApplyCommand.IsExecuting);
+ canExecuteApply = canExecuteApply.Merge(isExecutingObservable);
+ isExecutingObservable.Skip(1).Where(x => !x).Subscribe(x => _ps.Dirty = false);
}
public ProfileVm? CurrentProfile => _ps.CurrentProfile;
- public bool CanSave
- {
- get => _canSave;
- set => this.RaiseAndSetIfChanged(ref _canSave, value);
- }
- public bool IsExecutingSave => _isExecutingSave?.Value ?? false;
-
#endregion
#region Properties
diff --git a/YMouseButtonControl.Core/ViewModels/Models/BaseButtonMappingVm.cs b/YMouseButtonControl.Core/ViewModels/Models/BaseButtonMappingVm.cs
index f631ebe..2cad296 100644
--- a/YMouseButtonControl.Core/ViewModels/Models/BaseButtonMappingVm.cs
+++ b/YMouseButtonControl.Core/ViewModels/Models/BaseButtonMappingVm.cs
@@ -1,7 +1,7 @@
using System;
using Newtonsoft.Json;
using ReactiveUI;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.ViewModels.Models;
diff --git a/YMouseButtonControl.Core/ViewModels/Models/ProfileVm.cs b/YMouseButtonControl.Core/ViewModels/Models/ProfileVm.cs
index 60571de..56f491f 100644
--- a/YMouseButtonControl.Core/ViewModels/Models/ProfileVm.cs
+++ b/YMouseButtonControl.Core/ViewModels/Models/ProfileVm.cs
@@ -4,7 +4,7 @@
using DynamicData;
using Newtonsoft.Json;
using ReactiveUI;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.ViewModels.Models;
diff --git a/YMouseButtonControl.Core/ViewModels/ProfilesList/ProcessSelectorDialogViewModel.cs b/YMouseButtonControl.Core/ViewModels/ProfilesList/ProcessSelectorDialogViewModel.cs
index 61c30b6..8d10dbd 100644
--- a/YMouseButtonControl.Core/ViewModels/ProfilesList/ProcessSelectorDialogViewModel.cs
+++ b/YMouseButtonControl.Core/ViewModels/ProfilesList/ProcessSelectorDialogViewModel.cs
@@ -10,7 +10,7 @@
using YMouseButtonControl.Core.Services.Processes;
using YMouseButtonControl.Core.Services.Theme;
using YMouseButtonControl.Core.ViewModels.Models;
-using YMouseButtonControl.DataAccess.Models;
+using YMouseButtonControl.Domain.Models;
namespace YMouseButtonControl.Core.ViewModels.ProfilesList;
diff --git a/YMouseButtonControl.Core/YMouseButtonControl.Core.csproj b/YMouseButtonControl.Core/YMouseButtonControl.Core.csproj
index 8587cba..ba05255 100644
--- a/YMouseButtonControl.Core/YMouseButtonControl.Core.csproj
+++ b/YMouseButtonControl.Core/YMouseButtonControl.Core.csproj
@@ -20,9 +20,10 @@
-
+
+
diff --git a/YMouseButtonControl.DataAccess/Context/YMouseButtonControlDbContext.cs b/YMouseButtonControl.DataAccess/Context/YMouseButtonControlDbContext.cs
index 395fd5f..5397991 100644
--- a/YMouseButtonControl.DataAccess/Context/YMouseButtonControlDbContext.cs
+++ b/YMouseButtonControl.DataAccess/Context/YMouseButtonControlDbContext.cs
@@ -1,5 +1,4 @@
using System.Data;
-using Dapper;
using Microsoft.Data.Sqlite;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
@@ -7,8 +6,7 @@
namespace YMouseButtonControl.Infrastructure.Context;
-public class YMouseButtonControlDbContext(DbContextOptions opts)
- : DbContext(opts)
+public class YMouseButtonControlDbContext : DbContext
{
public DbSet Profiles { get; set; } = null!;
public DbSet Settings { get; set; } = null!;
@@ -22,6 +20,12 @@ public class YMouseButtonControlDbContext(DbContextOptions SimulatedKeystrokeMappings { get; set; } = null!;
public DbSet RightClickMappings { get; set; } = null!;
+ public YMouseButtonControlDbContext(DbContextOptions opts)
+ : base(opts)
+ {
+ Database.EnsureCreated();
+ }
+
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder
@@ -32,7 +36,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
Id = 1,
IsDefault = true,
Checked = true,
- DisplayPriority = 1,
+ DisplayPriority = 0,
Name = "Default",
Description = "Default description",
WindowCaption = "N/A",
@@ -104,6 +108,32 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
]
);
+ modelBuilder
+ .Entity()
+ .HasData(
+ new Theme
+ {
+ Id = 1,
+ Name = "Default",
+ Background = "SystemAltHighColor",
+ Highlight = "SystemAccentColor",
+ },
+ new Theme
+ {
+ Id = 2,
+ Name = "Light",
+ Background = "White",
+ Highlight = "Yellow",
+ },
+ new Theme
+ {
+ Id = 3,
+ Name = "Dark",
+ Background = "Black",
+ Highlight = "#3700b3",
+ }
+ );
+
modelBuilder
.Entity()
.HasData(
diff --git a/YMouseButtonControl.DataAccess/Migrations/20241207140626_Initial.Designer.cs b/YMouseButtonControl.DataAccess/Migrations/20241207140626_Initial.Designer.cs
new file mode 100644
index 0000000..c437681
--- /dev/null
+++ b/YMouseButtonControl.DataAccess/Migrations/20241207140626_Initial.Designer.cs
@@ -0,0 +1,349 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using YMouseButtonControl.Infrastructure.Context;
+
+#nullable disable
+
+namespace YMouseButtonControl.Infrastructure.Migrations
+{
+ [DbContext(typeof(YMouseButtonControlDbContext))]
+ [Migration("20241207140626_Initial")]
+ partial class Initial
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.11");
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.ButtonMapping", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AutoRepeatDelay")
+ .HasColumnType("INTEGER");
+
+ b.Property("AutoRepeatRandomizeDelayEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("BlockOriginalMouseInput")
+ .HasColumnType("INTEGER");
+
+ b.Property("ButtonMappingType")
+ .HasColumnType("INTEGER");
+
+ b.Property("Discriminator")
+ .IsRequired()
+ .HasMaxLength(21)
+ .HasColumnType("TEXT");
+
+ b.Property("Keys")
+ .HasColumnType("TEXT");
+
+ b.Property("MouseButton")
+ .HasColumnType("INTEGER");
+
+ b.Property("ProfileId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Selected")
+ .HasColumnType("INTEGER");
+
+ b.Property("SimulatedKeystrokeType")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProfileId");
+
+ b.ToTable("ButtonMappings");
+
+ b.HasDiscriminator().HasValue("ButtonMapping");
+
+ b.UseTphMappingStrategy();
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Profile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Checked")
+ .HasColumnType("INTEGER");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("DisplayPriority")
+ .HasColumnType("INTEGER");
+
+ b.Property("IsDefault")
+ .HasColumnType("INTEGER");
+
+ b.Property("MatchType")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ParentClass")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Process")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("WindowCaption")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("WindowClass")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Profiles");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Checked = true,
+ Description = "Default description",
+ DisplayPriority = 1,
+ IsDefault = true,
+ MatchType = "N/A",
+ Name = "Default",
+ ParentClass = "N/A",
+ Process = "*",
+ WindowCaption = "N/A",
+ WindowClass = "N/A"
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Setting", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Discriminator")
+ .IsRequired()
+ .HasMaxLength(13)
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Settings");
+
+ b.HasDiscriminator().HasValue("Setting");
+
+ b.UseTphMappingStrategy();
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Theme", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Background")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Highlight")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Themes");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.DisabledMapping", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("DisabledMapping");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.NothingMapping", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("NothingMapping");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ ButtonMappingType = 0,
+ MouseButton = 0,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 2,
+ ButtonMappingType = 0,
+ MouseButton = 1,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 3,
+ ButtonMappingType = 0,
+ MouseButton = 2,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 4,
+ ButtonMappingType = 0,
+ MouseButton = 3,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 5,
+ ButtonMappingType = 0,
+ MouseButton = 4,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 6,
+ ButtonMappingType = 0,
+ MouseButton = 5,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 7,
+ ButtonMappingType = 0,
+ MouseButton = 6,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 8,
+ ButtonMappingType = 0,
+ MouseButton = 7,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 9,
+ ButtonMappingType = 0,
+ MouseButton = 8,
+ ProfileId = 1,
+ Selected = false
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.RightClick", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("RightClick");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SimulatedKeystroke", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("SimulatedKeystroke");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SettingBool", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.Setting");
+
+ b.Property("BoolValue")
+ .HasColumnType("INTEGER");
+
+ b.HasDiscriminator().HasValue("SettingBool");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Name = "StartMinimized",
+ BoolValue = false
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SettingInt", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.Setting");
+
+ b.Property("IntValue")
+ .HasColumnType("INTEGER");
+
+ b.HasDiscriminator().HasValue("SettingInt");
+
+ b.HasData(
+ new
+ {
+ Id = 2,
+ Name = "Theme",
+ IntValue = 3
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SettingString", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.Setting");
+
+ b.Property("StringValue")
+ .HasColumnType("TEXT");
+
+ b.HasDiscriminator().HasValue("SettingString");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.ButtonMapping", b =>
+ {
+ b.HasOne("YMouseButtonControl.Domain.Models.Profile", "Profile")
+ .WithMany("ButtonMappings")
+ .HasForeignKey("ProfileId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Profile");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Profile", b =>
+ {
+ b.Navigation("ButtonMappings");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/YMouseButtonControl.DataAccess/Migrations/20241207140626_Initial.cs b/YMouseButtonControl.DataAccess/Migrations/20241207140626_Initial.cs
new file mode 100644
index 0000000..6833617
--- /dev/null
+++ b/YMouseButtonControl.DataAccess/Migrations/20241207140626_Initial.cs
@@ -0,0 +1,150 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
+
+namespace YMouseButtonControl.Infrastructure.Migrations
+{
+ ///
+ public partial class Initial : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.CreateTable(
+ name: "Profiles",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ IsDefault = table.Column(type: "INTEGER", nullable: false),
+ Checked = table.Column(type: "INTEGER", nullable: false),
+ DisplayPriority = table.Column(type: "INTEGER", nullable: false),
+ Name = table.Column(type: "TEXT", nullable: false),
+ Description = table.Column(type: "TEXT", nullable: false),
+ WindowCaption = table.Column(type: "TEXT", nullable: false),
+ Process = table.Column(type: "TEXT", nullable: false),
+ WindowClass = table.Column(type: "TEXT", nullable: false),
+ ParentClass = table.Column(type: "TEXT", nullable: false),
+ MatchType = table.Column(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Profiles", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Settings",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Name = table.Column(type: "TEXT", nullable: false),
+ Discriminator = table.Column(type: "TEXT", maxLength: 13, nullable: false),
+ BoolValue = table.Column(type: "INTEGER", nullable: true),
+ IntValue = table.Column(type: "INTEGER", nullable: true),
+ StringValue = table.Column(type: "TEXT", nullable: true)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Settings", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "Themes",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Name = table.Column(type: "TEXT", nullable: false),
+ Background = table.Column(type: "TEXT", nullable: false),
+ Highlight = table.Column(type: "TEXT", nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_Themes", x => x.Id);
+ });
+
+ migrationBuilder.CreateTable(
+ name: "ButtonMappings",
+ columns: table => new
+ {
+ Id = table.Column(type: "INTEGER", nullable: false)
+ .Annotation("Sqlite:Autoincrement", true),
+ Keys = table.Column(type: "TEXT", nullable: true),
+ MouseButton = table.Column(type: "INTEGER", nullable: false),
+ ProfileId = table.Column(type: "INTEGER", nullable: false),
+ SimulatedKeystrokeType = table.Column(type: "INTEGER", nullable: true),
+ AutoRepeatDelay = table.Column(type: "INTEGER", nullable: true),
+ AutoRepeatRandomizeDelayEnabled = table.Column(type: "INTEGER", nullable: true),
+ Selected = table.Column(type: "INTEGER", nullable: false),
+ BlockOriginalMouseInput = table.Column(type: "INTEGER", nullable: true),
+ ButtonMappingType = table.Column(type: "INTEGER", nullable: false),
+ Discriminator = table.Column(type: "TEXT", maxLength: 21, nullable: false)
+ },
+ constraints: table =>
+ {
+ table.PrimaryKey("PK_ButtonMappings", x => x.Id);
+ table.ForeignKey(
+ name: "FK_ButtonMappings_Profiles_ProfileId",
+ column: x => x.ProfileId,
+ principalTable: "Profiles",
+ principalColumn: "Id",
+ onDelete: ReferentialAction.Cascade);
+ });
+
+ migrationBuilder.InsertData(
+ table: "Profiles",
+ columns: new[] { "Id", "Checked", "Description", "DisplayPriority", "IsDefault", "MatchType", "Name", "ParentClass", "Process", "WindowCaption", "WindowClass" },
+ values: new object[] { 1, true, "Default description", 1, true, "N/A", "Default", "N/A", "*", "N/A", "N/A" });
+
+ migrationBuilder.InsertData(
+ table: "Settings",
+ columns: new[] { "Id", "BoolValue", "Discriminator", "Name" },
+ values: new object[] { 1, false, "SettingBool", "StartMinimized" });
+
+ migrationBuilder.InsertData(
+ table: "Settings",
+ columns: new[] { "Id", "Discriminator", "IntValue", "Name" },
+ values: new object[] { 2, "SettingInt", 3, "Theme" });
+
+ migrationBuilder.InsertData(
+ table: "ButtonMappings",
+ columns: new[] { "Id", "AutoRepeatDelay", "AutoRepeatRandomizeDelayEnabled", "BlockOriginalMouseInput", "ButtonMappingType", "Discriminator", "Keys", "MouseButton", "ProfileId", "Selected", "SimulatedKeystrokeType" },
+ values: new object[,]
+ {
+ { 1, null, null, null, 0, "NothingMapping", null, 0, 1, false, null },
+ { 2, null, null, null, 0, "NothingMapping", null, 1, 1, false, null },
+ { 3, null, null, null, 0, "NothingMapping", null, 2, 1, false, null },
+ { 4, null, null, null, 0, "NothingMapping", null, 3, 1, false, null },
+ { 5, null, null, null, 0, "NothingMapping", null, 4, 1, false, null },
+ { 6, null, null, null, 0, "NothingMapping", null, 5, 1, false, null },
+ { 7, null, null, null, 0, "NothingMapping", null, 6, 1, false, null },
+ { 8, null, null, null, 0, "NothingMapping", null, 7, 1, false, null },
+ { 9, null, null, null, 0, "NothingMapping", null, 8, 1, false, null }
+ });
+
+ migrationBuilder.CreateIndex(
+ name: "IX_ButtonMappings_ProfileId",
+ table: "ButtonMappings",
+ column: "ProfileId");
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DropTable(
+ name: "ButtonMappings");
+
+ migrationBuilder.DropTable(
+ name: "Settings");
+
+ migrationBuilder.DropTable(
+ name: "Themes");
+
+ migrationBuilder.DropTable(
+ name: "Profiles");
+ }
+ }
+}
diff --git a/YMouseButtonControl.DataAccess/Migrations/20241207141716_AddThemes.Designer.cs b/YMouseButtonControl.DataAccess/Migrations/20241207141716_AddThemes.Designer.cs
new file mode 100644
index 0000000..b965823
--- /dev/null
+++ b/YMouseButtonControl.DataAccess/Migrations/20241207141716_AddThemes.Designer.cs
@@ -0,0 +1,372 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using YMouseButtonControl.Infrastructure.Context;
+
+#nullable disable
+
+namespace YMouseButtonControl.Infrastructure.Migrations
+{
+ [DbContext(typeof(YMouseButtonControlDbContext))]
+ [Migration("20241207141716_AddThemes")]
+ partial class AddThemes
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.11");
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.ButtonMapping", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AutoRepeatDelay")
+ .HasColumnType("INTEGER");
+
+ b.Property("AutoRepeatRandomizeDelayEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("BlockOriginalMouseInput")
+ .HasColumnType("INTEGER");
+
+ b.Property("ButtonMappingType")
+ .HasColumnType("INTEGER");
+
+ b.Property("Discriminator")
+ .IsRequired()
+ .HasMaxLength(21)
+ .HasColumnType("TEXT");
+
+ b.Property("Keys")
+ .HasColumnType("TEXT");
+
+ b.Property("MouseButton")
+ .HasColumnType("INTEGER");
+
+ b.Property("ProfileId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Selected")
+ .HasColumnType("INTEGER");
+
+ b.Property("SimulatedKeystrokeType")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProfileId");
+
+ b.ToTable("ButtonMappings");
+
+ b.HasDiscriminator().HasValue("ButtonMapping");
+
+ b.UseTphMappingStrategy();
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Profile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Checked")
+ .HasColumnType("INTEGER");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("DisplayPriority")
+ .HasColumnType("INTEGER");
+
+ b.Property("IsDefault")
+ .HasColumnType("INTEGER");
+
+ b.Property("MatchType")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ParentClass")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Process")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("WindowCaption")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("WindowClass")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Profiles");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Checked = true,
+ Description = "Default description",
+ DisplayPriority = 1,
+ IsDefault = true,
+ MatchType = "N/A",
+ Name = "Default",
+ ParentClass = "N/A",
+ Process = "*",
+ WindowCaption = "N/A",
+ WindowClass = "N/A"
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Setting", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Discriminator")
+ .IsRequired()
+ .HasMaxLength(13)
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Settings");
+
+ b.HasDiscriminator().HasValue("Setting");
+
+ b.UseTphMappingStrategy();
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Theme", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Background")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Highlight")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Themes");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Background = "SystemAltHighColor",
+ Highlight = "SystemAccentColor",
+ Name = "Default"
+ },
+ new
+ {
+ Id = 2,
+ Background = "White",
+ Highlight = "Yellow",
+ Name = "Light"
+ },
+ new
+ {
+ Id = 3,
+ Background = "Black",
+ Highlight = "#3700b3",
+ Name = "Dark"
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.DisabledMapping", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("DisabledMapping");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.NothingMapping", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("NothingMapping");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ ButtonMappingType = 0,
+ MouseButton = 0,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 2,
+ ButtonMappingType = 0,
+ MouseButton = 1,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 3,
+ ButtonMappingType = 0,
+ MouseButton = 2,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 4,
+ ButtonMappingType = 0,
+ MouseButton = 3,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 5,
+ ButtonMappingType = 0,
+ MouseButton = 4,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 6,
+ ButtonMappingType = 0,
+ MouseButton = 5,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 7,
+ ButtonMappingType = 0,
+ MouseButton = 6,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 8,
+ ButtonMappingType = 0,
+ MouseButton = 7,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 9,
+ ButtonMappingType = 0,
+ MouseButton = 8,
+ ProfileId = 1,
+ Selected = false
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.RightClick", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("RightClick");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SimulatedKeystroke", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("SimulatedKeystroke");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SettingBool", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.Setting");
+
+ b.Property("BoolValue")
+ .HasColumnType("INTEGER");
+
+ b.HasDiscriminator().HasValue("SettingBool");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Name = "StartMinimized",
+ BoolValue = false
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SettingInt", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.Setting");
+
+ b.Property("IntValue")
+ .HasColumnType("INTEGER");
+
+ b.HasDiscriminator().HasValue("SettingInt");
+
+ b.HasData(
+ new
+ {
+ Id = 2,
+ Name = "Theme",
+ IntValue = 3
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SettingString", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.Setting");
+
+ b.Property("StringValue")
+ .HasColumnType("TEXT");
+
+ b.HasDiscriminator().HasValue("SettingString");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.ButtonMapping", b =>
+ {
+ b.HasOne("YMouseButtonControl.Domain.Models.Profile", "Profile")
+ .WithMany("ButtonMappings")
+ .HasForeignKey("ProfileId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Profile");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Profile", b =>
+ {
+ b.Navigation("ButtonMappings");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/YMouseButtonControl.DataAccess/Migrations/20241207141716_AddThemes.cs b/YMouseButtonControl.DataAccess/Migrations/20241207141716_AddThemes.cs
new file mode 100644
index 0000000..81f279a
--- /dev/null
+++ b/YMouseButtonControl.DataAccess/Migrations/20241207141716_AddThemes.cs
@@ -0,0 +1,45 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
+
+namespace YMouseButtonControl.Infrastructure.Migrations
+{
+ ///
+ public partial class AddThemes : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.InsertData(
+ table: "Themes",
+ columns: new[] { "Id", "Background", "Highlight", "Name" },
+ values: new object[,]
+ {
+ { 1, "SystemAltHighColor", "SystemAccentColor", "Default" },
+ { 2, "White", "Yellow", "Light" },
+ { 3, "Black", "#3700b3", "Dark" }
+ });
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.DeleteData(
+ table: "Themes",
+ keyColumn: "Id",
+ keyValue: 1);
+
+ migrationBuilder.DeleteData(
+ table: "Themes",
+ keyColumn: "Id",
+ keyValue: 2);
+
+ migrationBuilder.DeleteData(
+ table: "Themes",
+ keyColumn: "Id",
+ keyValue: 3);
+ }
+ }
+}
diff --git a/YMouseButtonControl.DataAccess/Migrations/20241207142135_CorrectDefaultProfileDisplayPriority.Designer.cs b/YMouseButtonControl.DataAccess/Migrations/20241207142135_CorrectDefaultProfileDisplayPriority.Designer.cs
new file mode 100644
index 0000000..b3fbfff
--- /dev/null
+++ b/YMouseButtonControl.DataAccess/Migrations/20241207142135_CorrectDefaultProfileDisplayPriority.Designer.cs
@@ -0,0 +1,372 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using YMouseButtonControl.Infrastructure.Context;
+
+#nullable disable
+
+namespace YMouseButtonControl.Infrastructure.Migrations
+{
+ [DbContext(typeof(YMouseButtonControlDbContext))]
+ [Migration("20241207142135_CorrectDefaultProfileDisplayPriority")]
+ partial class CorrectDefaultProfileDisplayPriority
+ {
+ ///
+ protected override void BuildTargetModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.11");
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.ButtonMapping", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AutoRepeatDelay")
+ .HasColumnType("INTEGER");
+
+ b.Property("AutoRepeatRandomizeDelayEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("BlockOriginalMouseInput")
+ .HasColumnType("INTEGER");
+
+ b.Property("ButtonMappingType")
+ .HasColumnType("INTEGER");
+
+ b.Property("Discriminator")
+ .IsRequired()
+ .HasMaxLength(21)
+ .HasColumnType("TEXT");
+
+ b.Property("Keys")
+ .HasColumnType("TEXT");
+
+ b.Property("MouseButton")
+ .HasColumnType("INTEGER");
+
+ b.Property("ProfileId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Selected")
+ .HasColumnType("INTEGER");
+
+ b.Property("SimulatedKeystrokeType")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProfileId");
+
+ b.ToTable("ButtonMappings");
+
+ b.HasDiscriminator().HasValue("ButtonMapping");
+
+ b.UseTphMappingStrategy();
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Profile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Checked")
+ .HasColumnType("INTEGER");
+
+ b.Property("Description")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("DisplayPriority")
+ .HasColumnType("INTEGER");
+
+ b.Property("IsDefault")
+ .HasColumnType("INTEGER");
+
+ b.Property("MatchType")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("ParentClass")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Process")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("WindowCaption")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("WindowClass")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Profiles");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Checked = true,
+ Description = "Default description",
+ DisplayPriority = 0,
+ IsDefault = true,
+ MatchType = "N/A",
+ Name = "Default",
+ ParentClass = "N/A",
+ Process = "*",
+ WindowCaption = "N/A",
+ WindowClass = "N/A"
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Setting", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Discriminator")
+ .IsRequired()
+ .HasMaxLength(13)
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Settings");
+
+ b.HasDiscriminator().HasValue("Setting");
+
+ b.UseTphMappingStrategy();
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Theme", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Background")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Highlight")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.Property("Name")
+ .IsRequired()
+ .HasColumnType("TEXT");
+
+ b.HasKey("Id");
+
+ b.ToTable("Themes");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Background = "SystemAltHighColor",
+ Highlight = "SystemAccentColor",
+ Name = "Default"
+ },
+ new
+ {
+ Id = 2,
+ Background = "White",
+ Highlight = "Yellow",
+ Name = "Light"
+ },
+ new
+ {
+ Id = 3,
+ Background = "Black",
+ Highlight = "#3700b3",
+ Name = "Dark"
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.DisabledMapping", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("DisabledMapping");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.NothingMapping", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("NothingMapping");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ ButtonMappingType = 0,
+ MouseButton = 0,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 2,
+ ButtonMappingType = 0,
+ MouseButton = 1,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 3,
+ ButtonMappingType = 0,
+ MouseButton = 2,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 4,
+ ButtonMappingType = 0,
+ MouseButton = 3,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 5,
+ ButtonMappingType = 0,
+ MouseButton = 4,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 6,
+ ButtonMappingType = 0,
+ MouseButton = 5,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 7,
+ ButtonMappingType = 0,
+ MouseButton = 6,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 8,
+ ButtonMappingType = 0,
+ MouseButton = 7,
+ ProfileId = 1,
+ Selected = false
+ },
+ new
+ {
+ Id = 9,
+ ButtonMappingType = 0,
+ MouseButton = 8,
+ ProfileId = 1,
+ Selected = false
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.RightClick", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("RightClick");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SimulatedKeystroke", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.ButtonMapping");
+
+ b.HasDiscriminator().HasValue("SimulatedKeystroke");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SettingBool", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.Setting");
+
+ b.Property("BoolValue")
+ .HasColumnType("INTEGER");
+
+ b.HasDiscriminator().HasValue("SettingBool");
+
+ b.HasData(
+ new
+ {
+ Id = 1,
+ Name = "StartMinimized",
+ BoolValue = false
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SettingInt", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.Setting");
+
+ b.Property("IntValue")
+ .HasColumnType("INTEGER");
+
+ b.HasDiscriminator().HasValue("SettingInt");
+
+ b.HasData(
+ new
+ {
+ Id = 2,
+ Name = "Theme",
+ IntValue = 3
+ });
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.SettingString", b =>
+ {
+ b.HasBaseType("YMouseButtonControl.Domain.Models.Setting");
+
+ b.Property("StringValue")
+ .HasColumnType("TEXT");
+
+ b.HasDiscriminator().HasValue("SettingString");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.ButtonMapping", b =>
+ {
+ b.HasOne("YMouseButtonControl.Domain.Models.Profile", "Profile")
+ .WithMany("ButtonMappings")
+ .HasForeignKey("ProfileId")
+ .OnDelete(DeleteBehavior.Cascade)
+ .IsRequired();
+
+ b.Navigation("Profile");
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Profile", b =>
+ {
+ b.Navigation("ButtonMappings");
+ });
+#pragma warning restore 612, 618
+ }
+ }
+}
diff --git a/YMouseButtonControl.DataAccess/Migrations/20241207142135_CorrectDefaultProfileDisplayPriority.cs b/YMouseButtonControl.DataAccess/Migrations/20241207142135_CorrectDefaultProfileDisplayPriority.cs
new file mode 100644
index 0000000..7f1d4d2
--- /dev/null
+++ b/YMouseButtonControl.DataAccess/Migrations/20241207142135_CorrectDefaultProfileDisplayPriority.cs
@@ -0,0 +1,32 @@
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace YMouseButtonControl.Infrastructure.Migrations
+{
+ ///
+ public partial class CorrectDefaultProfileDisplayPriority : Migration
+ {
+ ///
+ protected override void Up(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.UpdateData(
+ table: "Profiles",
+ keyColumn: "Id",
+ keyValue: 1,
+ column: "DisplayPriority",
+ value: 0);
+ }
+
+ ///
+ protected override void Down(MigrationBuilder migrationBuilder)
+ {
+ migrationBuilder.UpdateData(
+ table: "Profiles",
+ keyColumn: "Id",
+ keyValue: 1,
+ column: "DisplayPriority",
+ value: 1);
+ }
+ }
+}
diff --git a/YMouseButtonControl.DataAccess/Migrations/YMouseButtonControlDbContextModelSnapshot.cs b/YMouseButtonControl.DataAccess/Migrations/YMouseButtonControlDbContextModelSnapshot.cs
new file mode 100644
index 0000000..e0ff4ed
--- /dev/null
+++ b/YMouseButtonControl.DataAccess/Migrations/YMouseButtonControlDbContextModelSnapshot.cs
@@ -0,0 +1,369 @@
+//
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using YMouseButtonControl.Infrastructure.Context;
+
+#nullable disable
+
+namespace YMouseButtonControl.Infrastructure.Migrations
+{
+ [DbContext(typeof(YMouseButtonControlDbContext))]
+ partial class YMouseButtonControlDbContextModelSnapshot : ModelSnapshot
+ {
+ protected override void BuildModel(ModelBuilder modelBuilder)
+ {
+#pragma warning disable 612, 618
+ modelBuilder.HasAnnotation("ProductVersion", "8.0.11");
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.ButtonMapping", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("AutoRepeatDelay")
+ .HasColumnType("INTEGER");
+
+ b.Property("AutoRepeatRandomizeDelayEnabled")
+ .HasColumnType("INTEGER");
+
+ b.Property("BlockOriginalMouseInput")
+ .HasColumnType("INTEGER");
+
+ b.Property("ButtonMappingType")
+ .HasColumnType("INTEGER");
+
+ b.Property("Discriminator")
+ .IsRequired()
+ .HasMaxLength(21)
+ .HasColumnType("TEXT");
+
+ b.Property("Keys")
+ .HasColumnType("TEXT");
+
+ b.Property("MouseButton")
+ .HasColumnType("INTEGER");
+
+ b.Property("ProfileId")
+ .HasColumnType("INTEGER");
+
+ b.Property("Selected")
+ .HasColumnType("INTEGER");
+
+ b.Property("SimulatedKeystrokeType")
+ .HasColumnType("INTEGER");
+
+ b.HasKey("Id");
+
+ b.HasIndex("ProfileId");
+
+ b.ToTable("ButtonMappings");
+
+ b.HasDiscriminator().HasValue("ButtonMapping");
+
+ b.UseTphMappingStrategy();
+ });
+
+ modelBuilder.Entity("YMouseButtonControl.Domain.Models.Profile", b =>
+ {
+ b.Property("Id")
+ .ValueGeneratedOnAdd()
+ .HasColumnType("INTEGER");
+
+ b.Property("Checked")
+ .HasColumnType("INTEGER");
+
+ b.Property