Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/refactor and fix old functionalities #18

Merged
merged 23 commits into from
Sep 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions ModularToolManger.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ VisualStudioVersion = 17.0.32014.148
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BE409F60-F5A2-4643-B028-F124F6CC151A}"
ProjectSection(SolutionItems) = preProject
..\README.md = ..\README.md
README.md = README.md
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModularToolManager", "src\ModularToolManager\ModularToolManager.csproj", "{5EFD31F0-563B-45A5-8614-FE4EF0A2B12A}"
Expand All @@ -17,7 +17,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModularToolManagerPlugin",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DefaultPlugins", "src\DefaultPlugins\DefaultPlugins.csproj", "{FC3E8684-9A29-4959-81D5-9A29E8DE094A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ModularToolManagerModel", "src\ModularToolManagerModel\ModularToolManagerModel.csproj", "{BA2EB811-1909-4DAA-878A-185F5FF53C67}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ModularToolManagerModel", "src\ModularToolManagerModel\ModularToolManagerModel.csproj", "{BA2EB811-1909-4DAA-878A-185F5FF53C67}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,11 @@ There will be a document how to create your own plugin later on. At the moment y

If you are using any third party modules (Assembly files) be warned. Those could be infected by a virus or other software trying to damage your computer!

## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgit.luolix.top%2FXanatosX%2FModularToolManager.svg?type=large)](https://app.fossa.com/projects/git%2Bgit.luolix.top%2FXanatosX%2FModularToolManager?ref=badge_large)


[downloadPage]: https://bitbucket.org/XanatosX/modulartoolmanager/downloads/
[lastUnstable]: https://bitbucket.org/XanatosX/modulartoolmanager/downloads/LastUnstable_ModularToolManager.zip
[preSettings]: https://bitbucket.org/XanatosX/modulartoolmanager/downloads/ModularToolManager_release-preSettings.zip
[issuePage]: https://bitbucket.org/XanatosX/modulartoolmanager/issues




## License
[![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgit.luolix.top%2FXanatosX%2FModularToolManager.svg?type=large)](https://app.fossa.com/projects/git%2Bgit.luolix.top%2FXanatosX%2FModularToolManager?ref=badge_large)
4 changes: 3 additions & 1 deletion src/ModularToolManager/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
xmlns:local="using:ModularToolManager"
x:Class="ModularToolManager.App"
xmlns:p="clr-namespace:ModularToolManager.Properties">
<!--
<Application.DataTemplates>
<local:ViewLocator/>
</Application.DataTemplates>
-->

<Application.Styles>
<FluentTheme Mode="Dark"/>
Expand All @@ -14,7 +16,7 @@

<TrayIcon.Icons>
<TrayIcons>
<TrayIcon Icon="/Assets/avalonia-logo.ico" Command="{Binding ShowApplicationCommand}" ToolTipText="Modular tool manager">
<TrayIcon Icon="/Assets/avalonia-logo.ico" Command="{Binding ShowApplicationCommand}" ToolTipText="{x:Static p:Resources.Application_Name}">
<TrayIcon.Menu>
<NativeMenu>
<NativeMenuItem Header="{x:Static p:Resources.SubMenu_Exit}" Command="{Binding ExitApplicationCommand}"/>
Expand Down
27 changes: 16 additions & 11 deletions src/ModularToolManager/App.axaml.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
using Avalonia;
using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
using Microsoft.Extensions.DependencyInjection;
using ModularToolManager.DependencyInjection;
using ModularToolManager.Services.IO;
using ModularToolManager.Services.Logging;
using ModularToolManager.ViewModels;
using ModularToolManager.Views;
using ModularToolManagerModel.Services.IO;
using ModularToolManagerModel.Services.Logging;
using NLog.Config;
using NLog.Extensions.Logging;
using NLog.Targets;
using ReactiveUI;
using Splat;
using Splat.Microsoft.Extensions.DependencyInjection;
using System;
using System.IO;

namespace ModularToolManager;
Expand All @@ -37,8 +37,8 @@ private IServiceCollection BuildServiceCollection()
.AddViews()
.AddLogging(config =>
{
var pathService = Locator.Current.GetService<IPathService>() ?? new PathService();
string basePath = pathService?.GetSettingsFolderPathString() ?? Path.GetTempPath();
IPathService pathService = new PathService();
string basePath = pathService.GetSettingsFolderPathString() ?? Path.GetTempPath();
string logFolder = Path.Combine(basePath, "logs");

NLogConfiguration.AddTarget(new TraceTarget("trace-log"));
Expand All @@ -65,15 +65,20 @@ private IServiceCollection BuildServiceCollection()
/// <inheritdoc/>
public override void OnFrameworkInitializationCompleted()
{
BuildServiceCollection().UseMicrosoftDependencyResolver();
var provider = BuildServiceCollection().BuildServiceProvider();

Locator.CurrentMutable.InitializeSplat();
Locator.CurrentMutable.InitializeReactiveUI();
RxApp.MainThreadScheduler = AvaloniaScheduler.Instance;
ExpressionObserver.DataValidators.RemoveAll(x => x is DataAnnotationsValidationPlugin);
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
desktop.MainWindow = Locator.Current.GetService<MainWindow>();
desktop.MainWindow = provider.GetService<MainWindow>();
}
DataContext = provider.GetService<AppViewModel>();
var locator = provider.GetService<ViewLocator>();
if (locator is not null)
{
DataTemplates.Add(locator);
}


base.OnFrameworkInitializationCompleted();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using ModularToolManager.Services.Plugin;
using ModularToolManagerModel.Services.Plugin;
using ModularToolManagerModel.Services.Plugin;
using ModularToolManagerPlugin.Plugin;
using System;
using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
using Avalonia.ReactiveUI;
using Avalonia.Controls.Templates;
using Microsoft.Extensions.DependencyInjection;
using ModularToolManager.Services.Dependencies;
using ModularToolManager.Services.IO;
using ModularToolManager.Services.Language;
using ModularToolManager.Services.Plugin;
using ModularToolManager.Services.Serialization;
using ModularToolManager.Services.Styling;
using ModularToolManager.Services.Ui;
using ModularToolManager.ViewModels;
using ModularToolManager.Views;
using ModularToolManagerModel.Services.Dependency;
using ModularToolManagerModel.Services.Functions;
using ModularToolManagerModel.Services.IO;
using ModularToolManagerModel.Services.Language;
using ModularToolManagerModel.Services.Logging;
using ModularToolManagerModel.Services.Plugin;
using ModularToolManagerModel.Services.Serialization;
using ModularToolManagerPlugin.Services;
using ReactiveUI;
using System.Text.Json;

namespace ModularToolManager.DependencyInjection;
Expand All @@ -33,8 +33,7 @@ internal static class DependencyInjectionExtension
/// <returns>The extended collection</returns>
public static IServiceCollection AddAvaloniaDefault(this IServiceCollection collection)
{
return collection.AddSingleton<IActivationForViewFetcher, AvaloniaActivationForViewFetcher>()
.AddSingleton<IPropertyBindingHook, AutoDataTemplateBindingHook>();
return collection;
}

/// <summary>
Expand All @@ -46,7 +45,10 @@ public static IServiceCollection AddViewModels(this IServiceCollection collectio
{
return collection.AddTransient<AddFunctionViewModel>()
.AddTransient<FunctionSelectionViewModel>()
.AddTransient<MainWindowViewModel>();
.AddTransient<MainWindowViewModel>()
.AddTransient<ChangeLanguageViewModel>()
.AddTransient<SettingsViewModel>()
.AddTransient<AppViewModel>();
}

/// <summary>
Expand All @@ -56,11 +58,11 @@ public static IServiceCollection AddViewModels(this IServiceCollection collectio
/// <returns>The extended collection</returns>
public static IServiceCollection AddViews(this IServiceCollection collection)
{
return collection.AddTransient(resolver => new MainWindow(resolver?.GetService<IWindowManagmentService>())
return collection.AddTransient(resolver => new MainWindow(resolver?.GetService<IWindowManagementService>())
{
DataContext = resolver?.GetService<MainWindowViewModel>(),
})
.AddTransient<ModalWindow>();
.AddTransient<ModalWindow>();
}

/// <summary>
Expand All @@ -76,11 +78,15 @@ public static IServiceCollection AddServices(this IServiceCollection collection)
.AddSingleton<IFunctionSettingsService, FunctionSettingService>()
.AddSingleton<IUrlOpenerService, UrlOpenerService>()
.AddSingleton<ILanguageService, ResourceCultureService>()
.AddSingleton<IWindowManagmentService, WindowManagementService>()
.AddSingleton<IWindowManagementService, WindowManagementService>()
.AddSingleton<IPluginService, PluginService>()
.AddSingleton<ISerializationOptionFactory<JsonSerializerOptions>, JsonSerializationOptionFactory>()
.AddSingleton<ISerializeService, JsonSerializationService>()
.AddSingleton<IFunctionService, SerializedFunctionService>()
.AddTransient(typeof(IPluginLoggerService<>), typeof(LoggingPluginAdapter<>));
.AddTransient(typeof(IPluginLoggerService<>), typeof(LoggingPluginAdapter<>))
.AddSingleton<IViewModelLocatorService, ViewModelLocator>()
.AddSingleton<IDependencyResolverService, MicrosoftDepdencyResolverService>()
.AddSingleton<IFileSystemService, FileSystemService>()
.AddSingleton<ViewLocator>();
}
}
3 changes: 0 additions & 3 deletions src/ModularToolManager/FodyWeavers.xml

This file was deleted.

10 changes: 10 additions & 0 deletions src/ModularToolManager/Models/Messages/CloseApplicationMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using CommunityToolkit.Mvvm.Messaging.Messages;

namespace ModularToolManager.Models.Messages;

/// <summary>
/// Message to close the application
/// </summary>
internal class CloseApplicationMessage : RequestMessage<bool>
{
}
25 changes: 25 additions & 0 deletions src/ModularToolManager/Models/Messages/CloseModalMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Messaging.Messages;

namespace ModularToolManager.Models.Messages;

/// <summary>
/// Command to close a given modal
/// </summary>
internal class CloseModalMessage : RequestMessage<bool>
{
/// <summary>
/// The modal to close
/// </summary>
public ObservableObject ModalToClose { get; init; }

/// <summary>
/// Create a new instance of this message
/// </summary>
/// <param name="objectToClose">The modal to close</param>
public CloseModalMessage(ObservableObject objectToClose)
{
ModalToClose = objectToClose;
}

}
23 changes: 23 additions & 0 deletions src/ModularToolManager/Models/Messages/DeleteFunctionMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using CommunityToolkit.Mvvm.Messaging.Messages;

namespace ModularToolManager.Models.Messages;

/// <summary>
/// Message to inform that a function was deleted
/// </summary>
internal class DeleteFunctionMessage : RequestMessage<bool>
{
/// <summary>
/// The function which got deleted
/// </summary>
public FunctionModel Function { get; init; }

/// <summary>
/// Create a new instance of this message
/// </summary>
/// <param name="functionModel">The function to delete</param>
public DeleteFunctionMessage(FunctionModel functionModel)
{
Function = functionModel;
}
}
10 changes: 10 additions & 0 deletions src/ModularToolManager/Models/Messages/ReloadFunctionsMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using CommunityToolkit.Mvvm.Messaging.Messages;

namespace ModularToolManager.Models.Messages;

/// <summary>
/// Message to reload the functions
/// </summary>
internal class ReloadFunctionsMessage : RequestMessage<bool>
{
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using CommunityToolkit.Mvvm.Messaging.Messages;

namespace ModularToolManager.Models.Messages;

/// <summary>
/// Message to toggle the visiblity of the application
/// </summary>
internal class ToggleApplicationVisibilityMessage : RequestMessage<bool>
{
/// <summary>
/// Should the application be hidden or shown
/// </summary>
public bool Hide { get; init; }

/// <summary>
/// Create a new instance of this message
/// </summary>
/// <param name="hide">Set to true if the application should be hidden</param>
public ToggleApplicationVisibilityMessage(bool hide)
{
Hide = hide;
}
}
9 changes: 6 additions & 3 deletions src/ModularToolManager/Models/ShowWindowModel.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
using Avalonia.Controls;
using ModularToolManager.ViewModels;
using CommunityToolkit.Mvvm.ComponentModel;

namespace ModularToolManager.Models;

/// <summary>
/// Model for window modal information
/// </summary>
/// <param name="ViewModel">The view model to use</param>
/// <param name="Title">The title of the modal window</param>
/// <param name="ImagePath">An null string or the path to the image to show</param>
/// <param name="ModalContent">The content of the modal</param>
/// <param name="StartupLocation">The location where the modal should be positioned on startup</param>
public record ShowWindowModel(ModalWindowViewModel ViewModel, WindowStartupLocation StartupLocation);
///
public record ShowWindowModel(string Title, string? ImagePath, ObservableObject? ModalContent, WindowStartupLocation StartupLocation);
4 changes: 1 addition & 3 deletions src/ModularToolManager/ModularToolManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.18" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="6.0.0" />
<PackageReference Include="NLog.Extensions.Logging" Version="5.0.4" />
<PackageReference Include="ReactiveUI.Fody" Version="18.3.1" />
<PackageReference Include="Splat.Microsoft.Extensions.DependencyInjection" Version="14.4.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\ModularToolManagerModel\ModularToolManagerModel.csproj" />
Expand Down
4 changes: 1 addition & 3 deletions src/ModularToolManager/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Avalonia;
using Avalonia.ReactiveUI;
using System;

namespace ModularToolManager
Expand All @@ -17,7 +16,6 @@ public static void Main(string[] args) => BuildAvaloniaApp()
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.UseReactiveUI();
.LogToTrace();
}
}
27 changes: 27 additions & 0 deletions src/ModularToolManager/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading