Skip to content

Commit

Permalink
Merge pull request #292 from mgth/GitHub
Browse files Browse the repository at this point in the history
GitHub
  • Loading branch information
mgth committed Dec 19, 2023
2 parents 9d44b86 + fba516b commit 5160364
Show file tree
Hide file tree
Showing 7 changed files with 317 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@

<ItemGroup>
<ProjectReference Include="..\..\HLab\HLab.Base.Avalonia\HLab.Base.Avalonia.csproj" />
<ProjectReference Include="..\..\HLab\HLab.Bugs.Avalonia\HLab.Bugs.Avalonia.csproj" />
<ProjectReference Include="..\..\HLab\HLab.Mvvm.Avalonia\HLab.Mvvm.Avalonia.csproj" />
<ProjectReference Include="..\..\HLab\HLab.Mvvm.ReactiveUI\HLab.Mvvm.ReactiveUI.csproj" />
<ProjectReference Include="..\..\HLab\HLab.UserNotification.Avalonia\HLab.UserNotification.Avalonia.csproj" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ You should have received a copy of the GNU General Public License
using System.Threading.Tasks;
using Avalonia.Controls;
using Avalonia.Threading;
using ExCSS;
using HLab.Base.Avalonia;
using HLab.Mvvm;
using HLab.Mvvm.Annotations;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,5" Text="Little Big Mouse" FontSize="20" FontWeight="Bold"/>
<TextBlock HorizontalAlignment="Center" Text="{Binding Version}" TextWrapping="Wrap" FontSize="15"/>
<TextBlock HorizontalAlignment="Center" Text="Copyright (C) 2015 - 2023" FontSize="15"/>
<TextBlock HorizontalAlignment="Center" Margin="0,0,0,20" Text="Mathieu GRENET" FontSize="15"/>
<TextBlock PointerPressed="InputElement_OnPointerPressed" HorizontalAlignment="Center" Margin="0,0,0,20" Text="Mathieu GRENET" FontSize="15"/>

<icons:IconView HorizontalAlignment="Center" Margin="0,0,0,20" Path="Icon/lbm_logo" Height="50"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,8 @@ public double WheelDelta(PointerWheelEventArgs e)
return delta;
}

void InputElement_OnPointerPressed(object? sender, PointerPressedEventArgs e)
{
throw new System.NotImplementedException();
}
}
119 changes: 70 additions & 49 deletions LittleBigMouse.Ui/LittleBigMouse.Ui.Avalonia/Program.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
using System;
using System.Collections.Generic;
using System.Reactive;
using System.Runtime.ExceptionServices;
using System.Threading;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Logging;
using Avalonia.ReactiveUI;
using Grace.DependencyInjection;
using HLab.Base.Avalonia.Themes;
using HLab.Bugs.Avalonia;
using HLab.Core;
using HLab.Core.Annotations;
using HLab.Icons.Avalonia;
Expand Down Expand Up @@ -56,10 +58,10 @@ public static AppBuilder BuildAvaloniaApp()

//})
.UseSkia()
#if DEBUG
// .LogToTrace(LogEventLevel.Verbose)
#if DEBUG
// .LogToTrace(LogEventLevel.Verbose)
.LogToTrace(LogEventLevel.Debug)
#endif
#endif
;
}

Expand All @@ -72,78 +74,97 @@ public static void UIMain(Application app, string[] args)
return;
}

RxApp.DefaultExceptionHandler = Observer.Create<Exception>(Console.WriteLine);
try
{

RxApp.DefaultExceptionHandler = Observer.Create<Exception>(Console.WriteLine);

#if DEBUG
Locator.CurrentMutable.RegisterConstant(new LoggingService { Level = LogLevel.Info }, typeof(ILogger));
Locator.CurrentMutable.RegisterConstant(new LoggingService { Level = LogLevel.Info }, typeof(ILogger));
#endif

var container = new DependencyInjectionContainer();
container.Configure(c =>
{
//c.ExportInstance(app.ApplicationLifetime);
var container = new DependencyInjectionContainer();
container.Configure(c =>
{
//c.ExportInstance(app.ApplicationLifetime);
c.Export<IconService>().As<IIconService>().Lifestyle.Singleton();
c.Export<LocalizationService>().As<ILocalizationService>().Lifestyle.Singleton();
c.Export<MvvmService>().As<IMvvmService>().Lifestyle.Singleton();
c.Export<MvvmAvaloniaImpl>().As<IMvvmPlatformImpl>().Lifestyle.Singleton();
c.Export<HLab.Core.MessageBus>().As<IMessagesService>().Lifestyle.Singleton();
c.Export<UserNotificationServiceAvalonia>().As<IUserNotificationService>().Lifestyle.Singleton();
c.Export<IconService>().As<IIconService>().Lifestyle.Singleton();
c.Export<LocalizationService>().As<ILocalizationService>().Lifestyle.Singleton();
c.Export<MvvmService>().As<IMvvmService>().Lifestyle.Singleton();
c.Export<MvvmAvaloniaImpl>().As<IMvvmPlatformImpl>().Lifestyle.Singleton();
c.Export<HLab.Core.MessageBus>().As<IMessagesService>().Lifestyle.Singleton();
c.Export<UserNotificationServiceAvalonia>().As<IUserNotificationService>().Lifestyle.Singleton();
c.Export<MainService>().As<IMainService>().Lifestyle.Singleton();
c.Export<MainService>().As<IMainService>().Lifestyle.Singleton();
c.Export<SystemMonitorsService>().As<ISystemMonitorsService>().Lifestyle.Singleton();
c.Export<MainBootloader>().As<IBootloader>();
c.Export<SystemMonitorsService>().As<ISystemMonitorsService>().Lifestyle.Singleton();
c.Export<MainBootloader>().As<IBootloader>();
c.Export<LittleBigMouseClientService>().As<ILittleBigMouseClientService>().Lifestyle.Singleton();
c.Export<LittleBigMouseClientService>().As<ILittleBigMouseClientService>().Lifestyle.Singleton();
//c.Export<MonitorsLayout>().As<IMonitorsLayout>();
//c.Export<MonitorsLayout>().As<IMonitorsLayout>();
c.Export<MainViewModel>().As<IMainPluginsViewModel>().Lifestyle.Singleton();
c.Export<MainViewModel>().As<IMainPluginsViewModel>().Lifestyle.Singleton();
c.Export<MonitorDebugPlugin>().As<IBootloader>();
c.Export<MonitorLocationPlugin>().As<IBootloader>();
c.Export<MonitorDebugPlugin>().As<IBootloader>();
c.Export<MonitorLocationPlugin>().As<IBootloader>();
c.Export<VcpPlugin>().As<IBootloader>();
c.Export<VcpPlugin>().As<IBootloader>();
var parser = new AssemblyParser();
var parser = new AssemblyParser();
parser.LoadDll("LittleBigMouse.Plugin.Layout.Avalonia");
parser.LoadDll("LittleBigMouse.Plugin.Vcp.Avalonia");
parser.LoadDll("LittleBigMouse.Plugin.Layout.Avalonia");
parser.LoadDll("LittleBigMouse.Plugin.Vcp.Avalonia");
parser.LoadModules();
parser.LoadModules();
parser.Add<IView>(t => c.Export(t).As(typeof(IView)));
parser.Add<IViewModel>(t => c.Export(t).As(typeof(IViewModel)));
parser.Add<IBootloader>(t => c.Export(t).As(typeof(IBootloader)));
parser.Add<IView>(t => c.Export(t).As(typeof(IView)));
parser.Add<IViewModel>(t => c.Export(t).As(typeof(IViewModel)));
parser.Add<IBootloader>(t => c.Export(t).As(typeof(IBootloader)));
parser.Parse();
});
parser.Parse();
});

var boot = new Bootstrapper(() => container.Locate<IEnumerable<IBootloader>>());
var boot = new Bootstrapper(() => container.Locate<IEnumerable<IBootloader>>());

var theme = new ThemeService(app.Resources);
theme.SetTheme(ThemeService.WindowsTheme.Auto);
var theme = new ThemeService(app.Resources);
theme.SetTheme(ThemeService.WindowsTheme.Auto);

var cts = new CancellationTokenSource();
var cts = new CancellationTokenSource();

var task = boot.BootAsync();
var task = boot.BootAsync();

try
{
app.Run(cts.Token);
try
{
app.Run(cts.Token);
}
catch (InvalidOperationException)
{
cts.Cancel();
}

try
{
task.Wait(cts.Token);
}
catch (OperationCanceledException)
{
}
}
catch(InvalidOperationException)
catch (Exception ex)
{
cts.Cancel();
var view = new ExceptionView
{
Exception = ex,
ProductHeaderValue = "LittleBigMouse",
Project = "LittleBigMouse",
Repository = "Mgth"
};
view.Show();
//throw;
//ExceptionDispatchInfo.Capture(ex).Throw();
}

try
{
task.Wait(cts.Token);
}
catch(OperationCanceledException)
{ }
}
}
Loading

0 comments on commit 5160364

Please sign in to comment.