diff --git a/newFront/c#前端/CAD.Extend/.vs/CAD.Extend.csproj.dtbcache.json b/newFront/c#前端/CAD.Extend/.vs/CAD.Extend.csproj.dtbcache.json new file mode 100644 index 00000000..f1669d77 --- /dev/null +++ b/newFront/c#前端/CAD.Extend/.vs/CAD.Extend.csproj.dtbcache.json @@ -0,0 +1 @@ +{"RootPath":"E:\\Di-Electrical\\c#前端\\CAD.Extend","ProjectFileName":"CAD.Extend.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"Commands.cs"},{"SourceFile":"GlobalObject.cs"},{"SourceFile":"Model\\KeyValueModel.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"ViewModels\\DialogConvertBaseMapViewModel.cs"},{"SourceFile":"ViewModels\\myViewModelBase\\DialogBase.cs"},{"SourceFile":"Views\\CustomControl\\customWindowTitleBar.xaml.cs"},{"SourceFile":"Views\\CustomDialogWindow.xaml.cs"},{"SourceFile":"Views\\DialogConvertBaseMap.xaml.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"}],"References":[{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\DryIoc.dll.5.4.3\\lib\\net45\\DryIoc.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Microsoft.Bcl.AsyncInterfaces.8.0.0\\lib\\net462\\Microsoft.Bcl.AsyncInterfaces.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.1\\lib\\net462\\Microsoft.Extensions.DependencyInjection.Abstractions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Microsoft.Xaml.Behaviors.Wpf.1.1.122\\lib\\net462\\Microsoft.Xaml.Behaviors.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\PresentationCore.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\PresentationFramework.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Prism.Container.Abstractions.9.0.106\\lib\\net47\\Prism.Container.Abstractions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Prism.Container.DryIoc.9.0.106\\lib\\net47\\Prism.Container.DryIoc.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Prism.Container.Unity.9.0.106\\lib\\net462\\Prism.Container.Unity.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Prism.Core.9.0.537\\lib\\net47\\Prism.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Prism.DryIoc.9.0.537\\lib\\net47\\Prism.DryIoc.Wpf.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Prism.Events.9.0.537\\lib\\net47\\Prism.Events.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Prism.Unity.9.0.537\\lib\\net47\\Prism.Unity.Wpf.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Prism.Wpf.9.0.537\\lib\\net47\\Prism.Wpf.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD.Base\\bin\\Debug\\SWS.CAD.Base.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":true,"ProjectPath":"E:\\Di-Electrical\\c#前端\\SWS.CAD.Base\\bin\\Debug\\SWS.CAD.Base.dll"},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Configuration.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Drawing.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\System.Runtime.CompilerServices.Unsafe.4.5.3\\lib\\net461\\System.Runtime.CompilerServices.Unsafe.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\System.Threading.Tasks.Extensions.4.5.4\\lib\\net461\\System.Threading.Tasks.Extensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\System.ValueTuple.4.5.0\\lib\\net47\\System.ValueTuple.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Web.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Windows.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Windows.Forms.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xaml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.FileDialogs.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.GridView.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.Input.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.Navigation.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Unity.Abstractions.5.11.7\\lib\\net48\\Unity.Abstractions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Unity.Container.5.11.11\\lib\\net48\\Unity.Container.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\WindowsBase.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"E:\\Di-Electrical\\c#前端\\CAD.Extend\\bin\\Debug\\CAD.Extend.dll","OutputItemRelativePath":"CAD.Extend.dll"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file diff --git a/newFront/c#前端/CAD.Extend/CAD.Extend.csproj b/newFront/c#前端/CAD.Extend/CAD.Extend.csproj new file mode 100644 index 00000000..37231d23 --- /dev/null +++ b/newFront/c#前端/CAD.Extend/CAD.Extend.csproj @@ -0,0 +1,189 @@ + + + + + Debug + AnyCPU + {8740B023-B585-4E69-8521-4F62FA754A1B} + Library + Properties + CAD.Extend + CAD.Extend + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\..\Program Files\KunHeng\KunHengCAD V21 zh_CN\BrxMgd.dll + + + ..\packages\DryIoc.dll.5.4.3\lib\net45\DryIoc.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.122\lib\net462\Microsoft.Xaml.Behaviors.dll + + + + + ..\packages\Prism.Core.9.0.537\lib\net47\Prism.dll + + + ..\packages\Prism.Container.Abstractions.9.0.106\lib\net47\Prism.Container.Abstractions.dll + + + ..\packages\Prism.Container.DryIoc.9.0.106\lib\net47\Prism.Container.DryIoc.dll + + + ..\packages\Prism.Container.Unity.9.0.106\lib\net462\Prism.Container.Unity.dll + + + ..\packages\Prism.DryIoc.9.0.537\lib\net47\Prism.DryIoc.Wpf.dll + + + ..\packages\Prism.Events.9.0.537\lib\net47\Prism.Events.dll + + + ..\packages\Prism.Unity.9.0.537\lib\net47\Prism.Unity.Wpf.dll + + + ..\packages\Prism.Wpf.9.0.537\lib\net47\Prism.Wpf.dll + + + + + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + + + + + + + + + + + + + ..\..\..\..\..\Program Files\KunHeng\KunHengCAD V21 zh_CN\TD_Mgd.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.Data.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.FileDialogs.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.GridView.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.Input.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.Navigation.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Data.dll + + + ..\packages\Unity.Abstractions.5.11.7\lib\net48\Unity.Abstractions.dll + + + ..\packages\Unity.Container.5.11.11\lib\net48\Unity.Container.dll + + + + + + + + + + + + customWindowTitleBar.xaml + + + CustomDialogWindow.xaml + + + DialogConvertBaseMap.xaml + + + + + + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + + + + + + + {d4a15774-1469-45a0-9eff-771271764a00} + SWS.CAD.Base + + + + + + + \ No newline at end of file diff --git a/newFront/c#前端/CAD.Extend/CAD.Extend.csproj.user b/newFront/c#前端/CAD.Extend/CAD.Extend.csproj.user new file mode 100644 index 00000000..0a8cb176 --- /dev/null +++ b/newFront/c#前端/CAD.Extend/CAD.Extend.csproj.user @@ -0,0 +1,7 @@ + + + + Program + D:\Program Files\KunHeng\KunHengCAD V21 zh_CN\kunhengcad.exe + + \ No newline at end of file diff --git a/newFront/c#前端/CAD.Extend/Commands.cs b/newFront/c#前端/CAD.Extend/Commands.cs new file mode 100644 index 00000000..12c90eba --- /dev/null +++ b/newFront/c#前端/CAD.Extend/Commands.cs @@ -0,0 +1,145 @@ +using System; +using System.Linq; +using System.Windows.Forms; +using Bricscad.Ribbon; +using Bricscad.Windows; +using CAD.Extend; +using CAD.Extend.ViewModels; +using CAD.Extend.Views; +using Prism.Container.DryIoc; +using Prism.Dialogs; +using Prism.Ioc; +using SWS.CAD.Base; +using Teigha.Runtime; +using Telerik.Windows.Controls; +using Unity; +using Application = Bricscad.ApplicationServices.Application; + +[assembly: CommandClass(typeof(Commands))] +[assembly: ExtensionApplication(typeof(Commands))] +namespace CAD.Extend +{ + public partial class Commands : IExtensionApplication + { + + public void Initialize() + { + + try + { + AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException; + if (RibbonServices.RibbonPaletteSet == null) + RibbonServices.CreateRibbonPaletteSet(); + + Register(); + + AddTab(); + } + catch (System.Exception e) + { + Application.ShowAlertDialog(" An exception occurred in Initialize():\n" + e.ToString()); + } + } + + private void Register() + { + + GlobalObject._prismContainer = new DryIocContainerExtension(); + GlobalObject._prismContainer.Register(); + GlobalObject._prismContainer.Register(); + GlobalObject._prismContainer.RegisterDialog(); + } + + private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) + { + try + { + // 记录异常信息到日志文件,这里简单打印到控制台 + System.Exception ex = e.ExceptionObject as System.Exception; + Console.WriteLine($"发生未处理的异常: {ex.Message}"); + Console.WriteLine($"异常堆栈跟踪: {ex.StackTrace}"); + + // 关闭所有打开的对话框窗口 + + + // 提示用户发生了错误 + MessageBox.Show("发生错误,请检查日志文件以获取更多信息。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + catch (System.Exception innerEx) + { + // 如果在处理异常时又发生了异常,简单打印信息 + Console.WriteLine($"处理异常时发生错误: {innerEx.Message}"); + } + } + + public void Terminate() + { + } + + void AddTab() + { + RibbonControl rbnCtrl = ComponentManager.Ribbon; //整个上面都是ribbon,比如莫工做的电气系统,就是ribbon中的一个tab + + if (rbnCtrl == null) return; + #region create Ribbon tab + RibbonTab tab1 = new RibbonTab(); + tab1.Title = "扩展功能"; + tab1.Id = "扩展功能"; + rbnCtrl.Tabs.Add(tab1);//一个就行了 + #endregion + + #region Ribbon 图层管理 + RibbonPanelSource dataSource = new RibbonPanelSource(); + dataSource.Title = "图层操作"; + dataSource.Id = "图层操作"; + RibbonPanel dataPanel = new RibbonPanel(); + dataPanel.Source = dataSource; + tab1.Panels.Add(dataPanel); + + //垂直排列按钮panel + RibbonRowPanel ribbonRowPanel = new RibbonRowPanel(); + + #region buttons 一键转底图 + RibbonButton btnSinalManage = new RibbonButton(); + btnSinalManage.ToolTip = "一键转底图"; + btnSinalManage.Text = "一键转底图"; + btnSinalManage.ButtonStyle = RibbonButtonStyle.SmallWithText; + btnSinalManage.CommandHandler = new DelegateCommand(x => + { + var listObjectId=General.GetSelectedObjectId(); + if (listObjectId==null||!listObjectId.Any()) + { + MessageBox.Show("请先选择图元!"); + return; + } + //打开窗体 + Prism.Dialogs.DialogParameters para = new Prism.Dialogs.DialogParameters(); + para.Add(GlobalObject.dialogPar.info.ToString(), listObjectId); + var _dialogService = GlobalObject._prismContainer.Resolve(); + _dialogService.ShowDialog(nameof(DialogConvertBaseMap), para, (RES) => + { + if (RES.Result == ButtonResult.Yes) + { + + } + else if (RES.Result == ButtonResult.No) + { } + }); + }); + btnSinalManage.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CAD.Extend.Images.pic1.png"); + btnSinalManage.Id = "一键转底图"; + ribbonRowPanel.Items.Add(btnSinalManage); + ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列 + #endregion + dataSource.Items.Add(ribbonRowPanel); + #endregion + + } + + } +} + + + + + diff --git a/newFront/c#前端/CAD.Extend/GlobalObject.cs b/newFront/c#前端/CAD.Extend/GlobalObject.cs new file mode 100644 index 00000000..44e4c135 --- /dev/null +++ b/newFront/c#前端/CAD.Extend/GlobalObject.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Net.Http; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Media; +using Prism.Ioc; +using Unity; + +namespace CAD.Extend +{ + public class GlobalObject + { + public static IContainerExtension _prismContainer; + public enum dialogPar + { + info, + para1, + para2 + } + /// + /// 获取图片 + /// + /// 包括命名空间 + /// + public static System.Windows.Media.ImageSource ImageSourceFromEmbeddedResourceStream(string resName) + { + System.Reflection.Assembly assy = System.Reflection.Assembly.GetExecutingAssembly(); + //foreach (string resource in assy.GetManifestResourceNames()) + //{ + // Console.WriteLine(resource);//遍历所有的内嵌资源 + //} + System.IO.Stream stream = assy.GetManifestResourceStream(resName); + if (stream == null) + return null; + System.Windows.Media.Imaging.BitmapImage img = new System.Windows.Media.Imaging.BitmapImage(); + img.BeginInit(); + img.StreamSource = stream; + img.EndInit(); + return img; + } + + } +} diff --git a/newFront/c#前端/CAD.Extend/Properties/AssemblyInfo.cs b/newFront/c#前端/CAD.Extend/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..feb0fe8d --- /dev/null +++ b/newFront/c#前端/CAD.Extend/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("CAD.Extend")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("CAD.Extend")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("8740b023-b585-4e69-8521-4f62fa754a1b")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/newFront/c#前端/CAD.Extend/ViewModels/DialogConvertBaseMapViewModel.cs b/newFront/c#前端/CAD.Extend/ViewModels/DialogConvertBaseMapViewModel.cs new file mode 100644 index 00000000..25e55cae --- /dev/null +++ b/newFront/c#前端/CAD.Extend/ViewModels/DialogConvertBaseMapViewModel.cs @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +using Bricscad.Windows; +using CAD.Extend.Model; +using Prism.Commands; +using Prism.Dialogs; +using SWS.CAD.Base; +using Teigha.Colors; +using Teigha.DatabaseServices; +using Brush = System.Windows.Media.Brush; +using Color = System.Windows.Media.Color; + +namespace CAD.Extend.ViewModels +{ + public class DialogConvertBaseMapViewModel : DialogBase, IDialogAware + { + #region binding + private ObservableCollection _listLayerName = new ObservableCollection(); + /// + /// 底图名列表 + /// + public ObservableCollection listLayerName + { + get { return _listLayerName; } + set { _listLayerName = value; RaisePropertyChanged(nameof(listLayerName)); } + } + private KeyValueModel _SelectedLayerName; + /// + /// 选中的底图名 + /// + public KeyValueModel SelectedLayerName + { + get { return _SelectedLayerName; } + set { _SelectedLayerName = value; RaisePropertyChanged(nameof(SelectedLayerName)); } + } + private bool _IsToBlock; + /// + /// 是否转为图块 + /// + public bool IsToBlock + { + get { return _IsToBlock; } + set { _IsToBlock = value; RaisePropertyChanged(nameof(IsToBlock)); } + } + #endregion + + private string _BlockName = "EI-Elec专用底图"; + /// + /// 块名 + /// + public string BlockName + { + get { return _BlockName; } + set { _BlockName = value; RaisePropertyChanged(nameof(BlockName)); } + } + private Brush _BlockColor; + /// + /// 图层颜色 + /// + public Brush BlockColor + { + get { return _BlockColor; } + set { _BlockColor = value; RaisePropertyChanged(nameof(BlockColor)); } + } + + /// + /// 随机块名 + /// + public ICommand Command_BlockName { get; set; } + /// + /// 颜色 + /// + public ICommand Command_Color { get; set; } + /// + /// 图层颜色 默认灰色 + /// + Teigha.Colors.Color layerColor = Teigha.Colors.Color.FromColorIndex(ColorMethod.ByAci, 8); + List listObjectId = new List(); + string layerName = "EI-Elec专用底图图层"; + public DialogConvertBaseMapViewModel() + { + title = "背景底图设置"; + Command_BlockName = new DelegateCommand(onBlockName); + Command_Color = new DelegateCommand(onColor); + System.Drawing.Color winColor = layerColor.ColorValue; + var c = Color.FromArgb(winColor.A, winColor.R, winColor.G, winColor.B); + BlockColor = new SolidColorBrush(c); + } + /// + /// 颜色选择 + /// + public void onColor() + { + var list=General.GetTopLevelDictionaryNames(); + + ColorDialog dlg = new ColorDialog(); + + if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) + { + layerColor = dlg.Color; + System.Drawing.Color winColor = dlg.Color.ColorValue; + var b = Color.FromArgb(winColor.A, winColor.R, winColor.G, winColor.B); + BlockColor = new SolidColorBrush(b); + } + } + /// + /// 随机块名 + /// + public void onBlockName() + { + var a = GetRndABC(); + Thread.Sleep(10); + var b = GetRndABC(); + Thread.Sleep(10); + var c = GetRndABC(); + BlockName = "EI-Elec图块" + a + b + c; + } + public string GetRndABC() + { + // a-z ASCII值 97-122 + // A-Z ASCII值 65-90 + int i = new Random().Next(65, 90); + char c = (char)i; + return c.ToString(); + } + + #region Dialog + + public DialogCloseListener RequestClose { get; } + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + + } + + #endregion + + public void OnDialogOpened(IDialogParameters parameters) + { + listObjectId = parameters.GetValue>(GlobalObject.dialogPar.info.ToString()); + var list = General.GetAllLayerNames(); + foreach (var layerName in list) + { + if (layerName.Equals(layerName)) + { listLayerName.Insert(0, new KeyValueModel() { Key = layerName, Value = layerName }); } + else + { + listLayerName.Add(new KeyValueModel() { Key = layerName, Value = layerName }); + } + } + if (!listLayerName.Where(a => a.Key == layerName).Any()) + { listLayerName.Insert(0, new KeyValueModel() { Key = layerName, Value = layerName }); } + SelectedLayerName = listLayerName[0]; + } + public override void ExecuteOKCommandAsync(object para) + { + if (IsToBlock) + { + if (string.IsNullOrEmpty(BlockName)) + { + MessageBox.Show("块名不能为空!"); + return; + } + if (General.CheckHasBlockName(BlockName)) + { + MessageBox.Show("块名已存在,请更换块名!"); + return; + } + General.SetEntityToLayer(listObjectId, SelectedLayerName.Value, layerColor, BlockName); + } + else + { + General.SetEntityToLayer(listObjectId, SelectedLayerName.Value, layerColor); + } + MessageBox.Show("底图设置成功!"); + //Prism.Dialogs.DialogParameters resPara = new Prism.Dialogs.DialogParameters(); + //RequestClose.Invoke(resPara, ButtonResult.Yes); + } + public override void ExecuteCloseCommand(object parameter) + { + if (parameter as string == "ClickNo") + { + RequestClose.Invoke(ButtonResult.No); + } + else + { + RequestClose.Invoke(ButtonResult.Cancel); + } + this.Dispose(); + } + + } + + +} diff --git a/newFront/c#前端/CAD.Extend/app.config b/newFront/c#前端/CAD.Extend/app.config new file mode 100644 index 00000000..c5c88e05 --- /dev/null +++ b/newFront/c#前端/CAD.Extend/app.config @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/newFront/c#前端/CAD.Extend/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs b/newFront/c#前端/CAD.Extend/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs new file mode 100644 index 00000000..15efebfc --- /dev/null +++ b/newFront/c#前端/CAD.Extend/obj/Debug/.NETFramework,Version=v4.8.AssemblyAttributes.cs @@ -0,0 +1,4 @@ +// +using System; +using System.Reflection; +[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] diff --git a/newFront/c#前端/CAD.Extend/obj/Debug/CAD.Extend.csproj.AssemblyReference.cache b/newFront/c#前端/CAD.Extend/obj/Debug/CAD.Extend.csproj.AssemblyReference.cache new file mode 100644 index 00000000..29871103 Binary files /dev/null and b/newFront/c#前端/CAD.Extend/obj/Debug/CAD.Extend.csproj.AssemblyReference.cache differ diff --git a/newFront/c#前端/CAD.Extend/obj/Debug/CAD.Extend.csproj.FileListAbsolute.txt b/newFront/c#前端/CAD.Extend/obj/Debug/CAD.Extend.csproj.FileListAbsolute.txt new file mode 100644 index 00000000..5bb1707d --- /dev/null +++ b/newFront/c#前端/CAD.Extend/obj/Debug/CAD.Extend.csproj.FileListAbsolute.txt @@ -0,0 +1 @@ +E:\Di-Electrical\c#前端\CAD.Extend\obj\Debug\CAD.Extend.csproj.AssemblyReference.cache diff --git a/newFront/c#前端/CAD.Extend/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache b/newFront/c#前端/CAD.Extend/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache new file mode 100644 index 00000000..541f4246 Binary files /dev/null and b/newFront/c#前端/CAD.Extend/obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache differ diff --git a/newFront/c#前端/CAD.Extend/packages.config b/newFront/c#前端/CAD.Extend/packages.config new file mode 100644 index 00000000..496f75f8 --- /dev/null +++ b/newFront/c#前端/CAD.Extend/packages.config @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/newFront/c#前端/DI-Electrical/.vs/DI-Electrical.csproj.dtbcache.json b/newFront/c#前端/DI-Electrical/.vs/DI-Electrical.csproj.dtbcache.json new file mode 100644 index 00000000..77dfad2d --- /dev/null +++ b/newFront/c#前端/DI-Electrical/.vs/DI-Electrical.csproj.dtbcache.json @@ -0,0 +1 @@ +{"RootPath":"E:\\Di-Electrical\\c#前端\\DI-Electrical","ProjectFileName":"DI-Electrical.csproj","Configuration":"Debug|AnyCPU","FrameworkPath":"","Sources":[{"SourceFile":"App.xaml.cs"},{"SourceFile":"Event\\loginEvent.cs"},{"SourceFile":"GlobalObject.cs"},{"SourceFile":"Helper\\ConfigService.cs"},{"SourceFile":"Helper\\FileHelper.cs"},{"SourceFile":"Helper\\LoggerHelper.cs"},{"SourceFile":"Model\\ec_project.cs"},{"SourceFile":"Model\\NoEntity\\ConfigIni.cs"},{"SourceFile":"Model\\NoEntity\\learunHttpRes.cs"},{"SourceFile":"Model\\NoEntity\\loginRes.cs"},{"SourceFile":"Model\\NoEntity\\PageModel.cs"},{"SourceFile":"Model\\user.cs"},{"SourceFile":"Services\\HttpService.cs"},{"SourceFile":"Services\\LoginService.cs"},{"SourceFile":"Services\\ProjectService.cs"},{"SourceFile":"Services\\UserService.cs"},{"SourceFile":"ViewModels\\ConfigViewModel.cs"},{"SourceFile":"ViewModels\\LoginViewModel.cs"},{"SourceFile":"ViewModels\\DialogTestViewModel.cs"},{"SourceFile":"ViewModels\\myViewModelBase\\DialogBase.cs"},{"SourceFile":"ViewModels\\ProjectViewModel.cs"},{"SourceFile":"Views\\Config.xaml.cs"},{"SourceFile":"Views\\CustomControl\\customWindowTitleBar.xaml.cs"},{"SourceFile":"Helper\\PasswordHelper.cs"},{"SourceFile":"ViewModels\\MainWindowViewModel.cs"},{"SourceFile":"Views\\Dialog\\DialogTest.xaml.cs"},{"SourceFile":"Views\\Login.xaml.cs"},{"SourceFile":"Views\\MainWindow.xaml.cs"},{"SourceFile":"Views\\Project.xaml.cs"},{"SourceFile":"Properties\\AssemblyInfo.cs"},{"SourceFile":"Properties\\Resources.Designer.cs"},{"SourceFile":"Properties\\Settings.Designer.cs"},{"SourceFile":"obj\\Debug\\.NETFramework,Version=v4.8.AssemblyAttributes.cs"},{"SourceFile":"E:\\Di-Electrical\\c#前端\\DI-Electrical\\obj\\Debug\\Views\\Config.g.cs"},{"SourceFile":"E:\\Di-Electrical\\c#前端\\DI-Electrical\\obj\\Debug\\Views\\CustomControl\\customWindowTitleBar.g.cs"},{"SourceFile":"E:\\Di-Electrical\\c#前端\\DI-Electrical\\obj\\Debug\\Views\\Dialog\\DialogTest.g.cs"},{"SourceFile":"E:\\Di-Electrical\\c#前端\\DI-Electrical\\obj\\Debug\\Views\\MainWindow.g.cs"},{"SourceFile":"E:\\Di-Electrical\\c#前端\\DI-Electrical\\obj\\Debug\\Views\\Project.g.cs"},{"SourceFile":"E:\\Di-Electrical\\c#前端\\DI-Electrical\\obj\\Debug\\GeneratedInternalTypeHelper.g.cs"}],"References":[{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\DryIoc.dll.5.4.3\\lib\\net45\\DryIoc.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\EasyEncryption.1.0.2\\lib\\EasyEncryption.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\ini-parser.2.5.2\\lib\\net20\\INIFileParser.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Microsoft.Bcl.AsyncInterfaces.8.0.0\\lib\\net462\\Microsoft.Bcl.AsyncInterfaces.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\Microsoft.CSharp.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.1\\lib\\net462\\Microsoft.Extensions.DependencyInjection.Abstractions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\mscorlib.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Newtonsoft.Json.13.0.3\\lib\\net45\\Newtonsoft.Json.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\PresentationCore.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\PresentationFramework.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Configuration.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Core.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.DataSetExtensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Net.Http.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\System.Runtime.CompilerServices.Unsafe.4.5.3\\lib\\net461\\System.Runtime.CompilerServices.Unsafe.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\System.Threading.Tasks.Extensions.4.5.4\\lib\\net461\\System.Threading.Tasks.Extensions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\System.ValueTuple.4.5.0\\lib\\net47\\System.ValueTuple.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Web.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xaml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\System.Xml.Linq.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.FileDialogs.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.GridView.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.Input.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Controls.Navigation.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\SWS.CAD\\RefDLL\\WPF45\\Telerik.Windows.Data.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Unity.Abstractions.5.11.7\\lib\\net48\\Unity.Abstractions.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"E:\\Di-Electrical\\c#前端\\packages\\Unity.Container.5.11.11\\lib\\net48\\Unity.Container.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""},{"Reference":"C:\\Program Files (x86)\\Reference Assemblies\\Microsoft\\Framework\\.NETFramework\\v4.8\\WindowsBase.dll","ResolvedFrom":"","OriginalItemSpec":"","Name":"","EmbedInteropTypes":false,"CopyLocal":false,"IsProjectReference":false,"ProjectPath":""}],"Analyzers":[],"Outputs":[{"OutputItemFullPath":"E:\\Di-Electrical\\c#前端\\DI-Electrical\\bin\\Debug\\DI-Electrical.exe","OutputItemRelativePath":"DI-Electrical.exe"},{"OutputItemFullPath":"","OutputItemRelativePath":""}],"CopyToOutputEntries":[]} \ No newline at end of file diff --git a/newFront/c#前端/DI-Electrical/App.config b/newFront/c#前端/DI-Electrical/App.config new file mode 100644 index 00000000..efa79b30 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/App.config @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/newFront/c#前端/DI-Electrical/App.xaml b/newFront/c#前端/DI-Electrical/App.xaml new file mode 100644 index 00000000..0d30f24b --- /dev/null +++ b/newFront/c#前端/DI-Electrical/App.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + diff --git a/newFront/c#前端/DI-Electrical/App.xaml.cs b/newFront/c#前端/DI-Electrical/App.xaml.cs new file mode 100644 index 00000000..be4c6c7c --- /dev/null +++ b/newFront/c#前端/DI-Electrical/App.xaml.cs @@ -0,0 +1,71 @@ +using System.Windows; +using DI_Electrical.Helper; +using DI_Electrical.Services; +using DI_Electrical.ViewModels; +using DI_Electrical.Views; +using DI_Electrical.Views.Dialog; +using DI_Electrical.Views.Dialog.DialogSignalManagements; +using Prism.Events; +using Prism.Ioc; +using Prism.Services.Dialogs; +using Prism.Unity; +using Unity; + +namespace DI_Electrical +{ + /// + /// App.xaml 的交互逻辑 + /// + public partial class App : PrismApplication + { + protected override Window CreateShell() + { + return Container.Resolve(); + } + + protected override void InitializeShell(Window shell) + { + var login = Container.Resolve(); + login.ShowDialog(); + if (GlobalObject.userInfo == null) + { + Application.Current?.Shutdown(); + return; + } + var project = Container.Resolve(); + project.ShowDialog(); + if (GlobalObject.curProject == null) + { + Application.Current?.Shutdown(); + return; + } + base.InitializeShell(shell); + + } + + protected override void RegisterTypes(IContainerRegistry containerRegistry) + { + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterForNavigation(); + containerRegistry.RegisterDialog(); + containerRegistry.RegisterDialog(); + containerRegistry.RegisterDialog(); + containerRegistry.RegisterDialog(); + containerRegistry.RegisterDialog(); + containerRegistry.RegisterDialog(); + + containerRegistry.Register(); + + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + containerRegistry.RegisterSingleton(); + + } + } +} diff --git a/newFront/c#前端/DI-Electrical/DI-Electrical.csproj b/newFront/c#前端/DI-Electrical/DI-Electrical.csproj new file mode 100644 index 00000000..576fa5cc --- /dev/null +++ b/newFront/c#前端/DI-Electrical/DI-Electrical.csproj @@ -0,0 +1,308 @@ + + + + + Debug + AnyCPU + {924A2824-BE62-42A7-81A8-49BEFCB3801F} + WinExe + DI_Electrical + DI-Electrical + v4.8 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + true + + + x64 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + false + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\packages\DryIoc.dll.5.4.3\lib\net45\DryIoc.dll + + + ..\packages\EasyEncryption.1.0.2\lib\EasyEncryption.dll + + + ..\packages\ini-parser.2.5.2\lib\net20\INIFileParser.dll + + + ..\packages\log4net.3.1.0\lib\net462\log4net.dll + + + ..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll + + + ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll + + + ..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.122\lib\net462\Microsoft.Xaml.Behaviors.dll + + + False + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + ..\packages\Prism.Core.8.1.97\lib\net47\Prism.dll + + + ..\packages\Prism.Unity.8.1.97\lib\net47\Prism.Unity.Wpf.dll + + + ..\packages\Prism.Wpf.8.1.97\lib\net47\Prism.Wpf.dll + + + + + + ..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll + + + ..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll + + + ..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll + + + + + + + + + + 4.0 + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.Data.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.FileDialogs.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.GridView.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.Input.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.Navigation.dll + + + False + ..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Data.dll + + + ..\packages\Unity.Abstractions.5.11.7\lib\net48\Unity.Abstractions.dll + + + ..\packages\Unity.Container.5.11.11\lib\net48\Unity.Container.dll + + + + + + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Config.xaml + + + customWindowTitleBar.xaml + + + + + + + + + + + + + + + + DialogInput.xaml + + + DialogSignalManagement.xaml + + + DialogSignalNotice.xaml + + + DialogSignalPropertyhisAndLogs.xaml + + + DialogSignalSelect.xaml + + + DialogTest.xaml + + + Login.xaml + + + MainWindow.xaml + + + Project.xaml + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + PreserveNewest + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + + + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + \ No newline at end of file diff --git a/newFront/c#前端/DI-Electrical/DI-Electrical.csproj.user b/newFront/c#前端/DI-Electrical/DI-Electrical.csproj.user new file mode 100644 index 00000000..0b246432 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/DI-Electrical.csproj.user @@ -0,0 +1,6 @@ + + + + ProjectFiles + + \ No newline at end of file diff --git a/newFront/c#前端/DI-Electrical/Event/loginEvent.cs b/newFront/c#前端/DI-Electrical/Event/loginEvent.cs new file mode 100644 index 00000000..77a5e263 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Event/loginEvent.cs @@ -0,0 +1,14 @@ +using Newtonsoft.Json.Linq; +using Prism.Events; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DI_Electrical.Event +{ + public class loginEvent: PubSubEvent + { + } +} diff --git a/newFront/c#前端/DI-Electrical/Helper/ConfigService.cs b/newFront/c#前端/DI-Electrical/Helper/ConfigService.cs new file mode 100644 index 00000000..dbfee4b3 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Helper/ConfigService.cs @@ -0,0 +1,107 @@ +using System; +using System.IO; +using DI_Electrical.Services; +using IniParser; + +namespace DI_Electrical.Helper +{ + public class ConfigService + { + //public string path = Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\AppData\Roaming\SWS\Config.ini"); + public string path = GlobalObject.ConfigPath;// Path.Combine(AppDomain.CurrentDomain.BaseDirectory,@"\Config.ini"); + public FileIniDataParser parser = new FileIniDataParser(); + public HttpService _httpService; + /// + /// config.ini 给默认值,且创建出来 + /// + void SetDefaultConfigValue() + { + if (!File.Exists(path)) + { + //默认值 + var data = parser.Parser.Parse(""); + data["Profile"]["Address"] = "1.117.161.11"; + data["Profile"]["Port"] = "8080"; + string userProfilePath = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile); + + data["Profile"]["Directory"] = $"{userProfilePath}\\AppData\\Roaming\\SWS"; + Directory.CreateDirectory(Path.GetDirectoryName(path)); + parser.WriteFile(path, data); + GlobalObject.isConfigIniCreateBySys = true; + } + else + { + GlobalObject.isConfigIniCreateBySys = false; + } + } + public ConfigService(HttpService httpService) + { + _httpService = httpService; + SetDefaultConfigValue(); + string address; + int port; + string locDrawingPath; + Read(out address, out port,out locDrawingPath); + _httpService.Init(address, port); + } + public void Read(out string address, out int port, out string directory) + { + var data = parser.ReadFile(path); + address = data["Profile"]["Address"]; + port = int.Parse(data["Profile"]["Port"]); + directory = data["Profile"]["Directory"]; + } + + /// + /// 查询某个 + /// + /// + /// + public string Read(string keyName) + { + var data = parser.ReadFile(path); + return data["Profile"][keyName]; + } + /// + /// 查询某个 + /// + /// 节点 + /// key名称 + /// + public string Read(string session,string keyName) + { + try + { + var data = parser.ReadFile(path); + return data[session][keyName]; + } + catch + { + return null; + } + } + /// + /// 保存某个 + /// + /// + /// + public void Save(string keyName, string value) + { + var data = parser.ReadFile(path); + data["Profile"][keyName] = value; + parser.WriteFile(path, data); + } + /// + /// 保存某个值 + /// + /// 节点 + /// key名称 + /// 值 + public void Save(string session, string keyName, string value) + { + var data = parser.ReadFile(path); + data[session][keyName] = value; + parser.WriteFile(path, data); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Helper/Converter/CollectionToStringConverter.cs b/newFront/c#前端/DI-Electrical/Helper/Converter/CollectionToStringConverter.cs new file mode 100644 index 00000000..c3cf061c --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Helper/Converter/CollectionToStringConverter.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Windows.Data; +using DI_Electrical.Models; + +namespace DI_Electrical.Helper.Converter +{ + public class CollectionToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + ObservableCollection WHCPUs = value as ObservableCollection; + if (WHCPUs != null) + { + string sWHCPU = ""; + for (int i = 0; i < WHCPUs.Count; i++) + { + if (i!= WHCPUs.Count-1) + { + if (WHCPUs[i] != null) + { + sWHCPU = sWHCPU + WHCPUs[i].DataItemCode + "|"; + } + } + else + { + if (WHCPUs[i] != null) + { + sWHCPU = sWHCPU + WHCPUs[i].DataItemCode; + } + + } + } + return sWHCPU; + } + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Helper/Converter/RadGridViewRowToBoolConverter.cs b/newFront/c#前端/DI-Electrical/Helper/Converter/RadGridViewRowToBoolConverter.cs new file mode 100644 index 00000000..227021a3 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Helper/Converter/RadGridViewRowToBoolConverter.cs @@ -0,0 +1,55 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using DI_Electrical.ViewModels; + +namespace DI_Electrical.Helper.Converter +{ + public class RadGridViewRowToBoolConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + SignalManagementInfo smif = value as SignalManagementInfo; + if (smif != null) + { + if (smif.Status.Equals("deleted") || smif.Status.Equals("Confirmed")) + { + return true; + } + if (smif.type.Equals("信号")) + { + switch (parameter.ToString()) + { + case "关联的电缆信息": + case "关联的通道信息": + return true; + } + } + else + { + switch (parameter.ToString()) + { + case "组别": + case "编码": + case "信号类型": + case "Min": + case "Max": + case "单位": + case "CODE": + case "设备名": + case "关联的电缆信息": + case "关联的通道信息": + return true; + } + } + + } + return false; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Helper/Converter/StatusToColourConverter.cs b/newFront/c#前端/DI-Electrical/Helper/Converter/StatusToColourConverter.cs new file mode 100644 index 00000000..627eb147 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Helper/Converter/StatusToColourConverter.cs @@ -0,0 +1,25 @@ +using System; +using System.Globalization; +using System.Windows.Data; +using DI_Electrical.ViewModels; + +namespace DI_Electrical.Helper.Converter +{ + internal class StatusToColourConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + SignalManagementInfo smif = value as SignalManagementInfo; + if (smif != null) + { + return smif.Status; + } + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Helper/FileHelper.cs b/newFront/c#前端/DI-Electrical/Helper/FileHelper.cs new file mode 100644 index 00000000..b1c4b224 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Helper/FileHelper.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace Dl_Electrical.Helper +{ + public static class FileHelper + { + /// + /// dwg等文件名是否合法。不带后缀 + /// + /// + /// + public static bool IsValidFileName(string fileName) + { + if (string.IsNullOrEmpty(fileName)) + { + return false; + } + + // 获取 Windows 文件系统中不允许出现在文件名中的字符数组 + char[] invalidChars = Path.GetInvalidFileNameChars(); + + // 检查文件名中是否包含非法字符 + foreach (char c in invalidChars) + { + if (fileName.IndexOf(c) >= 0) + { + return false; + } + } + + // 检查是否为保留文件名 + string[] reservedNames = { "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" }; + string trimmedFileName = Path.GetFileNameWithoutExtension(fileName).Trim().ToUpper(); + foreach (string reservedName in reservedNames) + { + if (trimmedFileName == reservedName) + { + return false; + } + } + + // 检查文件名是否以空格或句点结尾 + if (fileName.TrimEnd().Length != fileName.Length || fileName.TrimEnd('.').Length != fileName.Length) + { + return false; + } + + return true; + } + + + public static string GetFileMD5(string filePath) + { + if (string.IsNullOrEmpty(filePath) || !File.Exists(filePath)) + { + throw new ArgumentException("文件路径无效或文件不存在", nameof(filePath)); + } + + using (var md5 = MD5.Create()) // 创建 MD5 哈希算法实例 + using (var stream = File.OpenRead(filePath)) // 打开文件流 + { + // 计算文件的 MD5 值 + byte[] hashBytes = md5.ComputeHash(stream); + + // 将字节数组转换为十六进制字符串 + StringBuilder sb = new StringBuilder(); + foreach (var b in hashBytes) + { + sb.Append(b.ToString("x2")); // x2 格式化为两位小写十六进制数 + } + + return sb.ToString(); // 返回 MD5 值的字符串 + } + } + + #region 检查文件是否被其他进程占用 + /// + /// 检查文件是否被其他进程占用 + /// + public static bool IsFileLocked(string filePath) + { + try + { + // 尝试以独占模式打开文件 + using (FileStream fs = File.Open( + filePath, + FileMode.Open, + FileAccess.ReadWrite, + FileShare.None)) // FileShare.None 表示禁止共享 + { + return false; // 成功打开则未被占用 + } + } + catch (IOException ex) + { + // 检查特定错误码 + int errorCode = Marshal.GetHRForException(ex) & 0xFFFF; + return errorCode == 32 || errorCode == 33; // 32: 共享冲突, 33: 进程锁定 + } + catch (UnauthorizedAccessException) + { + return true; // 无权限访问(可能被占用) + } + catch + { + return false; // 其他异常视为未被占用 + } + } + #endregion + } +} diff --git a/newFront/c#前端/DI-Electrical/Helper/LoggerHelper.cs b/newFront/c#前端/DI-Electrical/Helper/LoggerHelper.cs new file mode 100644 index 00000000..49673fbc --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Helper/LoggerHelper.cs @@ -0,0 +1,145 @@ +using System; +using System.IO; +using System.Reflection; +using Dl_Electrical.Helper; +using Newtonsoft.Json.Linq; + +namespace DI_Electrical.Helper +{ + /// + /// nLog使用帮助类 + /// + public class LoggerHelper + { + private static readonly log4net.ILog loginfo = log4net.LogManager.GetLogger("loginfo"); + private static readonly log4net.ILog logerror = log4net.LogManager.GetLogger("logerror"); + private static readonly log4net.ILog logdebug = log4net.LogManager.GetLogger("logdebug"); + private static readonly log4net.ILog logwarn = log4net.LogManager.GetLogger("logwarn"); + private static readonly log4net.ILog logfatal = log4net.LogManager.GetLogger("logfatal"); + + private static LoggerHelper _obj = null; + private static string logPath = string.Empty; + private LoggerHelper() + { + string codeBase = Assembly.GetExecutingAssembly().CodeBase; + string dllPath = codeBase.Replace("file:///", ""); + dllPath = Path.GetDirectoryName(dllPath); + logPath = Path.Combine(dllPath, "Logs\\"); + var configFile = new FileInfo(Path.Combine(dllPath, "log4net.config")); + log4net.Config.XmlConfigurator.ConfigureAndWatch(configFile); + } + /// + /// 获取当前的日志记录对象。 + /// + public static LoggerHelper Current + { + get => _obj ?? (new LoggerHelper()); + set => _obj = value; + } + + #region Debug,调试 + /// + /// 调试信息输出。 + /// + /// 需要记录的信息。 + public void Debug(string msg) + { + logdebug.Debug(msg); + } + + #endregion + + #region Info,信息 + /// + /// 普通信息输出。 + /// + /// 需要记录的信息。 + public void Info(string msg) + { + loginfo.Info(msg); + } + + #endregion + + #region Warn,警告 + /// + /// 警告级别信息输出。 + /// + /// 需要记录的信息。 + public void Warn(string msg) + { + logwarn.Warn(msg); + } + + #endregion + + #region Error,错误 + /// + /// 错误级别信息输出。 + /// + /// 需要记录的信息。 + public void Error(string msg) + { + logerror.Error("----------------------------Error BEGIN------------------------------"); + logerror.Error(msg); + logerror.Error("-----------------------------Error END-------------------------------"); + } + #endregion + + #region Fatal,致命错误 + /// + /// 致命错误级别信息输出。 + /// + /// 需要记录的信息。 + /// 需要记录的系统异常。 + public void Fatal(string msg) + { + logfatal.Fatal("----------------------------Fatal BEGIN------------------------------"); + logerror.Fatal(msg); + logerror.Fatal("-----------------------------Fatal END-------------------------------"); + } + #endregion + + #region 输出json日志 + + /// + /// 输出json日志 + /// + /// json方法名 + /// json数据 + public void WriteJson(string funName, string json) + { + try + { + //json路径文件名 Environment.ExpandEnvironmentVariables(@"%USERPROFILE%\AppData\Roaming\SWS\Logs\" + string filename = Path.Combine(logPath, funName + ".json"); + //判断文件是否被打开占用 + if (!FileHelper.IsFileLocked(filename)) + { + File.Delete(filename); + string strJson = string.Empty; + if (json.StartsWith("[")) + { + //格式化json数据 当前为组类型 + JArray jobj = JArray.Parse(json); + strJson = jobj.ToString(); + } + else if (json.StartsWith("{")) + { + //格式化json数据 当前为类类型 + JObject jobj = JObject.Parse(json); + strJson = jobj.ToString(); + } + //创建json文件,并输出数据 + FileStream fs = new FileStream(filename, FileMode.Append); + StreamWriter wr = null; + wr = new StreamWriter(fs); + wr.WriteLine(strJson); + wr.Close(); + } + } + catch { } + } + #endregion + } +} diff --git a/newFront/c#前端/DI-Electrical/Helper/PasswordHelper.cs b/newFront/c#前端/DI-Electrical/Helper/PasswordHelper.cs new file mode 100644 index 00000000..107ad48f --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Helper/PasswordHelper.cs @@ -0,0 +1,51 @@ +using Microsoft.Xaml.Behaviors; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Telerik.Windows.Controls; + +namespace DI_Electrical.Helper +{ + public class PasswordBoxBehavior : Behavior + { + public static readonly DependencyProperty PasswordProperty = + DependencyProperty.Register(nameof(Password), typeof(string), typeof(PasswordBoxBehavior), + new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnPasswordChanged)); + + public string Password + { + get { return (string)GetValue(PasswordProperty); } + set { SetValue(PasswordProperty, value); } + } + + protected override void OnAttached() + { + base.OnAttached(); + AssociatedObject.PasswordChanged += OnPasswordChanged; + } + + protected override void OnDetaching() + { + base.OnDetaching(); + AssociatedObject.PasswordChanged -= OnPasswordChanged; + } + + private void OnPasswordChanged(object sender, RoutedEventArgs e) + { + Password = AssociatedObject.Password; + } + + private static void OnPasswordChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is PasswordBoxBehavior behavior) + { + behavior.AssociatedObject.Password = e.NewValue as string ?? string.Empty; + } + } + } + + +} diff --git a/newFront/c#前端/DI-Electrical/Model/NoEntity/ConfigIni.cs b/newFront/c#前端/DI-Electrical/Model/NoEntity/ConfigIni.cs new file mode 100644 index 00000000..a060f56c --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/NoEntity/ConfigIni.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DI_Electrical.Model +{ + public class ConfigIni + { + /// + /// 用户名 + /// + public string UserName { get; set; } + /// + /// 用户密码 + /// + public string UserPs { get; set; } + /// + /// 项目id + /// + public string ProjectID { get; set; } + /// + /// 服务器ip + /// + public string Address { get; set; } + /// + /// 端口 + /// + public string Port { get; set; } + } +} diff --git a/newFront/c#前端/DI-Electrical/Model/NoEntity/PageModel.cs b/newFront/c#前端/DI-Electrical/Model/NoEntity/PageModel.cs new file mode 100644 index 00000000..6867d306 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/NoEntity/PageModel.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; + +namespace DI_Electrical.Model +{ + public class PageModel + { + public List Rows { get; set; } + public int Total { get; set; } + public int Records { get; set; } + } +} diff --git a/newFront/c#前端/DI-Electrical/Model/NoEntity/learunHttpRes.cs b/newFront/c#前端/DI-Electrical/Model/NoEntity/learunHttpRes.cs new file mode 100644 index 00000000..cef59a30 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/NoEntity/learunHttpRes.cs @@ -0,0 +1,13 @@ +namespace DI_Electrical.Model +{ + /// + /// learun mvc标准的http返回结果 + /// + /// + public class learunHttpRes + { + public int code { get; set; } + public string info { get; set; } + public T data { get; set; } + } +} diff --git a/newFront/c#前端/DI-Electrical/Model/NoEntity/loginRes.cs b/newFront/c#前端/DI-Electrical/Model/NoEntity/loginRes.cs new file mode 100644 index 00000000..1f1741d5 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/NoEntity/loginRes.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DI_Electrical.Model +{ + public class loginRes + { + public string token { get; set; } + public string loginMark { get; set; } + public string account { get; set; } + public string userId { get; set; } + public string RealName { get; set; } + + public string userPs { get; set; } + public string IsIOModuleAdmin { get; set; } + public string isFirstLogin { get; set; } + public string Department { get; set; } + } +} diff --git a/newFront/c#前端/DI-Electrical/Model/ec_Wire_Group.cs b/newFront/c#前端/DI-Electrical/Model/ec_Wire_Group.cs new file mode 100644 index 00000000..51f82012 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/ec_Wire_Group.cs @@ -0,0 +1,438 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DI_Electrical.Models +{ + public class ec_Wire_Group + { + public ec_Wire_Group() + { + //SoftTags = new List(); + NewSoftTags = new List(); + //Status = WireGroupStatusEnum.New; + } + #region 实体成员 + /// + /// 状态。比如“待删除的”。默认为New + /// 去找lr base dataitem数据字典的be_signalstate + /// + //[JsonConverter(typeof(SignalStatusConverter))] + public WireGroupStatusEnum Status { get; set; } = WireGroupStatusEnum.New; + + /// + /// 某一个输出的信号,可以关联多个输入的信号。关联的是 + /// + public string LinkedID { get; set; } = ""; + + /// + /// ID + /// + /// + + public string Wire_Group_ID { get; set; } + + /// + /// 信号名称(CH. No.)。 + /// 1462,C列。 + /// 8600,A列。 + /// 如果是虚拟点。就是主信号+ + /// + /// + public string Group_Name { get; set; } = ""; + /// + /// ChannelID。ec_panel_channel里。 + /// 如果为空,说明这个信号是关联前的状态(或者说未关联的状态) + /// + /// + public string ChannelID { get; set; } = ""; + /// + /// 英文描述(Description)。 + /// 1462,D列。 + /// 8600,B列。 + /// + /// + public string Group_Desc_EN { get; set; } = ""; + /// + /// 中文描述。 + /// 8600,B列(第二行)。 + /// + /// + public string Group_Desc { get; set; } = ""; + /// + /// (Signal_Type)信号类型,如4-20mA。 + /// 1462,I列。 + /// 8600,E列(模拟量)或F列(开关量)。 + /// + /// + public string IO_Type { get; set; } = ""; + + /// + /// 信号的分组(组成Group Name的第一部分) + /// + /// + public string Signal_Group { get; set; } = ""; + /// + /// 信号的序号(组成Group Name的第二部分) + /// + /// + public string Signal_SeqNo { get; set; } = ""; + /// + /// 信号组模板ID(平台上,savesignal时,不会带出这个)。 + /// 只是公司级上才有意义。 + /// + /// + public string WireGroupTemplateID { get; set; } = ""; + /// + /// 代码。 + /// 1462,H列。 + /// + /// + public string Code { get; set; } = ""; + /// + /// Range_Min。 + /// 1462,J列。 + /// 8600,G列(111~222)。 + /// + /// + public string Range_Min { get; set; } = ""; + /// + /// Range_Max. + /// 1462,k列。 + /// 8600,G列(111~222)。 + /// + /// + public string Range_Max { get; set; } = ""; + /// + /// Range_Min和Range_Max的单位。 + /// 1462,L列。 + /// 8600,H列。 + /// + /// + public string Unit { get; set; } = ""; + /// + /// Alarm_LL。 + /// 1462,m列。 + /// 8600,J列(第一行或第二行不确定)。 + /// + /// + public string Alarm_LL { get; set; } = ""; + /// + /// Alarm_L。 + /// 1462,n列。 + /// 8600,I列(第一行或第二行不确定)。 + /// + /// + public string Alarm_L { get; set; } = ""; + /// + /// Alarm_H。 + /// 1462,o列。 + /// 8600,I列(第一行或第二行不确定)。 + /// + /// + public string Alarm_H { get; set; } = ""; + /// + /// Alarm_HH。 + /// 1462,p列。 + /// 8600,J列(第一行或第二行不确定)。 + /// + /// + public string Alarm_HH { get; set; } = ""; + /// + /// AL_GRP 延申报警组。 + /// 1462,S列。 + /// 8600,U列。 + /// + /// + public string AL_GRP { get; set; } = ""; + /// + /// BL_GRP 抑制报警。 + /// 1462,T列。 + /// 8600,T列。 + /// + /// + public string BL_GRP { get; set; } = ""; + /// + /// 延时。 + /// 1462,U列。 + /// 8600,S列。 + /// + /// + public string Time_Delay { get; set; } = ""; + /// + /// 供应商。 + /// 1463,V列。 + /// 8600,L列。 + /// + /// + public string Supplier { get; set; } = ""; + + /// + /// 设备名 + /// + /// + public string EquipName { get; set; } = ""; + /// + /// 传感器代码。 + /// 1462,W列。 + /// 8600,K列。 + /// + /// + public string SENSOR_CODE { get; set; } = ""; + /// + /// VDR_Record。 + /// 1462,X列。 + /// + /// + public bool VDR_Record { get; set; } = false; + + /// + /// 是否为slow down信号。 + /// 1462,Q列。 + /// + /// + public bool SLD { get; set; } = false; + + /// + /// 是否为shut down信号。 + /// 1462,R列。 + /// + /// + public bool SHD { get; set; } = false; + /// + /// Remarks。 + /// 1462,Y列。 + /// 8600,X列。 + /// + /// + public string Remarks { get; set; } = ""; + + /// + /// 信号归属 + /// true,代表该信号是电气进行最终审核确认; + /// false,代表该信号是轮机进行最终审核确认; + /// + public bool ElecOnly { get; set; } = false; + + /// + /// 是否为通讯点。 + /// 1462,通过里的文字判断 + /// 8600,通过K列里的文字判断 + /// + public bool CommunicationPoint { get; set; } = false; + + + ///// + ///// ECC 。Bool类型数据库要么是int要么是bool + ///// + //public bool ECC { get; set; } = false; + + ///// + ///// WCC + ///// + //public bool WCC { get; set; } = false; + ///// + ///// BCC + ///// + //public bool BCC { get; set; } = false; + /// + /// IO类型,AI AO DI DO + /// + public string InOrOut { get; set; } = ""; + /// + /// 驾驶室(控制台)。 + /// 8600,M列。导入时,如果2行都有值,中间会|分开 + /// + public string WHConsole { get; set; } = ""; + /// + /// 驾驶室(计算机)。 + /// 8600,N列。导入时,如果2行都有值,中间会|分开 + /// + public string WHCPU { get; set; } = ""; + /// + /// 集控室(控制台)。 + /// 8600,O列。导入时,如果2行都有值,中间会|分开 + /// + public string ECRConsole { get; set; } = ""; + /// + /// 集控室(计算机)。 + /// 8600,P列(excel中,两行均有值时,以|分开) + /// + public string ECRCPU { get; set; } = ""; + /// + /// 船舶办公室(控制台)。 + /// 8600,Q列。导入时,如果2行都有值,中间会|分开 + /// + public string ShipOfficeConsole { get; set; } = ""; + /// + /// 船舶办公室(计算机)。 + /// 8600,R列。导入时,如果2行都有值,中间会|分开 + /// + public string ShipOfficeCPU { get; set; } = ""; + /// + /// 安全保护。(和 列有关系) + /// 8600,V列。 + /// + public string SafetyProt { get; set; } = ""; + /// + /// 安全保护延时。 + /// 8600,V列下。 + /// + public string SafetyDelay { get; set; } = ""; + + /// + /// SeriousType + /// 1462,AG列。 + /// + /// + public string SeriousType { get; set; } = ""; + + /// + /// 自动控制。 + /// 8600,W列。 + /// + public string AutoCtrl { get; set; } = ""; + /// + /// 爸爸。如果有值,则代表其为虚拟点的概念 + /// + /// + public string ParentID { get; set; } = ""; + /// + /// 删除标记。因为哪怕是删除了,也要保留数据,以便日后查看。 + /// + public bool DeleteFlg { get; set; } = false; + + /// + /// 电缆位号(某些项目的里,是允许编辑的IO_allowManualAssign) + /// + public string CableName { get; set; } + /// + /// 通讯类信号的母线ID + /// + public string CableId { get; set; } + /// + /// 创建人 + /// + /// + public string CreateUserID { get; set; } + /// + /// 创建时间 + /// + /// + public DateTime? CreateTime { get; set; } + /// + /// 更新人 + /// + /// + public string UpdateUserID { get; set; } + /// + /// 更新时间 + /// + /// + public DateTime? UpdateTime { get; set; } + #endregion + + + #region 扩展字段 + ///// + ///// 虚拟点 集合 + ///// + ////[SugarColumn(IsIgnore = true)] + //[Obsolete] + //[Navigate(NavigateType.OneToMany, nameof(ec_SofttagEntity.Wire_Group_ID))] //配置了导航,方便DeleteNav,ec_softtag表中的wiregroupid + //public List SoftTags { get; set; } + + + + public List NewSoftTags { get; set; } + /// + /// 柜子 + /// + + public string PanelName { get; set; } + /// + /// 通道号 + /// + + public string ChannelName { get; set; } + /// + /// 端子排 + /// + + public string StripName { get; set; } + + /// + /// 电缆对 + /// + + public string CableSetName { get; set; } + + /// + /// status的具体文字描述 + /// + + public string StatusValue { get; set; } + + + /// + /// 操作历史(因为现在插件端的保存是一次性的。哪怕有多个动作,也只是一次提交) + /// + + public List ActionHistorys { get; set; } + + /// + /// 信号属性变更历史 + /// + + public List Propertyhis { get; set; } + + /// + /// 信号日志 + /// + + public List Logs { get; set; } + #endregion + } + public enum WireGroupStatusEnum + { + /// + /// 待删除 + /// + [Description("待删除")] + ToDelete = 01, + /// + /// 新增的 + /// + [Description("新增的")] + New = 02, + /// + /// 已关联 + /// + [Description("已使用(关联)")] + Used = 03, + /// + /// 已审核 + /// + [Description("已确认(审核)")] + Confirmed = 04, + /// + /// 重新打开 + /// + [Description("重新打开")] + Reopen = 05, + /// + /// 彻底删除 + /// + [Description("彻底删除")] + deleted = 06 + } + public class ActionHistory + { + public DateTime? ActionTime { get; set; } + public Action ActionType { get; set; } + public string reason { get; set; } + } +} diff --git a/newFront/c#前端/DI-Electrical/Model/ec_dataitemdetail.cs b/newFront/c#前端/DI-Electrical/Model/ec_dataitemdetail.cs new file mode 100644 index 00000000..b655e641 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/ec_dataitemdetail.cs @@ -0,0 +1,81 @@ +using DryIoc.ImTools; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DI_Electrical.Models +{ + public class ec_dataitemdetail + { + #region 实体成员 + /// + /// 字典明细ID + /// + + public string DataItemDetailID { get; set; } + /// + /// 字典分类ID(存的是 + /// + public string DataItemID { get; set; } = ""; + /// + /// 上级字典明细ID。 + /// + public string UpDataItemDetailID { get; set; } = ""; + /// + /// 字典明细名称 + /// + public string DataItemName { get; set; } = ""; + /// + /// 字典明细名称(英文) + /// + public string DataItemNameEN { get; set; } = ""; + /// + /// 字典明细编号 + /// + public string DataItemCode { get; set; } = ""; + /// + /// 排序 + /// + public int? OrderID { get; set; } + /// + /// 是否有效 + /// + public int? IsEnabled { get; set; } + /// + /// 备注 + /// + public string Remark { get; set; } = ""; + /// + /// 创建人 + /// + public string CreateUserID { get; set; } + /// + /// 创建时间 + /// + public DateTime? CreateTime { get; set; } + /// + /// 更新人 + /// + public string UpdateUserID { get; set; } + /// + /// 更新时间 + /// + public DateTime? UpdateTime { get; set; } + #endregion + + #region 扩展字段 + /// + /// 字典编号。如Be_signal_group + /// + + public string ItemCode { get; set; } = ""; + /// + /// 信号 + /// + + public List Signals { get; set; } + #endregion + } +} diff --git a/newFront/c#前端/DI-Electrical/Model/ec_project.cs b/newFront/c#前端/DI-Electrical/Model/ec_project.cs new file mode 100644 index 00000000..979d1dce --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/ec_project.cs @@ -0,0 +1,123 @@ +using System; + +namespace DI_Electrical.Model +{ + /// + /// 项目 + /// + public class ec_project + { + #region 实体成员 + /// + /// 项目ID + /// + /// + public string ProjectId { get; set; } + /// + /// 项目名称 + /// + /// + public string ProjectName { get; set; } = ""; + /// + /// 项目代号 + /// + /// + public string ProjectCode { get; set; } = ""; + + ///// + ///// 船检 + ///// + //public string ShipCheck { get; set; } = ""; + /// + /// 船名(中文) + /// + /// + public string ShipNameCN { get; set; } = ""; + /// + /// 船名(英文) + /// + /// + public string ShipNameEN { get; set; } = ""; + /// + /// 船型(中文) + /// + /// + public string ShipTypeCN { get; set; } = ""; + /// + /// 船型(英文) + /// + /// + public string ShipTypeEN { get; set; } = ""; + /// + /// 船级社(id)。和船检的概念有些冲突 + /// + /// + public string ShipSociety { get; set; } = ""; + /// + /// 船东 + /// + /// + public string ShipOwner { get; set; } = ""; + /// + /// 挂旗国(船籍国) + /// + /// + public string FlagState { get; set; } = ""; + /// + /// IMO编号 + /// + /// + public string IMONumber { get; set; } = ""; + /// + /// 项目更多描述一 + /// + /// + public string Describe1 { get; set; } = ""; + /// + /// 项目更多描述二 + /// + /// + public string Describe2 { get; set; } = ""; + /// + /// 项目更多描述三 + /// + /// + public string Describe3 { get; set; } = ""; + /// + /// 项目更多描述四 + /// + /// + public string Describe4 { get; set; } = ""; + /// + /// 项目更多描述五 + /// + /// + public string Describe5 { get; set; } = ""; + /// + /// 项目序号 + /// + /// + public int? ProjectIndex { get; set; } + /// + /// 创建人 + /// + /// + public string CreateUserID { get; set; } + /// + /// 创建时间 + /// + /// + public DateTime? CreateTime { get; set; } + /// + /// 更新人 + /// + /// + public string UpdateUserID { get; set; } + /// + /// 更新时间 + /// + /// + public DateTime? UpdateTime { get; set; } + #endregion + } +} diff --git a/newFront/c#前端/DI-Electrical/Model/ec_wire_group_log.cs b/newFront/c#前端/DI-Electrical/Model/ec_wire_group_log.cs new file mode 100644 index 00000000..a7770640 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/ec_wire_group_log.cs @@ -0,0 +1,95 @@ +using Newtonsoft.Json.Converters; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace DI_Electrical.Models +{ + public class ec_wire_group_log + { + public ec_wire_group_log() + { + + } + public ec_wire_group_log(Action OperateType, string WireGroupID) + { + this.OperateType = OperateType; + this.WireGroupID = WireGroupID; + + } + /// + /// + /// + /// + /// + /// 因为的关系,所以时间是有值的 + public ec_wire_group_log(Action OperateType, string WireGroupID, DateTime? createtime) + { + this.OperateType = OperateType; + this.WireGroupID = WireGroupID; + + if (createtime != null) + { + this.CreateTime = createtime; + } + + } + #region 实体成员 + /// + /// 操作日志ID + /// + /// + + public string WireGroupLogID { get; set; } + /// + /// 信号ID + /// + /// + public string WireGroupID { get; set; } + /// + /// 操作类型 + /// + /// + [JsonConverter(typeof(StringEnumConverter))] + public Action OperateType { get; set; } + /// + /// 备注 + /// + /// + public string ExtraMsg { get; set; } + /// + /// 创建人 + /// + /// + public string CreateUserID { get; set; } + /// + /// 创建时间 + /// + /// + public DateTime? CreateTime { get; set; } + /// + /// 更新人 + /// + /// + public string UpdateUserID { get; set; } + /// + /// 更新时间 + /// + /// + public DateTime? UpdateTime { get; set; } + #endregion + + + #region 扩展字段 + /// + /// 创建人名称 + /// + /// + + public string CreateUserName { get; set; } + #endregion + } +} diff --git a/newFront/c#前端/DI-Electrical/Model/ec_wire_group_notice.cs b/newFront/c#前端/DI-Electrical/Model/ec_wire_group_notice.cs new file mode 100644 index 00000000..df9893ee --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/ec_wire_group_notice.cs @@ -0,0 +1,130 @@ +using System; + +namespace DI_Electrical.Models + +{ + /// + /// 动作。和状态是两码事情。 + /// + public enum Action + { + + 新增 = 0, + 修改 = 1, + 准备删除 = 2, + 撤销删除 = 3, + 删除 = 4, + 关联通道 = 5, + 审核 = 6, + 重新打开 = 7, + 关联解除 = 8, + 回收站恢复 = 9 + } + + public enum Department + { + 轮机 = 0, + 电气 = 1 + } + + public class ec_wire_group_notice + { + public ec_wire_group_notice() + { + } + /// + /// + /// + /// + /// 接收方 + /// + public ec_wire_group_notice(Action action, Department departmentRetrieveNotice, string WireGroupID) + { + ActionID = action; + CompanyID = departmentRetrieveNotice; + this.WireGroupID = WireGroupID; + + } + + #region 实体成员 + /// + /// 信号表通知ID + /// + /// + public string WireGroupNoticeID { get; set; } + /// + /// 信号ID + /// + /// + public string WireGroupID { get; set; } = ""; + /// + /// 动作 + /// + /// + public Action ActionID { get; set; } + + /// + /// 额外的消息(如删除时,必须要给一个删除理由) + /// + /// + public string Message { get; set; } = ""; + /// + /// 是否被确认。false未读。true已读。 + /// + public bool CheckFLG { get; set; } = false; + /// + /// 接收者的部门 + /// + public Department CompanyID { get; set; } + /// + /// 创建人(也就是发起通知的人) + /// + /// + public string CreateUserID { get; set; } + /// + /// 创建时间 + /// + /// + public DateTime? CreateTime { get; set; } + /// + /// 更新人(也就是确认这个消息已阅的人) + /// + /// + public string UpdateUserID { get; set; } + /// + /// 更新时间 + /// + /// + public DateTime? UpdateTime { get; set; } + #endregion + + #region 扩展字段 + + /// + /// 动作(描述) + /// + /// + public string Action { get; set; } + + /// + /// 创建人名称 + /// + /// + public string CreateUserName { get; set; } + + /// + /// 批准人名字 + /// + /// + public string UpdateUserName { get; set; } + #region 用于前端UI渲染,对应的信号的内容 + public string Group_Name { get; set; } + public string Group_Desc { get; set; } + public string Group_Desc_EN { get; set; } + public string IO_Type { get; set; } + #endregion + #endregion + + } +} + diff --git a/newFront/c#前端/DI-Electrical/Model/ec_wire_group_propertyhis.cs b/newFront/c#前端/DI-Electrical/Model/ec_wire_group_propertyhis.cs new file mode 100644 index 00000000..501cb19b --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/ec_wire_group_propertyhis.cs @@ -0,0 +1,71 @@ +using System; + +namespace DI_Electrical.Models +{ + public class ec_wire_group_propertyhis + { + #region 实体成员 + /// + /// 信号属性历史ID + /// + /// + + public string WireGroupPropertyhisID { get; set; } + /// + /// 信号ID + /// + /// + public string WireGroupID { get; set; } = ""; + /// + /// 属性名称 + /// + /// + public string PropertyName { get; set; } = ""; + /// + /// 旧属性值 + /// + /// + public string OldPropertyValue { get; set; } = ""; + /// + /// 新属性值 + /// + /// + public string NewPropertyValue { get; set; } = ""; + /// + /// 创建人 + /// + /// + public string CreateUserID { get; set; } + /// + /// 创建时间 + /// + /// + public DateTime? CreateTime { get; set; } + /// + /// 更新人 + /// + /// + public string UpdateUserID { get; set; } + /// + /// 更新时间 + /// + /// + public DateTime? UpdateTime { get; set; } + #endregion + + #region 扩展字段 + /// + /// 创建人名称 + /// + /// + + public string CreateUserName { get; set; } + /// + /// 属性名称描述 + /// + /// + + public string PropertyNameDec { get; set; } = ""; + #endregion + } +} diff --git a/newFront/c#前端/DI-Electrical/Model/user.cs b/newFront/c#前端/DI-Electrical/Model/user.cs new file mode 100644 index 00000000..abdd6bd1 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Model/user.cs @@ -0,0 +1,199 @@ +using System; + +namespace DI_Electrical.Model +{ + public class User + { + #region 实体成员 + /// + /// 用户主键 + /// + public string F_UserId { get; set; } + /// + /// 工号 + /// + public string F_EnCode { get; set; } + /// + /// 账户 + /// + public string F_Account { get; set; } + /// + /// 登录密码 + /// + public string F_Password { get; set; } + /// + /// 密码秘钥 + /// + public string F_Secretkey { get; set; } + /// + /// 真实姓名 + /// + public string F_RealName { get; set; } + /// + /// 呢称 + /// + public string F_NickName { get; set; } + /// + /// 头像 + /// + public string F_HeadIcon { get; set; } + /// + /// 快速查询 + /// + public string F_QuickQuery { get; set; } + /// + /// 简拼 + /// + public string F_SimpleSpelling { get; set; } + /// + /// 性别 + /// + public int? F_Gender { get; set; } + /// + /// 生日 + /// + public DateTime? F_Birthday { get; set; } + /// + /// 手机 + /// + public string F_Mobile { get; set; } + /// + /// 电话 + /// + public string F_Telephone { get; set; } + /// + /// 电子邮件 + /// + public string F_Email { get; set; } + /// + /// QQ号 + /// + public string F_OICQ { get; set; } + /// + /// 微信号 + /// + public string F_WeChat { get; set; } + /// + /// MSN + /// + public string F_MSN { get; set; } + /// + /// 公司或部门的主键 + /// + public string F_CompanyId { get; set; } + /// + /// 部门主键 + /// + public string F_DepartmentId { get; set; } + /// + /// 安全级别 + /// + public int? F_SecurityLevel { get; set; } + /// + /// 单点登录标识 + /// + public int? F_OpenId { get; set; } + /// + /// 密码提示问题 + /// + public string F_Question { get; set; } + /// + /// 密码提示答案 + /// + public string F_AnswerQuestion { get; set; } + /// + /// 允许多用户同时登录 + /// + public int? F_CheckOnLine { get; set; } + /// + /// 允许登录时间开始 + /// + public DateTime? F_AllowStartTime { get; set; } + /// + /// 允许登录时间结束 + /// + public DateTime? F_AllowEndTime { get; set; } + /// + /// 暂停用户开始日期 + /// + public DateTime? F_LockStartDate { get; set; } + /// + /// 暂停用户结束日期 + /// + public DateTime? F_LockEndDate { get; set; } + /// + /// 排序码 + /// + public int? F_SortCode { get; set; } + /// + /// 删除标记 + /// + public int? F_DeleteMark { get; set; } + /// + /// 有效标志 + /// + public int? F_EnabledMark { get; set; } + /// + /// 备注 + /// + public string F_Description { get; set; } + /// + /// 创建日期 + /// + public DateTime? F_CreateDate { get; set; } + /// + /// 创建用户主键 + /// + public string F_CreateUserId { get; set; } + /// + /// 创建用户 + /// + public string F_CreateUserName { get; set; } + /// + /// 修改日期 + /// + public DateTime? F_ModifyDate { get; set; } + /// + /// 修改用户主键 + /// + public string F_ModifyUserId { get; set; } + /// + /// 修改用户 + /// + public string F_ModifyUserName { get; set; } + /// + /// 密码更新时间 + /// + public DateTime? PasswordUpdateTime { get; set; }//add by chenkai 20210322 + /// + /// 微信OpenId + /// + public string WX_OpenId { get; set; } + #endregion + + + #region 扩展属性 + /// + /// 登录信息 + /// + public string LoginMsg { get; set; } + /// + /// 登录状态 + /// + public bool LoginOk { get; set; } + + /// + /// 公司名称 + /// + public string F_FullName { get; set; } + /// + /// 岗位名称 + /// + public string F_PostName { get; set; } + /// + /// 单位名称 + /// + public string F_CompanyName { get { return F_FullName; } } + #endregion + } +} diff --git a/newFront/c#前端/DI-Electrical/Properties/AssemblyInfo.cs b/newFront/c#前端/DI-Electrical/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..e8c85fde --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Properties/AssemblyInfo.cs @@ -0,0 +1,52 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("DI-Electrical")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("DI-Electrical")] +[assembly: AssemblyCopyright("Copyright © 2025")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +//若要开始生成可本地化的应用程序,请设置 +//.csproj 文件中的 CultureYouAreCodingWith +//在 中。例如,如果你使用的是美国英语。 +//使用的是美国英语,请将 设置为 en-US。 然后取消 +//对以下 NeutralResourceLanguage 特性的注释。 更新 +//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。 + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //主题特定资源词典所处位置 + //(未在页面中找到资源时使用, + //或应用程序资源字典中找到时使用) + ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置 + //(未在页面中找到资源时使用, + //、应用程序或任何主题专用资源字典中找到时使用) +)] + + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/newFront/c#前端/DI-Electrical/Properties/Resources.Designer.cs b/newFront/c#前端/DI-Electrical/Properties/Resources.Designer.cs new file mode 100644 index 00000000..b78274f2 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Properties/Resources.Designer.cs @@ -0,0 +1,71 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本: 4.0.30319.42000 +// +// 对此文件的更改可能导致不正确的行为,如果 +// 重新生成代码,则所做更改将丢失。 +// +//------------------------------------------------------------------------------ + +namespace DI_Electrical.Properties +{ + + + /// + /// 强类型资源类,用于查找本地化字符串等。 + /// + // 此类是由 StronglyTypedResourceBuilder + // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。 + // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen + // (以 /str 作为命令选项),或重新生成 VS 项目。 + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources + { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() + { + } + + /// + /// 返回此类使用的缓存 ResourceManager 实例。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager + { + get + { + if ((resourceMan == null)) + { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DI_Electrical.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// 重写当前线程的 CurrentUICulture 属性,对 + /// 使用此强类型资源类的所有资源查找执行重写。 + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture + { + get + { + return resourceCulture; + } + set + { + resourceCulture = value; + } + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Properties/Resources.resx b/newFront/c#前端/DI-Electrical/Properties/Resources.resx new file mode 100644 index 00000000..af7dbebb --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Properties/Resources.resx @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/newFront/c#前端/DI-Electrical/Properties/Settings.Designer.cs b/newFront/c#前端/DI-Electrical/Properties/Settings.Designer.cs new file mode 100644 index 00000000..f1d1fdd5 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Properties/Settings.Designer.cs @@ -0,0 +1,30 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace DI_Electrical.Properties +{ + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase + { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default + { + get + { + return defaultInstance; + } + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Properties/Settings.settings b/newFront/c#前端/DI-Electrical/Properties/Settings.settings new file mode 100644 index 00000000..033d7a5e --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Properties/Settings.settings @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/newFront/c#前端/DI-Electrical/Services/DataItemService.cs b/newFront/c#前端/DI-Electrical/Services/DataItemService.cs new file mode 100644 index 00000000..caf4d613 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Services/DataItemService.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using DI_Electrical.Models; + +namespace DI_Electrical.Services +{ + public class DataItemService : HttpService + { + public DataItemService( ) : base() + { + + } + + public async Task> GetDetails(string itemCode) + { + var res = await this.GetAsync>($"DataItemApi/GetDetails?projectId={GlobalObject.curProject.ProjectId}&itemCode={itemCode}"); + //OnRefresh(); + if (res.code == 200) + { + + return res.data; + } + else + { + return null;//ERROR INFO + } + } + + } +} diff --git a/newFront/c#前端/DI-Electrical/Services/HttpService.cs b/newFront/c#前端/DI-Electrical/Services/HttpService.cs new file mode 100644 index 00000000..2485af1a --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Services/HttpService.cs @@ -0,0 +1,263 @@ +using System; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Text; +using System.Threading.Tasks; +using DI_Electrical.Helper; +using DI_Electrical.Model; +using Newtonsoft.Json; +namespace DI_Electrical.Services +{ + public class HttpService + { + public HttpService() + { + } + public void Init(string address, int port) + { + // 如果 GlobalObject.client 已经是 null,初始化一个新的 HttpClient 实例 + //if (GlobalObject.client == null) + //{ + GlobalObject.client = new HttpClient() + { + BaseAddress = new Uri($"http://{address}:{port}/api/"), + Timeout = TimeSpan.FromSeconds(120) + }; + //} + //else + //{ + // // 如果已经有 client 实例,则更新它的 BaseAddress + // GlobalObject.client.BaseAddress = new Uri($"http://{address}:{port}/api/"); + //} + } + + /// + /// 带入授权码。 + /// + /// + protected virtual void OnInitAuthorizationCode() + { + //httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows 10.0.22621.1265; WOW64) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/110.0.835.163 Safari/535.1"); + + //if (AuthorizationCode.IsNullOrEmpty() || httpClient == null) return; + //httpClient.DefaultRequestHeaders.Add("Authorization", "Bearer " + AuthorizationCode); + } + protected virtual void OnInitRequestHeader(HttpClient httpClient, string mediaType) + { + //httpClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue(mediaType)); + httpClient.DefaultRequestHeaders.Add("Accept", mediaType); + httpClient.DefaultRequestHeaders.Add("ContentType", mediaType); + } + + private void WriteLog(string requestUri, string strJson) + { + try + { + var uri = new Uri(GlobalObject.client.BaseAddress + requestUri); + var funName = uri.Segments.Last(); + LoggerHelper.Current.WriteJson(funName, strJson); + } + catch { } + } + + public async Task> GetAsync(string requestUri) + { + //httpClient.Timeout = TimeSpan.FromSeconds(3000); + OnInitAuthorizationCode(); + string result = string.Empty; + learunHttpRes resultObj = null; + try + { + var response = await GlobalObject.client.GetAsync(requestUri); + if (response.StatusCode != HttpStatusCode.OK) + { + string errorMsg = $"服务器地址 [{requestUri}] 获取数据失败, 返回HTTP代码:" + response.StatusCode; + LoggerHelper.Current.Error(errorMsg); + throw new HttpRequestException(errorMsg); + } + result = await response.Content.ReadAsStringAsync(); + WriteLog(requestUri, result); + resultObj = JsonConvert.DeserializeObject>(result); + } + catch (JsonException) + { + string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result; + LoggerHelper.Current.Error(errorMsg); + resultObj = new learunHttpRes() { code = -100, info = errorMsg }; + return resultObj; + } + catch (Exception ex) + { + string errorMsg = $"接口:{requestUri}失败,异常:{ex.Message} "; + LoggerHelper.Current.Error(errorMsg); + resultObj = new learunHttpRes() { code = -100, info=errorMsg }; + return resultObj; + } + + if (resultObj.code != 200) + { + switch (resultObj.code) + { + case 400: + case 500: + break; + //业务错误,不是http本质错误 + default: + string errorMsg = $"服务器地址 [{requestUri}] Get失败, 返回自定义代码:" + resultObj.code; + LoggerHelper.Current.Error(errorMsg); + throw new HttpRequestException(errorMsg); + } + + } + LoggerHelper.Current.Info($"Get成功:{requestUri}"); + return resultObj; + + + } + public async Task GetAsyncByOnlyData(string requestUri) + { + //httpClient.Timeout = TimeSpan.FromSeconds(3000); + OnInitAuthorizationCode(); + string result = string.Empty; + T resultObj; + try + { + var response = await GlobalObject.client.GetAsync(requestUri); + if (response.StatusCode != HttpStatusCode.OK) + { + string errorMsg = $"服务器地址 [{requestUri}] 获取数据失败, 返回HTTP代码:" + response.StatusCode; + LoggerHelper.Current.Error(errorMsg); + throw new HttpRequestException(errorMsg); + } + result = await response.Content.ReadAsStringAsync(); + WriteLog(requestUri, result); + resultObj = JsonConvert.DeserializeObject(result); + } + catch (JsonException) + { + string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result; + LoggerHelper.Current.Error(errorMsg); + throw new JsonException(errorMsg); + } + catch (Exception ex) + { + string errorMsg = $"接口:{requestUri}失败,异常:{ex.Message} "; + LoggerHelper.Current.Error(errorMsg); + throw new JsonException(errorMsg); + } + + LoggerHelper.Current.Info($"Get成功:{requestUri}"); + return resultObj; + + + } + /// + /// + /// + /// 响应后的返回数据的类型 + /// POST数据对象的类型 + /// + /// + /// + /// + /// + public async Task> PostBodyAsync(string requestUri, T1 postObj) + { + OnInitAuthorizationCode(); + + string contentType = "application/json"; + string strContent = postObj != null ? JsonConvert.SerializeObject(postObj) : ""; + var content = new StringContent(strContent, Encoding.UTF8, contentType); + OnInitRequestHeader(GlobalObject.client, contentType); + learunHttpRes resultObj = null; + string result = string.Empty; + try + { + var response = await GlobalObject.client.PostAsync(requestUri, content); + if (response.StatusCode != HttpStatusCode.OK) + { + string errorMsg = $"服务器地址 [{requestUri}] Post数据失败, 返回HTTP代码:" + response.StatusCode; + LoggerHelper.Current.Error(errorMsg); + throw new HttpRequestException(errorMsg); + } + result = await response.Content.ReadAsStringAsync(); + WriteLog(requestUri, result); + resultObj = JsonConvert.DeserializeObject>(result); + } + catch (JsonException) + { + string errorMsg = $"服务器地址 [{requestUri}] 解析为{typeof(T).Name}失败,原始返回数据为: " + result; + LoggerHelper.Current.Error(errorMsg); + resultObj = new learunHttpRes() { code = -100, info = errorMsg }; + return resultObj; + } + catch (Exception ex) + { + string errorMsg = $"接口:{requestUri}失败,参数数据为:{strContent},异常:{ex.Message} "; + LoggerHelper.Current.Error(errorMsg); + resultObj = new learunHttpRes() { code = -100, info = errorMsg }; + return resultObj; + } + + if (resultObj.code != 200) + { + switch (resultObj.code) + { + case 400: + case 500: + break; + //业务错误,不是http本质错误 + default: + string errorMsg = $"服务器地址 [{requestUri}] Post失败, 返回自定义代码:" + resultObj.code; + LoggerHelper.Current.Error(errorMsg); + throw new HttpRequestException(errorMsg); + } + + } + LoggerHelper.Current.Info($"Post成功:{requestUri}"); + return resultObj; + + + } + + + + public async Task PostFileAsync(string requestUri, Stream stream, string fileName) + { + OnInitAuthorizationCode(); + + string contentType = "multipart/form-data"; + var streamContent = new StreamContent(stream, (int)stream.Length); + streamContent.Headers.Add("Content-Type", "application/octet-stream"); + var content = new MultipartFormDataContent + { + { streamContent, "file", fileName } + }; + OnInitRequestHeader(GlobalObject.client, contentType); + var response = await GlobalObject.client.PostAsync(requestUri, content); + if (response.StatusCode != HttpStatusCode.OK) + { + string errorMsg = $"服务器地址 [{requestUri}] Post数据失败, 返回HTTP代码:" + response.StatusCode; + LoggerHelper.Current.Error(errorMsg); + throw new HttpRequestException(errorMsg); + } + var result = await response.Content.ReadAsStringAsync(); + T resultObj; + try + { + resultObj = JsonConvert.DeserializeObject(result); + } + catch (JsonException) + { + string errorMsg = $"服务器地址 [{requestUri}] 解析为 string 失败,原始返回数据为: " + result; + LoggerHelper.Current.Error(errorMsg); + throw new JsonException(errorMsg); + } + LoggerHelper.Current.Info($"Post上传文件成功:{requestUri}"); + return resultObj; + } + + } +} diff --git a/newFront/c#前端/DI-Electrical/Services/LoginService.cs b/newFront/c#前端/DI-Electrical/Services/LoginService.cs new file mode 100644 index 00000000..c8e8e21f --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Services/LoginService.cs @@ -0,0 +1,50 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using DI_Electrical.Model; +using EasyEncryption; +using Newtonsoft.Json; + +namespace DI_Electrical.Services +{ + public class LoginService : HttpService + { + public LoginService() : base() + { + + } + + public async Task Login(string userName, string passwordOrigin) + { + + var password = MD5.ComputeMD5Hash(passwordOrigin); //B156525AFDB610B9D6830A1E9D0A1024 + try + { + var res = await this.GetAsync($"LoginApi/CheckLogin?username={userName}&password={password}"); + //OnRefresh(); + if (res.code == 200) + { + GlobalObject.userInfo = JsonConvert.DeserializeObject(res.data.ToString());// as loginRes; + GlobalObject.userInfo.userPs = passwordOrigin; + return ""; + } + else + { + return res.info;//ERROR INFO + } + + } + catch (HttpRequestException EX) + { + return "http错误。无法连接上服务器。请检查服务器 和 端口。" + EX.Message; + } + catch (Exception E) + { + return E.Message; + } + + + } + + } +} diff --git a/newFront/c#前端/DI-Electrical/Services/ProjectService.cs b/newFront/c#前端/DI-Electrical/Services/ProjectService.cs new file mode 100644 index 00000000..5c4e3765 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Services/ProjectService.cs @@ -0,0 +1,50 @@ +using System.Threading.Tasks; +using DI_Electrical.Model; +using Newtonsoft.Json.Linq; + +namespace DI_Electrical.Services +{ + public class ProjectService : HttpService + { + public ProjectService() : base() + { + + } + + public async Task> GetProjects(int pageNo, int pageSize) + { + + var res = await this.GetAsync>($"ProjectApi/GetProjectSelectPageList?pageNo={pageNo}&pageSize={pageSize}"); + if (res.code == 200) + { + return res.data; + } + else + { + } + return null; + } + + /// + /// 插件端选择项目后,统一、整合加载左侧面板里的数据 + /// + /// + /// + /// + public async Task InitProjInfo(string projectId, string userName) + { + var res = await this.GetAsync($"ProjectApi/InitProjInfo?ProjId={projectId}&User={userName}"); + if (res.code == 200) + { + var o = res.data as JToken; + + return o; + } + else + { + return null; + } + + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Services/UserService.cs b/newFront/c#前端/DI-Electrical/Services/UserService.cs new file mode 100644 index 00000000..34a65329 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Services/UserService.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using DI_Electrical.Model; + +namespace DI_Electrical.Services +{ + public class UserService : HttpService + { + public UserService() : base() + { + + } + public async Task GetList() + { + + var res = await this.GetAsync>($"UserApi/GetList"); + if (res.code == 200) + { + GlobalObject.Users = res.data; + } + else + { + } + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Services/WireGroupService.cs b/newFront/c#前端/DI-Electrical/Services/WireGroupService.cs new file mode 100644 index 00000000..aebc72a6 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Services/WireGroupService.cs @@ -0,0 +1,170 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using DI_Electrical.Models; + +namespace DI_Electrical.Services +{ + public class WireGroupService : HttpService + { + #region 辅助类 + /// + /// SaveSignals 专用 + /// + public class WireGroups + { + public string ID { get; set; } + public List Signals { get; set; } + } + #endregion + public WireGroupService() : base() + { + + } + /// + /// 获取所有的信号 + /// + /// + /// + /// + public async Task> GetSignals(string projId, bool Assigned) + { + + var res = await this.GetAsync>($"WireGroupApi/GetSignals?projId={projId}&Assigned={Assigned}"); + if (res.code == 200) + { + return res.data; + } + else + { + } + return null; + } + /// + /// 获取当前组可用的编码 + /// + /// + /// + public async Task GetNextAvailableSeq(string group) + { + var res = await this.GetAsync($"WireGroupApi/GetNextAvailableSeq?projId={GlobalObject.curProject?.ProjectId}&group={group}"); + if (res.code == 200) + { + return res.info; + } + else + { + } + return null; + } + + /// + /// 验证是否可以保存 + /// + /// + /// + public async Task CanSaveSignals(WireGroups entity ,Models.Action ActionType) + { + var res = await this.PostBodyAsync, WireGroups>($"WireGroupApi/CanSaveSignals?projId={GlobalObject.curProject?.ProjectId}&ActionType={ActionType}", entity); + if (res.code == 200) + { + return "OK"; + } + else + { + return res.info; + } + } + /// + /// 保存 + /// + /// + /// + public async Task> SaveSignals(WireGroups entity) + { + var res = await this.PostBodyAsync, WireGroups>($"WireGroupApi/SaveSignals?projId={GlobalObject.curProject?.ProjectId}&mode=0", entity); + if (res.code == 200) + { + return res.data; + } + else + { + } + return null; + } + + /// + /// 查询信号信息 + /// + /// + /// + public async Task> GetNotification() + { + var res = await this.GetAsync>($"WireGroupApi/GetNotification?projId={GlobalObject.curProject?.ProjectId}"); + if (res.code == 200) + { + return res.data; + } + else + { + } + return null; + } + + /// + /// 查询信号历史 + /// + /// 项目ID + /// 信号ID,多个用都逗号隔开 + /// + public async Task> GetSignalPropertyhis(string wireGroupIds) + { + var res = await this.GetAsync>($"WireGroupApi/GetSignalPropertyhis?projId={GlobalObject.curProject?.ProjectId}&wireGroupIds={wireGroupIds}"); + if (res.code == 200) + { + return res.data; + } + else + { + } + return null; + } + + /// + /// 查询信号日志 + /// + /// 项目ID + /// 信号ID,多个用都逗号隔开 + /// + public async Task> GetSignalLogs(string wireGroupIds) + { + var res = await this.GetAsync>($"WireGroupApi/GetSignalLogs?projId={GlobalObject.curProject?.ProjectId}&wireGroupIds={wireGroupIds}"); + if (res.code == 200) + { + return res.data; + } + else + { + } + return null; + } + + /// + /// 读信号通知 + /// + /// + /// + public async Task> ReadNotification(List NoticeIds) + { + var res = await this.PostBodyAsync,List>($"WireGroupApi/ReadNotification?projId={GlobalObject.curProject?.ProjectId}", NoticeIds); + if (res.code == 200) + { + return res.data; + } + else + { + } + return null; + } + + } +} diff --git a/newFront/c#前端/DI-Electrical/Style/CustomStyles.xaml b/newFront/c#前端/DI-Electrical/Style/CustomStyles.xaml new file mode 100644 index 00000000..b25aeb5e --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Style/CustomStyles.xaml @@ -0,0 +1,552 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #C0C4CC + M998 352c0 -8 -4 -17 -10 -23l-50 -50c-6 -6 -14 -10 -23 -10c-8 0 -17 4 -23 10l-393 393l-393 -393c-6 -6 -15 -10 -23 -10s-17 4 -23 10l-50 50c-6 6 -10 15 -10 23s4 17 10 23l466 466c6 6 15 10 23 10s17 -4 23 -10l466 -466c6 -6 10 -15 10 -23z + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/newFront/c#前端/DI-Electrical/Style/StyleSelectors/ConditionalStyleSelector.cs b/newFront/c#前端/DI-Electrical/Style/StyleSelectors/ConditionalStyleSelector.cs new file mode 100644 index 00000000..6f5ad24a --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Style/StyleSelectors/ConditionalStyleSelector.cs @@ -0,0 +1,82 @@ +using System.Collections.Generic; +using System.Windows.Controls; +using System.Windows.Data; + +namespace DI_Electrical.Style +{ + internal class ConditionalStyleSelector:StyleSelector + { + public override System.Windows.Style SelectStyle(object item, System.Windows.DependencyObject container) + { + //获取到转换器返回的值 + object conditionValue = this.ConditionConverter.Convert(item, null, null, null); + foreach (ConditionalStyleRule rule in this.Rules) + { + //值相同则返回当前样式 + if (Equals(rule.Value, conditionValue)) + { + return rule.Style; + } + } + + return base.SelectStyle(item, container); + } + + List _Rules; + public List Rules + { + get + { + if (this._Rules == null) + { + this._Rules = new List(); + } + + return this._Rules; + } + } + + IValueConverter _ConditionConverter; + public IValueConverter ConditionConverter + { + get + { + return this._ConditionConverter; + } + set + { + this._ConditionConverter = value; + } + } + } + + public class ConditionalStyleRule + { + object _Value; + public object Value + { + get + { + return this._Value; + } + set + { + this._Value = value; + } + } + + System.Windows.Style _Style; + public System.Windows.Style Style + { + get + { + return this._Style; + } + set + { + this._Style = value; + } + } + } + +} diff --git a/newFront/c#前端/DI-Electrical/Style/StyleSelectors/SignalNoticeStyleSelector.cs b/newFront/c#前端/DI-Electrical/Style/StyleSelectors/SignalNoticeStyleSelector.cs new file mode 100644 index 00000000..c10434ac --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Style/StyleSelectors/SignalNoticeStyleSelector.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.Windows; +using System.Windows.Controls; +using DI_Electrical.ViewModels; + +namespace DI_Electrical.Style +{ + internal class SignalNoticeStyleSelector:StyleSelector + { + public override System.Windows.Style SelectStyle(object item, DependencyObject container) + { + SignalNotice conditionValue = item as SignalNotice; + string value = conditionValue.CheckFLG.ToString(); + foreach (ConditionalStyleRule rule in this.Rules) + { + //值相同则返回当前样式 + if (Equals(rule.Value, value)) + { + return rule.Style; + } + } + + + return base.SelectStyle(item, container); + } + + List _Rules; + public List Rules + { + get + { + if (this._Rules == null) + { + this._Rules = new List(); + } + + return this._Rules; + } + } + } +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/ConfigViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/ConfigViewModel.cs new file mode 100644 index 00000000..56a4471d --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/ConfigViewModel.cs @@ -0,0 +1,98 @@ +using System.Windows; +using DI_Electrical.Helper; +using DI_Electrical.Services; + +namespace DI_Electrical.ViewModels +{ + public class ConfigViewModel : DialogBase + { + private string address; + public string Address + { + get { return this.address; } + set + { + if (value != this.address) + { + this.address = value; + RaisePropertyChanged(nameof(Address)); + } + } + } + private int port; + public int Port + { + get { return this.port; } + set + { + if (value != this.port) + { + this.port = value; + RaisePropertyChanged(nameof(Port)); + } + } + } + private string _directory; + public string Directory + { + get { return this._directory; } + set + { + if (value != this._directory) + { + this._directory = value; + RaisePropertyChanged(nameof(Directory)); + } + } + } + + + + ConfigService _configService; + LoginService _LoginService; + public ConfigViewModel(ConfigService configService, LoginService loginService) : base() + { + title = "设置"; + _configService = configService; + _LoginService = loginService; + _configService.Read(out address, out port, out _directory); + } + public override async void ExecuteOKCommandAsync(object obj) + { + if (string.IsNullOrEmpty(Directory)) + { + MessageBox.Show("本地文件目录不能为空。"); + return; + } + if (!System.IO.Directory.Exists(Directory)) + { + MessageBox.Show("本地文件目录不存在。"); + return; + } + var data = _configService.parser.ReadFile(_configService.path); + + _configService._httpService.Init(address, port); + IsBusy = true; + BusyContent = "保存中..."; + var testRes = await _LoginService.Login("1", "11"); + IsBusy = false; + if (testRes.StartsWith("http错误。")) + { + MessageBox.Show("无法连接上服务器。请检查服务器 和 端口。"); + return; + } + if (address.StartsWith("http")) + { + address = address.Replace("https://", "").Replace("http://", ""); + } + data["Profile"]["Address"] = address; + data["Profile"]["Port"] = port.ToString(); + data["Profile"]["Directory"] = _directory; + _configService.parser.WriteFile(_configService.path, data); + GlobalObject.isConfigIniCreateBySys = false; + GlobalObject.SetLocalFileDirectory(_directory); + + CloseWindowAction?.Invoke();//关闭 + } + } +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/DialogInputViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/DialogInputViewModel.cs new file mode 100644 index 00000000..b921bf01 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/DialogInputViewModel.cs @@ -0,0 +1,80 @@ +using Prism.Services.Dialogs; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using Telerik.Windows.Controls; +using Unity; +using DialogParameters = Prism.Services.Dialogs.DialogParameters; + +namespace DI_Electrical.ViewModels +{ + public class DialogInputViewModel : DialogBase, IDialogAware + { + + public DialogInputViewModel() + { + + } + + public event Action RequestClose; + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + + } + + private string _TextInfo; + /// + /// 文本内容 + /// + public string TextInfo + { + get { return _TextInfo; } + set { _TextInfo = value; RaisePropertyChanged(nameof(TextInfo)); } + } + private string _TextRemark; + /// + /// 注释 + /// + public string TextRemark + { + get { return _TextRemark; } + set { _TextRemark = value; RaisePropertyChanged(nameof(TextRemark)); } + } + + string IDialogAware.Title => throw new NotImplementedException(); + + public void OnDialogOpened(IDialogParameters parameters) + { + title = parameters.GetValue(GlobalObject.dialogPar.title.ToString()); + TextRemark = parameters.GetValue(GlobalObject.dialogPar.info.ToString()); + } + public override void ExecuteOKCommandAsync(object para) + { + IDialogParameters res = new DialogParameters(); + res.Add(GlobalObject.dialogPar.info.ToString(), $"{TextInfo}"); + DialogResult result = new DialogResult(ButtonResult.Yes, res); + RequestClose.Invoke(result); + } + public override void ExecuteCloseCommand(object parameter) + { + IDialogParameters par = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.No, par); + RequestClose.Invoke(result); + this.Dispose(); + } + + } + + +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalManagementViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalManagementViewModel.cs new file mode 100644 index 00000000..be736d0b --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalManagementViewModel.cs @@ -0,0 +1,1958 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Threading.Tasks; +using System.Windows.Input; +using Telerik.Windows.Controls; +using Unity; +using System.Windows; +using Prism.Ioc; +using Telerik.Windows.Data; +using System.Data; +using Prism.Services.Dialogs; +using DI_Electrical.Models; +using DI_Electrical.Services; +using static DI_Electrical.Services.WireGroupService; +using DialogParameters = Prism.Services.Dialogs.DialogParameters; +using DI_Electrical.Views.Dialog.DialogSignalManagements; +using DI_Electrical.Views.Dialog; + +namespace DI_Electrical.ViewModels +{ + public class DialogSignalManagementViewModel : DialogBase, IDialogAware + { + #region 属性 + + private ObservableCollection _smInfos = new ObservableCollection(); + /// + /// 表格数据源 + /// + public ObservableCollection smInfos + { + get { return _smInfos; } + set + { + _smInfos = value; + RaisePropertyChanged(nameof(smInfos)); + } + } + + private QueryableCollectionView _smInfosView; + /// + /// 可筛选的的集合视图 + /// + public QueryableCollectionView smInfosView + { + get { return _smInfosView; } + set { _smInfosView = value; RaisePropertyChanged(nameof(smInfosView)); } + } + + private SignalManagementInfo _SelectedSmInfo; + /// + /// 选中行 + /// + public SignalManagementInfo SelectedSmInfo + { + get { return _SelectedSmInfo; } + set { _SelectedSmInfo = value; RaisePropertyChanged(nameof(SelectedSmInfo)); } + } + + /// + /// 信号接口服务 + /// + WireGroupService _wireGroupService; + private readonly IDialogService _dialogService; + private string _count; + /// + /// 表格数据数量 + /// + public string count + { + get { return _count; } + set { _count = value; RaisePropertyChanged(nameof(count)); } + } + + private string _pojectName; + /// + /// 表格名 + /// + public string pojectName + { + get { return _pojectName; } + set { _pojectName = value; RaisePropertyChanged(nameof(pojectName)); } + } + + //public DialogSignalNotice SignalNoticeView { get; set; } + + private string _ButtonContent = "回收站"; + /// + /// 回收站按钮文本 + /// + public string ButtonContent + { + get { return _ButtonContent; } + set { _ButtonContent = value; RaisePropertyChanged(nameof(ButtonContent)); } + } + + private string _SearchText; + /// + /// 搜索框文本 + /// + public string SearchText + { + get { return _SearchText; } + set { _SearchText = value; RaisePropertyChanged(nameof(SearchText)); } + } + + + #region 下拉列表 + private List _GroupOthers; + /// + /// 绑定组别列表 + /// + public List GroupOthers + { + get { return _GroupOthers; } + set { _GroupOthers = value; RaisePropertyChanged(nameof(GroupOthers)); } + } + + private List _BelongingMajors = new List { "E", "M" }; + /// + /// 绑定归属专业 + /// + public List BelongingMajors + { + get { return _BelongingMajors; } + set { _BelongingMajors = value; RaisePropertyChanged(nameof(BelongingMajors)); } + } + + private List _InOrOuts = new List { "input", "output" }; + /// + /// 绑定IO类型 + /// + public List InOrOuts + { + get { return _InOrOuts; } + set { _InOrOuts = value; RaisePropertyChanged(nameof(InOrOuts)); } + } + + private List _IO_Types = new List { "ON/OFF", "NO", "NC", "4-20mA", "PT100", "Pulse", "N/A" }; + /// + /// 绑定信号类型 + /// + public List IO_Types + { + get { return _IO_Types; } + set { _IO_Types = value; RaisePropertyChanged(nameof(IO_Types)); } + } + + private List _AL_GRPs; + /// + /// 绑定AL_GRP + /// + public List AL_GRPs + { + get { return _AL_GRPs; } + set { _AL_GRPs = value; RaisePropertyChanged(nameof(AL_GRPs)); } + } + private List _BL_GRPs; + /// + /// 绑定BL_GRP + /// + public List BL_GRPs + { + get { return _BL_GRPs; } + set { _BL_GRPs = value; RaisePropertyChanged(nameof(BL_GRPs)); } + } + + private List _Suppliers; + /// + /// 绑定供应商 + /// + public List Suppliers + { + get { return _Suppliers; } + set { _Suppliers = value; RaisePropertyChanged(nameof(Suppliers)); } + } + + private List _WHCPUs; + /// + /// 绑定WHCPU + /// + public List WHCPUs + { + get { return _WHCPUs; } + set + { + _WHCPUs = value; + ECRCPUs = value; + ShipOfficeCPUs = value; + RaisePropertyChanged(nameof(WHCPUs)); + } + } + + private List _ECRCPUs; + /// + /// 绑定ECRCPU + /// + public List ECRCPUs + { + get { return _ECRCPUs; } + set { _ECRCPUs = value; RaisePropertyChanged(nameof(ECRCPUs)); } + } + + private List _ShipOfficeCPUs; + /// + /// 绑定ShipOfficeCPU + /// + public List ShipOfficeCPUs + { + get { return _ShipOfficeCPUs; } + set { _ShipOfficeCPUs = value; RaisePropertyChanged(nameof(ShipOfficeCPUs)); } + } + + private WireGroups _Ent; + /// + /// 新增或修改的列表 + /// + public WireGroups Ent + { + get { return _Ent; } + set { _Ent = value; } + } + + #endregion + + + #endregion + + string IDialogAware.Title => "信号管理"; + public event Action RequestClose; + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + + } + public DialogSignalManagementViewModel(IDialogService dialogService, IContainerProvider container) + { + title = "信号管理"; + + _dialogService = dialogService; + _wireGroupService = container.Resolve(); + var serv = container.Resolve(); + GroupOthers = Task.Run(() => serv.GetDetails("be_Signal_Group")).Result; + Suppliers = Task.Run(() => serv.GetDetails("Maker")).Result; + WHCPUs = Task.Run(() => serv.GetDetails("Alarm")).Result; + + Ent = new WireGroups(); + Ent.Signals = new List(); + + + + + } + + + + private List signals; + public async void OnDialogOpened(IDialogParameters parameters) + { + + try + { + IsBusy = true; BusyContent = "加载中..."; + signals = await _wireGroupService.GetSignals(GlobalObject.curProject.ProjectId, false); + IsBusy = false; + count = signals.Count.ToString(); + signals = signals.Where(s => s.Status != WireGroupStatusEnum.deleted).ToList(); + SetBaseData(signals); + count = smInfos.Count.ToString() + "/" + count; + pojectName = GlobalObject.curProject.ProjectName + " | " + GlobalObject.curProject.ShipNameCN; + + } + catch (Exception) + { + + + } + + } + public override void ExecuteOKCommandAsync(object para) + { + IDialogParameters res = new DialogParameters(); + //res.Add(GlobalObject.dialogPar.info.ToString(), $"{TextInfo}"); + DialogResult result = new DialogResult(ButtonResult.Yes, res); + RequestClose.Invoke(result); + } + public override void ExecuteCloseCommand(object parameter) + { + if (smInfos.Any(s => s.IsModified == true)) + { + MessageBoxResult resultMessage = MessageBox.Show("修改未保存,是否取消修改", "KunHengCAD", MessageBoxButton.OKCancel, MessageBoxImage.Question); + if (resultMessage != MessageBoxResult.OK) + { + return; + } + } + IDialogParameters par = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.No, par); + RequestClose.Invoke(result); + this.Dispose(); + + } + + #region 页面按钮事件 + public ICommand StatusButtonCmd => new DelegateCommand(StatusButton_Click); + /// + /// 显示状态按钮 + /// + /// + public virtual async void StatusButton_Click(object parameter) + { + smInfos = new ObservableCollection(); + IsBusy = true; BusyContent = "查询中..."; + signals = await _wireGroupService.GetSignals(GlobalObject.curProject.ProjectId, false); + IsBusy = false; + count = signals.Count.ToString(); + signals = signals.Where(s => s.Status != WireGroupStatusEnum.deleted).ToList(); + if (!parameter.Equals("All")) + { + signals = signals.Where(s => s.Status.ToString().Equals(parameter)).ToList(); + SetBaseData(signals, 1); + } + else + { + SetBaseData(signals); + } + + count = smInfos.Count.ToString() + "/" + count; + } + + + public ICommand ButtonCmd => new DelegateCommand(Button_Click); + /// + /// 页面右侧按钮 + /// + /// + public virtual async void Button_Click(object parameter) + { + if (!_smInfos.Any()) + { + return; + } + int index = _smInfos.IndexOf(_SelectedSmInfo);//当前选中项在源数据集合中的索引 + #region 新增信号按钮 + if (parameter.Equals("新增信号")) + { + + if (index != -1 || SelectedSmInfo.type != "虚拟点") + { + var newEntity = new SignalManagementInfo(); + newEntity.BelongingMajor = "M"; + newEntity.type = "信号"; + newEntity.Status = "New"; + newEntity.GroupOthers = GroupOthers; + newEntity.Suppliers = Suppliers; + newEntity.IsModified = true; + //订阅事件以更新数据。 + newEntity.GroupOtherChanged += (sender, e) => UpdateParametersValue((SignalManagementInfo)sender); + // 添加新行到选中行下方 + _smInfos.Insert(index == -1 ? 0 : index + 1, newEntity); + //重新排序 + int i = 0; + foreach (var item in _smInfos) + { + i++; + item.serialNumber = i.ToString(); + foreach (var item2 in item.ChildSignals) + { + i++; + item2.serialNumber = i.ToString(); + } + } + SelectedSmInfo = newEntity; + } + else + { + // 显示消息框 + MessageBox.Show("请选择信号节点!", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + + } + #endregion + + #region 新增虚拟点 + if (parameter.Equals("新增虚拟点")) + { + if (index == -1 || SelectedSmInfo.type.Equals("虚拟点")) + { + MessageBox.Show("请选择信号节点!", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + else + { + var newEntity = new SignalManagementInfo(); + newEntity.BelongingMajor = SelectedSmInfo.BelongingMajor; + newEntity.type = "虚拟点"; + newEntity.Status = "New"; + newEntity.ParentID = SelectedSmInfo.Wire_Group_ID; + newEntity.GroupOthers = GroupOthers; + newEntity.GroupOther = SelectedSmInfo.GroupOther; + newEntity.Suppliers = Suppliers; + newEntity.IsModified = true; + //订阅事件以更新数据。 + newEntity.ParametersChanged += (sender, e) => UpdateParametersValue((SignalManagementInfo)sender); + // 添加新行到选中行下方 + //smInfos.Insert(index + 1, newEntity); + SelectedSmInfo.ChildSignals.Add(newEntity); + //重新排序 + int i = 0; + foreach (var item in smInfos) + { + i++; + item.serialNumber = i.ToString(); + foreach (var item2 in item.ChildSignals) + { + i++; + item2.serialNumber = i.ToString(); + } + } + SelectedSmInfo = newEntity; + } + } + #endregion + + #region 信号转虚拟点 + if (parameter.Equals("信号转虚拟点")) + { + if (SelectedSmInfo != null) + { + if (SelectedSmInfo.type.Equals("信号")) + { + IDialogParameters res = new DialogParameters(); + res.Add(GlobalObject.dialogPar.para1.ToString(), smInfos); + _dialogService.ShowDialog(nameof(DialogSignalSelect), res, (RES) => + { + + if (RES.Result == ButtonResult.Yes) + { + var signal = RES.Parameters.GetValue(GlobalObject.dialogPar.para1.ToString()); + SelectedSmInfo.ParentID = signal.SignalId; + SelectedSmInfo.type = "虚拟点"; + SelectedSmInfo.Group_Name = SelectedSmInfo.Group_Name + (string.IsNullOrEmpty(SelectedSmInfo.Code) ? "" : "_" + SelectedSmInfo.Code); + SelectedSmInfo.IsModified = true; + var tempSmInfo = SelectedSmInfo; + smInfos.Remove(SelectedSmInfo); + + //var signalindex = smInfos.IndexOf(smInfos.FirstOrDefault(s => s.Wire_Group_ID == signal.SignalId)) + 1; + + //smInfos.Insert(signalindex, tempSmInfo); + + smInfos.FirstOrDefault(s => s.Wire_Group_ID == signal.SignalId).ChildSignals.Add(tempSmInfo); + + var i = 0; + foreach (var item in smInfos) + { + i++; + item.serialNumber = i.ToString(); + foreach (var item2 in item.ChildSignals) + { + i++; + item2.serialNumber = i.ToString(); + } + } + + SelectedSmInfo = tempSmInfo; + } + else if (RES.Result == ButtonResult.No) + { } + }); + + + } + else if (SelectedSmInfo.type.Equals("虚拟点")) + { + var parentSmif = smInfos.FirstOrDefault(s => s.Wire_Group_ID == SelectedSmInfo.ParentID); + SelectedSmInfo.type = "信号"; + SelectedSmInfo.ParentID = ""; + //SelectedSmInfo.Code = ""; + SelectedSmInfo.Group_Name = SelectedSmInfo.Group_Name.Split('_')[0]; + + SelectedSmInfo.IsModified = true; + + var tempSmInfo = SelectedSmInfo; + + parentSmif.ChildSignals.Remove(SelectedSmInfo); + var signalindex = smInfos.IndexOf(parentSmif); + //signalindex = smInfos.IndexOf(smInfos.Skip(signalindex).Where(s => s.type.Equals("信号")).First()); + smInfos.Insert(signalindex + 1, tempSmInfo); + + var i = 0; + foreach (var item in smInfos) + { + i++; + item.serialNumber = i.ToString(); + foreach (var item2 in item.ChildSignals) + { + i++; + item2.serialNumber = i.ToString(); + } + } + + SelectedSmInfo = tempSmInfo; + } + } + } + #endregion + + #region 删除 + if (parameter.Equals("删除")) + { + if (SelectedSmInfo != null) + { + //RadWindow.Alert("Start time: " + this.StartTime + "\nEnd time: " + this.EndTime); + // 显示消息框 + MessageBoxResult result = MessageBox.Show("确定准备删除选择的一行数据", "KunHengCAD", MessageBoxButton.OKCancel, MessageBoxImage.Question); + if (result == MessageBoxResult.OK) + { + + //id为空表示新增的未保存所以直接删除,不为空表示数据库已存在只修改状态 + if (string.IsNullOrEmpty(SelectedSmInfo.Wire_Group_ID)) + { + smInfos.Remove(SelectedSmInfo); + } + else + { + + IDialogParameters res = new DialogParameters(); + res.Add(GlobalObject.dialogPar.title.ToString(), "提示"); + res.Add(GlobalObject.dialogPar.info.ToString(), "请输入删除的原因:"); + _dialogService.ShowDialog(nameof(DialogInput), res, (RES) => + { + if (RES.Result == ButtonResult.Yes) + { + var Reason = RES.Parameters.GetValue(GlobalObject.dialogPar.info.ToString()); + if (string.IsNullOrEmpty(Reason)) + { + MessageBox.Show("您输入的信息为空!"); + } + else + { + List histories = new List() + { + new ActionHistory() + { + ActionTime= DateTime.Now, + ActionType = Models.Action.准备删除, + reason = Reason + + } + }; + SelectedSmInfo.ActionHistorys = histories; + SelectedSmInfo.Status = "ToDelete"; + SelectedSmInfo.IsModified = true; + if (SelectedSmInfo.type.Equals("虚拟点")) + { + SelectedSmInfo.GroupOther = ""; + } + } + } + else if (RES.Result == ButtonResult.No) + { } + }); + } + + } + + } + else + { + // 显示消息框 + MessageBox.Show("请选择要准备删除的信号!", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); + } + } + #endregion + + #region 撤销删除 + if (parameter.Equals("撤销删除")) + { + if (SelectedSmInfo != null && SelectedSmInfo.Status == "ToDelete") + { + List histories = new List() + { + new ActionHistory() + { + ActionTime= DateTime.Now, + ActionType = Models.Action.撤销删除, + + } + }; + SelectedSmInfo.ActionHistorys = histories; + SelectedSmInfo.Status = "New"; + SelectedSmInfo.IsModified = true; + } + else + { + MessageBox.Show("只有待删除的信号才能撤销删除"); + } + + } + #endregion + + #region 彻底删除 + if (parameter.Equals("彻底删除")) + { + if (SelectedSmInfo != null) + { + List Signals = new List() + { + new ec_Wire_Group() + { + Group_Name = SelectedSmInfo.Group_Name, + Wire_Group_ID = SelectedSmInfo.Wire_Group_ID + } + }; + WireGroups ent = new WireGroups(); + ent.Signals = Signals; + string message = await _wireGroupService.CanSaveSignals(ent, Models.Action.删除); + if (message != "OK") + { + // 显示消息框 + MessageBox.Show(message, "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + else + { + List histories = new List() + { + new ActionHistory() + { + ActionTime= DateTime.Now, + ActionType = Models.Action.删除, + reason = "" + + } + }; + SelectedSmInfo.ActionHistorys = histories; + SelectedSmInfo.Status = "deleted"; + SelectedSmInfo.DeleteFlg = true; + SelectedSmInfo.IsModified = true; + SignalManagementInfo tempsmif = new SignalManagementInfo(); + tempsmif = SelectedSmInfo; + if (SelectedSmInfo.type.Equals("信号")) + { + smInfos.Remove(SelectedSmInfo); + smInfos.Add(tempsmif); + } + else + { + var parentSmif = smInfos.FirstOrDefault(s => s.Wire_Group_ID == SelectedSmInfo.ParentID); + parentSmif.ChildSignals.Remove(SelectedSmInfo); + smInfos.Add(tempsmif); + } + + } + } + + } + #endregion + + #region 还原信号 + if (parameter.Equals("还原信号")) + { + if (SelectedSmInfo != null) + { + IDialogParameters res = new DialogParameters(); + res.Add(GlobalObject.dialogPar.title.ToString(), "提示"); + res.Add(GlobalObject.dialogPar.info.ToString(), "请输入还原信号的原因:"); + _dialogService.ShowDialog(nameof(DialogInput), res, (RES) => + { + if (RES.Result == ButtonResult.Yes) + { + var Reason = RES.Parameters.GetValue(GlobalObject.dialogPar.info.ToString()); + if (string.IsNullOrEmpty(Reason)) + { + MessageBox.Show("您输入的信息为空!"); + } + else + { + List histories = new List() + { + new ActionHistory() + { + ActionTime= DateTime.Now, + ActionType = Models.Action.回收站恢复, + reason = Reason + + } + }; + SelectedSmInfo.ActionHistorys = histories; + SelectedSmInfo.Status = "New"; + SelectedSmInfo.DeleteFlg = false; + SelectedSmInfo.IsModified = true; + SignalManagementInfo tempsmif = new SignalManagementInfo(); + tempsmif = SelectedSmInfo; + if (SelectedSmInfo.type.Equals("信号")) + { + smInfos.Remove(SelectedSmInfo); + smInfos.Add(tempsmif); + } + else + { + var parentSmif = smInfos.FirstOrDefault(s => s.Wire_Group_ID == SelectedSmInfo.ParentID); + parentSmif.ChildSignals.Remove(SelectedSmInfo); + smInfos.Add(tempsmif); + } + + } + } + else if (RES.Result == ButtonResult.No) + { } + }); + + + } + } + + #endregion + + #region 审核 + if (parameter.Equals("审核")) + { + if (SelectedSmInfo != null) + { + + List Signals = new List() + { + new ec_Wire_Group() + { + Group_Name = SelectedSmInfo.Group_Name, + Wire_Group_ID = SelectedSmInfo.Wire_Group_ID + } + }; + WireGroups ent = new WireGroups(); + ent.Signals = Signals; + string message = await _wireGroupService.CanSaveSignals(ent, Models.Action.审核); + if (message != "OK") + { + // 显示消息框 + MessageBox.Show(message, "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + else + { + List histories = new List() + { + new ActionHistory() + { + ActionTime= DateTime.Now, + ActionType = Models.Action.审核, + reason = "" + + } + }; + SelectedSmInfo.ActionHistorys = histories; + SelectedSmInfo.Status = "Confirmed"; + SelectedSmInfo.IsModified = true; + } + } + } + #endregion + + #region 重新打开 + if (parameter.Equals("重新打开")) + { + if (SelectedSmInfo != null) + { + var messageBoxResult = MessageBox.Show("确定重新打开选中的一行数据?", "KunHengCAD", MessageBoxButton.OKCancel, MessageBoxImage.Question); + if (messageBoxResult == MessageBoxResult.OK) + { + if (SelectedSmInfo.Status == "Confirmed") + { + IDialogParameters res = new DialogParameters(); + res.Add(GlobalObject.dialogPar.title.ToString(), "提示"); + res.Add(GlobalObject.dialogPar.info.ToString(), "请输入重新打开改信号的原因:"); + _dialogService.ShowDialog(nameof(DialogInput), res, (RES) => + { + if (RES.Result == ButtonResult.Yes) + { + var Reason = RES.Parameters.GetValue(GlobalObject.dialogPar.info.ToString()); + if (string.IsNullOrEmpty(Reason)) + { + MessageBox.Show("输入的信息不能为空!"); + } + else + { + List histories = new List() + { + new ActionHistory() + { + ActionTime= DateTime.Now, + ActionType = Models.Action.重新打开, + reason = Reason + + } + }; + SelectedSmInfo.ActionHistorys = histories; + SelectedSmInfo.Status = "Reopen"; + SelectedSmInfo.IsModified = true; + } + } + else if (RES.Result == ButtonResult.No) + { } + }); + } + else + { + // 显示消息框 + MessageBox.Show("只有已审核的信号才能重新打开", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + } + else + { + return; + } + + } + } + #endregion + } + + + + public ICommand HeadButtonCmd => new DelegateCommand(HeadButton_Click); + /// + /// 页面右侧按钮 + /// + /// + public virtual async void HeadButton_Click(object parameter) + { + #region 保存按钮 + if (parameter.Equals("保存")) + { + //新增或者修改的集合 + List updatals = new List(); + foreach (var item in smInfos) + { + if (item.IsModified) + { + updatals.Add(item); + } + foreach (var item2 in item.ChildSignals) + { + if (item2.IsModified) + { + updatals.Add(item2); + } + } + } + //updatals = smInfos.Where(s => s.IsModified == true).ToList(); + foreach (var item in updatals) + { + //保存的为信号时才判断组别 + if (item.type == "信号") + { + if (string.IsNullOrEmpty(item.GroupOther)) + { + // 显示消息框 + MessageBox.Show("组别不能为空", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + } + else if (item.type == "虚拟点") + { + if (string.IsNullOrEmpty(item.Code)) + { + MessageBox.Show("Code列不能为空", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Warning); + return; + } + } + + Ent.Signals.Add(item.to_ec_Wire_Group(signals)); + } + //保存 + var data = await _wireGroupService.SaveSignals(Ent); + if (data != null && data.Count != 0) + { + + //foreach (var item in data) + //{ + + //} + smInfos = new ObservableCollection(); + IsBusy = true; BusyContent = "保存中..."; + signals = await _wireGroupService.GetSignals(GlobalObject.curProject.ProjectId, false); + IsBusy = false; + count = signals.Count.ToString(); + if (ButtonContent.Equals("回收站")) + { + signals = signals.Where(s => s.Status != WireGroupStatusEnum.deleted).ToList(); + } + else + { + signals = signals.Where(s => s.Status == WireGroupStatusEnum.deleted).ToList(); + } + + SetBaseData(signals); + count = smInfos.Count.ToString() + "/" + count; + Ent.Signals.Clear(); + // 显示消息框 + MessageBox.Show("保存成功", "KunHengCAD", MessageBoxButton.OK, MessageBoxImage.Information); + } + else + { + return; + } + + } + #endregion + + #region 退出按钮 + if (parameter.Equals("退出")) + { + if (smInfos.Any(s => s.IsModified == true)) + { + MessageBoxResult resultMessage = MessageBox.Show("修改未保存,是否取消修改", "KunHengCAD", MessageBoxButton.OKCancel, MessageBoxImage.Question); + if (resultMessage != MessageBoxResult.OK) + { + return; + } + } + IDialogParameters par = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.No, par); + RequestClose.Invoke(result); + this.Dispose(); + } + #endregion + + #region 通知消息 + if (parameter.Equals("通知信息")) + { + + //RadWindow window = new RadWindow(); + + //window.Content = new DialogSignalNotice(); + //window.WindowStartupLocation = WindowStartupLocation.CenterOwner; + //window.Header = "通知消息"; + ////window.CanClose = false; + //window.Show(); + + //打开窗体 + IDialogParameters res = new DialogParameters(); + _dialogService.ShowDialog(nameof(DialogSignalNotice), res, (RES) => + { + if (RES.Result == ButtonResult.Yes) + { + + } + else if (RES.Result == ButtonResult.No) + { } + }); + + } + #endregion + + #region 历史记录 + if (parameter.Equals("历史记录")) + { + if (SelectedSmInfo != null) + { + //打开窗体 + IDialogParameters res = new DialogParameters(); + res.Add(GlobalObject.dialogPar.para1.ToString(), SelectedSmInfo); + _dialogService.ShowDialog(nameof(DialogSignalPropertyhisAndLogs), res, (RES) => + { + if (RES.Result == ButtonResult.Yes) + { + + } + else if (RES.Result == ButtonResult.No) + { } + }); + } + + } + #endregion + + #region 回收站 + if (parameter.Equals("回收站")) + { + switch (ButtonContent) + { + case "回收站": + ButtonContent = "显示全部"; + break; + case "显示全部": + ButtonContent = "回收站"; + break; + } + + + smInfos = new ObservableCollection(); + IsBusy = true; BusyContent = "查询中..."; + signals = await _wireGroupService.GetSignals(GlobalObject.curProject.ProjectId, false); + IsBusy = false; + count = signals.Count.ToString(); + if (ButtonContent.Equals("回收站")) + { + signals = signals.Where(s => s.Status != WireGroupStatusEnum.deleted).ToList(); + } + else + { + signals = signals.Where(s => s.Status == WireGroupStatusEnum.deleted).ToList(); + + } + SetBaseData(signals); + count = smInfos.Count.ToString() + "/" + count; + } + #endregion + + #region 搜索 + if (parameter.Equals("搜索框")) + { + PerformSearch(); + } + #endregion + + } + + public ICommand EditEndCmd => new DelegateCommand(EditEnd); + + + + /// + /// 编辑结束事件 + /// + /// + public virtual void EditEnd(object parameter) + { + //做个标记表示该项修改过 + SelectedSmInfo.IsModified = true; + + } + + + + #endregion + + #region 方法 + /// + /// 设置数据 + /// 0是初始化数据,1是查询数据 + /// + public void SetBaseData(List signals, int model = 0) + { + + int index = 0; + foreach (var signal in signals) + { + if (model == 0) + { + if (string.IsNullOrEmpty(signal.ParentID)) + { + index++; + SignalManagementInfo info = new SignalManagementInfo(); + info.serialNumber = index.ToString(); + SetEntData(info, signal); + smInfos.Add(info); + foreach (var signal2 in signals) + { + if (signal.Wire_Group_ID.Equals(signal2.ParentID)) + { + index++; + SignalManagementInfo info2 = new SignalManagementInfo(); + + info2.serialNumber = index.ToString(); + SetEntData(info2, signal2); + info.ChildSignals.Add(info2); + info.ChildSignalsView = new QueryableCollectionView(info.ChildSignals); + info.IsExpandable = true; + } + } + } + } + else + { + index++; + SignalManagementInfo info = new SignalManagementInfo(); + info.serialNumber = index.ToString(); + SetEntData(info, signal); + smInfos.Add(info); + } + + } + smInfosView = new QueryableCollectionView(smInfos); + } + + public void SetEntData(SignalManagementInfo info, ec_Wire_Group signal) + { + info.Wire_Group_ID = signal.Wire_Group_ID; + info.ParentID = signal.ParentID; + info.Status = signal.Status.ToString(); + info.type = string.IsNullOrEmpty(signal.ParentID) ? "信号" : "虚拟点"; + info.Group_Name = signal.Group_Name; + info.Group_Desc_EN = signal.Group_Desc_EN; + info.Group_Desc = signal.Group_Desc; + info.BelongingMajor = signal.ElecOnly ? "E" : "M"; + + info.GroupOthers = GroupOthers; + info.GroupOther = GroupOthers.Where(g => g.DataItemCode == signal.Signal_Group).Select(g => g.DataItemName).FirstOrDefault(); + + info.Signal_SeqNo = signal.Signal_SeqNo; + info.Code = signal.Code; + info.InOrOut = signal.InOrOut; + info.IO_Type = signal.IO_Type; + info.Range_Min = signal.Range_Min; + info.Range_Max = signal.Range_Max; + info.Unit = signal.Unit; + info.Alarm_LL = signal.Alarm_LL; + info.Alarm_L = signal.Alarm_L; + info.Alarm_H = signal.Alarm_H; + info.Alarm_HH = signal.Alarm_HH; + info.SENSOR_CODE = signal.SENSOR_CODE; + info.CommunicationPoint = signal.CommunicationPoint; + info.SeriousType = signal.SeriousType; + info.AL_GRP = signal.AL_GRP; + info.BL_GRP = signal.BL_GRP; + info.Time_Delay = signal.Time_Delay; + info.Suppliers = Suppliers; + info.Supplier = Suppliers.Where(g => g.DataItemCode == signal.Supplier).Select(g => g.DataItemName).FirstOrDefault(); + info.EquipName = signal.EquipName; + info.VDR_Record = signal.VDR_Record; + info.WHConsole = signal.WHConsole; + //info.WHCPU = signal.WHCPU; + foreach (var item in signal.WHCPU.Split('|')) + { + info.WHCPUs.Add(WHCPUs.Where(e => e.DataItemCode.Equals(item.Trim())).FirstOrDefault()); + } + info.ECRConsole = signal.ECRConsole; + //info.ECRCPU = signal.ECRCPU; + foreach (var item in signal.ECRCPU.Split('|')) + { + info.ECRCPUs.Add(ECRCPUs.Where(e => e.DataItemCode.Equals(item.Trim())).FirstOrDefault()); + } + info.ShipOfficeConsole = signal.ShipOfficeConsole; + //info.ShipOfficeCPU = signal.ShipOfficeCPU; + foreach (var item in signal.ShipOfficeCPU.Split('|')) + { + info.ShipOfficeCPUs.Add(ShipOfficeCPUs.Where(e => e.DataItemCode.Equals(item.Trim())).FirstOrDefault()); + } + info.SLD = signal.SLD; + info.SHD = signal.SHD; + info.SafetyDelay = signal.SafetyDelay; + info.AutoCtrl = signal.AutoCtrl; + info.AssociatedCableInfo = (signal.CableName == "" || signal.CableName == null ? "" : "电缆位号:" + signal.CableName) + (signal.CableSetName == null ? "" : " 电缆对:" + signal.CableSetName); + info.AssociatedChannelInfo = (signal.PanelName == null ? "" : "采集箱:" + signal.PanelName) + (signal.StripName == null ? "" : "端子排:" + signal.StripName) + (signal.ChannelName == null ? "" : " 通道:" + signal.ChannelName); + info.Remarks = signal.Remarks; + info.DeleteFlg = signal.DeleteFlg; + //订阅事件以更新数据。 + info.ParametersChanged += (sender, e) => UpdateParametersValue((SignalManagementInfo)sender); + } + + + /// + /// 选择组别改变时修改Group_Name和Code() + /// + /// + private async void UpdateParametersValue(SignalManagementInfo item) + { + if (item.type == "信号") + { + //获取当前组别的可用编码 + string group = GroupOthers.Where(e => e.DataItemName.Equals(item.GroupOther)).Select(e => e.DataItemCode).FirstOrDefault(); + if (string.IsNullOrEmpty(item.Signal_SeqNo))//编码列为空时才通过接口获取可用编码 + { + var seq = await _wireGroupService.GetNextAvailableSeq(group); + int count = smInfos.Where(s => s.IsModified == true && string.IsNullOrEmpty(s.Wire_Group_ID)).ToList().Count; + if (count > 1) + { + seq = (double.Parse(seq) + count - 1).ToString(); + } + item.Signal_SeqNo = seq.ToString(); + } + item.Group_Name = group + item.Signal_SeqNo; + } + else if (item.type == "虚拟点") + { + if (string.IsNullOrEmpty(item.Group_Name)) + { + string Group_Name = smInfos.Where(e => e.Wire_Group_ID == item.ParentID).Select(e => e.Group_Name).FirstOrDefault(); + item.Group_Name = Group_Name + "_" + item.Code; + } + else + { + item.Group_Name = item.Group_Name.Split('_')[0] + "_" + item.Code; + } + + } + + + + } + /// + /// 搜索方法 + /// + private void PerformSearch() + { + //smInfosView.FilterDescriptors.Clear(); + //if (!string.IsNullOrEmpty(SearchText)) + //{ + // var searchLower = SearchText.ToLower(); + // // // 使用 LINQ 过滤父对象及子集合 + // // var filteredData = smInfos.Where(parent => + // // // 检查父对象属性 + // // parent.GetType().GetProperties() + // // .Any(p => p.PropertyType == typeof(string) && + // // (p.GetValue(parent)?.ToString().ToLower().Contains(searchLower)).HasValue) || + + // // // 检查子集合属性(解决 bool? 问题) + // // (parent.ChildSignals?.Any(child => + // // child.GetType().GetProperties() + // // .Any(c => c.PropertyType == typeof(string) && + // // (c.GetValue(child)?.ToString().ToLower().Contains(searchLower)).HasValue) + // // ) ?? false) // 关键修复:将 bool? 转换为 bool + // //).ToList(); + // // smInfosView = new QueryableCollectionView(filteredData); + // // smInfosView.Refresh(); + + + // var list = new List(); + // foreach (var parent in smInfos) + // { + // foreach (var p in parent.GetType().GetProperties()) + // { + // if (p.PropertyType == typeof(string)) + // { + // var value = p.GetValue(parent); + // if (value != null) + // { + // if (value.ToString().Contains(searchLower)) + // { + + // list.Add(parent); + // } + // } + // } + // } + + // foreach (var Child in parent.ChildSignals) + // { + // foreach (var c in Child.GetType().GetProperties()) + // { + // if (c.PropertyType == typeof(string)) + // { + // var value = c.GetValue(Child); + // if (value != null) + // { + // if (value.ToString().Contains(searchLower)) + // { + // //parent.IsExpandable = true; + // //parent.IsExpanded = true; + // list.Add(parent); + // } + // } + // } + // } + // } + // } + // smInfos = new ObservableCollection(); + // smInfos.AddRange(list); + //} + + + + //if (!string.IsNullOrEmpty(SearchText)) + //{ + // var compositeFilter = new CompositeFilterDescriptor + // { + // LogicalOperator = FilterCompositionLogicalOperator.Or + // }; + + // foreach (var prop in typeof(SignalManagementInfo).GetProperties()) + // { + // if (prop.PropertyType == typeof(string)) + // { + // compositeFilter.FilterDescriptors.Add(new FilterDescriptor + // { + // Member = prop.Name, + // Operator = FilterOperator.Contains, + // Value = SearchText.ToLower(), + // IsCaseSensitive = false + // }); + // } + // } + + // smInfosView.FilterDescriptors.Add(compositeFilter); + //} + + } + #endregion + + } + public class SignalManagementInfo : DialogBase + { + public event EventHandler GroupOtherChanged; + public event EventHandler CodeChanged; + public event EventHandler ParametersChanged; + + #region 表格字段 + + private string _Wire_Group_ID; + /// + /// ID + /// + public string Wire_Group_ID + { + get { return _Wire_Group_ID; } + set { _Wire_Group_ID = value; RaisePropertyChanged(nameof(Wire_Group_ID)); } + } + + private string _ParentID; + /// + /// 如果有值表示其为虚拟点 + /// + public string ParentID + { + get { return _ParentID; } + set { _ParentID = value; } + } + + + private string _Status; + /// + /// 状态 + /// + public string Status + { + get { return _Status; } + set { _Status = value; RaisePropertyChanged(nameof(Status)); } + } + + private string _serialNumber; + /// + /// 序号 + /// + public string serialNumber + { + get { return _serialNumber; } + set { _serialNumber = value; RaisePropertyChanged(nameof(serialNumber)); } + } + private string _type; + /// + /// 类型 + /// + public string type + { + get { return _type; } + set { _type = value; RaisePropertyChanged(nameof(type)); } + } + private string _Group_Name; + /// + /// CH.NO + /// + public string Group_Name + { + get { return _Group_Name; } + set { _Group_Name = value; RaisePropertyChanged(nameof(Group_Name)); } + } + + + private string _Group_Desc_EN; + /// + /// 英文描述 + /// + public string Group_Desc_EN + { + get { return _Group_Desc_EN; } + set { _Group_Desc_EN = value; RaisePropertyChanged(nameof(Group_Desc_EN)); } + } + private string _Group_Desc; + /// + /// 中文描述 + /// + public string Group_Desc + { + get { return _Group_Desc; } + set { _Group_Desc = value; RaisePropertyChanged(nameof(Group_Desc)); } + } + private string _BelongingMajor; + /// + /// 归属专业 + /// + public string BelongingMajor + { + get { return _BelongingMajor; } + set { _BelongingMajor = value; RaisePropertyChanged(nameof(BelongingMajor)); } + } + + private string _GroupOther; + /// + /// 组别 + /// + public string GroupOther + { + get { return _GroupOther; } + set + { + _GroupOther = value; + RaisePropertyChanged(nameof(GroupOther)); + ParametersChanged?.Invoke(this, EventArgs.Empty); + } + } + private List _GroupOthers; + /// + /// 组别列表 + /// + public List GroupOthers + { + get { return _GroupOthers; } + set { _GroupOthers = value; RaisePropertyChanged(nameof(GroupOthers)); } + } + + private string _Signal_SeqNo; + /// + /// 编码 + /// + public string Signal_SeqNo + { + get { return _Signal_SeqNo; } + set { _Signal_SeqNo = value; RaisePropertyChanged(nameof(Signal_SeqNo)); } + } + private string _Code; + /// + /// Code + /// + public string Code + { + get { return _Code; } + set + { + _Code = value; + RaisePropertyChanged(nameof(Code)); + ParametersChanged?.Invoke(this, EventArgs.Empty); + } + } + private string _InOrOut; + /// + /// IO类型 + /// + public string InOrOut + { + get { return _InOrOut; } + set { _InOrOut = value; RaisePropertyChanged(nameof(InOrOut)); } + } + + private string _IO_Type; + /// + /// 信号类型 + /// + public string IO_Type + { + get { return _IO_Type; } + set { _IO_Type = value; RaisePropertyChanged(nameof(IO_Type)); } + } + private string _Range_Min; + /// + /// Range_Min + /// + public string Range_Min + { + get { return _Range_Min; } + set { _Range_Min = value; RaisePropertyChanged(nameof(Range_Min)); } + } + private string _Range_Max; + /// + /// Range_Max + /// + public string Range_Max + { + get { return _Range_Max; } + set { _Range_Max = value; RaisePropertyChanged(nameof(Range_Max)); } + } + private string _Unit; + /// + /// 单位 + /// + public string Unit + { + get { return _Unit; } + set { _Unit = value; RaisePropertyChanged(nameof(Unit)); } + } + private string _Alarm_LL; + + public string Alarm_LL + { + get { return _Alarm_LL; } + set { _Alarm_LL = value; RaisePropertyChanged(nameof(Alarm_LL)); } + } + private string _Alarm_L; + + public string Alarm_L + { + get { return _Alarm_L; } + set { _Alarm_L = value; RaisePropertyChanged(nameof(Alarm_L)); } + } + private string _Alarm_H; + + public string Alarm_H + { + get { return _Alarm_H; } + set { _Alarm_H = value; RaisePropertyChanged(nameof(Alarm_H)); } + } + private string _Alarm_HH; + + public string Alarm_HH + { + get { return _Alarm_HH; } + set { _Alarm_HH = value; RaisePropertyChanged(nameof(Alarm_HH)); } + } + private string _SENSOR_CODE; + + public string SENSOR_CODE + { + get { return _SENSOR_CODE; } + set { _SENSOR_CODE = value; RaisePropertyChanged(nameof(SENSOR_CODE)); } + } + private bool _CommunicationPoint; + /// + /// 是否是通讯点 + /// + public bool CommunicationPoint + { + get { return _CommunicationPoint; } + set { _CommunicationPoint = value; RaisePropertyChanged(nameof(CommunicationPoint)); } + } + private string _SeriousType; + + public string SeriousType + { + get { return _SeriousType; } + set { _SeriousType = value; RaisePropertyChanged(nameof(SeriousType)); } + } + private string _AL_GRP; + + public string AL_GRP + { + get { return _AL_GRP; } + set { _AL_GRP = value; RaisePropertyChanged(nameof(AL_GRP)); } + } + private string _BL_GRP; + + public string BL_GRP + { + get { return _BL_GRP; } + set { _BL_GRP = value; RaisePropertyChanged(nameof(BL_GRP)); } + } + private string _Time_Delay; + + public string Time_Delay + { + get { return _Time_Delay; } + set { _Time_Delay = value; RaisePropertyChanged(nameof(Time_Delay)); } + } + private string _Supplier; + /// + /// 供应商 + /// + public string Supplier + { + get { return _Supplier; } + set { _Supplier = value; RaisePropertyChanged(nameof(Supplier)); } + } + private string _EquipName; + /// + /// 设备名 + /// + public string EquipName + { + get { return _EquipName; } + set { _EquipName = value; RaisePropertyChanged(nameof(EquipName)); } + } + private bool _VDR_Record; + + public bool VDR_Record + { + get { return _VDR_Record; } + set { _VDR_Record = value; RaisePropertyChanged(nameof(VDR_Record)); } + } + private string _WHConsole; + + public string WHConsole + { + get { return _WHConsole; } + set { _WHConsole = value; RaisePropertyChanged(nameof(WHConsole)); } + } + private ObservableCollection _WHCPU = new ObservableCollection(); + + public ObservableCollection WHCPU + { + get { return _WHCPU; } + set + { + _WHCPU = value; + WHCPUs.AddRange(value); + RaisePropertyChanged(nameof(WHCPU)); + } + } + private ObservableCollection _WHCPUs = new ObservableCollection(); + public ObservableCollection WHCPUs + { + get { return _WHCPUs; } + set { _WHCPUs = value; RaisePropertyChanged(nameof(WHCPUs)); } + } + + private string _ECRConsole; + + public string ECRConsole + { + get { return _ECRConsole; } + set { _ECRConsole = value; RaisePropertyChanged(nameof(ECRConsole)); } + } + private string _ECRCPU; + + public string ECRCPU + { + get { return _ECRCPU; } + set { _ECRCPU = value; RaisePropertyChanged(nameof(ECRCPU)); } + } + + private ObservableCollection _ECRCPUs = new ObservableCollection(); + public ObservableCollection ECRCPUs + { + get { return _ECRCPUs; } + set { _ECRCPUs = value; RaisePropertyChanged(nameof(ECRCPUs)); } + } + + private string _ShipOfficeConsole; + + public string ShipOfficeConsole + { + get { return _ShipOfficeConsole; } + set { _ShipOfficeConsole = value; RaisePropertyChanged(nameof(ShipOfficeConsole)); } + } + private string _ShipOfficeCPU; + + public string ShipOfficeCPU + { + get { return _ShipOfficeCPU; } + set { _ShipOfficeCPU = value; RaisePropertyChanged(nameof(ShipOfficeCPU)); } + } + + private ObservableCollection _ShipOfficeCPUs = new ObservableCollection(); + + public ObservableCollection ShipOfficeCPUs + { + get { return _ShipOfficeCPUs; } + set { _ShipOfficeCPUs = value; RaisePropertyChanged(nameof(ShipOfficeCPUs)); } + } + + + private bool _SLD; + + public bool SLD + { + get { return _SLD; } + set { _SLD = value; RaisePropertyChanged(nameof(SLD)); } + } + private bool _SHD; + + public bool SHD + { + get { return _SHD; } + set { _SHD = value; RaisePropertyChanged(nameof(SHD)); } + } + private string _SafetyDelay; + /// + /// 安保延迟 + /// + public string SafetyDelay + { + get { return _SafetyDelay; } + set { _SafetyDelay = value; RaisePropertyChanged(nameof(SafetyDelay)); } + } + private string _AutoCtrl; + /// + /// 自动控制 + /// + public string AutoCtrl + { + get { return _AutoCtrl; } + set { _AutoCtrl = value; RaisePropertyChanged(nameof(AutoCtrl)); } + } + private string _AssociatedCableInfo; + /// + /// 关联电缆信息 + /// + public string AssociatedCableInfo + { + get { return _AssociatedCableInfo; } + set { _AssociatedCableInfo = value; RaisePropertyChanged(nameof(AssociatedCableInfo)); } + } + private string _AssociatedChannelInfo; + /// + /// 关联通道信息 + /// + public string AssociatedChannelInfo + { + get { return _AssociatedChannelInfo; } + set { _AssociatedChannelInfo = value; RaisePropertyChanged(nameof(AssociatedChannelInfo)); } + } + private string _Remarks; + /// + /// 备注 + /// + public string Remarks + { + get { return _Remarks; } + set { _Remarks = value; RaisePropertyChanged(nameof(Remarks)); } + } + private List _Suppliers; + /// + /// 绑定供应商 + /// + public List Suppliers + { + get { return _Suppliers; } + set { _Suppliers = value; RaisePropertyChanged(nameof(Suppliers)); } + } + + #region 扩展字段 + private bool _IsModified; + /// + /// 是否修改 + /// + public bool IsModified + { + get { return _IsModified; } + set { _IsModified = value; RaisePropertyChanged(nameof(IsModified)); } + } + + private bool _IsExpanded = false; + /// + /// 是否展开 + /// + public bool IsExpanded + { + get { return _IsExpanded; } + set { _IsExpanded = value; RaisePropertyChanged(nameof(IsExpanded)); } + } + + private bool _IsExpandable; + /// + /// 是否可展开 + /// + public bool IsExpandable + { + get { return _IsExpandable; } + set { _IsExpandable = value; RaisePropertyChanged(nameof(IsExpandable)); } + } + + + + private List _ActionHistorys; + /// + /// 操作历史 + /// + public List ActionHistorys + { + get { return _ActionHistorys; } + set { _ActionHistorys = value; } + } + + private bool _DeleteFlg; + /// + /// 删除标记 + /// + public bool DeleteFlg + { + get { return _DeleteFlg; } + set { _DeleteFlg = value; } + } + + private ObservableCollection _ChildSignals = new ObservableCollection(); + /// + /// 虚拟点集合 + /// + public ObservableCollection ChildSignals + { + get { return _ChildSignals; } + set + { + _ChildSignals = value; + ChildSignalsView = new QueryableCollectionView(value); + RaisePropertyChanged(nameof(ChildSignals)); + } + } + + private QueryableCollectionView _ChildSignalsView; + /// + /// 虚拟点集合视图 + /// + public QueryableCollectionView ChildSignalsView + { + get { return _ChildSignalsView; } + set { _ChildSignalsView = value; RaisePropertyChanged(nameof(ChildSignalsView)); } + } + + + #endregion + + + + #endregion + + #region 方法 + /// + /// 将表格对象转换为数据模型类 + /// + /// + public ec_Wire_Group to_ec_Wire_Group(List sigals) + { + ec_Wire_Group ent; + if (string.IsNullOrEmpty(Wire_Group_ID)) + { + ent = new ec_Wire_Group(); + } + else + { + ent = sigals.Where(e => e.Wire_Group_ID.Equals(Wire_Group_ID)).First(); + } + switch (Status) + { + case "ToDelete": + ent.Status = WireGroupStatusEnum.ToDelete; + break; + case "New": + ent.Status = WireGroupStatusEnum.New; + break; + case "Used": + ent.Status = WireGroupStatusEnum.Used; + break; + case "Confirmed": + ent.Status = WireGroupStatusEnum.Confirmed; + break; + case "Reopen": + ent.Status = WireGroupStatusEnum.Reopen; + break; + case "deleted": + ent.Status = WireGroupStatusEnum.deleted; + break; + } + + ent.Wire_Group_ID = Wire_Group_ID; + ent.ParentID = ParentID; + ent.Group_Name = Group_Name; + ent.Group_Desc_EN = Group_Desc_EN; + ent.Group_Desc = Group_Desc; + ent.ElecOnly = BelongingMajor.Equals("E") ? true : false; + if (GroupOther == null) + { + ent.Signal_Group = ""; + } + else + { + ent.Signal_Group = GroupOthers.Where(g => g.DataItemName == GroupOther).Select(g => g.DataItemCode).FirstOrDefault(); + + } + ent.Signal_SeqNo = Signal_SeqNo; + ent.Code = Code; + ent.InOrOut = InOrOut; + ent.IO_Type = IO_Type; + ent.Range_Min = Range_Min; + ent.Range_Max = Range_Max; + ent.Unit = Unit; + ent.Alarm_LL = Alarm_LL; + ent.Alarm_L = Alarm_L; + ent.Alarm_H = Alarm_H; + ent.Alarm_HH = Alarm_HH; + ent.SENSOR_CODE = SENSOR_CODE; + ent.CommunicationPoint = CommunicationPoint; + ent.SeriousType = SeriousType; + ent.AL_GRP = AL_GRP; + ent.BL_GRP = BL_GRP; + ent.Time_Delay = Time_Delay; + ent.Supplier = Suppliers.Where(g => g.DataItemName == Supplier).Select(g => g.DataItemCode).FirstOrDefault(); + ent.EquipName = EquipName; + ent.VDR_Record = VDR_Record; + ent.WHConsole = WHConsole; + ent.WHCPU = ""; + foreach (var item in WHCPUs) + { + if (item != null) + { + ent.WHCPU = ent.WHCPU + item.DataItemCode + "|"; + } + + } + ent.ECRConsole = ECRConsole; + ent.ECRCPU = ""; + foreach (var item in ECRCPUs) + { + if (item != null) + { + ent.ECRCPU = ent.ECRCPU + item.DataItemCode + "|"; + } + + } + ent.ShipOfficeConsole = ShipOfficeConsole; + ent.ShipOfficeCPU = ""; + foreach (var item in ShipOfficeCPUs) + { + if (item != null) + { + ent.ShipOfficeCPU = ent.ShipOfficeCPU + item.DataItemCode + "|"; + } + + } + ent.SLD = SLD; + ent.SHD = SHD; + ent.SafetyDelay = SafetyDelay; + ent.AutoCtrl = AutoCtrl; + if (string.IsNullOrEmpty(AssociatedCableInfo)) + { + //// 使用正则表达式匹配模式,并提取每组数据 + //var matches = Regex.Matches(AssociatedCableInfo, @"电缆位号:(.*?)\s电缆对:(.*)"); + // if (matches.Count > 0) // 确保至少有一个匹配项 + // { + // string cableNumber = matches[0].Groups[1].Value; // 第一个冒号后的值 + // string cableSet = matches[0].Groups[2].Value; // 第二个冒号后的值 + // } + ent.CableName = ""; + ent.CableSetName = ""; + } + else + { + ent.CableName = AssociatedCableInfo.Split(' ')[0].Split(':')[1]; + ent.CableSetName = (AssociatedCableInfo.Split(' ').Count() > 1) ? AssociatedCableInfo.Split(' ')[1].Split(':')[1] : ""; + } + if (string.IsNullOrEmpty(AssociatedChannelInfo)) + { + ent.PanelName = ""; + ent.StripName = ""; + ent.ChannelName = ""; + } + else + { + ent.PanelName = AssociatedChannelInfo.Split(' ')[0].Split(':')[1]; + ent.StripName = (AssociatedChannelInfo.Split(' ').Count() > 1) ? AssociatedChannelInfo.Split(' ')[1].Split(':')[1] : ""; + ent.ChannelName = (AssociatedChannelInfo.Split(' ').Count() > 2) ? AssociatedChannelInfo.Split(' ')[2].Split(':')[2] : ""; + } + ent.Remarks = Remarks; + ent.ActionHistorys = ActionHistorys; + ent.DeleteFlg = DeleteFlg; + + return ent; + } + #endregion + + } + +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalNoticeViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalNoticeViewModel.cs new file mode 100644 index 00000000..62d2711b --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalNoticeViewModel.cs @@ -0,0 +1,423 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Windows.Input; +using Telerik.Windows.Controls; +using Unity; +using Prism.Services.Dialogs; +using DI_Electrical.Services; +using DI_Electrical.Models; +using DialogParameters = Prism.Services.Dialogs.DialogParameters; +using Prism.Ioc; +//using DI_Electrical.Views.Dialog.DialogSignalManagements; + +namespace DI_Electrical.ViewModels +{ + public class DialogSignalNoticeViewModel : DialogBase, IDialogAware + { + #region 属性 + private ObservableCollection _MySignalNotices = new ObservableCollection(); + /// + /// 表格数据源 + /// + public ObservableCollection MySignalNotices + { + get { return _MySignalNotices; } + set { _MySignalNotices = value; RaisePropertyChanged(nameof(MySignalNotices)); } + } + private SignalNotice _SelectedSignalNotice; + /// + /// 选中行 + /// + public SignalNotice SelectedSignalNotice + { + get { return _SelectedSignalNotice; } + set { _SelectedSignalNotice = value; RaisePropertyChanged(nameof(SelectedSignalNotice)); } + } + + /// + /// 信号接口服务 + /// + WireGroupService _wireGroupService; + + //public DialogSignalNotice SignalNoticeView { get; set; } + + + + + + #endregion + + + public DialogSignalNoticeViewModel(IContainerProvider container) + { + title = "通知信息"; + _wireGroupService = container.Resolve(); + } + + public event Action RequestClose; + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + + } + + private List SignalNotices; + public async void OnDialogOpened(IDialogParameters parameters) + { + SignalNotices = await _wireGroupService.GetNotification(); + int index = 0; + foreach (var item in SignalNotices) + { + index++; + SignalNotice s= new SignalNotice(item); + s.ID = index; + MySignalNotices.Add(s); + } + + } + public override void ExecuteOKCommandAsync(object para) + { + IDialogParameters res = new DialogParameters(); + //res.Add(GlobalObject.dialogPar.info.ToString(), $"{TextInfo}"); + DialogResult result = new DialogResult(ButtonResult.Yes, res); + RequestClose.Invoke(result); + } + public override void ExecuteCloseCommand(object parameter) + { + //if (parameter as string == "ClickNo") + //{ + // RequestClose.Invoke(ButtonResult.No); + //} + //else + //{ + // RequestClose.Invoke(ButtonResult.Cancel); + //} + //this.Dispose(); + IDialogParameters res = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.No, res); + RequestClose.Invoke(result); + this.Dispose(); + } + + #region 状态按钮 + public ICommand StatusButtonCmd => new DelegateCommand(StatusButton_Click); + /// + /// 显示状态按钮 + /// + /// + public virtual async void StatusButton_Click(object parameter) + { + MySignalNotices = new ObservableCollection(); + + SignalNotices = await _wireGroupService.GetNotification(); + if (!parameter.Equals("All")) + { + SignalNotices = SignalNotices.Where(s => s.CheckFLG.ToString().Equals(parameter)).ToList(); + } + + int index = 0; + foreach (var item in SignalNotices) + { + index++; + SignalNotice s = new SignalNotice(item); + s.ID = index; + MySignalNotices.Add(s); + } + } + #endregion + + #region 右侧按钮 + + public ICommand ButtonCmd => new DelegateCommand(Button_Click); + + string IDialogAware.Title => throw new NotImplementedException(); + + /// + /// 页面右侧按钮 + /// + /// + public virtual async void Button_Click(object parameter) + { + #region 确定 + if (parameter.Equals("确定")) + { + List noticeIds = new List(); + foreach (var item in MySignalNotices) + { + noticeIds = MySignalNotices.Where(e => e.IsModified == true).Select(e => e.WireGroupNoticeID).ToList(); + } + List ReNotices = await _wireGroupService.ReadNotification(noticeIds); + foreach (var item in ReNotices) + { + var ent = MySignalNotices.FirstOrDefault(x => x.WireGroupNoticeID == item.WireGroupNoticeID); + if (ent != null) + { + ent.UpdateTime = item.UpdateTime; + } + } + + + IDialogParameters res = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.Yes, res); + RequestClose.Invoke(result); + this.Dispose(); + + } + #endregion + + #region 取消 + if (parameter.Equals("取消")) + { + IDialogParameters res = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.Cancel, res); + RequestClose.Invoke(result); + this.Dispose(); + } + #endregion + + #region 已阅 + if (parameter.Equals("已阅")) + { + + if (SelectedSignalNotice == null) + { + return; + } + else + { + if (!SelectedSignalNotice.CheckFLG) + { + SelectedSignalNotice.CheckFLG = true; + SelectedSignalNotice.IsModified = true; + } + } + + } + #endregion + + #region 全部已阅 + if (parameter.Equals("全部已阅")) + { + foreach (var item in MySignalNotices) + { + if (!item.CheckFLG) + { + item.CheckFLG = true; + item.IsModified = true; + } + } + } + #endregion + + } + #endregion + } + + public class SignalNotice: DialogBase + { + #region 属性 + private int _ID; + /// + /// 序号 + /// + public int ID + { + get { return _ID; } + set { _ID = value; } + } + + private string _WireGroupNoticeID; + /// + /// 信号通知ID + /// + public string WireGroupNoticeID + { + get { return _WireGroupNoticeID; } + set { _WireGroupNoticeID = value; } + } + + private string _Group_Name; + /// + /// CH.NO + /// + public string Group_Name + { + get { return _Group_Name; } + set { _Group_Name = value; } + } + private string _Group_Desc; + /// + /// z中文描述 + /// + public string Group_Desc + { + get { return _Group_Desc; } + set { _Group_Desc = value; } + } + + + private string _Group_Desc_EN; + /// + /// 英文描述 + /// + public string Group_Desc_EN + { + get { return _Group_Desc_EN; } + set { _Group_Desc_EN = value; } + } + + private string _IO_Type; + /// + /// 信号类型 + /// + public string IO_Type + { + get { return _IO_Type; } + set { _IO_Type = value; } + } + + private Models.Action _ActionID; + /// + /// 操作ID + /// + public Models.Action ActionID + { + get { return _ActionID; } + set { _ActionID = value; } + } + + private string _Action; + /// + /// 操作 + /// + public string Action + { + get { return _Action; } + set { _Action = value; } + } + + + private string _CreateUserName; + /// + /// 发出者 + /// + public string CreateUserName + { + get { return _CreateUserName; } + set { _CreateUserName = value; } + } + + private DateTime? _CreateTime; + /// + /// 操作时间 + /// + public DateTime? CreateTime + { + get { return _CreateTime; } + set { _CreateTime = value; } + } + + private string _UpdateUserName; + /// + /// 已阅人 + /// + public string UpdateUserName + { + get { return _UpdateUserName; } + set { _UpdateUserName = value; } + } + + private DateTime? _UpdateTime; + /// + /// 已阅时间 + /// + public DateTime? UpdateTime + { + get { return _UpdateTime; } + set { _UpdateTime = value; } + } + + private string _Message; + /// + /// 操作信息 + /// + public string Message + { + get { return _Message; } + set { _Message = value; } + } + + private bool _CheckFLG; + /// + /// 是否已读 + /// + public bool CheckFLG + { + get { return _CheckFLG; } + set { _CheckFLG = value; } + } + + private bool _IsModified; + /// + /// 是否修改 + /// + public bool IsModified + { + get { return _IsModified; } + set { _IsModified = value; RaisePropertyChanged(nameof(IsModified)); } + } + + private bool _IsReadOnly; + /// + /// 是否可编辑 + /// + public bool IsReadOnly + { + get { return _IsReadOnly; } + set { _IsReadOnly = value; RaisePropertyChanged(nameof(IsReadOnly)); } + } + #endregion + + #region 方法 + public SignalNotice() + { + + } + public SignalNotice(ec_wire_group_notice ec_Notice) + { + #region 前端表格对应列 + this.Group_Name = ec_Notice.Group_Name; + this.Group_Desc = ec_Notice.Group_Desc; + this.Group_Desc_EN = ec_Notice.Group_Desc_EN; + this.IO_Type = ec_Notice.IO_Type; + this.Action = ec_Notice.Action; + this.CreateUserName = ec_Notice.CreateUserName; + this.CreateTime = ec_Notice.CreateTime; + this.UpdateUserName = ec_Notice.UpdateUserName; + this.UpdateTime = ec_Notice.UpdateTime; + this.Message = ec_Notice.Message; + #endregion + + this.WireGroupNoticeID = ec_Notice.WireGroupNoticeID; + this.CheckFLG = ec_Notice.CheckFLG; + this.IsReadOnly = ec_Notice.CheckFLG; + } + /// + /// 设置数据 + /// + public void setData() + { + + } + #endregion + } + + +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalPropertyhisAndLogsViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalPropertyhisAndLogsViewModel.cs new file mode 100644 index 00000000..f38d327b --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalPropertyhisAndLogsViewModel.cs @@ -0,0 +1,380 @@ +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Windows.Input; +using Telerik.Windows.Controls; +using Unity; +using System; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json; +using Prism.Services.Dialogs; +using DI_Electrical.Services; +using DI_Electrical.Models; +using DialogParameters = Prism.Services.Dialogs.DialogParameters; +using Prism.Ioc; +namespace DI_Electrical.ViewModels +{ + public class DialogSignalPropertyhisAndLogsViewModel : DialogBase, IDialogAware + { + #region 属性 + private SignalManagementInfo _SignalInfo; + /// + /// 传入选中的信号对象 + /// + public SignalManagementInfo SignalInfo + { + get { return _SignalInfo; } + set { _SignalInfo = value; RaisePropertyChanged(nameof(SignalInfo)); } + } + + + private ObservableCollection _MySignalLogs = new ObservableCollection(); + /// + /// 表格数据源 + /// + public ObservableCollection MySignalLogs + { + get { return _MySignalLogs; } + set { _MySignalLogs = value; RaisePropertyChanged(nameof(MySignalLogs)); } + } + private SignalLog _SelectedSignalLog; + /// + /// 选中行 + /// + public SignalLog SelectedSignalLog + { + get { return _SelectedSignalLog; } + set { _SelectedSignalLog = value; RaisePropertyChanged(nameof(SelectedSignalLog)); } + } + + private ObservableCollection _MySingnalPropertyhis = new ObservableCollection(); + /// + /// 表格数据源 + /// + public ObservableCollection MySingnalPropertyhis + { + get { return _MySingnalPropertyhis; } + set { _MySingnalPropertyhis = value; RaisePropertyChanged(nameof(MySingnalPropertyhis)); } + } + private SingnalPropertyhis _SelectedPropertyhi; + /// + /// 选中行 + /// + public SingnalPropertyhis SelectedPropertyhi + { + get { return _SelectedPropertyhi; } + set { _SelectedPropertyhi = value; RaisePropertyChanged(nameof(SelectedPropertyhi)); } + } + + /// + /// 信号接口服务 + /// + WireGroupService _wireGroupService; + + + + #endregion + + + public DialogSignalPropertyhisAndLogsViewModel(IContainerProvider container) + { + + _wireGroupService = container.Resolve(); + } + + + + public event Action RequestClose; + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + + } + + private List SignalLogs; + private List SignalPropertyhis; + public async void OnDialogOpened(IDialogParameters parameters) + { + SignalInfo = parameters.GetValue(GlobalObject.dialogPar.para1.ToString()); + title = SignalInfo.Group_Name + " 信号属性修改历史和操作记录"; + + SignalLogs = await _wireGroupService.GetSignalLogs(SignalInfo.Wire_Group_ID); + if(SignalLogs != null) + { + int index = 0; + foreach (var item in SignalLogs) + { + index++; + SignalLog s = new SignalLog(item); + s.ID = index; + MySignalLogs.Add(s); + } + } + SignalPropertyhis = await _wireGroupService.GetSignalPropertyhis(SignalInfo.Wire_Group_ID); + if (SignalPropertyhis != null) + { + int index = 0; + foreach (var item in SignalPropertyhis) + { + index++; + SingnalPropertyhis s = new SingnalPropertyhis(item); + s.ID = index; + MySingnalPropertyhis.Add(s); + } + } + + + } + public override void ExecuteOKCommandAsync(object para) + { + IDialogParameters res = new DialogParameters(); + //res.Add(GlobalObject.dialogPar.info.ToString(), $"{TextInfo}"); + DialogResult result = new DialogResult(ButtonResult.Yes, res); + RequestClose.Invoke(result); + } + public override void ExecuteCloseCommand(object parameter) + { + IDialogParameters res = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.No, res); + RequestClose.Invoke(result); + this.Dispose(); + } + + + + #region 右侧按钮 + + public ICommand ButtonCmd => new DelegateCommand(Button_Click); + + string IDialogAware.Title => throw new NotImplementedException(); + + /// + /// 页面右侧按钮 + /// + /// + public virtual async void Button_Click(object parameter) + { + #region 确定 + if (parameter.Equals("确定")) + { + + IDialogParameters res = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.Yes, res); + RequestClose.Invoke(result); + this.Dispose(); + + } + #endregion + + #region 取消 + if (parameter.Equals("取消")) + { + IDialogParameters res = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.Cancel, res); + RequestClose.Invoke(result); + this.Dispose(); + } + #endregion + + + } + #endregion + } + + public class SignalLog: DialogBase + { + #region 属性 + private int _ID; + /// + /// 序号 + /// + public int ID + { + get { return _ID; } + set { _ID = value; } + } + + private string _WireGroupLogID; + + public string WireGroupLogID + { + get { return _WireGroupLogID; } + set { _WireGroupLogID = value; } + } + private string _WireGroupID; + + public string WireGroupID + { + get { return _WireGroupID; } + set { _WireGroupID = value; } + } + [JsonConverter(typeof(StringEnumConverter))] + private Models.Action _OperateType; + /// + /// 操作 + /// + public Models.Action OperateType + { + get { return _OperateType; } + set { _OperateType = value; } + } + private string _ExtraMsg; + /// + /// 附加信息 + /// + public string ExtraMsg + { + get { return _ExtraMsg; } + set { _ExtraMsg = value; } + } + private string _CreateUserID; + + public string CreateUserID + { + get { return _CreateUserID; } + set { _CreateUserID = value; } + } + private string _CreateUserName; + /// + /// 操作人 + /// + public string CreateUserName + { + get { return _CreateUserName; } + set { _CreateUserName = value; } + } + + private DateTime? _CreateTime; + /// + /// 操作时间 + /// + /// + public DateTime? CreateTime + { + get { return _CreateTime; } + set { _CreateTime = value; } + } + + + + + + #endregion + + #region 方法 + public SignalLog() + { + + } + public SignalLog(ec_wire_group_log ec_Notice) + { + #region 前端表格对应列 + this.OperateType = ec_Notice.OperateType; + this.ExtraMsg = ec_Notice.ExtraMsg; + this.CreateUserName = ec_Notice.CreateUserName; + this.CreateTime = ec_Notice.CreateTime; + #endregion + + } + /// + /// 设置数据 + /// + public void setData() + { + + } + #endregion + } + + public class SingnalPropertyhis : DialogBase + { + #region 属性 + private int _ID; + /// + /// 序号 + /// + public int ID + { + get { return _ID; } + set { _ID = value; } + } + + private string _PropertyName; + /// + /// 属性 + /// + public string PropertyName + { + get { return _PropertyName; } + set { _PropertyName = value; } + } + private string _PropertyNameDec; + /// + /// 属性名称描述 + /// + public string PropertyNameDec + { + get { return _PropertyNameDec; } + set { _PropertyNameDec = value; } + } + + private string _OldPropertyValue; + /// + /// 旧属性值 + /// + public string OldPropertyValue + { + get { return _OldPropertyValue; } + set { _OldPropertyValue = value; } + } + private string _NewPropertyValue; + /// + /// 新属性值 + /// + public string NewPropertyValue + { + get { return _NewPropertyValue; } + set { _NewPropertyValue = value; } + } + private string _CreateUserName; + /// + /// 修改人 + /// + public string CreateUserName + { + get { return _CreateUserName; } + set { _CreateUserName = value; } + } + private DateTime? _CreateTime; + /// + /// 修改时间 + /// + public DateTime? CreateTime + { + get { return _CreateTime; } + set { _CreateTime = value; } + } + + #endregion + + #region 方法 + public SingnalPropertyhis(ec_wire_group_propertyhis ec_Wire_Group_Propertyhis) + { + #region 前端渲染 + this.PropertyName = ec_Wire_Group_Propertyhis.PropertyName; + this.PropertyNameDec = ec_Wire_Group_Propertyhis.PropertyNameDec; + this.OldPropertyValue = ec_Wire_Group_Propertyhis.OldPropertyValue; + this.NewPropertyValue = ec_Wire_Group_Propertyhis.NewPropertyValue; + this.CreateUserName = ec_Wire_Group_Propertyhis.CreateUserName; + this._CreateTime = ec_Wire_Group_Propertyhis.CreateTime; + #endregion + + } + #endregion + } + +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalSelectViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalSelectViewModel.cs new file mode 100644 index 00000000..f003da56 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/DialogSignalManagementVM/DialogSignalSelectViewModel.cs @@ -0,0 +1,112 @@ +using System; +using System.Collections.ObjectModel; +using System.Windows; +using Prism.Ioc; +using Prism.Services.Dialogs; +using Telerik.Windows.Controls; +using DialogParameters = Prism.Services.Dialogs.DialogParameters; + +namespace DI_Electrical.ViewModels +{ + public class DialogSignalSelectViewModel : DialogBase, IDialogAware + { + + public DialogSignalSelectViewModel(IContainerProvider container) + { + title = "信号选择框"; + } + + + public event Action RequestClose; + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + + } + private ObservableCollection _listSignal; + /// + /// 单位列表 + /// + public ObservableCollection listSignal + { + get { return _listSignal; } + set { _listSignal = value; RaisePropertyChanged(nameof(listSignal)); } + } + private Signal _SelectedSignal; + /// + /// 选中的单位 + /// + public Signal SelectedSignal + { + get { return _SelectedSignal; } + set { _SelectedSignal = value; RaisePropertyChanged(nameof(SelectedSignal)); } + } + + public string Title => "信号选择框"; + + public void OnDialogOpened(IDialogParameters parameters) + { + var signals = parameters.GetValue>(GlobalObject.dialogPar.para1.ToString()); + + listSignal = new ObservableCollection(); + foreach (var item in signals) + { + if (item.type.Equals("信号")) + { + listSignal.Add(new Signal() { SignalId = item.Wire_Group_ID, SignalName = item.Group_Name }); + } + } + } + public override void ExecuteOKCommandAsync(object para) + { + if (SelectedSignal == null) + { + MessageBox.Show("请选择一个信号!"); + return; + } + IDialogParameters res = new DialogParameters(); + res.Add(GlobalObject.dialogPar.para1.ToString(), SelectedSignal); + DialogResult result = new DialogResult(ButtonResult.Yes, res); + RequestClose.Invoke(result); + } + public override void ExecuteCloseCommand(object parameter) + { + IDialogParameters res = new DialogParameters(); + DialogResult result = new DialogResult(ButtonResult.No, res); + RequestClose.Invoke(result); + this.Dispose(); + } + + } + + + public class Signal : ViewModelBase + { + private string _SignalId; + /// + /// Id + /// + public string SignalId + { + get { return _SignalId; } + set { _SignalId = value; RaisePropertyChanged(nameof(SignalId)); } + } + + private string _SignalName; + /// + /// 信号 + /// + public string SignalName + { + get { return _SignalName; } + set { _SignalName = value; RaisePropertyChanged(nameof(SignalName)); } + } + + } + +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/DialogTestViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/DialogTestViewModel.cs new file mode 100644 index 00000000..0441a8b2 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/DialogTestViewModel.cs @@ -0,0 +1,74 @@ +using System; +using System.Windows.Input; +using Prism.Mvvm; +using Prism.Services.Dialogs; +using Telerik.Windows.Controls; +using DialogParameters = Prism.Services.Dialogs.DialogParameters; + +namespace DI_Electrical.ViewModels +{ + public class DialogTestViewModel : DialogBase, IDialogAware + { + #region binding + private string _parText; + /// + /// 参数值 + /// + public string parText + { + get { return _parText; } + set { _parText = value; OnPropertyChanged(nameof(parText)); } + } + + #endregion + + /// + /// 命令事件 + /// + public ICommand Command_Close1 { get; set; } + /// + /// 命令事件 + /// + public ICommand Command_Close2 { get; set; } + + public DialogTestViewModel() + { + Command_Close1 = new DelegateCommand(onClose1); + Command_Close2 = new DelegateCommand(onClose2); + } + + public string Title => "弹框测试页面"; + + public event Action RequestClose; + + public bool CanCloseDialog() + { + return true; + } + + public void OnDialogClosed() + { + + } + + public void OnDialogOpened(IDialogParameters parameters) + { + parText = parameters.GetValue(GlobalObject.dialogPar.para1.ToString()); + } + + public void onClose1(object o) + { + IDialogParameters par = new DialogParameters(); + par.Add(GlobalObject.dialogPar.para1.ToString(), "xxx"); + DialogResult result = new DialogResult(ButtonResult.Yes, par); + RequestClose.Invoke(result); + } + public void onClose2(object o) + { + IDialogParameters par = new DialogParameters(); + par.Add(GlobalObject.dialogPar.para1.ToString(), "zzz"); + DialogResult result = new DialogResult(ButtonResult.No, par); + RequestClose.Invoke(result); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/LoginViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/LoginViewModel.cs new file mode 100644 index 00000000..7ccb36da --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/LoginViewModel.cs @@ -0,0 +1,152 @@ + using System.Threading; +using System.Windows; +using System.Windows.Input; +using DI_Electrical.Helper; +using DI_Electrical.Model; +using DI_Electrical.Services; +using DI_Electrical.Views; +using Prism.Events; +using Prism.Ioc; +using Prism.Mvvm; +using Prism.Services.Dialogs; +using Telerik.Windows.Controls; +using Unity; +using DialogParameters = Prism.Services.Dialogs.DialogParameters; + +namespace DI_Electrical.ViewModels +{ + public class LoginViewModel : DialogBase + { + #region BINDING + + private bool _rememberPs; + + public bool rememberPs + { + get { return _rememberPs; } + set { _rememberPs = value; RaisePropertyChanged(nameof(rememberPs)); } + } + + + private string _UserName; + + public string UserName + { + get { return _UserName; } + set { _UserName = value; RaisePropertyChanged(nameof(UserName)); } + } + private string _UserPs; + + + private string _curServer; + + public string curServer + { + get { return _curServer; } + set { _curServer = value; RaisePropertyChanged(nameof(curServer)); } + } + private string _sPASSWORD; + + public string sPASSWORD + { + get { return _sPASSWORD; } + set + { + _sPASSWORD = value; + RaisePropertyChanged(nameof(sPASSWORD)); + } + } + + + + #endregion + /// + /// 设置 + /// + public ICommand Command_Config { get; set; } + LoginService _Service; + ConfigService _configService; + UserService _UserService; + IContainerProvider containerProvider; + public LoginViewModel(IContainerProvider container) + { + title = "系统登录"; + _UserService = container.Resolve(); + _Service = container.Resolve(); + _configService = container.Resolve(); + Command_Config = new DelegateCommand(onConfig); + containerProvider = container; + if (GlobalObject.isConfigIniCreateBySys) + { + var config= container.Resolve(); + config.ShowDialog(); + } + + UserName = _configService.Read(nameof(ConfigIni.UserName)); + sPASSWORD = _configService.Read(nameof(ConfigIni.UserPs)); + if (string.IsNullOrEmpty(sPASSWORD)) + { + rememberPs = false; + } + else + { + rememberPs = true; + } + if (GlobalObject.userInfo != null && rememberPs) + { + sPASSWORD = GlobalObject.userInfo.userPs; + } + curServer = "当前服务器: " + _configService.Read(nameof(ConfigIni.Address)) + ":" + _configService.Read(nameof(ConfigIni.Port)); + + } + public void onConfig(object o) + { + var config = containerProvider.Resolve(); + config.ShowDialog(); + curServer = "当前服务器: " + _configService.Read(nameof(ConfigIni.Address)) + ":" + _configService.Read(nameof(ConfigIni.Port)); + + } + public override async void ExecuteOKCommandAsync(object obj) + { + if (obj != null) + { + + } + var passBox = obj as RadPasswordBox; + var Userpass = passBox.Password; + if (string.IsNullOrEmpty(UserName) || string.IsNullOrEmpty(Userpass)) + { + MessageBox.Show("用户名和密码不能为空!"); + } + else + { + IsBusy = true; BusyContent = "登录中..."; + var res = await _Service.Login(UserName, Userpass); + IsBusy = false; + if (string.IsNullOrEmpty(res)) + { + _configService.Save(nameof(ConfigIni.UserName), UserName); + if (rememberPs) + { + _configService.Save(nameof(ConfigIni.UserPs), Userpass); + } + else + { + _configService.Save(nameof(ConfigIni.UserPs), ""); + } + + #region 拿一些全局的东西 + await _UserService.GetList(); + #endregion + CloseWindowAction?.Invoke(); + } + else + { + MessageBox.Show(res); + } + + } + } + + } +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/MainWindowViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/MainWindowViewModel.cs new file mode 100644 index 00000000..ee3c208b --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/MainWindowViewModel.cs @@ -0,0 +1,90 @@ +using System.Windows; +using System.Windows.Input; +using DI_Electrical.Event; +using DI_Electrical.Views.Dialog; +using DI_Electrical.Views.Dialog.DialogSignalManagements; +using DryIoc; +using Newtonsoft.Json.Linq; +using Prism.Events; +using Prism.Ioc; +using Prism.Mvvm; +using Prism.Services.Dialogs; +using Telerik.Windows.Controls; +using DialogParameters = Prism.Services.Dialogs.DialogParameters; + +namespace DI_Electrical.ViewModels +{ + public class MainWindowViewModel : ViewModelBase + { + #region binding + private string _ProjectName; + /// + ///当前项目 + /// + public string ProjectName + { + get { return _ProjectName; } + set { _ProjectName = value; OnPropertyChanged(nameof(ProjectName)); } + } + + #endregion + /// + /// 命令事件 + /// + public ICommand Command_ShowDialogTest { get; set; } + public ICommand Command_ShowDialogSignalManagement { get; set; } + private readonly IDialogService _dialogService; + private IEventAggregator _eventAggregator; + public MainWindowViewModel(IDialogService dialogService , IEventAggregator eventAggregator) + { + Command_ShowDialogTest = new DelegateCommand(onShowDialogTest); + Command_ShowDialogSignalManagement = new DelegateCommand(onShowDialogSignalManagement); + _dialogService = dialogService; + _eventAggregator= eventAggregator; + _eventAggregator.GetEvent().Subscribe(onEnterProjOK, ThreadOption.UIThread, true); + + } + /// + /// 选中项目 + /// + /// + private void onEnterProjOK(JToken obj) + { + ProjectName = GlobalObject.curProject?.ProjectName; + } + public void onShowDialogTest(object o) + { + IDialogParameters par = new DialogParameters(); + par.Add(GlobalObject.dialogPar.para1.ToString(), "abc你我他"); + _dialogService.ShowDialog(nameof(DialogTest), par, (result) => + { + var res = result.Parameters.GetValue(GlobalObject.dialogPar.para1.ToString()); + if (result.Result == ButtonResult.OK || result.Result == ButtonResult.Yes) + { + MessageBox.Show("窗体Yes关闭,返回:"+res); + } + else + { + + MessageBox.Show("窗体NO关闭,返回:" + res); + } + }); + } + public void onShowDialogSignalManagement(object o) + { + IDialogParameters par = new DialogParameters(); + _dialogService.ShowDialog(nameof(DialogSignalManagement), par, (result) => + { + var res = result.Parameters.GetValue(GlobalObject.dialogPar.para1.ToString()); + if (result.Result == ButtonResult.OK || result.Result == ButtonResult.Yes) + { + + } + else + { + + } + }); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/ProjectViewModel.cs b/newFront/c#前端/DI-Electrical/ViewModels/ProjectViewModel.cs new file mode 100644 index 00000000..b997588e --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/ProjectViewModel.cs @@ -0,0 +1,66 @@ +using System.Collections.Generic; +using System.Windows; +using DI_Electrical.Event; +using DI_Electrical.Helper; +using DI_Electrical.Model; +using DI_Electrical.Services; +using Prism.Events; +using Prism.Ioc; + +namespace DI_Electrical.ViewModels +{ + public class ProjectViewModel : DialogBase + { + private List projects; + public List Projects + { + get { return this.projects; } + set + { + this.projects = value; + RaisePropertyChanged(nameof(Projects)); + + } + } + private ec_project _select; + + public ec_project select + { + get { return _select; } + set { _select = value; RaisePropertyChanged(nameof(select)); } + } + ProjectService _Service; + ConfigService _configService; + IEventAggregator _eventAggregator; + public ProjectViewModel(IContainerProvider container) : base() + { + title = "项目选择"; + _Service = container.Resolve(); + _configService = container.Resolve(); + _eventAggregator= container.Resolve(); + } + public async override void onWindow_loaded(object para) + { + Projects = (await _Service.GetProjects(1, 200)).Rows; + base.onWindow_loaded(para); + } + public override async void ExecuteOKCommandAsync(object para) + { + if (select == null) + { + MessageBox.Show("请选择一个项目。"); + return; + } + _configService.Save(nameof(ConfigIni.ProjectID), select.ProjectId); + GlobalObject.curProject = select; + + IsBusy = true; + BusyContent = "项目加载中..."; + var userName = _configService.Read(nameof(ConfigIni.UserName)); + var o = await _Service.InitProjInfo(GlobalObject.curProject.ProjectId, userName); + IsBusy = false; + _eventAggregator.GetEvent().Publish(o); + CloseWindowAction?.Invoke(); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/ViewModels/myViewModelBase/DialogBase.cs b/newFront/c#前端/DI-Electrical/ViewModels/myViewModelBase/DialogBase.cs new file mode 100644 index 00000000..ed2fa546 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/ViewModels/myViewModelBase/DialogBase.cs @@ -0,0 +1,79 @@ +using System; +using System.Windows.Input; +using Prism.Ioc; +using Prism.Services.Dialogs; +using Telerik.Windows.Controls; +using Unity; +namespace DI_Electrical.ViewModels +{ + /// + /// abstract 不同于接口,可以实现具体的代码 + /// + public abstract class DialogBase : ViewModelBase + { + public DialogBase() + { + window_loaded = new DelegateCommand(onWindow_loaded); + CloseCommand = new DelegateCommand(ExecuteCloseCommand); + OKCommand = new DelegateCommand(ExecuteOKCommandAsync); + + } + #region binding + private bool _isbusy; + + public bool IsBusy + { + get { return _isbusy; } + set { _isbusy = value; RaisePropertyChanged(nameof(IsBusy)); } + } + private string _BusyContent; + + public string BusyContent + { + get { return _BusyContent; } + set { _BusyContent = value; RaisePropertyChanged(nameof(BusyContent)); } + } + + /// + /// 加载后 + /// + public ICommand window_loaded { get; } + public ICommand CloseCommand { get; } + + public ICommand OKCommand { get; } + private string _title; + + public string title + { + get { return _title; } + set { _title = value; RaisePropertyChanged(nameof(title)); } + } + #endregion + IUnityContainer _unityContainer; + /// + /// CODE-BEHAND里设置为this.close以关闭。调用时,.invoke即可 + /// + public Action CloseWindowAction { get; set; } + + /// + /// virtual 可以重写 + /// + /// + public virtual void ExecuteCloseCommand(object parameter) + { + // 关闭窗口 (需要通过 CommandParameter 传入窗口实例) + if (parameter is System.Windows.Window window) + { + window.Close(); + } + } + public virtual void onWindow_loaded(object para) + { + + } + public virtual void ExecuteOKCommandAsync(object para) + { + + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/Config.xaml b/newFront/c#前端/DI-Electrical/Views/Config.xaml new file mode 100644 index 00000000..1b7fc4b2 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/Config.xaml @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/newFront/c#前端/DI-Electrical/Views/Config.xaml.cs b/newFront/c#前端/DI-Electrical/Views/Config.xaml.cs new file mode 100644 index 00000000..d0aa9e23 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/Config.xaml.cs @@ -0,0 +1,44 @@ +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; +using DI_Electrical.ViewModels; + +namespace DI_Electrical.Views +{ + /// + /// Config.xaml 的交互逻辑 + /// + public partial class Config : Window + { + public Config(ConfigViewModel viewModel) + { + InitializeComponent(); + viewModel.CloseWindowAction = this.Close; // 将关闭方法传递给 ViewModel + DataContext = viewModel; + } + private void RadFilePathPicker_FilePathChanged(object sender, Telerik.Windows.Controls.FileDialogs.FilePathChangedEventArgs e) + { + if (string.IsNullOrEmpty(e.FilePath)) + { + this.filepath.FilePath = ""; + var x = DataContext as ConfigViewModel; + x.Directory = ""; + } + else + { + var x = DataContext as ConfigViewModel; + x.Directory = e.FilePath; + } + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/IconButton/IconButton.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/IconButton/IconButton.cs new file mode 100644 index 00000000..e99c0de9 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/IconButton/IconButton.cs @@ -0,0 +1,79 @@ +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Shapes; + +namespace DI_Electrical.Views.CustomControl +{ + [TemplatePart(Name = "PART_Icon", Type = typeof(Path))] + [TemplatePart(Name = "PART_Content", Type = typeof(ContentPresenter))] + public class IconButton : Button + { + static IconButton() + { + DefaultStyleKeyProperty.OverrideMetadata( + typeof(IconButton), + new FrameworkPropertyMetadata(typeof(IconButton))); + } + + #region 依赖属性 + // 矢量路径数据 + public static readonly DependencyProperty IconDataProperty = + DependencyProperty.Register( + "IconData", + typeof(Geometry), + typeof(IconButton), + new FrameworkPropertyMetadata(null)); + + // 图标尺寸 + public static readonly DependencyProperty IconSizeProperty = + DependencyProperty.Register( + "IconSize", + typeof(double), + typeof(IconButton), + new FrameworkPropertyMetadata(16.0)); + + // 图标位置 + public static readonly DependencyProperty IconPlacementProperty = + DependencyProperty.Register( + "IconPlacement", + typeof(Dock), + typeof(IconButton), + new FrameworkPropertyMetadata(Dock.Left)); + + // 图标与文字间距 + public static readonly DependencyProperty IconMarginProperty = + DependencyProperty.Register( + "IconMargin", + typeof(Thickness), + typeof(IconButton), + new FrameworkPropertyMetadata(new Thickness(0, 0, 5, 0))); + #endregion + + #region 属性包装器 + public Geometry IconData + { + get => (Geometry)GetValue(IconDataProperty); + set => SetValue(IconDataProperty, value); + } + + public double IconSize + { + get => (double)GetValue(IconSizeProperty); + set => SetValue(IconSizeProperty, value); + } + + public Dock IconPlacement + { + get => (Dock)GetValue(IconPlacementProperty); + set => SetValue(IconPlacementProperty, value); + } + + public Thickness IconMargin + { + get => (Thickness)GetValue(IconMarginProperty); + set => SetValue(IconMarginProperty, value); + } + #endregion + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/CollectionToStringConverter.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/CollectionToStringConverter.cs new file mode 100644 index 00000000..a3fda24d --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/CollectionToStringConverter.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Windows.Data; +using DI_Electrical.Models; + +namespace DI_Electrical.Views.CustomControl +{ + public class CollectionToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + ObservableCollection WHCPUs = value as ObservableCollection; + if (WHCPUs != null) + { + string sWHCPU = ""; + for (int i = 0; i < WHCPUs.Count; i++) + { + if (i!= WHCPUs.Count-1) + { + if (WHCPUs[i] != null) + { + sWHCPU = sWHCPU + WHCPUs[i].DataItemCode + "|"; + } + } + else + { + if (WHCPUs[i] != null) + { + sWHCPU = sWHCPU + WHCPUs[i].DataItemCode; + } + + } + } + return sWHCPU; + } + return null; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/DoubleUtil.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/DoubleUtil.cs new file mode 100644 index 00000000..643c211b --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/DoubleUtil.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; + +namespace DI_Electrical.Views.CustomControl +{ + + public static class DoubleUtil + { + internal const double DBL_EPSILON = 2.2204460492503131e-016; /* smallest such that 1.0+DBL_EPSILON != 1.0 */ + internal const float FLT_MIN = 1.175494351e-38F; /* Number close to zero, where float.MinValue is -float.MaxValue */ + + + public static bool IsZero(double value) => Math.Abs(value) < 10.0 * DBL_EPSILON; + + public static bool AreClose(double value1, double value2) + { + if (value1 == value2) return true; + double eps = (Math.Abs(value1) + Math.Abs(value2) + 10.0) * DBL_EPSILON; + double delta = value1 - value2; + return (-eps < delta) && (eps > delta); + } + + public static bool LessThan(double value1, double value2) => (value1 < value2) && !AreClose(value1, value2); + + public static bool GreaterThan(double value1, double value2) => (value1 > value2) && !AreClose(value1, value2); + + public static bool LessThanOrClose(double value1, double value2) => (value1 < value2) || AreClose(value1, value2); + + public static bool GreaterThanOrClose(double value1, double value2) => (value1 > value2) || AreClose(value1, value2); + + [StructLayout(LayoutKind.Explicit)] + private struct NanUnion + { + [FieldOffset(0)] + internal double DoubleValue; + [FieldOffset(0)] + internal UInt64 UintValue; + } + + public static bool IsNaN(double value) + { + NanUnion t = new NanUnion(); + t.DoubleValue = value; + + UInt64 exp = t.UintValue & 0xfff0000000000000; + UInt64 man = t.UintValue & 0x000fffffffffffff; + + return (exp == 0x7ff0000000000000 || exp == 0xfff0000000000000) && (man != 0); + } + + public static bool IsOne(double value) + { + return Math.Abs(value - 1.0) < 10.0 * DBL_EPSILON; + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/ElementHelper.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/ElementHelper.cs new file mode 100644 index 00000000..8a9d432e --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/ElementHelper.cs @@ -0,0 +1,113 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; +using System.Windows; + +namespace DI_Electrical.Views.CustomControl +{ + public class ElementHelper : DependencyObject + { + public static readonly DependencyProperty CornerRadiusProperty = + DependencyProperty.RegisterAttached("CornerRadius", typeof(CornerRadius), typeof(ElementHelper), + new PropertyMetadata(new CornerRadius(0))); + + public static readonly DependencyProperty WatermarkProperty = + DependencyProperty.RegisterAttached("Watermark", typeof(string), typeof(ElementHelper), + new PropertyMetadata(string.Empty)); + + public static readonly DependencyProperty IsStripeProperty = + DependencyProperty.RegisterAttached("IsStripe", typeof(bool), typeof(ElementHelper), + new PropertyMetadata(false)); + + public static readonly DependencyProperty IsRoundProperty = + DependencyProperty.RegisterAttached("IsRound", typeof(bool), typeof(ElementHelper), + new PropertyMetadata(false)); + + public static readonly DependencyProperty IsClearProperty = + DependencyProperty.RegisterAttached("IsClear", typeof(bool), typeof(ElementHelper), + new PropertyMetadata(false, OnIsClearChanged)); + + public static CornerRadius GetCornerRadius(DependencyObject obj) + { + return (CornerRadius)obj.GetValue(CornerRadiusProperty); + } + + public static void SetCornerRadius(DependencyObject obj, CornerRadius value) + { + obj.SetValue(CornerRadiusProperty, value); + } + + public static string GetWatermark(DependencyObject obj) + { + return (string)obj.GetValue(WatermarkProperty); + } + + public static void SetWatermark(DependencyObject obj, string value) + { + obj.SetValue(WatermarkProperty, value); + } + + public static bool GetIsStripe(DependencyObject obj) + { + return (bool)obj.GetValue(IsStripeProperty); + } + + public static void SetIsStripe(DependencyObject obj, bool value) + { + obj.SetValue(IsStripeProperty, value); + } + + public static bool GetIsRound(DependencyObject obj) + { + return (bool)obj.GetValue(IsRoundProperty); + } + + public static void SetIsRound(DependencyObject obj, bool value) + { + obj.SetValue(IsRoundProperty, value); + } + + public static void SetIsClear(UIElement element, bool value) + { + element.SetValue(IsClearProperty, value); + } + + public static bool GetIsClear(UIElement element) + { + return (bool)element.GetValue(IsClearProperty); + } + + private static void OnIsClearChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var button = d as Button; + if (button != null) + { + if ((bool)e.NewValue) + button.Click += ButtonClear_Click; + else + button.Click -= ButtonClear_Click; + } + } + + private static void ButtonClear_Click(object sender, RoutedEventArgs e) + { + if (sender is Button button) + { + if (button.TemplatedParent is TextBox textBox) + textBox.Clear(); + else if (button.TemplatedParent is PasswordBox passwordBox) + passwordBox.Clear(); + else if (button.TemplatedParent is TabItem tabItem) + { + var tabControl = tabItem.Parent as TabControl; + if (tabControl != null) + tabControl.Items.Remove(tabItem); + } + } + } + + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/GeometryHelper.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/GeometryHelper.cs new file mode 100644 index 00000000..3030fae7 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/GeometryHelper.cs @@ -0,0 +1,155 @@ +using System; +using System.Windows.Media; +using System.Windows; + +namespace DI_Electrical.Views.CustomControl +{ + internal class GeometryHelper + { + public static void GenerateGeometry(StreamGeometryContext ctx, Rect rect, Radii radii) + { + var point = new Point(radii.LeftTop, 0.0); + var point2 = new Point(rect.Width - radii.RightTop, 0.0); + var point3 = new Point(rect.Width, radii.TopRight); + var point4 = new Point(rect.Width, rect.Height - radii.BottomRight); + var point5 = new Point(rect.Width - radii.RightBottom, rect.Height); + var point6 = new Point(radii.LeftBottom, rect.Height); + var point7 = new Point(0.0, rect.Height - radii.BottomLeft); + var point8 = new Point(0.0, radii.TopLeft); + if (point.X > point2.X) + { + var x = radii.LeftTop / (radii.LeftTop + radii.RightTop) * rect.Width; + point.X = x; + point2.X = x; + } + if (point3.Y > point4.Y) + { + var y = radii.TopRight / (radii.TopRight + radii.BottomRight) * rect.Height; + point3.Y = y; + point4.Y = y; + } + if (point5.X < point6.X) + { + var x2 = radii.LeftBottom / (radii.LeftBottom + radii.RightBottom) * rect.Width; + point5.X = x2; + point6.X = x2; + } + if (point7.Y < point8.Y) + { + var y2 = radii.TopLeft / (radii.TopLeft + radii.BottomLeft) * rect.Height; + point7.Y = y2; + point8.Y = y2; + } + var vector = new Vector(rect.TopLeft.X, rect.TopLeft.Y); + point += vector; + point2 += vector; + point3 += vector; + point4 += vector; + point5 += vector; + point6 += vector; + point7 += vector; + point8 += vector; + ctx.BeginFigure(point, true, true); + ctx.LineTo(point2, true, false); + var width = rect.TopRight.X - point2.X; + var height = point3.Y - rect.TopRight.Y; + if (!DoubleUtil.IsZero(width) || !DoubleUtil.IsZero(height)) + { + ctx.ArcTo(point3, new Size(width, height), 0.0, false, SweepDirection.Clockwise, true, false); + } + ctx.LineTo(point4, true, false); + width = rect.BottomRight.X - point5.X; + height = rect.BottomRight.Y - point4.Y; + if (!DoubleUtil.IsZero(width) || !DoubleUtil.IsZero(height)) + { + ctx.ArcTo(point5, new Size(width, height), 0.0, false, SweepDirection.Clockwise, true, false); + } + ctx.LineTo(point6, true, false); + width = point6.X - rect.BottomLeft.X; + height = rect.BottomLeft.Y - point7.Y; + if (!DoubleUtil.IsZero(width) || !DoubleUtil.IsZero(height)) + { + ctx.ArcTo(point7, new Size(width, height), 0.0, false, SweepDirection.Clockwise, true, false); + } + ctx.LineTo(point8, true, false); + width = point.X - rect.TopLeft.X; + height = point8.Y - rect.TopLeft.Y; + if (!DoubleUtil.IsZero(width) || !DoubleUtil.IsZero(height)) + { + ctx.ArcTo(point, new Size(width, height), 0.0, false, SweepDirection.Clockwise, true, false); + } + } + public struct Radii + { + internal Radii(CornerRadius radii, Thickness borders, bool outer) + { + var left = 0.5 * borders.Left; + var top = 0.5 * borders.Top; + var right = 0.5 * borders.Right; + var bottom = 0.5 * borders.Bottom; + if (!outer) + { + LeftTop = Math.Max(0.0, radii.TopLeft - left); + TopLeft = Math.Max(0.0, radii.TopLeft - top); + TopRight = Math.Max(0.0, radii.TopRight - top); + RightTop = Math.Max(0.0, radii.TopRight - right); + RightBottom = Math.Max(0.0, radii.BottomRight - right); + BottomRight = Math.Max(0.0, radii.BottomRight - bottom); + BottomLeft = Math.Max(0.0, radii.BottomLeft - bottom); + LeftBottom = Math.Max(0.0, radii.BottomLeft - left); + return; + } + if (DoubleUtil.IsZero(radii.TopLeft)) + { + LeftTop = (TopLeft = 0.0); + } + else + { + LeftTop = radii.TopLeft + left; + TopLeft = radii.TopLeft + top; + } + if (DoubleUtil.IsZero(radii.TopRight)) + { + TopRight = (RightTop = 0.0); + } + else + { + TopRight = radii.TopRight + top; + RightTop = radii.TopRight + right; + } + if (DoubleUtil.IsZero(radii.BottomRight)) + { + RightBottom = (BottomRight = 0.0); + } + else + { + RightBottom = radii.BottomRight + right; + BottomRight = radii.BottomRight + bottom; + } + if (DoubleUtil.IsZero(radii.BottomLeft)) + { + BottomLeft = (LeftBottom = 0.0); + return; + } + BottomLeft = radii.BottomLeft + bottom; + LeftBottom = radii.BottomLeft + left; + } + + internal double LeftTop; + + internal double TopLeft; + + internal double TopRight; + + internal double RightTop; + + internal double RightBottom; + + internal double BottomRight; + + internal double BottomLeft; + + internal double LeftBottom; + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/MultiSelectComboBoxItem.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/MultiSelectComboBoxItem.cs new file mode 100644 index 00000000..5d6d2bca --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/MultiSelectComboBoxItem.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls; + +namespace DI_Electrical.Views.CustomControl +{ + public class MultiSelectComboBoxItem : ListBoxItem + { + } + +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/MultiSelectListBox.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/MultiSelectListBox.cs new file mode 100644 index 00000000..40f9c24d --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/MultiSelectListBox.cs @@ -0,0 +1,18 @@ +using System.Windows; +using System.Windows.Controls; + +namespace DI_Electrical.Views.CustomControl +{ + public class MultiSelectListBox:ListBox + { + protected override bool IsItemItsOwnContainerOverride(object item) + { + return item is MultiSelectComboBoxItem; + } + + protected override DependencyObject GetContainerForItemOverride() + { + return new MultiSelectComboBoxItem(); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/MultiSelectSearchComboBox.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/MultiSelectSearchComboBox.cs new file mode 100644 index 00000000..a3a99276 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/MultiSelectSearchComboBox.cs @@ -0,0 +1,630 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Controls.Primitives; +using System.Windows.Controls; +using System.Windows.Interop; +using System.Windows; + +namespace DI_Electrical.Views.CustomControl +{ + [TemplatePart(Name = "PART_TextBox", Type = typeof(TextBox))] + [TemplatePart(Name = "PART_Popup", Type = typeof(Popup))] + [TemplatePart(Name = "PART_Selector", Type = typeof(ListBox))] + [TemplatePart(Name = "PART_SelectAll", Type = typeof(CheckBox))] + [TemplatePart(Name = "PART_SearchSelector", Type = typeof(ListBox))] + public class MultiSelectSearchComboBox : Control + { + private const string TextBoxTemplateName = "PART_TextBox"; + private const string PopupTemplateName = "PART_Popup"; + private const string ListBoxTemplateName = "PART_Selector"; + private const string CheckBoxTemplateName = "PART_SelectAll"; + private const string ListBoxTemplateNameSearch = "PART_SearchSelector"; + + public static readonly RoutedEvent ClosedEvent = + EventManager.RegisterRoutedEvent("Closed", + RoutingStrategy.Bubble, + typeof(RoutedEventHandler), + typeof(MultiSelectSearchComboBox)); + + public static readonly DependencyProperty DisplayMemberPathProperty = + DependencyProperty.Register("DisplayMemberPath", + typeof(string), + typeof(MultiSelectSearchComboBox), + new PropertyMetadata(string.Empty)); + + public static readonly DependencyProperty SelectedValuePathProperty = + DependencyProperty.Register("SelectedValuePath", + typeof(string), + typeof(MultiSelectSearchComboBox), + new PropertyMetadata(string.Empty)); + + public static readonly DependencyProperty TextProperty = + DependencyProperty.Register("Text", + typeof(string), + typeof(MultiSelectSearchComboBox), + new PropertyMetadata(string.Empty)); + + public static readonly DependencyProperty ItemsSourceProperty = + DependencyProperty.Register("ItemsSource", typeof(IEnumerable), typeof(MultiSelectSearchComboBox), + new PropertyMetadata()); + + public static readonly DependencyProperty ItemsSourceSearchProperty = + DependencyProperty.Register("ItemsSourceSearch", typeof(IEnumerable), typeof(MultiSelectSearchComboBox), + new PropertyMetadata()); + + public static readonly DependencyProperty SelectAllContentProperty = + DependencyProperty.Register("SelectAllContent", typeof(object), typeof(MultiSelectSearchComboBox), + new PropertyMetadata("全选")); + + public static readonly DependencyProperty IsSelectAllActiveProperty = + DependencyProperty.Register("IsSelectAllActive", typeof(bool), typeof(MultiSelectSearchComboBox), + new PropertyMetadata(false)); + + public static readonly DependencyProperty DelimiterProperty = + DependencyProperty.Register("Delimiter", typeof(string), typeof(MultiSelectSearchComboBox), + new PropertyMetadata(";")); + + public static readonly DependencyProperty IsDropDownOpenProperty = + DependencyProperty.Register("IsDropDownOpen", typeof(bool), typeof(MultiSelectSearchComboBox), + new PropertyMetadata(false, OnIsDropDownOpenChanged)); + + public static readonly DependencyProperty MaxDropDownHeightProperty = + DependencyProperty.Register("MaxDropDownHeight", typeof(double), typeof(MultiSelectSearchComboBox), + new UIPropertyMetadata(SystemParameters.PrimaryScreenHeight / 3.0, OnMaxDropDownHeightChanged)); + + public static readonly DependencyProperty SelectedItemsProperty = + DependencyProperty.Register("SelectedItems", typeof(IList), typeof(MultiSelectSearchComboBox), + new FrameworkPropertyMetadata(new ArrayList(), + FrameworkPropertyMetadataOptions.BindsTwoWayByDefault | FrameworkPropertyMetadataOptions.Journal, + OnSelectedItemsChanged)); + + public static readonly DependencyProperty SearchWatermarkProperty = + DependencyProperty.Register("SearchWatermark", + typeof(string), + typeof(MultiSelectSearchComboBox), + new PropertyMetadata(string.Empty)); + + private CheckBox _checkBox; + private ListBox _listBox; + private ListBox _listBoxSearch; + private Popup _popup; + private TextBox _textBox; + private List selectedItems; + + private List selectedList; + private List selectedSearchList; + + private bool _isTemplateApplied = false; + private IList _pendingSelectedItems; + + private string theLastText; + + static MultiSelectSearchComboBox() + { + DefaultStyleKeyProperty.OverrideMetadata(typeof(MultiSelectSearchComboBox), + new FrameworkPropertyMetadata(typeof(MultiSelectSearchComboBox))); + } + + public string Delimiter + { + get => (string)GetValue(DelimiterProperty); + set => SetValue(DelimiterProperty, value); + } + + public string SelectedValuePath + { + get => (string)GetValue(SelectedValuePathProperty); + set => SetValue(SelectedValuePathProperty, value); + } + + public string DisplayMemberPath + { + get => (string)GetValue(DisplayMemberPathProperty); + set => SetValue(DisplayMemberPathProperty, value); + } + + public string Text + { + get => (string)GetValue(TextProperty); + set => SetValue(TextProperty, value); + } + + public IEnumerable ItemsSource + { + get => (IEnumerable)GetValue(ItemsSourceProperty); + set => SetValue(ItemsSourceProperty, value); + } + + public IEnumerable ItemsSourceSearch + { + get => (IEnumerable)GetValue(ItemsSourceSearchProperty); + set => SetValue(ItemsSourceSearchProperty, value); + } + + public object SelectAllContent + { + get => GetValue(SelectAllContentProperty); + set => SetValue(SelectAllContentProperty, value); + } + + public bool IsSelectAllActive + { + get => (bool)GetValue(IsSelectAllActiveProperty); + set => SetValue(IsSelectAllActiveProperty, value); + } + + public bool IsDropDownOpen + { + get => (bool)GetValue(IsDropDownOpenProperty); + set => SetValue(IsDropDownOpenProperty, value); + } + + public double MaxDropDownHeight + { + get => (double)GetValue(MaxDropDownHeightProperty); + set => SetValue(MaxDropDownHeightProperty, value); + } + + public IList SelectedItems + { + get => (IList)GetValue(SelectedItemsProperty); + set => SetValue(SelectedItemsProperty, value); + } + + public string SearchWatermark + { + get => (string)GetValue(SearchWatermarkProperty); + set => SetValue(SearchWatermarkProperty, value); + } + + [DllImport(Win32.User32)] + private static extern IntPtr SetFocus(IntPtr hWnd); + + public event RoutedEventHandler Closed + { + add => AddHandler(ClosedEvent, value); + remove => RemoveHandler(ClosedEvent, value); + } + + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + selectedList = new List(); + selectedSearchList = new List(); + selectedItems = new List(); + _textBox = GetTemplateChild(TextBoxTemplateName) as TextBox; + _popup = GetTemplateChild(PopupTemplateName) as Popup; + if (_popup != null) + _popup.GotFocus += OnPopup_GotFocus; + _listBox = GetTemplateChild(ListBoxTemplateName) as ListBox; + + _checkBox = GetTemplateChild(CheckBoxTemplateName) as CheckBox; + _listBoxSearch = GetTemplateChild(ListBoxTemplateNameSearch) as ListBox; + if (_textBox != null) + { + _textBox.TextChanged -= OnTextbox_TextChanged; + _textBox.TextChanged += OnTextbox_TextChanged; + } + + if (_checkBox != null) + { + _checkBox.Checked -= OnCheckBox_Checked; + _checkBox.Unchecked -= OnCheckBox_Unchecked; + _checkBox.Checked += OnCheckBox_Checked; + _checkBox.Unchecked += OnCheckBox_Unchecked; + } + + if (_listBox != null) + { + _listBox.IsVisibleChanged -= OnListBox_IsVisibleChanged; + _listBox.IsVisibleChanged += OnListBox_IsVisibleChanged; + _listBox.SelectionChanged -= OnListBox_SelectionChanged; + _listBox.SelectionChanged += OnListBox_SelectionChanged; + } + + if (_listBoxSearch != null) + { + _listBoxSearch.IsVisibleChanged -= OnListBoxSearch_IsVisibleChanged; + _listBoxSearch.IsVisibleChanged += OnListBoxSearch_IsVisibleChanged; + _listBoxSearch.SelectionChanged -= OnListBoxSearch_SelectionChanged; + _listBoxSearch.SelectionChanged += OnListBoxSearch_SelectionChanged; + } + + // 标记模板已应用 + _isTemplateApplied = true; + + // 处理之前暂存的 SelectedItems + if (_pendingSelectedItems != null) + { + HandleSelectedItemsChanged(_pendingSelectedItems); + _pendingSelectedItems = null; + } + } + + private void OnListBoxSearch_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if ((bool)e.NewValue) + UpdateIsChecked(_listBoxSearch); + } + + private void OnListBox_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) + { + if ((bool)e.NewValue) + { + foreach (var item in selectedSearchList) + if (!_listBox.SelectedItems.Contains(item)) + _listBox.SelectedItems.Add(item); + UpdateIsChecked(_listBox); + } + } + + private void UpdateIsChecked(ListBox listBox) + { + _checkBox.Checked -= OnCheckBox_Checked; + if (listBox.Items.Count > 0 && listBox.Items.Count == listBox.SelectedItems.Count) + { + if (_checkBox.IsChecked != true) + _checkBox.IsChecked = true; + } + else + { + if (listBox.SelectedItems.Count == 0) + _checkBox.IsChecked = false; + else + _checkBox.IsChecked = null; + } + + _checkBox.Checked += OnCheckBox_Checked; + } + + private void OnPopup_GotFocus(object sender, RoutedEventArgs e) + { + var source = (HwndSource)PresentationSource.FromVisual(_popup.Child); + if (source != null) + { + SetFocus(source.Handle); + _textBox.Focus(); + } + } + + private void OnCheckBox_Unchecked(object sender, RoutedEventArgs e) + { + if (_listBoxSearch.Visibility == Visibility.Visible) + _listBoxSearch.UnselectAll(); + else + _listBox.UnselectAll(); + } + + private void OnCheckBox_Checked(object sender, RoutedEventArgs e) + { + if (_listBoxSearch.Visibility == Visibility.Visible) + _listBoxSearch.SelectAll(); + else + _listBox.SelectAll(); + } + + private void Combination() + { + var seletedName = new List(); + foreach (var item in _listBox.SelectedItems) + { + var name = GetDisplayText(item); + if (!string.IsNullOrWhiteSpace(name)) + seletedName.Add(name); + else + seletedName.Add(item.ToString()); + } + + foreach (var item in _listBoxSearch.SelectedItems) + { + if (_listBox.SelectedItems.Contains(item)) + continue; + var name = GetDisplayText(item); + if (!string.IsNullOrWhiteSpace(name)) + seletedName.Add(name); + else + seletedName.Add(item.ToString()); + } + + Text = string.Join(Delimiter, seletedName.ToArray()); + } + + private void OnListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (e.RemovedItems.Count > 0) + { + foreach (var item in e.RemovedItems) + { + if (_checkBox.IsChecked == true) + { + _checkBox.Unchecked -= OnCheckBox_Unchecked; + if (_listBox.Items.Count == 1) + _checkBox.IsChecked = false; + else + _checkBox.IsChecked = null; + _checkBox.Unchecked += OnCheckBox_Unchecked; + } + + if (_listBoxSearch.SelectedItems.Contains(item)) + _listBoxSearch.SelectedItems.Remove(item); + if (selectedSearchList.Contains(item)) + selectedSearchList.Remove(item); + } + + SelectionChecked(_listBox); + } + + + if (e.AddedItems.Count > 0) + SelectionChecked(_listBox); + Combination(); + var selectedItems = _listBox.SelectedItems; + if (SelectedItems == null) + SelectedItems = selectedItems; + else + { + foreach (var item in selectedItems) + { + if (!SelectedItems.Contains(item)) + SelectedItems.Add(item); + } + } + } + + private void OnListBoxSearch_SelectionChanged(object sender, SelectionChangedEventArgs e) + { + if (!_listBoxSearch.IsVisible) + return; + if (e.RemovedItems.Count > 0) + { + foreach (var item in e.RemovedItems) + { + if (selectedSearchList.Contains(item)) + selectedSearchList.Remove(item); + if (_listBoxSearch.Items.Contains(item)) + { + if (_listBox.SelectedItems.Contains(item)) + _listBox.SelectedItems.Remove(item); + } + + if (selectedList.Contains(item)) + selectedList.Remove(item); + } + + Combination(); + SelectionChecked(_listBoxSearch); + } + + if (e.AddedItems.Count > 0) + { + foreach (var item in e.AddedItems) + if (!_listBox.SelectedItems.Contains(item)) + _listBox.SelectedItems.Add(item); + Combination(); + SelectionChecked(_listBoxSearch); + } + } + + private void SelectionChecked(ListBox listbox) + { + if (listbox.SelectedItems.Count > 0 + && + listbox.Items.Count == listbox.SelectedItems.Count) + { + _checkBox.Checked -= OnCheckBox_Checked; + _checkBox.IsChecked = true; + _checkBox.Checked += OnCheckBox_Checked; + } + else + { + _checkBox.Checked -= OnCheckBox_Checked; + if (listbox.SelectedItems.Count > 0 + && + listbox.Items.Count == listbox.SelectedItems.Count) + { + if (_checkBox.IsChecked != true) + _checkBox.IsChecked = true; + } + else + { + if (listbox.SelectedItems.Count == 0) + _checkBox.IsChecked = false; + else + _checkBox.IsChecked = null; + } + + _checkBox.Checked += OnCheckBox_Checked; + } + } + + private string GetDisplayText(object dataItem, string path = null) + { + if (dataItem == null) return string.Empty; + return GetPropertyValue(dataItem); + } + + private void OnTextbox_TextChanged(object sender, TextChangedEventArgs e) + { + if (string.IsNullOrWhiteSpace(theLastText)) theLastText = _textBox.Text; + SearchText(_textBox.Text); + } + + private void SearchText(string _text) + { + var text = _text; + if (string.IsNullOrWhiteSpace(text)) + { + if (_listBoxSearch.Visibility != Visibility.Collapsed) + _listBoxSearch.Visibility = Visibility.Collapsed; + if (_listBox.Visibility != Visibility.Visible) + _listBox.Visibility = Visibility.Visible; + } + else + { + if (_listBoxSearch.Visibility != Visibility.Visible) + _listBoxSearch.Visibility = Visibility.Visible; + if (_listBox.Visibility != Visibility.Collapsed) + _listBox.Visibility = Visibility.Collapsed; + var listSearch = new List(); + foreach (var item in _listBox.Items) + { + var str = GetPropertyValue(item); + if (string.IsNullOrWhiteSpace(str)) + str = item.ToString(); + if (!string.IsNullOrWhiteSpace(str)) + if (str.ToUpperInvariant().Contains(text.ToUpperInvariant())) + listSearch.Add(item); + } + + foreach (var item in selectedList) + if (!listSearch.Contains(item)) + listSearch.Add(item); + + var lastItem = ItemsSourceSearch; + ItemsSourceSearch = listSearch; + SelectionChecked(_listBoxSearch); + selectedItems.Clear(); + foreach (var item in _listBoxSearch.Items) + if (_listBox.SelectedItems.Contains(item)) + if (!_listBoxSearch.SelectedItems.Contains(item)) + _listBoxSearch.SelectedItems.Add(item); + } + } + + private string GetPropertyValue(object item) + { + var result = string.Empty; + var nameParts = DisplayMemberPath.Split('.'); + if (nameParts.Length == 1) + { + var property = item.GetType().GetProperty(DisplayMemberPath); + if (property != null) + return (property.GetValue(item, null) ?? string.Empty).ToString(); + } + + return result.ToUpperInvariant(); + } + + private static void OnIsDropDownOpenChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + var multiSelectionSearchComboBox = o as MultiSelectSearchComboBox; + if (multiSelectionSearchComboBox != null) + multiSelectionSearchComboBox.OnIsOpenChanged((bool)e.OldValue, (bool)e.NewValue); + } + + protected virtual void OnIsOpenChanged(bool oldValue, bool newValue) + { + if (!newValue) + RaiseRoutedEvent(ClosedEvent); + } + + private void RaiseRoutedEvent(RoutedEvent routedEvent) + { + var args = new RoutedEventArgs(routedEvent, this); + RaiseEvent(args); + } + + private static void OnMaxDropDownHeightChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) + { + var comboBox = o as MultiSelectSearchComboBox; + if (comboBox != null) + comboBox.OnMaxDropDownHeightChanged((double)e.OldValue, (double)e.NewValue); + } + + protected virtual void OnMaxDropDownHeightChanged(double oldValue, double newValue) + { + } + + private static void OnSelectedItemsChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + + var mltiSelectionSearchComboBox = d as MultiSelectSearchComboBox; + + if (e.NewValue != null) + { + var collection = e.NewValue as IList; + if (collection.Count <= 0) return; + + //mltiSelectionSearchComboBox._listBox.SelectionChanged -= + // mltiSelectionSearchComboBox.OnListBox_SelectionChanged; + // foreach (var item in collection) + // { + // var name = mltiSelectionSearchComboBox.GetPropertyValue(item); + // object model = null; + // if (!string.IsNullOrWhiteSpace(name)) + // model = mltiSelectionSearchComboBox._listBox.ItemsSource.OfType().FirstOrDefault(h => + // mltiSelectionSearchComboBox.GetPropertyValue(h) == name); + // else + // model = mltiSelectionSearchComboBox._listBox.ItemsSource.OfType() + // .FirstOrDefault(h => h == item); + // if (model != null && !mltiSelectionSearchComboBox._listBox.SelectedItems.Contains(item)) + // mltiSelectionSearchComboBox._listBox.SelectedItems.Add(model); + // } + + // mltiSelectionSearchComboBox._listBox.SelectionChanged += + // mltiSelectionSearchComboBox.OnListBox_SelectionChanged; + // mltiSelectionSearchComboBox.Combination(); + // 如果模板未应用,暂存 SelectedItems + if (!mltiSelectionSearchComboBox._isTemplateApplied) + { + mltiSelectionSearchComboBox._pendingSelectedItems = e.NewValue as IList; + return; + } + + // 模板已应用,正常处理 + mltiSelectionSearchComboBox.HandleSelectedItemsChanged(e.NewValue as IList); + + } + } + + private void HandleSelectedItemsChanged(IList newSelectedItems) + { + if (newSelectedItems == null || _listBox == null) + return; + + _listBox.SelectionChanged -= OnListBox_SelectionChanged; + + // 清空并重新添加选中项 + _listBox.SelectedItems.Clear(); + foreach (var item in newSelectedItems) + { + var model = FindItemInItemsSource(item); + if (model != null && !_listBox.SelectedItems.Contains(model)) + _listBox.SelectedItems.Add(model); + } + + _listBox.SelectionChanged += OnListBox_SelectionChanged; + Combination(); // 更新显示文本 + } + private object FindItemInItemsSource(object targetItem) + { + if (targetItem == null) return null; + + // 根据 DisplayMemberPath 或直接比较查找匹配项 + var displayPath = DisplayMemberPath; + if (string.IsNullOrEmpty(displayPath)) + return targetItem; + + var items = _listBox.ItemsSource?.OfType().ToList(); + if (items == null) return null; + + var property = targetItem.GetType().GetProperty(displayPath); + if (property == null) return null; + + var targetValue = property.GetValue(targetItem)?.ToString(); + return items.FirstOrDefault(i => + { + var iValue = i.GetType().GetProperty(displayPath)?.GetValue(i)?.ToString(); + return iValue == targetValue; + }); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/SmallPanel.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/SmallPanel.cs new file mode 100644 index 00000000..640c996f --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/SmallPanel.cs @@ -0,0 +1,52 @@ +using System; +using System.Windows; +using System.Windows.Controls; + +namespace DI_Electrical.Views.CustomControl +{ + /// + /// 当不需要使用Grid的分行分列,则可使用 SmallPanel + /// + public class SmallPanel : Panel + { + /// + /// Content measurement. + /// + /// Constraint + /// Desired size + protected override Size MeasureOverride(Size constraint) + { + Size gridDesiredSize = new Size(); + UIElementCollection children = InternalChildren; + + for (int i = 0, count = children.Count; i < count; ++i) + { + UIElement child = children[i]; + if (child != null) + { + child.Measure(constraint); + gridDesiredSize.Width = Math.Max(gridDesiredSize.Width, child.DesiredSize.Width); + gridDesiredSize.Height = Math.Max(gridDesiredSize.Height, child.DesiredSize.Height); + } + } + return (gridDesiredSize); + } + /// + /// Content arrangement. + /// + /// Arrange size + protected override Size ArrangeOverride(Size arrangeSize) + { + UIElementCollection children = InternalChildren; + for (int i = 0, count = children.Count; i < count; ++i) + { + UIElement child = children[i]; + if (child != null) + { + child.Arrange(new Rect(arrangeSize)); + } + } + return (arrangeSize); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/WDBorder.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/WDBorder.cs new file mode 100644 index 00000000..565b9dc8 --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/WDBorder.cs @@ -0,0 +1,50 @@ +using System.Windows.Media; +using System.Windows; +using System.Windows.Controls; + +namespace DI_Electrical.Views.CustomControl +{ + public class WDBorder : Border + { + public static readonly DependencyPropertyKey ContentClipPropertyKey = + DependencyProperty.RegisterReadOnly("ContentClip", typeof(Geometry), typeof(WDBorder), + new PropertyMetadata(null)); + + public static readonly DependencyProperty ContentClipProperty = ContentClipPropertyKey.DependencyProperty; + + public Geometry ContentClip + { + get => (Geometry)GetValue(ContentClipProperty); + set => SetValue(ContentClipProperty, value); + } + + private Geometry CalculateContentClip() + { + var borderThickness = BorderThickness; + var cornerRadius = CornerRadius; + var renderSize = RenderSize; + var width = renderSize.Width - borderThickness.Left - borderThickness.Right; + var height = renderSize.Height - borderThickness.Top - borderThickness.Bottom; + if (width > 0.0 && height > 0.0) + { + var rect = new Rect(0.0, 0.0, width, height); + var radii = new GeometryHelper.Radii(cornerRadius, borderThickness, false); + var streamGeometry = new StreamGeometry(); + using (var streamGeometryContext = streamGeometry.Open()) + { + GeometryHelper.GenerateGeometry(streamGeometryContext, rect, radii); + streamGeometry.Freeze(); + return streamGeometry; + } + } + + return null; + } + + protected override void OnRender(DrawingContext dc) + { + SetValue(ContentClipPropertyKey, CalculateContentClip()); + base.OnRender(dc); + } + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/Win32.cs b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/Win32.cs new file mode 100644 index 00000000..9c81227a --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/MultiSelectSearchComboBox/Win32.cs @@ -0,0 +1,170 @@ +using System; +using System.Runtime.InteropServices; +using System.Text; + +namespace DI_Electrical.Views.CustomControl +{ + public static class Win32 + { + public const string + User32 = "user32.dll", + Gdi32 = "gdi32.dll", + GdiPlus = "gdiplus.dll", + Kernel32 = "kernel32.dll", + Shell32 = "shell32.dll", + MsImg = "msimg32.dll", + NTdll = "ntdll.dll", + DwmApi = "dwmapi.dll", + Winmm = "winmm.dll", + Shcore = "Shcore.dll"; + //查找窗口的委托 查找逻辑 + public delegate bool EnumWindowsProc(IntPtr hwnd, IntPtr lParam); + + [DllImport(User32)] + public static extern IntPtr FindWindow(string className, string winName); + + [DllImport(User32)] + public static extern IntPtr SendMessageTimeout(IntPtr hwnd, uint msg, IntPtr wParam, IntPtr lParam, + uint fuFlage, uint timeout, IntPtr result); + + [DllImport(User32)] + public static extern bool EnumWindows(EnumWindowsProc proc, IntPtr lParam); + + [DllImport(User32)] + public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string className, + string winName); + + [DllImport(User32)] + public static extern bool ShowWindow(IntPtr hwnd, int nCmdShow); + + [DllImport(User32)] + public static extern IntPtr SetParent(IntPtr hwnd, IntPtr parentHwnd); + + [DllImport(User32)] + public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong); + + [DllImport(User32)] + public static extern bool SetForegroundWindow(IntPtr hWnd); + + [DllImport(User32)] + public static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam); + + [DllImport(User32)] + public static extern int GetWindowText(IntPtr hWnd, StringBuilder lpString, int nMaxCount); + + [DllImport(Winmm)] + public static extern long mciSendString(string strCommand, StringBuilder strReturn, + int iReturnLength, IntPtr hwndCallback); + + #region WINAPI DLL Imports + + [DllImport(Gdi32, ExactSpelling = true, PreserveSig = true, SetLastError = true)] + public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); + + [DllImport(Gdi32)] + public static extern IntPtr CreateCompatibleBitmap(IntPtr hdc, int nWidth, int nHeight); + + [DllImport(Gdi32, SetLastError = true)] + public static extern IntPtr CreateCompatibleDC(IntPtr hdc); + + [DllImport(Gdi32)] + public static extern bool DeleteObject(IntPtr hObject); + + [DllImport(Gdi32)] + public static extern IntPtr CreateBitmap(int nWidth, int nHeight, uint cPlanes, uint cBitsPerPel, + IntPtr lpvBits); + + [DllImport(User32)] + public static extern IntPtr GetDC(IntPtr hWnd); + + [DllImport(User32)] + public static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC); + + + [DllImport(Gdi32, EntryPoint = "DeleteDC")] + public static extern IntPtr DeleteDC(IntPtr hDc); + + + public const int SM_CXSCREEN = 0; + + public const int SM_CYSCREEN = 1; + + [DllImport(User32, EntryPoint = "GetDesktopWindow")] + public static extern IntPtr GetDesktopWindow(); + + [DllImport(User32, EntryPoint = "GetSystemMetrics")] + public static extern int GetSystemMetrics(int abc); + + [DllImport(User32, EntryPoint = "GetWindowDC")] + public static extern IntPtr GetWindowDC(int ptr); + + public struct DeskTopSize + { + public int cx; + public int cy; + } + + public enum TernaryRasterOperations : uint + { + /// dest = source + SRCCOPY = 0x00CC0020, + + /// dest = source OR dest + SRCPAINT = 0x00EE0086, + + /// dest = source AND dest + SRCAND = 0x008800C6, + + /// dest = source XOR dest + SRCINVERT = 0x00660046, + + /// dest = source AND (NOT dest) + SRCERASE = 0x00440328, + + /// dest = (NOT source) + NOTSRCCOPY = 0x00330008, + + /// dest = (NOT src) AND (NOT dest) + NOTSRCERASE = 0x001100A6, + + /// dest = (source AND pattern) + MERGECOPY = 0x00C000CA, + + /// dest = (NOT source) OR dest + MERGEPAINT = 0x00BB0226, + + /// dest = pattern + PATCOPY = 0x00F00021, + + /// dest = DPSnoo + PATPAINT = 0x00FB0A09, + + /// dest = pattern XOR dest + PATINVERT = 0x005A0049, + + /// dest = (NOT dest) + DSTINVERT = 0x00550009, + + /// dest = BLACK + BLACKNESS = 0x00000042, + + /// dest = WHITE + WHITENESS = 0x00FF0062 + } + + [DllImport(Gdi32)] + public static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, + int nXSrc, int nYSrc, TernaryRasterOperations dwRop); + + #endregion + + /// + /// 设置鼠标的坐标 + /// + /// 横坐标 + /// 纵坐标 + [DllImport(User32)] + public extern static void SetCursorPos(int x, int y); + + } +} diff --git a/newFront/c#前端/DI-Electrical/Views/CustomControl/customWindowTitleBar.xaml b/newFront/c#前端/DI-Electrical/Views/CustomControl/customWindowTitleBar.xaml new file mode 100644 index 00000000..074fa09e --- /dev/null +++ b/newFront/c#前端/DI-Electrical/Views/CustomControl/customWindowTitleBar.xaml @@ -0,0 +1,37 @@ + + + +