diff --git a/App.xaml b/App.xaml
index 79923b4..c02ef92 100644
--- a/App.xaml
+++ b/App.xaml
@@ -2,13 +2,14 @@
x:Class="PMSWPF.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
xmlns:local="clr-namespace:PMSWPF"
- StartupUri="Views/PlcListView.xaml">
+ >
-
-
+
+
diff --git a/App.xaml.cs b/App.xaml.cs
index cd89c38..d1ef0f7 100644
--- a/App.xaml.cs
+++ b/App.xaml.cs
@@ -14,29 +14,55 @@ namespace PMSWPF
///
public partial class App : Application
{
- [STAThread]
- static void Main(string[] args)
- {
- using IHost host = CreateHostBuilder(args).Build();
- host.Start();
- App app = new App();
- app.InitializeComponent();
- app.MainWindow = host.Services.GetRequiredService();
- app.MainWindow.Visibility = Visibility.Visible;
- app.Run();
+ public new static App Current => (App)Application.Current;
+ public IServiceProvider Services { get; }
+ public App()
+ {
+ var container = new ServiceCollection();
+ container.AddSingleton();
+ container.AddSingleton();
+ container.AddSingleton();
+ container.AddSingleton();
+ container.AddSingleton();
+ container.AddSingleton(dp => new MainView()
+ { DataContext = dp.GetRequiredService() });
+ container.AddSingleton();
+ container.AddSingleton();
+ container.AddSingleton();
+
+ Services = container.BuildServiceProvider();
}
- private static IHostBuilder CreateHostBuilder(string[] args)
+ protected override void OnStartup(StartupEventArgs e)
{
- return Host.CreateDefaultBuilder(args).ConfigureServices(services =>
- {
-
- services.AddHostedService();
- services.AddSingleton();
- services.AddSingleton();
- });
+ base.OnStartup(e);
+ MainWindow = Services.GetRequiredService();
+ MainWindow.Show();
}
+
+ // [STAThread]
+ // static void Main(string[] args)
+ // {
+ // using IHost host = CreateHostBuilder(args).Build();
+ // host.Start();
+ // App app = new App();
+ // app.InitializeComponent();
+ // app.MainWindow = host.Services.GetRequiredService();
+ // app.MainWindow.Visibility = Visibility.Visible;
+ // app.Run();
+ //
+ // }
+ //
+ // private static IHostBuilder CreateHostBuilder(string[] args)
+ // {
+ // return Host.CreateDefaultBuilder(args).ConfigureServices(services =>
+ // {
+ //
+ // services.AddHostedService();
+ // services.AddSingleton();
+ // services.AddSingleton();
+ // });
+ // }
}
-
-}
+}
\ No newline at end of file
diff --git a/PMSWPF.csproj b/PMSWPF.csproj
index 8e041bf..5d0efd2 100644
--- a/PMSWPF.csproj
+++ b/PMSWPF.csproj
@@ -7,14 +7,10 @@
enable
true
-
-
-
-
-
+
diff --git a/Services/NavgatorServices.cs b/Services/NavgatorServices.cs
new file mode 100644
index 0000000..b0b96fb
--- /dev/null
+++ b/Services/NavgatorServices.cs
@@ -0,0 +1,29 @@
+using System.ComponentModel;
+using System.Windows;
+using Microsoft.Extensions.DependencyInjection;
+using PMSWPF.ViewModels;
+
+namespace PMSWPF.Services;
+
+public class NavgatorServices
+{
+ private ViewModelBase currentViewModel;
+
+ public ViewModelBase CurrentViewModel
+ {
+ get { return currentViewModel; }
+ set
+ {
+ currentViewModel = value;
+ OnViewModelChanged?.Invoke();
+ }
+ }
+
+ public event Action OnViewModelChanged ;
+
+ public void NavigateTo() where T : ViewModelBase
+ {
+ // Application.Current
+ CurrentViewModel = App.Current.Services.GetService();
+ }
+}
\ No newline at end of file
diff --git a/ViewModels/DataTransformViewModel.cs b/ViewModels/DataTransformViewModel.cs
new file mode 100644
index 0000000..7842222
--- /dev/null
+++ b/ViewModels/DataTransformViewModel.cs
@@ -0,0 +1,6 @@
+namespace PMSWPF.ViewModels;
+
+public class DataTransformViewModel:ViewModelBase
+{
+
+}
\ No newline at end of file
diff --git a/ViewModels/DevicesViewModel.cs b/ViewModels/DevicesViewModel.cs
new file mode 100644
index 0000000..6301f9f
--- /dev/null
+++ b/ViewModels/DevicesViewModel.cs
@@ -0,0 +1,6 @@
+namespace PMSWPF.ViewModels;
+
+public class DevicesViewModel:ViewModelBase
+{
+
+}
\ No newline at end of file
diff --git a/ViewModels/HomeViewModel.cs b/ViewModels/HomeViewModel.cs
new file mode 100644
index 0000000..2209d82
--- /dev/null
+++ b/ViewModels/HomeViewModel.cs
@@ -0,0 +1,6 @@
+namespace PMSWPF.ViewModels;
+
+public class HomeViewModel:ViewModelBase
+{
+
+}
\ No newline at end of file
diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs
index 87419fd..538664f 100644
--- a/ViewModels/MainViewModel.cs
+++ b/ViewModels/MainViewModel.cs
@@ -3,15 +3,30 @@ using CommunityToolkit.Mvvm.Messaging;
using PMSWPF.Data.Entities;
using PMSWPF.Message;
using System.Collections.ObjectModel;
+using PMSWPF.Services;
namespace PMSWPF.ViewModels
{
partial class MainViewModel : ObservableRecipient, IRecipient
{
-
- public MainViewModel()
- {
+ private readonly NavgatorServices _navgatorServices;
+
+ [ObservableProperty]
+ private ViewModelBase currentViewModel;
+ public MainViewModel(NavgatorServices navgatorServices)
+ {
+ _navgatorServices = navgatorServices;
+ _navgatorServices.OnViewModelChanged += () =>
+ {
+ CurrentViewModel = _navgatorServices.CurrentViewModel;
+ };
IsActive = true;
+ CurrentViewModel = new HomeViewModel();
+ }
+
+ public void NavgateTo() where T : ViewModelBase
+ {
+ _navgatorServices.NavigateTo();
}
string text = "Hello Count:";
diff --git a/ViewModels/PlcListViewModel.cs b/ViewModels/PlcListViewModel.cs
deleted file mode 100644
index f4766b5..0000000
--- a/ViewModels/PlcListViewModel.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using CommunityToolkit.Mvvm.ComponentModel;
-using PMSWPF.Data.Entities;
-using System.Collections.ObjectModel;
-
-namespace PMSWPF.ViewModels
-{
- public partial class PlcListViewModel : ObservableRecipient
- {
- [ObservableProperty]
- private ObservableCollection plcList;
- public PlcListViewModel()
- {
- plcList = new ObservableCollection();
-
- }
- }
-}
diff --git a/ViewModels/ViewModelBase.cs b/ViewModels/ViewModelBase.cs
new file mode 100644
index 0000000..aab001b
--- /dev/null
+++ b/ViewModels/ViewModelBase.cs
@@ -0,0 +1,6 @@
+namespace PMSWPF.ViewModels;
+
+public class ViewModelBase
+{
+
+}
\ No newline at end of file
diff --git a/Views/DataTransformView.xaml b/Views/DataTransformView.xaml
new file mode 100644
index 0000000..75e7a0f
--- /dev/null
+++ b/Views/DataTransformView.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/Views/DataTransformView.xaml.cs b/Views/DataTransformView.xaml.cs
new file mode 100644
index 0000000..587a038
--- /dev/null
+++ b/Views/DataTransformView.xaml.cs
@@ -0,0 +1,11 @@
+using System.Windows.Controls;
+
+namespace PMSWPF.Views;
+
+public partial class DataTransformView : UserControl
+{
+ public DataTransformView()
+ {
+ InitializeComponent();
+ }
+}
\ No newline at end of file
diff --git a/Views/DevicesView.xaml b/Views/DevicesView.xaml
new file mode 100644
index 0000000..3b405cc
--- /dev/null
+++ b/Views/DevicesView.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/Views/DevicesView.xaml.cs b/Views/DevicesView.xaml.cs
new file mode 100644
index 0000000..f6b6e18
--- /dev/null
+++ b/Views/DevicesView.xaml.cs
@@ -0,0 +1,11 @@
+using System.Windows.Controls;
+
+namespace PMSWPF.Views;
+
+public partial class DevicesView : UserControl
+{
+ public DevicesView()
+ {
+ InitializeComponent();
+ }
+}
\ No newline at end of file
diff --git a/Views/HomeView.xaml b/Views/HomeView.xaml
new file mode 100644
index 0000000..42a767d
--- /dev/null
+++ b/Views/HomeView.xaml
@@ -0,0 +1,12 @@
+
+
+
+
+
diff --git a/Views/HomeView.xaml.cs b/Views/HomeView.xaml.cs
new file mode 100644
index 0000000..bc48690
--- /dev/null
+++ b/Views/HomeView.xaml.cs
@@ -0,0 +1,11 @@
+using System.Windows.Controls;
+
+namespace PMSWPF.Views;
+
+public partial class HomeView : UserControl
+{
+ public HomeView()
+ {
+ InitializeComponent();
+ }
+}
\ No newline at end of file
diff --git a/Views/MainView.xaml b/Views/MainView.xaml
index c55a8fa..2af2892 100644
--- a/Views/MainView.xaml
+++ b/Views/MainView.xaml
@@ -3,29 +3,123 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:hc="https://handyorg.github.io/handycontrol"
+ xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
+ xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:PMSWPF.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:vm="clr-namespace:PMSWPF.ViewModels"
Title="MainView"
Width="800"
- Height="450"
+ Height="600"
+ ui:WindowHelper.UseModernWindowStyle="True"
+ ui:WindowHelper.SystemBackdropType="Mica"
d:DataContext="{d:DesignInstance vm:MainViewModel}"
mc:Ignorable="d">
-
-
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Views/MainView.xaml.cs b/Views/MainView.xaml.cs
index e364eda..9bf4185 100644
--- a/Views/MainView.xaml.cs
+++ b/Views/MainView.xaml.cs
@@ -1,4 +1,6 @@
using System.Windows;
+using CommunityToolkit.Mvvm.ComponentModel;
+using iNKORE.UI.WPF.Modern.Controls;
using PMSWPF.ViewModels;
namespace PMSWPF.Views
@@ -8,10 +10,34 @@ namespace PMSWPF.Views
///
public partial class MainView : Window
{
+
public MainView()
{
+
InitializeComponent();
- this.DataContext = new MainViewModel();
+
+ }
+
+ private void NavigationView_SelectionChanged(NavigationView sender, NavigationViewSelectionChangedEventArgs args)
+ {
+ NavigationViewItem? item = args.SelectedItem as NavigationViewItem;
+ MainViewModel mainViewModel = (MainViewModel)this.DataContext ;
+ switch (item.Tag)
+ {
+ case "Home":
+ mainViewModel.NavgateTo();
+ break;
+ case "Devices":
+ mainViewModel.NavgateTo();
+ break;
+ case "DataTransform":
+ mainViewModel.NavgateTo();
+ break;
+ default:
+ mainViewModel.NavgateTo();
+ break;
+
+ }
}
}
}
diff --git a/Views/PlcListView.xaml b/Views/PlcListView.xaml
deleted file mode 100644
index e0dc78a..0000000
--- a/Views/PlcListView.xaml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/Views/PlcListView.xaml.cs b/Views/PlcListView.xaml.cs
deleted file mode 100644
index 8efd747..0000000
--- a/Views/PlcListView.xaml.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Shapes;
-
-namespace PMSWPF.Views
-{
- ///
- /// PlcListView.xaml 的交互逻辑
- ///
- public partial class PlcListView : Window
- {
- public PlcListView()
- {
- InitializeComponent();
- }
- }
-}