From 9de71dcef1a46e45429eae5e0b84bf3430fb3788 Mon Sep 17 00:00:00 2001 From: lihanbo Date: Mon, 14 Oct 2024 08:41:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- App.config | 6 ++ App.xaml | 14 +++ App.xaml.cs | 46 ++++++++ ExcelHelper.csproj | 57 ++++++++++ ExcelHelper.sln | 25 +++++ MainWindow.xaml | 58 ++++++++++ MainWindow.xaml.cs | 37 +++++++ Message/ErrorDialogMessage.cs | 9 ++ Message/UpdateDataGridColumnsMessage.cs | 13 +++ Properties/Resources.Designer.cs | 71 +++++++++++++ Properties/Resources.resx | 117 +++++++++++++++++++++ Properties/Settings.Designer.cs | 30 ++++++ Properties/Settings.settings | 7 ++ Services/ExcelHelperHostedService.cs | 27 +++++ Services/NavigationService.cs | 35 +++++++ Utils/HostExtension.cs | 32 ++++++ Utils/PasswordBoxHelper.cs | 83 +++++++++++++++ Views/IView.cs | 6 ++ Views/IViewModel.cs | 6 ++ Views/Pages/DataListPage.xaml | 16 +++ Views/Pages/DataListPage.xaml.cs | 15 +++ Views/Pages/ImportExcelPage.xaml | 116 ++++++++++++++++++++ Views/Pages/ImportExcelPage.xaml.cs | 79 ++++++++++++++ Views/ViewModels/ImportViewModel.cs | 134 ++++++++++++++++++++++++ Views/ViewModels/MainViewModel.cs | 34 ++++++ 25 files changed, 1073 insertions(+) create mode 100644 App.config create mode 100644 App.xaml create mode 100644 App.xaml.cs create mode 100644 ExcelHelper.csproj create mode 100644 ExcelHelper.sln create mode 100644 MainWindow.xaml create mode 100644 MainWindow.xaml.cs create mode 100644 Message/ErrorDialogMessage.cs create mode 100644 Message/UpdateDataGridColumnsMessage.cs create mode 100644 Properties/Resources.Designer.cs create mode 100644 Properties/Resources.resx create mode 100644 Properties/Settings.Designer.cs create mode 100644 Properties/Settings.settings create mode 100644 Services/ExcelHelperHostedService.cs create mode 100644 Services/NavigationService.cs create mode 100644 Utils/HostExtension.cs create mode 100644 Utils/PasswordBoxHelper.cs create mode 100644 Views/IView.cs create mode 100644 Views/IViewModel.cs create mode 100644 Views/Pages/DataListPage.xaml create mode 100644 Views/Pages/DataListPage.xaml.cs create mode 100644 Views/Pages/ImportExcelPage.xaml create mode 100644 Views/Pages/ImportExcelPage.xaml.cs create mode 100644 Views/ViewModels/ImportViewModel.cs create mode 100644 Views/ViewModels/MainViewModel.cs diff --git a/App.config b/App.config new file mode 100644 index 0000000..aee9adf --- /dev/null +++ b/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/App.xaml b/App.xaml new file mode 100644 index 0000000..74a86bf --- /dev/null +++ b/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/App.xaml.cs b/App.xaml.cs new file mode 100644 index 0000000..f13a95d --- /dev/null +++ b/App.xaml.cs @@ -0,0 +1,46 @@ +using System; +using System.Windows; +using ExcelHelper.Services; +using ExcelHelper.Utils; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace ExcelHelper +{ + /// + /// App.xaml 的交互逻辑 + /// + public partial class App : Application + { + + public static App AppHost; + private readonly IHost _host = Host.CreateDefaultBuilder() + .AddViewAndViewModel() + .ConfigureServices((context, services) => + { + services.AddHostedService(); + services.AddSingleton(); + + + }) + .Build(); + protected override void OnStartup(StartupEventArgs e) + { + AppHost = this; + + base.OnStartup(e); + + // 初始化AppHost + _host.Start(); + } + + public T Get() + { + return _host.Services.GetService(); + } + public object Get(Type type) + { + return _host.Services.GetService(type); + } + } +} diff --git a/ExcelHelper.csproj b/ExcelHelper.csproj new file mode 100644 index 0000000..0da09ee --- /dev/null +++ b/ExcelHelper.csproj @@ -0,0 +1,57 @@ + + + net9.0-windows + WinExe + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + 12.0 + false + true + true + + + + False + Microsoft .NET Framework 4.8.1 %28x86 和 x64%29 + true + + + False + .NET Framework 3.5 SP1 + false + + + + + 8.3.2 + + + 3.5.1 + + + + 1.34.2 + + + 1.14.1 + runtime; build; native; contentfiles; analyzers; buildtransitive + all + + + + + + \ No newline at end of file diff --git a/ExcelHelper.sln b/ExcelHelper.sln new file mode 100644 index 0000000..a09320b --- /dev/null +++ b/ExcelHelper.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35327.3 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExcelHelper", "ExcelHelper.csproj", "{C7A7E24D-513F-4D66-9953-42EDBD0038B7}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C7A7E24D-513F-4D66-9953-42EDBD0038B7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7A7E24D-513F-4D66-9953-42EDBD0038B7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7A7E24D-513F-4D66-9953-42EDBD0038B7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7A7E24D-513F-4D66-9953-42EDBD0038B7}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F92EF236-3F64-4327-8CF6-C6FDBDC7939E} + EndGlobalSection +EndGlobal diff --git a/MainWindow.xaml b/MainWindow.xaml new file mode 100644 index 0000000..e5dfeb2 --- /dev/null +++ b/MainWindow.xaml @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + +