This commit is contained in:
Thomas Peterson 2024-11-26 19:08:52 +01:00
parent 7a11a59f7b
commit d0352818f0
25 changed files with 354 additions and 112 deletions

View File

@ -22,6 +22,7 @@
<entry key="PSCHelpdesk/PSCHelpdesk/Views/SettingsGlobalView.axaml" value="PSCHelpdesk/PSCHelpdesk.Desktop/PSCHelpdesk.Desktop.csproj" />
<entry key="PSCHelpdesk/PSCHelpdesk/Views/SettingsView.axaml" value="PSCHelpdesk/PSCHelpdesk.Desktop/PSCHelpdesk.Desktop.csproj" />
<entry key="PSCHelpdesk/PSCHelpdesk/Views/SettingsWindow.axaml" value="PSCHelpdesk/PSCHelpdesk.Desktop/PSCHelpdesk.Desktop.csproj" />
<entry key="PSCHelpdesk/PSCHelpdesk/Views/TestListView.axaml" value="PSCHelpdesk/PSCHelpdesk.Desktop/PSCHelpdesk.Desktop.csproj" />
<entry key="PSCHelpdesk/PSCHelpdesk/Views/TestView.axaml" value="PSCHelpdesk/PSCHelpdesk.Desktop/PSCHelpdesk.Desktop.csproj" />
<entry key="Shared/Shared.axaml" value="PSCHelpdesk/PSCHelpdesk.Desktop/PSCHelpdesk.Desktop.csproj" />
<entry key="Shared/Views/MenuItem.axaml" value="PSCHelpdesk/PSCHelpdesk.Desktop/PSCHelpdesk.Desktop.csproj" />

View File

@ -13,13 +13,23 @@
<list default="true" id="95257dc5-08bd-4c50-8726-85956b3c2c92" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.PSCHelpdesk/.idea/avalonia.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.PSCHelpdesk/.idea/avalonia.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.PSCHelpdesk/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.PSCHelpdesk/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/HetznerServer/HetznerServer.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/HetznerServer.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/HetznerServer/ViewModels/ServerViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/HetznerServer/ViewModels/ServerViewModel.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk.sln.DotSettings.user" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk.sln.DotSettings.user" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/App.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/App.axaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/App.axaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/App.axaml.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/PSCHelpdesk.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/PSCHelpdesk.csproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Startup.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Startup.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/MainDockWindowViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/MainDockWindowViewModel.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/MainWindowViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/MainWindowViewModel.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/PluginListViewModel.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/ViewModels/PluginListViewModel.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/MainDockWindow.axaml" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/MainDockWindow.axaml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/MainDockWindow.axaml.cs" beforeDir="false" afterPath="$PROJECT_DIR$/PSCHelpdesk/PSCHelpdesk/Views/MainDockWindow.axaml.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Shared/Setting/SettingsManager.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Shared/Setting/SettingsManager.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Shared/Shared.csproj" beforeDir="false" afterPath="$PROJECT_DIR$/Shared/Shared.csproj" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Shared/ViewModels/ViewModelBase.cs" beforeDir="false" afterPath="$PROJECT_DIR$/Shared/ViewModels/ViewModelBase.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.deps.json" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.deps.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.dll" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/hetzner/HetznerServer.pdb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_dist/nextcloud/Nextcloud.deps.json" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/nextcloud/Nextcloud.deps.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_dist/nextcloud/Nextcloud.dll" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/nextcloud/Nextcloud.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/_dist/nextcloud/Nextcloud.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/_dist/nextcloud/Nextcloud.pdb" afterDir="false" />
</list>
@ -35,7 +45,9 @@
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/8b4806d72c8e4cc3b55824ab34018d6a31600/06/4ff6aee3/RootDockGroup.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/8b4806d72c8e4cc3b55824ab34018d6a31600/9a/c689be08/StackDockGroup.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/ca55e2cf16410d6583d46a0c9733075e7c0a9d8bff277747e638859b39c45/DockItemViewModel.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/fa3c59274a754721f822d1776be91c7ffdd37ff4219098396aa16ba1fc5447/Ioc.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/HetznerServer/ViewModels/ServerViewModel.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/HetznerServer/Views/ServerView.axaml" root0="FORCE_HIGHLIGHTING" />
@ -69,40 +81,40 @@
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;.NET Project.PSCHelpdesk.Desktop ohne plugin.executor&quot;: &quot;Run&quot;,
&quot;.NET Project.PSCHelpdesk.Desktop.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Build HetznerServer Plugin Debug.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Copy Fastbill.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Copy Hetzner Target.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Copy Hetzner.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Copy NextCloud Target.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Copy NextCloud.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Copy PrinshopCreator.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Publish HetznerServer to folder.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Publish NextCloud to folder.executor&quot;: &quot;Run&quot;,
&quot;Publish to folder.Publish Nextcloud to folder.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;XThreadsFramesViewSplitterKey&quot;: &quot;0.4427131&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;ignore.virus.scanning.warn.message&quot;: &quot;true&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/thomas/RiderProjects/PSCHelpdesk/PSCHelpdesk/PSCHelpdesk.Desktop/bin/Debug/net9.0/plugins&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;preferences.pluginManager&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
".NET Project.PSCHelpdesk.Desktop ohne plugin.executor": "Run",
".NET Project.PSCHelpdesk.Desktop.executor": "Run",
"Publish to folder.Build HetznerServer Plugin Debug.executor": "Run",
"Publish to folder.Copy Fastbill.executor": "Run",
"Publish to folder.Copy Hetzner Target.executor": "Run",
"Publish to folder.Copy Hetzner.executor": "Run",
"Publish to folder.Copy NextCloud Target.executor": "Run",
"Publish to folder.Copy NextCloud.executor": "Run",
"Publish to folder.Copy PrinshopCreator.executor": "Run",
"Publish to folder.Publish HetznerServer to folder.executor": "Run",
"Publish to folder.Publish NextCloud to folder.executor": "Run",
"Publish to folder.Publish Nextcloud to folder.executor": "Run",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.git.unshallow": "true",
"XThreadsFramesViewSplitterKey": "0.4427131",
"git-widget-placeholder": "master",
"ignore.virus.scanning.warn.message": "true",
"last_opened_file_path": "/home/thomas/RiderProjects/PSCHelpdesk/PSCHelpdesk/PSCHelpdesk.Desktop/bin/Debug/net9.0/plugins",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "preferences.pluginManager",
"vue.rearranger.settings.migration": "true"
},
&quot;keyToStringList&quot;: {
&quot;com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File&quot;: [
&quot;Shell Script&quot;
"keyToStringList": {
"com.intellij.ide.scratch.ScratchImplUtil$2/New Scratch File": [
"Shell Script"
]
}
}</component>
}]]></component>
<component name="RunManager" selected=".NET Project.PSCHelpdesk.Desktop">
<configuration name="Copy Fastbill" type="DotNetFolderPublish" factoryName="Publish to folder">
<riderPublish configuration="Debug" platform="Any CPU" runtime="Portable" target_folder="$PROJECT_DIR$/_dist/fastbill" target_framework="net9.0" uuid_high="-7209100147811201171" uuid_low="-5152034027148450759" />
@ -246,6 +258,7 @@
<workItem from="1732088722904" duration="10121000" />
<workItem from="1732263256084" duration="10035000" />
<workItem from="1732368344000" duration="2447000" />
<workItem from="1732522254277" duration="18965000" />
</task>
<task id="LOCAL-00001" summary="Backup">
<option name="closed" value="true" />
@ -392,10 +405,10 @@
<line>99</line>
<properties documentPath="C:\Users\boonkerz\RiderProjects\PSCHelpDesk\HetznerServer\ViewModels\ServerViewModel.cs" containingFunctionPresentation="Method 'saveServerSettings'">
<startOffsets>
<option value="3608" />
<option value="3585" />
</startOffsets>
<endOffsets>
<option value="3651" />
<option value="3628" />
</endOffsets>
</properties>
<option name="timeStamp" value="204" />

View File

@ -21,7 +21,7 @@ public class HetznerServer : Contract
var serverTab = new Item()
{
Header = "Server",
CommandParameter = new ServerViewModel(new ServerService())
CommandParameter = new ServerViewModel()
};
menuService.AddMenuItem(serverTab);

View File

@ -28,13 +28,13 @@ public partial class ServerViewModel : ViewModelBase, IViewModelBase
public ReadOnlyObservableCollection<Server> Server => _server;
private SettingsManager _settingsManager;
public ServerViewModel(ServerService _serverService)
public ServerViewModel()
{
ServerService = new ServerService();
SelectedServer = new Server(1,"","","","","");
SelectionChanged = ReactiveCommand.Create<SelectionChangedEventArgs>(selectionChanged);
SaveServerSettings = ReactiveCommand.Create(saveServerSettings);
_settingsManager = (SettingsManager)Ioc.Default.GetService<ISettingsManager>();
ServerService = _serverService;
ServerService.SourceCache.Connect()
// Sort Ascending on the OrderIndex property
.Sort(SortExpressionComparer<Server>.Ascending(t => t.ServerId))

View File

@ -58,6 +58,7 @@
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AReplaceManager_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F1524add2024c462eba359b6f11cc1aba12c00_003F21_003Fed98e75c_003FReplaceManager_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AReplaySubject_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F27be5d106a789638721745a2a46f9cb0f7a39905117d644638b6e0d56261be_003FReplaySubject_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AReplaySubject_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F27be5d106a789638721745a2a46f9cb0f7a39905117d644638b6e0d56261be_003FReplaySubject_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARootDockGroup_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F8b4806d72c8e4cc3b55824ab34018d6a31600_003F06_003F4ff6aee3_003FRootDockGroup_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeHelpers_002ECoreCLR_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003F5ef9e37e2f99ef2688a1586afed1cff6eef912a11aa9b20a56943a255a6e6b_003FRuntimeHelpers_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002ECoreCLR_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003FAppData_003FRoaming_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fad1d58b8dd22123dfae3f2cf5d8b199992465c9c344d032f93a826d8e5539ff_003FRuntimeType_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ARuntimeType_002ECoreCLR_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002Econfig_003FJetBrains_003FRider2024_002E2_003Fresharper_002Dhost_003FSourcesCache_003Fbaf2eef7c7bbea3742b74ee71fe7168c3a8c2269a1ce22d51333175656840_003FRuntimeType_002ECoreCLR_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>

View File

@ -3,6 +3,8 @@ using Avalonia.Controls.ApplicationLifetimes;
using Avalonia.Data.Core;
using Avalonia.Data.Core.Plugins;
using Avalonia.Markup.Xaml;
using CommunityToolkit.Mvvm.DependencyInjection;
using NP.Ava.UniDockService;
using PSCHelpdesk.ViewModels;
using PSCHelpdesk.Views;
@ -17,15 +19,13 @@ public partial class App : Application
public override void OnFrameworkInitializationCompleted()
{
Startup.RegisterServices();
if (ApplicationLifetime is IClassicDesktopStyleApplicationLifetime desktop)
{
// Line below is needed to remove Avalonia data validation.
// Without this line you will get duplicate validations from both Avalonia and CT
BindingPlugins.DataValidators.RemoveAt(0);
desktop.MainWindow = new MainDockWindow
{
DataContext = new MainDockWindowViewModel()
};
desktop.MainWindow = new MainDockWindow();
}
else if (ApplicationLifetime is ISingleViewApplicationLifetime singleViewPlatform)
{

View File

@ -0,0 +1,8 @@
using NP.Ava.UniDockService;
namespace PSCHelpdesk.Events;
public class OpenEventArg
{
public DockItemViewModelBase Sender;
}

View File

@ -2,6 +2,7 @@ using CommunityToolkit.Mvvm.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using NP.Ava.UniDock;
using NP.Ava.UniDock.Factories;
using NP.Ava.UniDockService;
using Prise.DependencyInjection;
using Prise.Proxy;
using PSCHelpdesk.Converter;
@ -18,6 +19,9 @@ namespace PSCHelpdesk;
class Startup
{
public static DockManager TheDockManager { get; } = new DockManager();
public static void RegisterServices()
{
var menuService = new MenuService();
@ -25,7 +29,6 @@ class Startup
var settingsService = new SettingsService();
var taskManager = new TaskManager();
var toastManager = new ToastManager();
var theDockManager = new DockManager();
var te = new ServiceCollection()
.AddSingleton<IUserInterfaceDispatchService, AvaloniaDispatcherService>()
@ -38,7 +41,8 @@ class Startup
.AddSingleton<IMenuService>(menuService)
.AddSingleton<ITestService>(new TestService())
.AddSingleton<PluginManager>()
.AddSingleton<DockManager>(theDockManager)
.AddSingleton<DockManager>(TheDockManager)
.AddSingleton<IUniDockService>(TheDockManager)
.AddSingleton<IToastManager>(toastManager)
.AddTransient<PluginListViewModel>();

View File

@ -1,45 +1,108 @@
using System.Collections.ObjectModel;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Reactive;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using NP.Ava.UniDock;
using NP.Ava.UniDockService;
using PSCHelpdesk.Events;
using PSCHelpdesk.Services;
using PSCHelpdesk.Shared.Menu;
using PSCHelpdesk.Shared.Service;
using PSCHelpdesk.Shared.Tasks;
using PSCHelpdesk.Shared.ViewModels;
using PSCHelpdesk.Tasks;
using PSCHelpdesk.Toasts.Display;
using ReactiveUI;
namespace PSCHelpdesk.ViewModels;
public class MainDockWindowViewModel : ViewModelBase, IViewModelBase
{
private DockManager _dockManager;
private ObservableCollection<DockItemViewModelBase> _vms;
private MenuService MenuService;
public ObservableCollection<DockItemViewModelBase> VMs
private List<Item> _menuItems;
public List<Item> MenuItems
{
get => _vms;
set => SetAndRaisePropertyChanged(ref _vms, value);
get => _menuItems;
set => SetAndRaisePropertyChanged(ref _menuItems, value);
}
public DockManager DockManager => _dockManager;
public ReactiveCommand<string, Unit> ClickMenu { get; }
public ReactiveCommand<Unit,Unit> OpenPlugins { get; }
public EventHandler<OpenEventArg> openTab;
public MainDockWindowViewModel()
{
Startup.RegisterServices();
ClickMenu = ReactiveCommand.Create<string>(SelectMenu);
OpenPlugins = ReactiveCommand.Create(openPlugins);
VMs = new ObservableCollection<DockItemViewModelBase>();
_dockManager = Ioc.Default.GetService<DockManager>();
DockItemViewModelBase vm1 = new DockItemViewModelBase
this.MenuItems = new List<Item>();
MenuService = (MenuService)Ioc.Default.GetService(typeof(IMenuService));
MenuService.MenuChanged += delegate(object? sender, EventArgs args)
{
DockId = "Tab1",
Header = "Tab1",
DefaultDockGroupId = "Group1",
DefaultDockOrderInGroup = 1,
Content = "Hello World!"
foreach (var menuServiceMenuItem in MenuService.MenuItems)
{
if (!this.MenuItems.Contains(menuServiceMenuItem))
{
menuServiceMenuItem.Command = this.ClickMenu;
this.MenuItems.Add(menuServiceMenuItem);
}
}
foreach (var menuServiceMenuItem in MenuService.MenuOptionItems)
{
if (!this.MenuItems.Contains(menuServiceMenuItem))
{
menuServiceMenuItem.Command = this.ClickMenu;
this.MenuItems.Add(menuServiceMenuItem);
}
}
};
VMs.Add(vm1);
this.InitializeClient();
}
_dockManager.DockItemsViewModels = VMs;
private void InitializeClient()
{
this.MenuService.CreateMenu();
}
public void SelectMenu(string parameter)
{
var obj = this.MenuService.MenuItems.FirstOrDefault(menuItem => menuItem.Header == parameter.ToString(), null);
if (obj != null)
{
this.openTab?.Invoke(this, new OpenEventArg()
{
Sender = new DockItemViewModelBase()
{
DockId = obj.Header,
Header = obj.Header,
DefaultDockGroupId = "Tabs",
Content = obj.CommandParameter
}
});
}
}
void openPlugins()
{
this.openTab?.Invoke(this, new OpenEventArg()
{
Sender = new DockItemViewModelBase()
{
DockId = "plugins",
Header = "Plugins",
DefaultDockGroupId = "Tabs",
Content = new PluginListViewModel(Ioc.Default.GetService<PluginManager>())
}
});
}
}

View File

@ -126,6 +126,6 @@ public class MainWindowViewModel : ViewModelBase, IViewModelBase
TabItems.Add(new TabItemViewModel("Plugins",
new PluginListViewModel(Ioc.Default.GetService<PluginManager>())));
SelectedTabItem = TabItems.Last();
}
}
}

View File

@ -1,6 +1,7 @@
using Avalonia.Collections;
using Avalonia.Controls;
using CommunityToolkit.Mvvm.Input;
using NP.Ava.UniDockService;
using PSCHelpdesk.Services;
using PSCHelpdesk.Shared.ViewModels;

View File

@ -0,0 +1,8 @@
using PSCHelpdesk.Shared.ViewModels;
namespace PSCHelpdesk.ViewModels;
public class TestViewModel: ViewModelBase, IViewModelBase
{
}

View File

@ -10,9 +10,8 @@
x:Class="PSCHelpdesk.Views.MainDockWindow"
Icon="/Assets/avalonia-logo.ico"
xmlns:np="https://np.com/visuals"
np:DockAttachedProperties.TheDockManager="{Binding DockManager}"
np:DockAttachedProperties.DockChildWindowOwner="{Binding RelativeSource={RelativeSource Mode=Self}}"
np:DockAttachedProperties.WindowId="TheMainWindow"
xmlns:uniDockService="clr-namespace:NP.Ava.UniDockService;assembly=NP.Ava.UniDockService"
np:DockAttachedProperties.TheDockManager="{DynamicResource TheDockManager}"
x:DataType="vm:MainDockWindowViewModel"
Title="PSCHelpdesk"
x:Name="MainWindowView">
@ -25,12 +24,28 @@
<StyleInclude Source="avares://NP.Ava.UniDock/Themes/DockStyles.axaml"/>
</Window.Styles>
<Grid RowDefinitions="Auto, *, Auto"
<Grid RowDefinitions="Auto, *"
Margin="5">
<ListBox ItemsSource="{Binding DockManager}"
Height="70">
<Menu Grid.Row="0">
<MenuItem Header="_File">
<MenuItem Click="Settings_OnClick" Header="_Settings"/>
<Separator/>
<MenuItem Click="Exit_OnClick" Header="_Exit"/>
</MenuItem>
<MenuItem Header="_Module" ItemsSource="{Binding MenuItems}" Classes="SubItems">
<MenuItem.Styles>
<Style Selector="MenuItem.SubItems MenuItem" x:DataType="vs:Item">
<Setter Property="Header" Value="{Binding Header }"/>
<Setter Property="ItemsSource" Value="{Binding Items}"/>
<Setter Property="Command" Value="{Binding Command }"></Setter>
<Setter Property="CommandParameter" Value="{Binding Header}"></Setter>
</Style>
</MenuItem.Styles>
</MenuItem>
<MenuItem Header="_Plugins" Command="{Binding OpenPlugins}">
</ListBox>
</MenuItem>
</Menu>
<!-- top level group should reference the dock manager-->
<np:RootDockGroup TheDockManager="{StaticResource TheDockManager}"
Grid.Row="1">
@ -38,40 +53,10 @@
vertically-->
<np:StackDockGroup TheOrientation="Vertical"
DockId="RootGroup">
<!-- top group arranges two top Dock Panes horizontally-->
<np:StackDockGroup TheOrientation="Horizontal"
IsStableGroup="True"
DockId="TopStackGroup">
<np:DockItem Header="Hi">
<TextBlock Text="Hi World!"/>
</np:DockItem>
<np:DockItem Header="Hello">
<TextBlock Text="Hello World!"/>
</np:DockItem>
</np:StackDockGroup>
<!-- Tabbed group at the bottom -->
<np:TabbedDockGroup IsStableGroup="True"
DockId="Tabs"/>
DockId="Tabs" HorizontalContentAlignment="Stretch"/>
</np:StackDockGroup>
</np:RootDockGroup>
<StackPanel Orientation="Horizontal"
Grid.Row="2"
HorizontalAlignment="Right">
<Button x:Name="AddTabButton"
Content="AddTab"
Padding="10,5"
Margin="5"/>
<Button x:Name="SaveButton"
Content="Save"
Padding="10,5"
Margin="5"/>
<Button x:Name="RestoreButton"
Content="Restore"
Padding="10,5"
Margin="5"/>
</StackPanel>
</Grid>
</Window>

View File

@ -1,13 +1,80 @@
using Avalonia;
using System.Collections.ObjectModel;
using System.IO;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using CommunityToolkit.Mvvm.DependencyInjection;
using NP.Ava.UniDock;
using NP.Ava.UniDockService;
using PSCHelpdesk.Shared.Service;
using PSCHelpdesk.Shared.Setting;
using PSCHelpdesk.ViewModels;
namespace PSCHelpdesk.Views;
public partial class MainDockWindow : Window
{
private DockManager _dockManager;
public IUniDockService _uniDockService;
public MainDockWindow()
{
this.DataContext = new MainDockWindowViewModel();
InitializeComponent();
_dockManager = (DockManager) this.FindResource("TheDockManager")!;
_uniDockService = (IUniDockService)_dockManager!;
_uniDockService.DockItemsViewModels =
new ObservableCollection<DockItemViewModelBase>();
(this.DataContext as MainDockWindowViewModel).openTab += (_, e) =>
{
_uniDockService.DockItemsViewModels.Add
(
e.Sender as DockItemViewModelBase
);
};
//_uniDockService.DockItemsViewModels = null;
var settingsManager = (SettingsManager)Ioc.Default.GetService<ISettingsManager>();
// restore the layout
//_uniDockService.RestoreFromFile(Path.Combine(settingsManager.DataRoot, "DockSerialization.xml"));
}
private void Exit_OnClick(object? sender, RoutedEventArgs e)
{
var settingsManager = (SettingsManager)Ioc.Default.GetService<ISettingsManager>();
// save the layout
//_uniDockService.SaveToFile(Path.Combine(settingsManager.DataRoot, "DockSerialization.xml"));
// save the view models
//_uniDockService.SaveViewModelsToFile(Path.Combine(settingsManager.DataRoot, "DockVMSerialization.xml"));
Close();
}
private void Settings_OnClick(object? sender, RoutedEventArgs e)
{
_uniDockService.DockItemsViewModels.Add
(
new DockItemViewModelBase
{
DockId = "tabStr",
Header = "tabStr",
Content = $"This is tab ",
DefaultDockGroupId = "Tabs",
DefaultDockOrderInGroup = 1,
IsSelected = true,
IsActive = true
});
return;
SettingsWindow settings = new SettingsWindow
{
DataContext = new SettingsViewModel(),
Width = 800,
Height = 600
};
settings.Show();
}
}

View File

@ -0,0 +1,10 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
xmlns:vm="clr-namespace:PSCHelpdesk.ViewModels"
x:DataType="vm:TestViewModel"
x:Class="PSCHelpdesk.Views.TestListView">
Welcome to Avalonia!
</UserControl>

View File

@ -0,0 +1,13 @@
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
namespace PSCHelpdesk.Views;
public partial class TestListView : UserControl
{
public TestListView()
{
InitializeComponent();
}
}

View File

@ -5,7 +5,7 @@ namespace PSCHelpdesk.Shared.Setting;
public class SettingsManager: ISettingsManager
{
private string DataRoot => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PSC", "PSCHelpDesk");
public string DataRoot => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PSC", "PSCHelpDesk");
private string SettingsPath => Path.Combine(this.DataRoot, "settings.json");

View File

@ -27,6 +27,7 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="11.2.0" />
<PackageReference Include="NP.Ava.UniDockService" Version="1.0.6" />
</ItemGroup>
</Project>

View File

@ -1,10 +1,11 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using NP.Ava.UniDockService;
namespace PSCHelpdesk.Shared.ViewModels;
public class ViewModelBase : INotifyPropertyChanged
public class ViewModelBase :INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;

View File

@ -279,6 +279,25 @@
}
}
},
"NP.Ava.UniDockService/1.0.6": {
"dependencies": {
"NP.Utilities": "1.0.30"
},
"runtime": {
"lib/net8.0/NP.Ava.UniDockService.dll": {
"assemblyVersion": "1.0.6.0",
"fileVersion": "1.0.6.0"
}
}
},
"NP.Utilities/1.0.30": {
"runtime": {
"lib/net8.0/NP.Utilities.dll": {
"assemblyVersion": "1.0.30.0",
"fileVersion": "1.0.30.0"
}
}
},
"ReactiveUI/20.1.1": {
"dependencies": {
"DynamicData": "8.4.1",
@ -472,6 +491,20 @@
"path": "newtonsoft.json/13.0.3",
"hashPath": "newtonsoft.json.13.0.3.nupkg.sha512"
},
"NP.Ava.UniDockService/1.0.6": {
"type": "package",
"serviceable": true,
"sha512": "sha512-GHS67athB7fd/qvHJOEbYJUtJjKjjqf0sVcF1iB0CxqNrKgG5LPGzGyCdynYsy+gi7SqO29S+eqQK+3E9D7Mrw==",
"path": "np.ava.unidockservice/1.0.6",
"hashPath": "np.ava.unidockservice.1.0.6.nupkg.sha512"
},
"NP.Utilities/1.0.30": {
"type": "package",
"serviceable": true,
"sha512": "sha512-yNvPMvlhuh8oYt9qYOoGC650uhe/lSleKI6RV7hEOyLWiah8NgPXwdj2GquR9ySCtWefjPkHYwTUDRwP0hw0ZQ==",
"path": "np.utilities/1.0.30",
"hashPath": "np.utilities.1.0.30.nupkg.sha512"
},
"ReactiveUI/20.1.1": {
"type": "package",
"serviceable": true,

Binary file not shown.

Binary file not shown.

View File

@ -347,6 +347,25 @@
}
}
},
"NP.Ava.UniDockService/1.0.6": {
"dependencies": {
"NP.Utilities": "1.0.30"
},
"runtime": {
"lib/net8.0/NP.Ava.UniDockService.dll": {
"assemblyVersion": "1.0.6.0",
"fileVersion": "1.0.6.0"
}
}
},
"NP.Utilities/1.0.30": {
"runtime": {
"lib/net8.0/NP.Utilities.dll": {
"assemblyVersion": "1.0.30.0",
"fileVersion": "1.0.30.0"
}
}
},
"ReactiveUI/20.1.1": {
"dependencies": {
"DynamicData": "8.4.1",
@ -725,6 +744,20 @@
"path": "newtonsoft.json/13.0.3",
"hashPath": "newtonsoft.json.13.0.3.nupkg.sha512"
},
"NP.Ava.UniDockService/1.0.6": {
"type": "package",
"serviceable": true,
"sha512": "sha512-GHS67athB7fd/qvHJOEbYJUtJjKjjqf0sVcF1iB0CxqNrKgG5LPGzGyCdynYsy+gi7SqO29S+eqQK+3E9D7Mrw==",
"path": "np.ava.unidockservice/1.0.6",
"hashPath": "np.ava.unidockservice.1.0.6.nupkg.sha512"
},
"NP.Utilities/1.0.30": {
"type": "package",
"serviceable": true,
"sha512": "sha512-yNvPMvlhuh8oYt9qYOoGC650uhe/lSleKI6RV7hEOyLWiah8NgPXwdj2GquR9ySCtWefjPkHYwTUDRwP0hw0ZQ==",
"path": "np.utilities/1.0.30",
"hashPath": "np.utilities.1.0.30.nupkg.sha512"
},
"ReactiveUI/20.1.1": {
"type": "package",
"serviceable": true,

Binary file not shown.

Binary file not shown.