-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPlugin.cs
More file actions
42 lines (36 loc) · 1.45 KB
/
Plugin.cs
File metadata and controls
42 lines (36 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using neo_bpsys_wpf.Core;
using neo_bpsys_wpf.Core.Abstractions;
using neo_bpsys_wpf.Core.Extensions.Registry;
using neo_bpsys_wpf.Core.Helpers;
using neo_bpsys_wpf._3DViewerIDV.Models;
using neo_bpsys_wpf._3DViewerIDV.ViewModels;
using neo_bpsys_wpf._3DViewerIDV.Views;
using System;
using System.IO;
namespace neo_bpsys_wpf._3DViewerIDV;
public class Plugin : PluginBase
{
public override void Initialize(HostBuilderContext context, IServiceCollection services)
{
// Load settings from JSON
var configFolder = Path.Combine(
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
"neo-bpsys-wpf", "Plugins", "3DViewerIDV"
);
Directory.CreateDirectory(configFolder);
var settingsFilePath = Path.Combine(configFolder, "Settings.json");
var settings = ConfigureFileHelper.LoadConfig<PluginSettings>(settingsFilePath);
// Save settings when properties change
settings.PropertyChanged += (sender, args) =>
{
ConfigureFileHelper.SaveConfig(settingsFilePath, settings);
};
// Register settings as singleton
services.AddSingleton(settings);
// Register windows and pages
services.AddFrontedWindow<StatsViewerWindow, StatsViewerWindowViewModel>();
services.AddBackendPage<SettingsPage, SettingsPageViewModel>();
}
}