Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
9ca0905
wip
FaithBeam Dec 6, 2024
7cd32e6
wip
FaithBeam Dec 7, 2024
b2ab9fa
wip
FaithBeam Dec 7, 2024
28b288e
wip
FaithBeam Dec 15, 2024
2b1983e
fixed canapply
FaithBeam Dec 18, 2024
04bf7d4
initial
FaithBeam Dec 21, 2024
05cd55b
up
FaithBeam Dec 21, 2024
f6274cb
Create button mappings in a function
FaithBeam Dec 21, 2024
dfd3d76
Default sort by process name
FaithBeam Dec 21, 2024
b3c8aca
up
FaithBeam Dec 21, 2024
5b6f00c
Moved startmenu services
FaithBeam Dec 22, 2024
ff5af68
Add StartMinimized Query
FaithBeam Dec 22, 2024
396041d
change these to use handlers
FaithBeam Dec 22, 2024
e94c9cb
theme variant
FaithBeam Dec 22, 2024
abde216
Startup installer
FaithBeam Dec 22, 2024
94fdd54
remove unused interface
FaithBeam Dec 22, 2024
4efd37c
wip
FaithBeam Dec 23, 2024
dc21e55
more
FaithBeam Dec 24, 2024
b78b6b0
Move profile up
FaithBeam Dec 24, 2024
9b2598d
Move profile down
FaithBeam Dec 24, 2024
a137f05
Export profile
FaithBeam Dec 24, 2024
017eb97
Rename ProfilesService to ProfilesCache
FaithBeam Dec 24, 2024
054aee6
Import and export profiles
FaithBeam Dec 24, 2024
5e2e1fe
cleanup
FaithBeam Dec 24, 2024
9d2669a
Is cache dirty
FaithBeam Dec 24, 2024
123b854
ApplyProfiles
FaithBeam Dec 24, 2024
f459b90
Profiles information
FaithBeam Dec 24, 2024
370604b
Smoother process enumeration for add profile dialog
FaithBeam Dec 24, 2024
957a44c
Move stuff
FaithBeam Dec 25, 2024
e6a7b14
Removed os specific projects because its not needed
FaithBeam Dec 25, 2024
8ae476d
no need for multiple backgroundtaskrunner classes
FaithBeam Dec 25, 2024
ee5a471
more cleanup
FaithBeam Dec 25, 2024
a3be882
remove profile repo
FaithBeam Dec 25, 2024
3b05a37
more cleanup
FaithBeam Dec 25, 2024
b96a80f
Use compiled bindings
FaithBeam Dec 25, 2024
132157f
fix error
FaithBeam Dec 26, 2024
c2ce1a9
Use my own mappings instead of mapperly
FaithBeam Dec 26, 2024
26358ce
remove tests for now
FaithBeam Dec 26, 2024
eab9b3d
fix namespaces
FaithBeam Dec 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

179 changes: 157 additions & 22 deletions YMouseButtonControl.Core/Mappings/ButtonMappingMapper.cs
Original file line number Diff line number Diff line change
@@ -1,33 +1,168 @@
using System;
using Riok.Mapperly.Abstractions;
using YMouseButtonControl.Core.ViewModels.Models;
using YMouseButtonControl.DataAccess.Models;
using YMouseButtonControl.Domain.Models;

namespace YMouseButtonControl.Core.Mappings;

[Mapper]
public static partial class ButtonMappingMapper
public static class ButtonMappingMapper
{
[MapDerivedType<DisabledMapping, DisabledMappingVm>]
[MapDerivedType<NothingMapping, NothingMappingVm>]
[MapDerivedType<SimulatedKeystroke, SimulatedKeystrokeVm>]
[MapDerivedType<RightClick, RightClickVm>]
public static partial BaseButtonMappingVm Map(ButtonMapping? buttonMapping);

[MapDerivedType<DisabledMappingVm, DisabledMapping>]
[MapDerivedType<NothingMappingVm, NothingMapping>]
[MapDerivedType<SimulatedKeystrokeVm, SimulatedKeystroke>]
[MapDerivedType<RightClickVm, RightClick>]
public static partial ButtonMapping Map(BaseButtonMappingVm buttonMapping);

[MapDerivedType<DisabledMappingVm, DisabledMapping>]
[MapDerivedType<NothingMappingVm, NothingMapping>]
[MapDerivedType<SimulatedKeystrokeVm, SimulatedKeystroke>]
[MapDerivedType<RightClickVm, RightClick>]
public static partial void Map(BaseButtonMappingVm src, ButtonMapping dst);
public static BaseButtonMappingVm MapToViewModel(ButtonMapping buttonMapping)
{
return buttonMapping switch
{
DisabledMapping disabledMapping => MapDisabledMapping(disabledMapping),
NothingMapping nothingMapping => MapNothingMapping(nothingMapping),
SimulatedKeystroke simulatedKeystroke => MapSimulatedKeystroke(simulatedKeystroke),
RightClick rightClick => MapRightClick(rightClick),
_ => throw new InvalidOperationException("Unknown button mapping type"),
};
}

private static DisabledMappingVm MapDisabledMapping(DisabledMapping disabledMapping) =>
new()
{
Id = disabledMapping.Id,
ProfileId = disabledMapping.ProfileId,
MouseButton = disabledMapping.MouseButton,
Keys = disabledMapping.Keys,
AutoRepeatDelay = disabledMapping.AutoRepeatDelay,
AutoRepeatRandomizeDelayEnabled = disabledMapping.AutoRepeatRandomizeDelayEnabled,
BlockOriginalMouseInput = disabledMapping.BlockOriginalMouseInput,
Selected = disabledMapping.Selected,
};

private static NothingMappingVm MapNothingMapping(NothingMapping nothingMapping) =>
new()
{
Id = nothingMapping.Id,
ProfileId = nothingMapping.ProfileId,
MouseButton = nothingMapping.MouseButton,
Keys = nothingMapping.Keys,
AutoRepeatDelay = nothingMapping.AutoRepeatDelay,
AutoRepeatRandomizeDelayEnabled = nothingMapping.AutoRepeatRandomizeDelayEnabled,
BlockOriginalMouseInput = nothingMapping.BlockOriginalMouseInput,
Selected = nothingMapping.Selected,
};

private static SimulatedKeystrokeVm MapSimulatedKeystroke(SimulatedKeystroke simulatedKeystroke)
{
var viewModel = new SimulatedKeystrokeVm
{
Id = simulatedKeystroke.Id,
ProfileId = simulatedKeystroke.ProfileId,
MouseButton = simulatedKeystroke.MouseButton,
Keys = simulatedKeystroke.Keys,
AutoRepeatDelay = simulatedKeystroke.AutoRepeatDelay,
AutoRepeatRandomizeDelayEnabled = simulatedKeystroke.AutoRepeatRandomizeDelayEnabled,
BlockOriginalMouseInput = simulatedKeystroke.BlockOriginalMouseInput,
Selected = simulatedKeystroke.Selected,
};

if (simulatedKeystroke.SimulatedKeystrokeType != null)
{
viewModel.SimulatedKeystrokeType = MapSimulatedKeystrokeType(
simulatedKeystroke.SimulatedKeystrokeType
);
}

return viewModel;
}

private static RightClickVm MapRightClick(RightClick rightClick) =>
new()
{
Id = rightClick.Id,
ProfileId = rightClick.ProfileId,
MouseButton = rightClick.MouseButton,
Keys = rightClick.Keys,
AutoRepeatDelay = rightClick.AutoRepeatDelay,
AutoRepeatRandomizeDelayEnabled = rightClick.AutoRepeatRandomizeDelayEnabled,
BlockOriginalMouseInput = rightClick.BlockOriginalMouseInput,
Selected = rightClick.Selected,
};

public static ButtonMapping MapToEntity(BaseButtonMappingVm buttonMappingVm)
{
return buttonMappingVm switch
{
DisabledMappingVm disabledMappingVm => MapDisabledMappingVm(disabledMappingVm),
NothingMappingVm nothingMappingVm => MapNothingMappingVm(nothingMappingVm),
SimulatedKeystrokeVm simulatedKeystrokeVm => MapSimulatedKeystrokeVm(
simulatedKeystrokeVm
),
RightClickVm rightClickVm => MapRightClickVm(rightClickVm),
_ => throw new InvalidOperationException("Unknown button mapping VM type"),
};
}

private static DisabledMapping MapDisabledMappingVm(DisabledMappingVm disabledMappingVm) =>
new()
{
Id = disabledMappingVm.Id,
ProfileId = disabledMappingVm.ProfileId,
MouseButton = disabledMappingVm.MouseButton,
Keys = disabledMappingVm.Keys,
AutoRepeatDelay = disabledMappingVm.AutoRepeatDelay,
AutoRepeatRandomizeDelayEnabled = disabledMappingVm.AutoRepeatRandomizeDelayEnabled,
BlockOriginalMouseInput = disabledMappingVm.BlockOriginalMouseInput,
Selected = disabledMappingVm.Selected,
};

private static NothingMapping MapNothingMappingVm(NothingMappingVm nothingMappingVm) =>
new()
{
Id = nothingMappingVm.Id,
ProfileId = nothingMappingVm.ProfileId,
MouseButton = nothingMappingVm.MouseButton,
Keys = nothingMappingVm.Keys,
AutoRepeatDelay = nothingMappingVm.AutoRepeatDelay,
AutoRepeatRandomizeDelayEnabled = nothingMappingVm.AutoRepeatRandomizeDelayEnabled,
BlockOriginalMouseInput = nothingMappingVm.BlockOriginalMouseInput,
Selected = nothingMappingVm.Selected,
};

private static SimulatedKeystroke MapSimulatedKeystrokeVm(
SimulatedKeystrokeVm simulatedKeystrokeVm
)
{
var entity = new SimulatedKeystroke
{
Id = simulatedKeystrokeVm.Id,
ProfileId = simulatedKeystrokeVm.ProfileId,
MouseButton = simulatedKeystrokeVm.MouseButton,
Keys = simulatedKeystrokeVm.Keys,
AutoRepeatDelay = simulatedKeystrokeVm.AutoRepeatDelay,
AutoRepeatRandomizeDelayEnabled = simulatedKeystrokeVm.AutoRepeatRandomizeDelayEnabled,
BlockOriginalMouseInput = simulatedKeystrokeVm.BlockOriginalMouseInput,
Selected = simulatedKeystrokeVm.Selected,
};

// Assuming BaseSimulatedKeystrokeTypeVm has a method or constructor that can map SimulatedKeystrokeType to it
if (simulatedKeystrokeVm.SimulatedKeystrokeType != null)
{
entity.SimulatedKeystrokeType = MapSimulatedKeystrokeTypeVm(
simulatedKeystrokeVm.SimulatedKeystrokeType
);
}

return entity;
}

private static RightClick MapRightClickVm(RightClickVm rightClickVm) =>
new()
{
Id = rightClickVm.Id,
ProfileId = rightClickVm.ProfileId,
MouseButton = rightClickVm.MouseButton,
Keys = rightClickVm.Keys,
AutoRepeatDelay = rightClickVm.AutoRepeatDelay,
AutoRepeatRandomizeDelayEnabled = rightClickVm.AutoRepeatRandomizeDelayEnabled,
BlockOriginalMouseInput = rightClickVm.BlockOriginalMouseInput,
Selected = rightClickVm.Selected,
};

public static BaseSimulatedKeystrokeTypeVm MapSimulatedKeystrokeType(
SimulatedKeystrokeType simulatedKeystrokeType
SimulatedKeystrokeType? simulatedKeystrokeType
) =>
simulatedKeystrokeType switch
{
Expand Down
59 changes: 42 additions & 17 deletions YMouseButtonControl.Core/Mappings/ProfileMapper.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
using System.Collections.Generic;
using System.Linq;
using Riok.Mapperly.Abstractions;
using System.Linq;
using YMouseButtonControl.Core.ViewModels.Models;
using YMouseButtonControl.DataAccess.Models;
using YMouseButtonControl.Domain.Models;

namespace YMouseButtonControl.Core.Mappings;

[Mapper]
public static partial class ProfileMapper
public static class ProfileMapper
{
public static partial ProfileVm Map(Profile? profile);
public static ProfileVm MapToViewModel(Profile profile)
{
var buttonMappings = profile
.ButtonMappings.Select(ButtonMappingMapper.MapToViewModel)
.ToList();
var viewModel = new ProfileVm(buttonMappings)
{
Id = profile.Id,
IsDefault = profile.IsDefault,
Checked = profile.Checked,
Name = profile.Name,
Description = profile.Description,
WindowCaption = profile.WindowCaption,
Process = profile.Process,
WindowClass = profile.WindowClass,
ParentClass = profile.ParentClass,
MatchType = profile.MatchType,
DisplayPriority = profile.DisplayPriority,
};

public static partial Profile Map(ProfileVm vm);
return viewModel;
}

public static partial void Map(ProfileVm src, Profile dst);

private static List<BaseButtonMappingVm> MapButtonMapping(
ICollection<ButtonMapping> buttonMappings
) => buttonMappings.Select(ButtonMappingMapper.Map).ToList();

private static ICollection<ButtonMapping> MapButtonMappingVms(
List<BaseButtonMappingVm> buttonMappings
) => buttonMappings.Select(ButtonMappingMapper.Map).ToList();
public static Profile MapToEntity(ProfileVm profileVm) =>
new()
{
Id = profileVm.Id,
IsDefault = profileVm.IsDefault,
Checked = profileVm.Checked,
Name = profileVm.Name,
Description = profileVm.Description,
WindowCaption = profileVm.WindowCaption,
Process = profileVm.Process,
WindowClass = profileVm.WindowClass,
ParentClass = profileVm.ParentClass,
MatchType = profileVm.MatchType,
DisplayPriority = profileVm.DisplayPriority,
ButtonMappings = profileVm
.ButtonMappings.Select(ButtonMappingMapper.MapToEntity)
.ToList(),
};
}
24 changes: 0 additions & 24 deletions YMouseButtonControl.Core/Mappings/SettingMapper.cs

This file was deleted.

13 changes: 0 additions & 13 deletions YMouseButtonControl.Core/Mappings/ThemeMapper.cs

This file was deleted.

Loading
Loading