电器前端提交

This commit is contained in:
CHEN-ZW\acer 2025-08-15 11:55:13 +08:00
parent 5cdc926342
commit e1651383e2
13 changed files with 669 additions and 0 deletions

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,189 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8740B023-B585-4E69-8521-4F62FA754A1B}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CAD.Extend</RootNamespace>
<AssemblyName>CAD.Extend</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="BrxMgd">
<HintPath>..\..\..\..\..\Program Files\KunHeng\KunHengCAD V21 zh_CN\BrxMgd.dll</HintPath>
</Reference>
<Reference Include="DryIoc, Version=5.4.3.0, Culture=neutral, PublicKeyToken=dfbf2bd50fcf7768, processorArchitecture=MSIL">
<HintPath>..\packages\DryIoc.dll.5.4.3\lib\net45\DryIoc.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.8.0.0\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=8.0.0.1, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.8.0.1\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.122\lib\net462\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Prism, Version=9.0.537.60525, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Core.9.0.537\lib\net47\Prism.dll</HintPath>
</Reference>
<Reference Include="Prism.Container.Abstractions, Version=9.0.106.9543, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Container.Abstractions.9.0.106\lib\net47\Prism.Container.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Prism.Container.DryIoc, Version=9.0.106.9543, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Container.DryIoc.9.0.106\lib\net47\Prism.Container.DryIoc.dll</HintPath>
</Reference>
<Reference Include="Prism.Container.Unity, Version=9.0.106.9543, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Container.Unity.9.0.106\lib\net462\Prism.Container.Unity.dll</HintPath>
</Reference>
<Reference Include="Prism.DryIoc.Wpf, Version=9.0.537.60525, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.DryIoc.9.0.537\lib\net47\Prism.DryIoc.Wpf.dll</HintPath>
</Reference>
<Reference Include="Prism.Events, Version=9.0.537.60525, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Events.9.0.537\lib\net47\Prism.Events.dll</HintPath>
</Reference>
<Reference Include="Prism.Unity.Wpf, Version=9.0.537.60525, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Unity.9.0.537\lib\net47\Prism.Unity.Wpf.dll</HintPath>
</Reference>
<Reference Include="Prism.Wpf, Version=9.0.537.60525, Culture=neutral, PublicKeyToken=40ee6c3a2184dc59, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Wpf.9.0.537\lib\net47\Prism.Wpf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.5.4\lib\net461\System.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="System.ValueTuple, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.5.0\lib\net47\System.ValueTuple.dll</HintPath>
</Reference>
<Reference Include="System.Web" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="TD_Mgd">
<HintPath>..\..\..\..\..\Program Files\KunHeng\KunHengCAD V21 zh_CN\TD_Mgd.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls, Version=2024.1.130.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Data, Version=2024.1.130.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.Data.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.FileDialogs, Version=2024.1.130.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.FileDialogs.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.GridView, Version=2024.1.130.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.GridView.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Input, Version=2024.1.130.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.Input.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Controls.Navigation, Version=2024.1.130.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Controls.Navigation.dll</HintPath>
</Reference>
<Reference Include="Telerik.Windows.Data, Version=2024.1.130.45, Culture=neutral, PublicKeyToken=5803cfa389c90ce7, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\SWS.CAD\RefDLL\WPF45\Telerik.Windows.Data.dll</HintPath>
</Reference>
<Reference Include="Unity.Abstractions, Version=5.11.7.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\packages\Unity.Abstractions.5.11.7\lib\net48\Unity.Abstractions.dll</HintPath>
</Reference>
<Reference Include="Unity.Container, Version=5.11.11.0, Culture=neutral, PublicKeyToken=489b6accfaf20ef0, processorArchitecture=MSIL">
<HintPath>..\packages\Unity.Container.5.11.11\lib\net48\Unity.Container.dll</HintPath>
</Reference>
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="Commands.cs" />
<Compile Include="GlobalObject.cs" />
<Compile Include="Model\KeyValueModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ViewModels\DialogConvertBaseMapViewModel.cs" />
<Compile Include="ViewModels\myViewModelBase\DialogBase.cs" />
<Compile Include="Views\CustomControl\customWindowTitleBar.xaml.cs">
<DependentUpon>customWindowTitleBar.xaml</DependentUpon>
</Compile>
<Compile Include="Views\CustomDialogWindow.xaml.cs">
<DependentUpon>CustomDialogWindow.xaml</DependentUpon>
</Compile>
<Compile Include="Views\DialogConvertBaseMap.xaml.cs">
<DependentUpon>DialogConvertBaseMap.xaml</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Images\pic1.png" />
</ItemGroup>
<ItemGroup>
<Page Include="Views\CustomControl\customWindowTitleBar.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\CustomDialogWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Views\DialogConvertBaseMap.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Views\Style\CustomStyles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SWS.CAD.Base\SWS.CAD.Base.csproj">
<Project>{d4a15774-1469-45a0-9eff-771271764a00}</Project>
<Name>SWS.CAD.Base</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Folder Include="CADFunc\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartAction>Program</StartAction>
<StartProgram>D:\Program Files\KunHeng\KunHengCAD V21 zh_CN\kunhengcad.exe</StartProgram>
</PropertyGroup>
</Project>

View File

@ -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<IDialogService, DialogService>();
GlobalObject._prismContainer.Register<IDialogWindow, CustomDialogWindow>();
GlobalObject._prismContainer.RegisterDialog<DialogConvertBaseMap, DialogConvertBaseMapViewModel>();
}
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<IDialogService>();
_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
}
}
}

View File

@ -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
}
/// <summary>
/// 获取图片
/// </summary>
/// <param name="resName">包括命名空间</param>
/// <returns></returns>
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;
}
}
}

View File

@ -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")]

View File

@ -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<KeyValueModel> _listLayerName = new ObservableCollection<KeyValueModel>();
/// <summary>
/// 底图名列表
/// </summary>
public ObservableCollection<KeyValueModel> listLayerName
{
get { return _listLayerName; }
set { _listLayerName = value; RaisePropertyChanged(nameof(listLayerName)); }
}
private KeyValueModel _SelectedLayerName;
/// <summary>
/// 选中的底图名
/// </summary>
public KeyValueModel SelectedLayerName
{
get { return _SelectedLayerName; }
set { _SelectedLayerName = value; RaisePropertyChanged(nameof(SelectedLayerName)); }
}
private bool _IsToBlock;
/// <summary>
/// 是否转为图块
/// </summary>
public bool IsToBlock
{
get { return _IsToBlock; }
set { _IsToBlock = value; RaisePropertyChanged(nameof(IsToBlock)); }
}
#endregion
private string _BlockName = "EI-Elec专用底图";
/// <summary>
/// 块名
/// </summary>
public string BlockName
{
get { return _BlockName; }
set { _BlockName = value; RaisePropertyChanged(nameof(BlockName)); }
}
private Brush _BlockColor;
/// <summary>
/// 图层颜色
/// </summary>
public Brush BlockColor
{
get { return _BlockColor; }
set { _BlockColor = value; RaisePropertyChanged(nameof(BlockColor)); }
}
/// <summary>
/// 随机块名
/// </summary>
public ICommand Command_BlockName { get; set; }
/// <summary>
/// 颜色
/// </summary>
public ICommand Command_Color { get; set; }
/// <summary>
/// 图层颜色 默认灰色
/// </summary>
Teigha.Colors.Color layerColor = Teigha.Colors.Color.FromColorIndex(ColorMethod.ByAci, 8);
List<ObjectId> listObjectId = new List<ObjectId>();
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);
}
/// <summary>
/// 颜色选择
/// </summary>
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);
}
}
/// <summary>
/// 随机块名
/// </summary>
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<List<ObjectId>>(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();
}
}
}

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Prism.Container.Abstractions" publicKeyToken="40ee6c3a2184dc59" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.107.57918" newVersion="9.0.107.57918" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.2.0.1" newVersion="4.2.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]

View File

@ -0,0 +1 @@
E:\Di-Electrical\c#前端\CAD.Extend\obj\Debug\CAD.Extend.csproj.AssemblyReference.cache

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="DryIoc.dll" version="5.4.3" targetFramework="net48" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="8.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="8.0.1" targetFramework="net48" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.122" targetFramework="net48" />
<package id="Prism.Container.Abstractions" version="9.0.106" targetFramework="net48" />
<package id="Prism.Container.DryIoc" version="9.0.106" targetFramework="net48" />
<package id="Prism.Container.Unity" version="9.0.106" targetFramework="net48" />
<package id="Prism.Core" version="9.0.537" targetFramework="net48" />
<package id="Prism.DryIoc" version="9.0.537" targetFramework="net48" />
<package id="Prism.Events" version="9.0.537" targetFramework="net48" />
<package id="Prism.Unity" version="9.0.537" targetFramework="net48" />
<package id="Prism.Wpf" version="9.0.537" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.5.3" targetFramework="net48" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
<package id="Unity.Abstractions" version="5.11.7" targetFramework="net48" />
<package id="Unity.Container" version="5.11.11" targetFramework="net48" />
</packages>