From 80ee49214799c94ceaaa4b23583ec78072dfce62 Mon Sep 17 00:00:00 2001 From: ZGGSONG Date: Fri, 20 May 2022 19:45:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=9F=BA=E6=9C=AC=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 398 +++++++++++++++++++++ ScadaTool.sln | 25 ++ ScadaTool/App.config | 6 + ScadaTool/App.xaml | 17 + ScadaTool/App.xaml.cs | 17 + ScadaTool/Helper/CommandHelper.cs | 37 ++ ScadaTool/Helper/GoCSharpHelper.cs | 32 ++ ScadaTool/Helper/SingletonMode.cs | 29 ++ ScadaTool/Helper/ViewModelHelper.cs | 19 + ScadaTool/MainWindow.xaml | 46 +++ ScadaTool/MainWindow.xaml.cs | 39 ++ ScadaTool/Properties/AssemblyInfo.cs | 55 +++ ScadaTool/Properties/Resources.Designer.cs | 93 +++++ ScadaTool/Properties/Resources.resx | 130 +++++++ ScadaTool/Properties/Settings.Designer.cs | 29 ++ ScadaTool/Properties/Settings.settings | 7 + ScadaTool/Resources/icon.ico | Bin 0 -> 67646 bytes ScadaTool/Resources/icon_red.ico | Bin 0 -> 67646 bytes ScadaTool/Resources/none.ico | Bin 0 -> 67646 bytes ScadaTool/ScadaTool.csproj | 146 ++++++++ ScadaTool/ViewModel/BaseViewModel.cs | 17 + ScadaTool/ViewModel/MainViewModel.cs | 104 ++++++ ScadaTool/packages.config | 7 + 23 files changed, 1253 insertions(+) create mode 100644 .gitignore create mode 100644 ScadaTool.sln create mode 100644 ScadaTool/App.config create mode 100644 ScadaTool/App.xaml create mode 100644 ScadaTool/App.xaml.cs create mode 100644 ScadaTool/Helper/CommandHelper.cs create mode 100644 ScadaTool/Helper/GoCSharpHelper.cs create mode 100644 ScadaTool/Helper/SingletonMode.cs create mode 100644 ScadaTool/Helper/ViewModelHelper.cs create mode 100644 ScadaTool/MainWindow.xaml create mode 100644 ScadaTool/MainWindow.xaml.cs create mode 100644 ScadaTool/Properties/AssemblyInfo.cs create mode 100644 ScadaTool/Properties/Resources.Designer.cs create mode 100644 ScadaTool/Properties/Resources.resx create mode 100644 ScadaTool/Properties/Settings.Designer.cs create mode 100644 ScadaTool/Properties/Settings.settings create mode 100644 ScadaTool/Resources/icon.ico create mode 100644 ScadaTool/Resources/icon_red.ico create mode 100644 ScadaTool/Resources/none.ico create mode 100644 ScadaTool/ScadaTool.csproj create mode 100644 ScadaTool/ViewModel/BaseViewModel.cs create mode 100644 ScadaTool/ViewModel/MainViewModel.cs create mode 100644 ScadaTool/packages.config diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..426d76d --- /dev/null +++ b/.gitignore @@ -0,0 +1,398 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET Core +project.lock.json +project.fragment.lock.json +artifacts/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml diff --git a/ScadaTool.sln b/ScadaTool.sln new file mode 100644 index 0000000..37521a4 --- /dev/null +++ b/ScadaTool.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31702.278 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ScadaTool", "ScadaTool\ScadaTool.csproj", "{0094F091-CB99-4044-88F0-0B26EAE2CA0C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0094F091-CB99-4044-88F0-0B26EAE2CA0C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0094F091-CB99-4044-88F0-0B26EAE2CA0C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0094F091-CB99-4044-88F0-0B26EAE2CA0C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0094F091-CB99-4044-88F0-0B26EAE2CA0C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {04B7ED67-0335-4EAA-AADB-393227E9B0E2} + EndGlobalSection +EndGlobal diff --git a/ScadaTool/App.config b/ScadaTool/App.config new file mode 100644 index 0000000..88fa402 --- /dev/null +++ b/ScadaTool/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/ScadaTool/App.xaml b/ScadaTool/App.xaml new file mode 100644 index 0000000..1ccb6a4 --- /dev/null +++ b/ScadaTool/App.xaml @@ -0,0 +1,17 @@ + + + + + + + + + + + diff --git a/ScadaTool/App.xaml.cs b/ScadaTool/App.xaml.cs new file mode 100644 index 0000000..80d6a6a --- /dev/null +++ b/ScadaTool/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace ScadaTool +{ + /// + /// App.xaml 的交互逻辑 + /// + public partial class App : Application + { + } +} diff --git a/ScadaTool/Helper/CommandHelper.cs b/ScadaTool/Helper/CommandHelper.cs new file mode 100644 index 0000000..0968fda --- /dev/null +++ b/ScadaTool/Helper/CommandHelper.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; + +namespace ScadaTool.Helper +{ + public class RelayCommand : ICommand + { + private Predicate _canExecute; + private Action _execute; + + public RelayCommand(Predicate canExecute, Action execute) + { + this._canExecute = canExecute; + this._execute = execute; + } + + public event EventHandler CanExecuteChanged + { + add { CommandManager.RequerySuggested += value; } + remove { CommandManager.RequerySuggested -= value; } + } + + public bool CanExecute(object parameter) + { + return _canExecute(parameter); + } + + public void Execute(object parameter) + { + _execute(parameter); + } + } +} diff --git a/ScadaTool/Helper/GoCSharpHelper.cs b/ScadaTool/Helper/GoCSharpHelper.cs new file mode 100644 index 0000000..afa4ec1 --- /dev/null +++ b/ScadaTool/Helper/GoCSharpHelper.cs @@ -0,0 +1,32 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace ScadaTool.Helper +{ + public class GoCSharpHelper : SingletonMode + { + /// + /// 转换Go string类型为C# String + /// + public struct GoString + { + public IntPtr p; + public int n; + public GoString(IntPtr n1, int n2) + { + p = n1; n = n2; + } + } + public string GoStringToCSharpString(GoString goString) + { + byte[] bytes = new byte[goString.n]; + for (int i = 0; i < goString.n; i++) + { + bytes[i] = Marshal.ReadByte(goString.p, i); + } + string result = Encoding.UTF8.GetString(bytes); + return result; + } + } +} diff --git a/ScadaTool/Helper/SingletonMode.cs b/ScadaTool/Helper/SingletonMode.cs new file mode 100644 index 0000000..d6da988 --- /dev/null +++ b/ScadaTool/Helper/SingletonMode.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ScadaTool.Helper +{ + /// + /// 单例辅助类 + /// + public class SingletonMode where T : class + { + public static T _Instance; + public static T Instance() + { + Type type = typeof(T); + lock (type) + { + if (SingletonMode._Instance == null) + { + SingletonMode._Instance = (Activator.CreateInstance(typeof(T), true) as T); + } + return SingletonMode._Instance; + } + } + + } +} diff --git a/ScadaTool/Helper/ViewModelHelper.cs b/ScadaTool/Helper/ViewModelHelper.cs new file mode 100644 index 0000000..22a4967 --- /dev/null +++ b/ScadaTool/Helper/ViewModelHelper.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace ScadaTool.Helper +{ + public class ViewModelHelper : SingletonMode + { + public SynchronizationContext Context; + + public void UpdateUI(Action action) + { + Context?.Post((state) => action(), null); + } + } +} diff --git a/ScadaTool/MainWindow.xaml b/ScadaTool/MainWindow.xaml new file mode 100644 index 0000000..31ee1af --- /dev/null +++ b/ScadaTool/MainWindow.xaml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +