Skip to content

Commit c0df5c2

Browse files
committed
Merge branch 'development'
2 parents b1e39db + f2d51b8 commit c0df5c2

File tree

152 files changed

+846
-712
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

152 files changed

+846
-712
lines changed

src/Artemis.Core/Artemis.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
</ItemGroup>
3636

3737
<ItemGroup>
38-
<PackageReference Include="DryIoc.dll" Version="5.3.4" />
38+
<PackageReference Include="DryIoc.dll" Version="5.4.0" />
3939
<PackageReference Include="EmbedIO" Version="3.5.2" />
4040
<PackageReference Include="HidSharp" Version="2.1.0" />
4141
<PackageReference Include="Humanizer.Core" Version="2.14.1" />

src/Artemis.UI.Linux/App.axaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<Application xmlns="https://github.com/avaloniaui"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:ui="clr-namespace:Artemis.UI;assembly=Artemis.UI"
4+
xmlns:root="clr-namespace:Artemis.UI.Screens.Root;assembly=Artemis.UI"
5+
x:DataType="root:RootViewModel"
46
x:Class="Artemis.UI.Linux.App">
57
<Application.DataTemplates>
68
<ui:ViewLocator />
@@ -12,16 +14,16 @@
1214

1315
<TrayIcon.Icons>
1416
<TrayIcons>
15-
<TrayIcon Icon="avares://Artemis.UI/Assets/Images/Logo/application.ico" ToolTipText="Artemis" Command="{Binding OpenScreen}" CommandParameter="Home">
17+
<TrayIcon Icon="avares://Artemis.UI/Assets/Images/Logo/application.ico" ToolTipText="Artemis" Command="{CompiledBinding OpenScreen}" CommandParameter="Home">
1618
<TrayIcon.Menu>
1719
<NativeMenu>
18-
<NativeMenuItem Header="Home" Command="{Binding OpenScreen}" CommandParameter="Home" />
19-
<!-- <NativeMenuItem Header="Workshop" Command="{Binding OpenScreen}" CommandParameter="Workshop" /> -->
20-
<NativeMenuItem Header="Surface Editor" Command="{Binding OpenScreen}" CommandParameter="Surface Editor" />
21-
<NativeMenuItem Header="Settings" Command="{Binding OpenScreen}" CommandParameter="Settings" />
20+
<NativeMenuItem Header="Home" Command="{CompiledBinding OpenScreen}" CommandParameter="Home" />
21+
<!-- <NativeMenuItem Header="Workshop" Command="{CompiledBinding OpenScreen}" CommandParameter="Workshop" /> -->
22+
<NativeMenuItem Header="Surface Editor" Command="{CompiledBinding OpenScreen}" CommandParameter="Surface Editor" />
23+
<NativeMenuItem Header="Settings" Command="{CompiledBinding OpenScreen}" CommandParameter="Settings" />
2224
<NativeMenuItemSeparator />
23-
<NativeMenuItem Header="Debugger" Command="{Binding OpenDebugger}" />
24-
<NativeMenuItem Header="Exit" Command="{Binding Exit}" />
25+
<NativeMenuItem Header="Debugger" Command="{CompiledBinding OpenDebugger}" />
26+
<NativeMenuItem Header="Exit" Command="{CompiledBinding Exit}" />
2527
</NativeMenu>
2628
</TrayIcon.Menu>
2729
</TrayIcon>

src/Artemis.UI.Linux/App.axaml.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,20 @@ public override void Initialize()
2222
Program.CreateLogger(_container);
2323
RxApp.MainThreadScheduler = AvaloniaScheduler.Instance;
2424
AvaloniaXamlLoader.Load(this);
25-
26-
RegisterProviders();
2725
}
2826

2927
public override void OnFrameworkInitializationCompleted()
3028
{
3129
if (Design.IsDesignMode)
3230
return;
33-
31+
32+
if (ApplicationLifetime is not IClassicDesktopStyleApplicationLifetime desktop)
33+
return;
34+
3435
ArtemisBootstrapper.Initialize();
35-
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
36-
_applicationStateManager = new ApplicationStateManager(_container!, desktop.Args);
36+
37+
_applicationStateManager = new ApplicationStateManager(_container!, desktop.Args);
38+
RegisterProviders();
3739
}
3840

3941
private void RegisterProviders()

src/Artemis.UI.Linux/Artemis.UI.Linux.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
<None Remove=".gitignore" />
1717
</ItemGroup>
1818
<ItemGroup>
19-
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
20-
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
19+
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
20+
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview8" />
2121
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
22-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
23-
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
22+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
23+
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
2424
<PackageReference Include="ReactiveUI" Version="18.4.26" />
2525
</ItemGroup>
2626
<ItemGroup>

src/Artemis.UI.Linux/Providers/Input/Enums/LinuxDeviceType.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
public enum LinuxDeviceType
44
{
5+
Unknown,
56
Keyboard,
67
Mouse,
78
Gamepad

src/Artemis.UI.Linux/Providers/Input/LinuxInputDevice.cs

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,24 @@ public LinuxInputDevice(IEnumerable<string> lines)
1919
switch (dataType)
2020
{
2121
case 'I':
22-
InputId = new LinuxInputId(data);
22+
InputId = data;
2323
break;
2424
case 'N':
2525
Name = data.Replace("\"", "").Replace("Name=", "");
2626
break;
2727
case 'H':
2828
Handlers = data.Replace("Handlers=", "").Split(" ");
2929

30-
if (Handlers?.Any(h => h.Contains("mouse")) == true)
30+
if (Handlers.Any(h => h.Contains("mouse")))
3131
DeviceType = LinuxDeviceType.Mouse;
32-
else if (Handlers?.Any(h => h.Contains("kbd")) == true)
32+
else if (Handlers.Any(h => h.Contains("kbd")))
3333
DeviceType = LinuxDeviceType.Keyboard;
34-
else if (Handlers?.Any(h => h.Contains("js")) == true)
34+
else if (Handlers.Any(h => h.Contains("js")))
3535
DeviceType = LinuxDeviceType.Gamepad;
36+
else
37+
DeviceType = LinuxDeviceType.Unknown;
3638

37-
string evt = Handlers!.First(h => h.Contains("event"));
39+
string evt = Handlers.First(h => h.Contains("event"));
3840

3941
EventPath = $"/dev/input/{evt}";
4042
break;
@@ -45,7 +47,7 @@ public LinuxInputDevice(IEnumerable<string> lines)
4547
throw new ArtemisLinuxInputProviderException("Linux device definition did not contain necessary data");
4648
}
4749

48-
public LinuxInputId InputId { get; }
50+
public string InputId { get; }
4951
public string Name { get; }
5052
public string[] Handlers { get; }
5153
public string EventPath { get; }
@@ -60,29 +62,4 @@ public override string ToString()
6062
}
6163

6264
#endregion
63-
64-
public class LinuxInputId
65-
{
66-
public LinuxInputId(string line)
67-
{
68-
Dictionary<string, string> components = line.Split(" ")
69-
.Select(c => c.Split('='))
70-
.ToDictionary(c => c[0], c => c[1]);
71-
72-
Bus = components["Bus"];
73-
Vendor = components["Vendor"];
74-
Product = components["Product"];
75-
Version = components["Version"];
76-
}
77-
78-
public string Bus { get; }
79-
public string Vendor { get; }
80-
public string Product { get; }
81-
public string Version { get; }
82-
83-
public override string ToString()
84-
{
85-
return $"Bus={Bus} Vendor={Vendor} Product={Product} Version={Version}";
86-
}
87-
}
8865
}

src/Artemis.UI.Linux/Providers/Input/LinuxInputDeviceFinder.cs

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,36 @@ public static class LinuxInputDeviceFinder
1111

1212
public static IEnumerable<LinuxInputDevice> Find()
1313
{
14-
return File.ReadAllLines(DEVICES_FILE)
15-
.PartitionBy(s => s?.Length == 0) //split on empty lines
16-
.Select(lineGroup => new LinuxInputDevice(lineGroup));
14+
IEnumerable<IEnumerable<string>> lineGroups = File.ReadAllLines(DEVICES_FILE).PartitionBy(s => s?.Length == 0); //split on empty lines
15+
16+
foreach (IEnumerable<string> lineGroup in lineGroups)
17+
{
18+
LinuxInputDevice device;
19+
20+
try
21+
{
22+
device = new LinuxInputDevice(lineGroup);
23+
}
24+
catch
25+
{
26+
continue;
27+
//some devices don't have all the required data, we can ignore those
28+
}
29+
30+
if (ShouldReadDevice(device))
31+
{
32+
yield return device;
33+
}
34+
}
35+
}
36+
37+
private static bool ShouldReadDevice(LinuxInputDevice device)
38+
{
39+
if (device.DeviceType == LinuxDeviceType.Unknown)
40+
return false;
41+
//possibly add more checks here
42+
43+
return true;
1744
}
1845

1946
//https://stackoverflow.com/questions/56623354
@@ -34,7 +61,7 @@ private static IEnumerable<IEnumerable<T>> PartitionBy<T>(this IEnumerable<T> a,
3461
return groupNumber;
3562
};
3663
return a
37-
.Select(x => new {Value = x, GroupNumber = getGroupNumber(predicate(x))})
64+
.Select(x => new { Value = x, GroupNumber = getGroupNumber(predicate(x)) })
3865
.Where(x => x.GroupNumber != null)
3966
.GroupBy(x => x.GroupNumber)
4067
.Select(g => g.Select(x => x.Value));

src/Artemis.UI.Linux/Providers/Input/LinuxInputProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ private void HandleKeyboardData(LinuxInputDevice keyboard, LinuxInputEventArgs a
7575

7676
//_logger.Verbose($"Keyboard Key: {(LinuxKeyboardKeyCodes)args.Code} | Down: {isDown}");
7777

78-
LinuxInputDevice.LinuxInputId identifier = keyboard.InputId;
78+
string identifier = keyboard.InputId;
7979
OnIdentifierReceived(identifier, InputDeviceType.Keyboard);
8080
ArtemisDevice? device = null;
8181

@@ -93,7 +93,7 @@ private void HandleKeyboardData(LinuxInputDevice keyboard, LinuxInputEventArgs a
9393

9494
private void HandleMouseData(LinuxInputDevice mouse, LinuxInputEventArgs args)
9595
{
96-
LinuxInputDevice.LinuxInputId identifier = mouse.InputId;
96+
string identifier = mouse.InputId;
9797
OnIdentifierReceived(identifier, InputDeviceType.Mouse);
9898
ArtemisDevice? device = null;
9999

src/Artemis.UI.Linux/Utilities/InputUtilities.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static KeyboardKey KeyFromKeyCode(LinuxKeyboardKeyCodes code)
5252
LinuxKeyboardKeyCodes.KEY_APOSTROPHE => KeyboardKey.OemQuotes,
5353
LinuxKeyboardKeyCodes.KEY_GRAVE => KeyboardKey.OemTilde,
5454
LinuxKeyboardKeyCodes.KEY_LEFTSHIFT => KeyboardKey.LeftShift,
55-
LinuxKeyboardKeyCodes.KEY_BACKSLASH => KeyboardKey.OemBackslash,
55+
LinuxKeyboardKeyCodes.KEY_BACKSLASH => KeyboardKey.OemPipe,
5656
LinuxKeyboardKeyCodes.KEY_Z => KeyboardKey.Z,
5757
LinuxKeyboardKeyCodes.KEY_X => KeyboardKey.X,
5858
LinuxKeyboardKeyCodes.KEY_C => KeyboardKey.C,
@@ -94,7 +94,7 @@ public static KeyboardKey KeyFromKeyCode(LinuxKeyboardKeyCodes code)
9494
LinuxKeyboardKeyCodes.KEY_KP0 => KeyboardKey.NumPad0,
9595
LinuxKeyboardKeyCodes.KEY_KPDOT => KeyboardKey.NumPadDecimal,
9696
// LinuxKeyboardKeyCodes.KEY_ZENKAKUHANKAKU => expr,
97-
// LinuxKeyboardKeyCodes.KEY_102ND => expr,
97+
LinuxKeyboardKeyCodes.KEY_102ND => KeyboardKey.OemBackslash,
9898
LinuxKeyboardKeyCodes.KEY_F11 => KeyboardKey.F11,
9999
LinuxKeyboardKeyCodes.KEY_F12 => KeyboardKey.F12,
100100
//LinuxKeyboardKeyCodes.KEY_RO => expr,

src/Artemis.UI.MacOS/App.axaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<Application xmlns="https://github.com/avaloniaui"
22
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
33
xmlns:ui="clr-namespace:Artemis.UI;assembly=Artemis.UI"
4+
xmlns:root="clr-namespace:Artemis.UI.Screens.Root;assembly=Artemis.UI"
5+
x:DataType="root:RootViewModel"
46
x:Class="Artemis.UI.MacOS.App">
57
<Application.DataTemplates>
68
<ui:ViewLocator />
@@ -12,16 +14,16 @@
1214

1315
<TrayIcon.Icons>
1416
<TrayIcons>
15-
<TrayIcon Icon="avares://Artemis.UI/Assets/Images/Logo/application.ico" ToolTipText="Artemis" Command="{Binding OpenScreen}" CommandParameter="Home">
17+
<TrayIcon Icon="avares://Artemis.UI/Assets/Images/Logo/application.ico" ToolTipText="Artemis" Command="{CompiledBinding OpenScreen}" CommandParameter="Home">
1618
<TrayIcon.Menu>
1719
<NativeMenu>
18-
<NativeMenuItem Header="Home" Command="{Binding OpenScreen}" CommandParameter="Home" />
19-
<!-- <NativeMenuItem Header="Workshop" Command="{Binding OpenScreen}" CommandParameter="Workshop" /> -->
20-
<NativeMenuItem Header="Surface Editor" Command="{Binding OpenScreen}" CommandParameter="Surface Editor" />
21-
<NativeMenuItem Header="Settings" Command="{Binding OpenScreen}" CommandParameter="Settings" />
20+
<NativeMenuItem Header="Home" Command="{CompiledBinding OpenScreen}" CommandParameter="Home" />
21+
<!-- <NativeMenuItem Header="Workshop" Command="{CompiledBinding OpenScreen}" CommandParameter="Workshop" /> -->
22+
<NativeMenuItem Header="Surface Editor" Command="{CompiledBinding OpenScreen}" CommandParameter="Surface Editor" />
23+
<NativeMenuItem Header="Settings" Command="{CompiledBinding OpenScreen}" CommandParameter="Settings" />
2224
<NativeMenuItemSeparator />
23-
<NativeMenuItem Header="Debugger" Command="{Binding OpenDebugger}" />
24-
<NativeMenuItem Header="Exit" Command="{Binding Exit}" />
25+
<NativeMenuItem Header="Debugger" Command="{CompiledBinding OpenDebugger}" />
26+
<NativeMenuItem Header="Exit" Command="{CompiledBinding Exit}" />
2527
</NativeMenu>
2628
</TrayIcon.Menu>
2729
</TrayIcon>

src/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
<None Remove=".gitignore" />
1616
</ItemGroup>
1717
<ItemGroup>
18-
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
19-
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview6" />
18+
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
19+
<PackageReference Include="Avalonia.Desktop" Version="11.0.0-preview8" />
2020
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
21-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
22-
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
21+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
22+
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
2323
<PackageReference Include="ReactiveUI" Version="18.4.26" />
2424
</ItemGroup>
2525
<ItemGroup>

src/Artemis.UI.Shared/Artemis.UI.Shared.csproj

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
</PropertyGroup>
1111

1212
<ItemGroup>
13-
<PackageReference Include="Avalonia" Version="11.0.0-preview6" />
13+
<PackageReference Include="Avalonia" Version="11.0.0-preview8" />
1414
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
15-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview6" />
16-
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview6" />
17-
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-preview6" />
15+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0-preview8" />
16+
<PackageReference Include="Avalonia.ReactiveUI" Version="11.0.0-preview8" />
17+
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.0.0-preview8" />
1818
<PackageReference Include="DynamicData" Version="7.13.1" />
19-
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview6" />
19+
<PackageReference Include="FluentAvaloniaUI" Version="2.0.0-preview8" />
2020
<PackageReference Include="Material.Icons.Avalonia" Version="2.0.0-preview3" />
2121
<PackageReference Include="ReactiveUI" Version="18.4.26" />
2222
<PackageReference Include="ReactiveUI.Validation" Version="3.1.7" />

src/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ private void Update()
6464
Background = TextElement.GetForeground(this),
6565
VerticalAlignment = VerticalAlignment.Stretch,
6666
HorizontalAlignment = HorizontalAlignment.Stretch,
67-
OpacityMask = new ImageBrush(new Bitmap(iconString)) {BitmapInterpolationMode = BitmapInterpolationMode.MediumQuality}
67+
OpacityMask = new ImageBrush(new Bitmap(iconString))
6868
};
6969
}
7070
else

src/Artemis.UI.Shared/Controls/DataModelPicker/DataModelPicker.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ protected override void OnAttachedToVisualTree(VisualTreeAttachmentEventArgs e)
308308
{
309309
GetDataModel();
310310
UpdateCurrentPath(true);
311-
_updateTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(200), DispatcherPriority.Normal, Update);
311+
_updateTimer = new DispatcherTimer(TimeSpan.FromMilliseconds(200), DispatcherPriority.Background, Update);
312312
_updateTimer.Start();
313313
}
314314

src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ public DeviceVisualizer()
4141
PropertyChanged += OnPropertyChanged;
4242
}
4343

44-
4544
/// <inheritdoc />
4645
public override void Render(DrawingContext drawingContext)
4746
{
@@ -67,8 +66,7 @@ public override void Render(DrawingContext drawingContext)
6766
drawingContext.DrawImage(
6867
_deviceImage,
6968
new Rect(_deviceImage.Size),
70-
new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height),
71-
RenderOptions.GetBitmapInterpolationMode(this)
69+
new Rect(0, 0, Device.RgbDevice.ActualSize.Width, Device.RgbDevice.ActualSize.Height)
7270
);
7371

7472
if (!ShowColors)
@@ -306,8 +304,9 @@ private void SetupForDevice()
306304

307305
using DrawingContext context = renderTargetBitmap.CreateDrawingContext();
308306
using Bitmap bitmap = new(device.Layout.Image.LocalPath);
309-
context.DrawImage(bitmap, new Rect(bitmap.Size), new Rect(renderTargetBitmap.Size), BitmapInterpolationMode.HighQuality);
310-
307+
using Bitmap scaledBitmap = bitmap.CreateScaledBitmap(renderTargetBitmap.PixelSize);
308+
309+
context.DrawImage(scaledBitmap, new Rect(scaledBitmap.Size));
311310
lock (_deviceVisualizerLeds)
312311
{
313312
foreach (DeviceVisualizerLed deviceVisualizerLed in _deviceVisualizerLeds)

src/Artemis.UI.Shared/Controls/DeviceVisualizerLed.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,10 @@ public void DrawBitmap(DrawingContext drawingContext, double scale)
4646
try
4747
{
4848
using Bitmap bitmap = new(Led.Layout.Image.LocalPath);
49+
using Bitmap scaledBitmap = bitmap.CreateScaledBitmap(new PixelSize((Led.RgbLed.Size.Width * scale).RoundToInt(), (Led.RgbLed.Size.Height * scale).RoundToInt()));
4950
drawingContext.DrawImage(
50-
bitmap,
51-
new Rect(bitmap.Size),
52-
new Rect(Led.RgbLed.Location.X * scale, Led.RgbLed.Location.Y * scale, Led.RgbLed.Size.Width * scale, Led.RgbLed.Size.Height * scale),
53-
BitmapInterpolationMode.HighQuality
51+
scaledBitmap,
52+
new Rect(Led.RgbLed.Location.X * scale, Led.RgbLed.Location.Y * scale, scaledBitmap.Size.Width, scaledBitmap.Size.Height)
5453
);
5554
}
5655
catch

0 commit comments

Comments
 (0)