diff --git a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj.user b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj.user
index 0b246432..a607660d 100644
--- a/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj.user
+++ b/Learun.Framework.Module/Learun.Application.Module/Learun.Application.TwoDevelopment/Learun.Application.TwoDevelopment.csproj.user
@@ -1,6 +1,6 @@
- ProjectFiles
+ ShowAllFiles
\ No newline at end of file
diff --git a/newFront/c#前端/SWS.CAD.Base/General.cs b/newFront/c#前端/SWS.CAD.Base/General.cs
index 36bdcaf5..8df9cbb4 100644
--- a/newFront/c#前端/SWS.CAD.Base/General.cs
+++ b/newFront/c#前端/SWS.CAD.Base/General.cs
@@ -14,6 +14,7 @@ using Entity = Teigha.DatabaseServices.Entity;
using Path = System.IO.Path;
using Color = Teigha.Colors.Color;
using System.Security.Cryptography;
+using System.Threading.Tasks;
namespace SWS.CAD.Base
{
public static class General
@@ -137,7 +138,7 @@ namespace SWS.CAD.Base
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
- ObjectId idBtr = doc.Database.Insert(blockName, blockName, blockDb, true);
+ ObjectId idBtr = doc.Database.Insert(blockName, blockName, blockDb, true);
BlockTableRecord curBtr = trans.GetObject(db.CurrentSpaceId, OpenMode.ForWrite) as BlockTableRecord;
var block = new BlockReference(Point3d.Origin, idBtr);
block.Position = position;
@@ -1065,12 +1066,13 @@ namespace SWS.CAD.Base
}
#endregion
- #region 获取当前图纸所有实体
+ #region 获取当前图纸XData不为空的所有实体
///
/// 获取当前图纸XData不为空的所有实体
///
+ /// 要删除的位号
///
- public static List GetAllEntity()
+ public static List GetAllEntity(List listTagNumber)
{
doc = Application.DocumentManager.MdiActiveDocument;
ed = doc.Editor;
@@ -1084,18 +1086,20 @@ namespace SWS.CAD.Base
{
// 获取模型空间块表记录
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
- BlockTableRecord modelSpace = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
-
+ BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
+ // 收集要删除的块参照
+ ObjectIdCollection idsToErase = new ObjectIdCollection();
// 遍历模型空间中的所有实体
- foreach (ObjectId objId in modelSpace)
+ foreach (ObjectId objId in btr)
{
- Entity entity = tr.GetObject(objId, OpenMode.ForRead) as Entity;
+ Entity entity = tr.GetObject(objId, OpenMode.ForWrite) as Entity;
if (entity != null && entity.XData != null)
{
// 提取句柄(十六进制格式)
var blockRef = entity as BlockReference;
if (blockRef != null)
{
+ bool flag = true;
var dto = new DtoBasePoint()
{
Handle = entity.Handle.ToString(),
@@ -1113,14 +1117,27 @@ namespace SWS.CAD.Base
if (attRef.Tag == "HKSK_TAG")
{
dto.TagNumber = attRef.TextString;
+ if (listTagNumber != null && listTagNumber.Contains(attRef.TextString))
+ {
+ idsToErase.Add(objId);
+ flag = false;
+ }
break;
}
}
-
- handles.Add(dto);
+ if (flag)
+ { handles.Add(dto); }
}
}
}
+ if (idsToErase.Count > 0)
+ {
+ foreach (ObjectId id in idsToErase)
+ {
+ Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);
+ ent.Erase();
+ }
+ }
tr.Commit();
}
@@ -1920,15 +1937,18 @@ namespace SWS.CAD.Base
/// 位号值
/// true:默认块,false:异性块
///
- public static bool UpdateCableNo(string dwgName, List listTagName, string tagNumber, bool IsNotDefaultSymbol, string tag, string system)
+ public static string UpdateCableNo(string dwgName, List listTagName, string tagNumber, bool IsNotDefaultSymbol, string tag, string system)
{
try
{
- OpenDwg(dwgName);
+ //OpenDwg(dwgName);
+ Application.DocumentManager.Open(dwgName);
+ //Thread.Sleep(1000);
doc = Application.DocumentManager.MdiActiveDocument;
ed = doc.Editor;
db = doc.Database;
+ var s=doc.Name;
// 开启事务
using (Transaction tr = db.TransactionManager.StartTransaction())
{
@@ -1986,12 +2006,13 @@ namespace SWS.CAD.Base
tr.Commit();
}
doc.CloseAndSave(dwgName);
- return true;
+ Thread.Sleep(20);
+ return "";
}
catch (Exception ex)
{
SendMessage(ex.Message);
- return false;
+ return ex.Message;
}
}
@@ -2019,7 +2040,7 @@ namespace SWS.CAD.Base
// 创建多行文字对象
MText mText = new MText();
mText.Contents = textInfo.Text;
- mText.Location = textInfo.Position;
+ mText.Location = textInfo.Position;
mText.TextHeight = textInfo.Height;
mText.Width = textInfo.Width; // 设置文本宽度,控制自动换行
if (textInfo.Align == 0)
@@ -2040,7 +2061,7 @@ namespace SWS.CAD.Base
DBText dbText = new DBText();
dbText.TextString = textInfo.Text;
dbText.Position = textInfo.Position;
- dbText.AlignmentPoint= textInfo.Position;
+ dbText.AlignmentPoint = textInfo.Position;
dbText.Height = textInfo.Height;
if (textInfo.Align == 0)
{
@@ -2078,7 +2099,7 @@ namespace SWS.CAD.Base
/// 坐标位置
///
public static ObjectId AddBlockDWG(string filePath, string blockName, Point3d position)
- {
+ {
Document doc = Application.DocumentManager.MdiActiveDocument;
var ed = doc.Editor;
ObjectId oid = ObjectId.Null;
@@ -2118,10 +2139,10 @@ namespace SWS.CAD.Base
// 处理插入结果
btr.AppendEntity(br);
- tr.AddNewlyCreatedDBObject(br, true);
+ tr.AddNewlyCreatedDBObject(br, true);
tr.Commit();
- oid = br.Id;
- }
+ oid = br.Id;
+ }
}
catch (Exception ex)
{
diff --git a/newFront/c#前端/SWS.CAD.Base/bin/Debug/log4net.config b/newFront/c#前端/SWS.CAD.Base/bin/Debug/log4net.config
index dc48092d..2e52c6ab 100644
--- a/newFront/c#前端/SWS.CAD.Base/bin/Debug/log4net.config
+++ b/newFront/c#前端/SWS.CAD.Base/bin/Debug/log4net.config
@@ -8,13 +8,30 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
@@ -29,7 +46,25 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -70,24 +105,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/newFront/c#前端/SWS.CAD/Commands.cs b/newFront/c#前端/SWS.CAD/Commands.cs
index a28f2dcd..d89cee31 100644
--- a/newFront/c#前端/SWS.CAD/Commands.cs
+++ b/newFront/c#前端/SWS.CAD/Commands.cs
@@ -25,6 +25,10 @@ using GlobalObject = SWS.Commons.GlobalObject;
using SWS.Model;
using SWS.Service;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
+using SWS.CAD.ViewModels;
+using SWS.CAD.Base;
+using System.Windows;
+using MessageBox = System.Windows.Forms.MessageBox;
[assembly: CommandClass(typeof(Commands))]
@@ -67,6 +71,15 @@ namespace SWS.CAD
panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
panel.Visible = true;
+ if (System.Windows.Application.Current == null)
+ {
+ var app = new System.Windows.Application
+ {
+ // 设置为显式关闭,防止窗口关闭时 Application 被自动终结
+ ShutdownMode = ShutdownMode.OnExplicitShutdown
+ };
+ }
+ GlobalObject.ClearLog();
}
catch (System.Exception e)
{
@@ -191,9 +204,17 @@ namespace SWS.CAD
login.ButtonStyle = RibbonButtonStyle.SmallWithText;
login.CommandHandler = new DelegateCommand(x =>
{
- var loginView = GlobalObject.container.Resolve();
- //Application.ShowModalDialog(Application.MainWindow,);// 用来显示WinForms对话框
- Application.ShowModalWindow(Application.MainWindow.Handle, loginView);//用来显示WPF的对话框,任务栏里可以看到2个Windows
+ try
+ {
+ var loginView = GlobalObject.container.Resolve();
+ //Application.ShowModalDialog(Application.MainWindow,);// 用来显示WinForms对话框
+ Application.ShowModalWindow(Application.MainWindow.Handle, loginView);//用来显示WPF的对话框,任务栏里可以看到2个Windows
+
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
});
login.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Login.png");
login.Id = "用户登录";
@@ -414,9 +435,106 @@ namespace SWS.CAD
btnSwitchbox.ToolTip = "分电箱";
btnSwitchbox.Text = "分电箱";
btnSwitchbox.ButtonStyle = RibbonButtonStyle.LargeWithText;
- btnSwitchbox.CommandHandler = new DelegateCommand(x =>
+ btnSwitchbox.CommandHandler = new DelegateCommand(async x =>
{
- MessageBox.Show("功能开发中...");
+ //if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ //{
+ // MessageBox.Show("请先登录系统并选择项目!");
+ // return;
+ //}
+ ////在SWS系统内打开且不是只读的图纸才可
+ //var dwgName = General.GetDwgName();
+ //var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ //if (dwgFile == null)
+ //{ return; }
+ //Document doc = Application.DocumentManager.MdiActiveDocument;
+ //Database db = doc.Database;
+ //Editor ed = doc.Editor;
+ ////选择的元素返回的属性信息
+ //var ResTagInfosByPixels = new Model.ec_objecttype();
+ //var listPropertys = new List();
+ ////获取服务接口
+ //var _objectTypeService = GlobalObject.container.Resolve();
+ //var _iOModuleService = GlobalObject.container.Resolve();
+ //// 持续选择直到获取有效电缆
+ //bool isValidCable = false;
+
+ //try
+ //{
+ // #region 选择电缆
+ // // 创建选择选项(禁用回车确认)
+ // PromptEntityOptions options = new PromptEntityOptions("\n请单击选择对象: ");
+ // options.AllowNone = false; // 禁止空选
+
+ // // 执行选择(直接单击生效)
+ // PromptEntityResult resultEntity = ed.GetEntity(options);
+ // //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ // while (resultEntity.Status == PromptStatus.OK)
+ // {
+ // using (Transaction tr = db.TransactionManager.StartTransaction())
+ // {
+ // // 获取选中的电缆实体
+ // Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ // //if (cable != null&&cable.XData != null)
+ // if (cable != null)
+ // {
+ // // 获取句柄(Handle 是字符串类型)
+ // var handId = (cable.Handle.ToString());
+ // var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ // if (res != null)
+ // {
+ // if (res.Count == 1)
+ // {
+ // var item = res[0];
+ // var objTypeName = item.ObjectTypeName;
+ // if (!objTypeName.Contains("电缆"))
+ // {
+ // ResTagInfosByPixels = item;
+ // isValidCable = true; // 校验通过
+ // ed.WriteMessage($"\n已选择对象:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ // }
+
+ // }
+ // }
+
+ // }
+ // tr.Commit();
+ // }
+ // if (isValidCable)
+ // {
+ // break;
+ // }
+ // else
+ // {
+ // ed.WriteMessage($"\n已选择电缆:");
+ // resultEntity = ed.GetEntity(options);
+ // }
+
+ // }
+ // #endregion
+ //}
+ //catch (System.Exception ex)
+ //{
+ // ed.WriteMessage($"\n错误: {ex.Message}");
+ //}
+
+ if (true)
+ {
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogSectionBox), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
});
btnSwitchbox.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Switchbox.png");
btnSwitchbox.Id = "分电箱";
@@ -569,7 +687,7 @@ namespace SWS.CAD
var handId = (cable.Handle.ToString());
_objectTypeService = GlobalObject.container.Resolve();
var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
- if (res != null)
+ if (res != null)
{
if (res.Count == 1)
{
@@ -584,7 +702,7 @@ namespace SWS.CAD
}
}
-
+
}
tr.Commit();
}
@@ -909,6 +1027,7 @@ namespace SWS.CAD
//选择的元素返回的属性信息
var ResTagInfosByPixels = new Model.ec_objecttype();
var listPropertys = new List();
+ //获取服务接口
var _objectTypeService = GlobalObject.container.Resolve();
var _iOModuleService = GlobalObject.container.Resolve();
// 持续选择直到获取有效电缆
@@ -981,7 +1100,7 @@ namespace SWS.CAD
//获取位号的电缆属性,判断是否设置电缆规格
var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
- if(string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
//if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
{
System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
@@ -1128,11 +1247,11 @@ namespace SWS.CAD
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
{
- Tag = Tag + (char)('A' + (n-1));
+ Tag = Tag + (char)('A' + (n - 1));
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
- Tag = (i+1)+"-"+ n.ToString();
+ Tag = (i + 1) + "-" + n.ToString();
}
break;
case "按电缆对编号"://一个电缆对中线号按顺序编号,另一个电缆对中线号重新从1开始编号
@@ -1146,7 +1265,7 @@ namespace SWS.CAD
}
else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
{
- Tag = (i+1) + "-" + (j+1).ToString();
+ Tag = (i + 1) + "-" + (j + 1).ToString();
}
break;
}
diff --git a/newFront/c#前端/SWS.CAD/Commands_BACKUP_547.cs b/newFront/c#前端/SWS.CAD/Commands_BACKUP_547.cs
new file mode 100644
index 00000000..39f172cf
--- /dev/null
+++ b/newFront/c#前端/SWS.CAD/Commands_BACKUP_547.cs
@@ -0,0 +1,1643 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Forms;
+using Bricscad.ApplicationServices;
+using Bricscad.EditorInput;
+using Bricscad.Ribbon;
+using Bricscad.Windows;
+using Prism.Events;
+using Prism.Ioc;
+using Prism.Services.Dialogs;
+using SWS.CAD;
+using SWS.CAD.CADFunc;
+using SWS.CAD.Event;
+using SWS.CAD.Views;
+using SWS.CAD.Views.Dialog;
+using Teigha.DatabaseServices;
+using Teigha.Runtime;
+using Telerik.Windows.Controls;
+using Unity;
+using Application = Bricscad.ApplicationServices.Application;
+using Panel = Bricscad.Windows.Panel;
+using GlobalObject = SWS.Commons.GlobalObject;
+using SWS.Model;
+using SWS.Service;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
+<<<<<<< HEAD
+using SWS.CAD.ViewModels;
+using SWS.CAD.Base;
+=======
+using System.Windows;
+using MessageBox = System.Windows.Forms.MessageBox;
+>>>>>>> c78178035f19e4ed599c777c75da005f0d2787ad
+
+
+[assembly: CommandClass(typeof(Commands))]
+[assembly: ExtensionApplication(typeof(Commands))]
+namespace SWS.CAD
+{
+ public partial class Commands : IExtensionApplication
+ {
+
+ public void Initialize()
+ {
+
+ try
+ {
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+ if (RibbonServices.RibbonPaletteSet == null)
+ RibbonServices.CreateRibbonPaletteSet(); //needed for ribbon samples
+ Start.RegisterTypes();
+ DockingTemplate dockTemplate = new DockingTemplate();
+ dockTemplate.DefaultStackId = "DI-ELEC_LDock"; //default stack is RDOCK panelset
+ dockTemplate.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate.DefaultDock = DockSides.Left; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView = GlobalObject.container.Resolve();
+ Panel panel = new Panel(nameof(LeftPanel), dockTemplate, drawingView);
+ panel.Title = "DI_左面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ AddTab();
+
+ DockingTemplate dockTemplate2 = new DockingTemplate();
+ dockTemplate2.DefaultStackId = "RDOCK"; //default stack is RDOCK panelset
+ dockTemplate2.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate2.DefaultDock = DockSides.Right; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView2 = GlobalObject.container.Resolve();
+ panel = new Panel(nameof(RightPanel), dockTemplate2, drawingView2);
+ panel.Title = "DI_右面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ if (System.Windows.Application.Current == null)
+ {
+ var app = new System.Windows.Application
+ {
+ // 设置为显式关闭,防止窗口关闭时 Application 被自动终结
+ ShutdownMode = ShutdownMode.OnExplicitShutdown
+ };
+ }
+ GlobalObject.ClearLog();
+ }
+ catch (System.Exception e)
+ {
+ Application.ShowAlertDialog(" An exception occurred in Initialize():\n" + e.ToString());
+ }
+ }
+
+
+
+ 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()
+ {
+ }
+
+ #region 显示属性弹窗
+ ///
+ /// 显示属性弹窗
+ ///
+ private ObservableCollection ShowPropertyMessage(string title, List listPropertys)
+ {
+
+ ObservableCollection ReslistPro = new ObservableCollection();
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ para.Add(GlobalObject.dialogPar.title.ToString(), title);
+ para.Add(GlobalObject.dialogPar.para1.ToString(), listPropertys);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogNewPositional), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+ ReslistPro = RES.Parameters.GetValue>(GlobalObject.dialogPar.para1.ToString());
+ }
+ else if (RES.Result == ButtonResult.No)
+ {
+ }
+ });
+ return ReslistPro;
+ }
+ #endregion
+
+ void AddTab()
+ {
+ RibbonControl rbnCtrl = ComponentManager.Ribbon; //整个上面都是ribbon,比如莫工做的电气系统,就是ribbon中的一个tab
+
+ if (rbnCtrl == null) return;
+ #region create Ribbon tab
+ RibbonTab tab1 = new RibbonTab();
+ tab1.Title = "智设电气(2)";
+ tab1.Id = "智设电气(2)";
+ rbnCtrl.Tabs.Add(tab1);//一个就行了
+ #endregion
+ //RibbonControl - RibbonTab - RibbonPanel - RibbonPanelSource - RibbonButton
+ #region Ribbon 项目操作
+ RibbonPanelSource userSource = new RibbonPanelSource();
+ userSource.Title = "项目操作";
+ userSource.Id = "项目操作";
+ RibbonPanel userPanel = new RibbonPanel();
+ userPanel.Source = userSource;
+ tab1.Panels.Add(userPanel);
+ #region buttons 选择项目
+ RibbonButton project = new RibbonButton();
+ project.ToolTip = "选择项目";
+ project.Text = "选择项目";
+ project.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ project.CommandHandler = new DelegateCommand(x =>
+ {
+ var projectView = GlobalObject.container.Resolve();
+ if (GlobalObject.userInfo != null)
+ {
+ Application.ShowModalWindow(Application.MainWindow.Handle, projectView);
+ }
+
+ });
+ project.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"OpenProject.png");
+ project.Id = "选择项目";
+ userSource.Items.Add(project);
+ #endregion
+ #region buttons 刷新项目
+ RibbonButton btnRefresh = new RibbonButton();
+ btnRefresh.ToolTip = "刷新项目";
+ btnRefresh.Text = "刷新项目";
+ btnRefresh.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnRefresh.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefresh.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshProject.png");
+ btnRefresh.Id = "刷新项目";
+ userSource.Items.Add(btnRefresh);
+ #endregion
+
+ //垂直排列按钮panel
+ RibbonRowPanel ribbonRowPanel = new RibbonRowPanel();
+
+ #region buttons 用户登录
+
+ RibbonButton login = new RibbonButton();
+ login.ToolTip = "用户登录";
+ login.Text = "用户登录";
+ login.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ login.CommandHandler = new DelegateCommand(x =>
+ {
+ try
+ {
+ var loginView = GlobalObject.container.Resolve();
+ //Application.ShowModalDialog(Application.MainWindow,);// 用来显示WinForms对话框
+ Application.ShowModalWindow(Application.MainWindow.Handle, loginView);//用来显示WPF的对话框,任务栏里可以看到2个Windows
+
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ });
+ login.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Login.png");
+ login.Id = "用户登录";
+ //userSource.Items.Add(login);
+ ribbonRowPanel.Items.Add(login);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 属性窗口
+ RibbonButton btnProperty = new RibbonButton();
+ btnProperty.ToolTip = "属性窗口";
+ btnProperty.Text = "属性窗口";
+ btnProperty.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnProperty.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnProperty.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Message.png");
+ btnProperty.Id = "属性窗口";
+ ribbonRowPanel.Items.Add(btnProperty);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 项目消息
+ RibbonButton UserNotification = new RibbonButton();
+ UserNotification.ToolTip = "项目消息";
+ UserNotification.Text = "项目消息";
+ UserNotification.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ UserNotification.CommandHandler = new DelegateCommand(x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ try
+ {
+ var View = GlobalObject.container.Resolve();
+ var eventAggregator = GlobalObject.container.Resolve();
+ eventAggregator.GetEvent().Publish(new List());
+ Application.ShowModalWindow(Application.MainWindow.Handle, View);
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+
+ });
+ UserNotification.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Message.png");
+ UserNotification.Id = "项目消息";
+ //userSource.Items.Add(UserNotification);
+ ribbonRowPanel.Items.Add(UserNotification);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+
+ userSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 快速计算
+ RibbonPanelSource calcSource = new RibbonPanelSource();
+ calcSource.Title = "快速计算";
+ calcSource.Id = "快速计算";
+ RibbonPanel calcPanel = new RibbonPanel();
+ calcPanel.Source = calcSource;
+ tab1.Panels.Add(calcPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 电缆压降
+ RibbonButton btnCableDrop = new RibbonButton();
+ btnCableDrop.ToolTip = "电缆压降";
+ btnCableDrop.Text = "电缆压降";
+ btnCableDrop.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableDrop.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCableDrop.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CalCable.png");
+ btnCableDrop.Id = "电缆压降";
+ ribbonRowPanel.Items.Add(btnCableDrop);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 启动顺序
+ RibbonButton btnCalBoot = new RibbonButton();
+ btnCalBoot.ToolTip = "启动顺序";
+ btnCalBoot.Text = "启动顺序";
+ btnCalBoot.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCalBoot.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCalBoot.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CalBoot.png");
+ btnCalBoot.Id = "启动顺序";
+ ribbonRowPanel.Items.Add(btnCalBoot);
+ #endregion
+ calcSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 设计成图
+ RibbonPanelSource designSource = new RibbonPanelSource();
+ designSource.Title = "设计成图";
+ designSource.Id = "设计成图";
+ RibbonPanel designPanel = new RibbonPanel();
+ designPanel.Source = designSource;
+ tab1.Panels.Add(designPanel);
+ //大按钮
+ #region buttons 绘照明线路
+ RibbonButton btnLightLine = new RibbonButton();
+ btnLightLine.ToolTip = "绘照明线路";
+ btnLightLine.Text = "绘照明线路";
+ btnLightLine.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnLightLine.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnLightLine.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"lightLine.png");
+ btnLightLine.Id = "绘照明线路";
+ designSource.Items.Add(btnLightLine);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 生成端子图
+ RibbonButton btnEquipmentjoin = new RibbonButton();
+ btnEquipmentjoin.ToolTip = "生成端子图";
+ btnEquipmentjoin.Text = "生成端子图";
+ btnEquipmentjoin.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnEquipmentjoin.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnEquipmentjoin.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Equipmentjoin.png");
+ btnEquipmentjoin.Id = "生成端子图";
+ ribbonRowPanel.Items.Add(btnEquipmentjoin);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成系统图
+ RibbonButton btnJoinSys = new RibbonButton();
+ btnJoinSys.ToolTip = "生成系统图";
+ btnJoinSys.Text = "生成系统图";
+ btnJoinSys.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnJoinSys.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnJoinSys.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"joinsys.png");
+ btnJoinSys.Id = "生成系统图";
+ ribbonRowPanel.Items.Add(btnJoinSys);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成OPC
+ RibbonButton btnOPC = new RibbonButton();
+ btnOPC.ToolTip = "生成OPC";
+ btnOPC.Text = "生成OPC";
+ btnOPC.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnOPC.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnOPC.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"OPC.png");
+ btnOPC.Id = "生成OPC";
+ ribbonRowPanel.Items.Add(btnOPC);
+ #endregion
+ designSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 生成布置图
+ RibbonButton btnPlaneLayout = new RibbonButton();
+ btnPlaneLayout.ToolTip = "生成布置图";
+ btnPlaneLayout.Text = "生成布置图";
+ btnPlaneLayout.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnPlaneLayout.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnPlaneLayout.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"PlaneLayout.png");
+ btnPlaneLayout.Id = "生成布置图";
+ ribbonRowPanel.Items.Add(btnPlaneLayout);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成链路系统图
+ RibbonButton btnEquipmentSys = new RibbonButton();
+ btnEquipmentSys.ToolTip = "生成链路系统图";
+ btnEquipmentSys.Text = "生成链路系统图";
+ btnEquipmentSys.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnEquipmentSys.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnEquipmentSys.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"EquipmentSys.png");
+ btnEquipmentSys.Id = "生成链路系统图";
+ ribbonRowPanel.Items.Add(btnEquipmentSys);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 照明回路开关
+ RibbonButton btnBatchSwitch = new RibbonButton();
+ btnBatchSwitch.ToolTip = "照明回路开关";
+ btnBatchSwitch.Text = "照明回路开关";
+ btnBatchSwitch.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnBatchSwitch.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnBatchSwitch.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"BatchSwitch.png");
+ btnBatchSwitch.Id = "照明回路开关";
+ ribbonRowPanel.Items.Add(btnBatchSwitch);
+ #endregion
+ designSource.Items.Add(ribbonRowPanel);
+
+ #endregion
+
+ #region Ribbon 数据管理
+ RibbonPanelSource dataSource = new RibbonPanelSource();
+ dataSource.Title = "数据管理";
+ dataSource.Id = "数据管理";
+ RibbonPanel dataPanel = new RibbonPanel();
+ dataPanel.Source = dataSource;
+ tab1.Panels.Add(dataPanel);
+ //大按钮
+ #region buttons 分电箱
+ RibbonButton btnSwitchbox = new RibbonButton();
+ btnSwitchbox.ToolTip = "分电箱";
+ btnSwitchbox.Text = "分电箱";
+ btnSwitchbox.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnSwitchbox.CommandHandler = new DelegateCommand(async x =>
+ {
+ //if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ //{
+ // MessageBox.Show("请先登录系统并选择项目!");
+ // return;
+ //}
+ ////在SWS系统内打开且不是只读的图纸才可
+ //var dwgName = General.GetDwgName();
+ //var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ //if (dwgFile == null)
+ //{ return; }
+ //Document doc = Application.DocumentManager.MdiActiveDocument;
+ //Database db = doc.Database;
+ //Editor ed = doc.Editor;
+ ////选择的元素返回的属性信息
+ //var ResTagInfosByPixels = new Model.ec_objecttype();
+ //var listPropertys = new List();
+ ////获取服务接口
+ //var _objectTypeService = GlobalObject.container.Resolve();
+ //var _iOModuleService = GlobalObject.container.Resolve();
+ //// 持续选择直到获取有效电缆
+ //bool isValidCable = false;
+
+ //try
+ //{
+ // #region 选择电缆
+ // // 创建选择选项(禁用回车确认)
+ // PromptEntityOptions options = new PromptEntityOptions("\n请单击选择对象: ");
+ // options.AllowNone = false; // 禁止空选
+
+ // // 执行选择(直接单击生效)
+ // PromptEntityResult resultEntity = ed.GetEntity(options);
+ // //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ // while (resultEntity.Status == PromptStatus.OK)
+ // {
+ // using (Transaction tr = db.TransactionManager.StartTransaction())
+ // {
+ // // 获取选中的电缆实体
+ // Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ // //if (cable != null&&cable.XData != null)
+ // if (cable != null)
+ // {
+ // // 获取句柄(Handle 是字符串类型)
+ // var handId = (cable.Handle.ToString());
+ // var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ // if (res != null)
+ // {
+ // if (res.Count == 1)
+ // {
+ // var item = res[0];
+ // var objTypeName = item.ObjectTypeName;
+ // if (!objTypeName.Contains("电缆"))
+ // {
+ // ResTagInfosByPixels = item;
+ // isValidCable = true; // 校验通过
+ // ed.WriteMessage($"\n已选择对象:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ // }
+
+ // }
+ // }
+
+ // }
+ // tr.Commit();
+ // }
+ // if (isValidCable)
+ // {
+ // break;
+ // }
+ // else
+ // {
+ // ed.WriteMessage($"\n已选择电缆:");
+ // resultEntity = ed.GetEntity(options);
+ // }
+
+ // }
+ // #endregion
+ //}
+ //catch (System.Exception ex)
+ //{
+ // ed.WriteMessage($"\n错误: {ex.Message}");
+ //}
+
+ if (true)
+ {
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogSectionBox), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ });
+ btnSwitchbox.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Switchbox.png");
+ btnSwitchbox.Id = "分电箱";
+ dataSource.Items.Add(btnSwitchbox);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 平行电缆
+ RibbonButton btnParallel = new RibbonButton();
+ btnParallel.ToolTip = "平行电缆";
+ btnParallel.Text = "平行电缆";
+ btnParallel.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnParallel.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ #region 平行电缆
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ if (string.IsNullOrEmpty(GlobalObject.currentTagNumber))
+ { return; }
+ //选择集数量只有1才行
+ int count = General.SelectedCount();
+ if (count != 1)
+ {
+ MessageBox.Show("请选择1个电缆!");
+ return;
+ }
+ //var listHandid = General.GetSelectedHandles();
+ //if (listHandid.Count != 1)
+ //{
+ // MessageBox.Show("请选择1个电缆!");
+ // return;
+ //}
+ //var tagNumber = listHandid[0];
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var res = await _objectTypeService.GetTagInfosByTags(GlobalObject.currentTagNumber);
+ if (!res.Any())
+ {
+ //MessageBox.Show("获取位号数据异常:");
+ return;
+ }
+ if (!GlobalObject.IsCable(res[0]))
+ {
+ MessageBox.Show("选中的元素不是电缆!");
+ return;
+ }
+ //取“平行电缆”和“平行电缆位号”属性
+
+ var listPro = res[0].props;
+ var listTaginfo = res[0].tags[0].EngineDataProperty;
+ var pro1 = listPro.FirstOrDefault(a => a.PropertyName == "平行电缆");
+ var tag1 = listTaginfo.FirstOrDefault(a => a.PropertyName == "平行电缆");
+ var model1 = new propertyModel()
+ {
+ Id = tag1.EngineDataID,
+ DisplayText = pro1.PropertyName,
+ PropertyValue = tag1.PropertyValue,
+ DetailId = tag1.EngineDataPropertyID
+ };
+ var pro2 = listPro.FirstOrDefault(a => a.PropertyName == "平行电缆位号");
+ var tag2 = listTaginfo.FirstOrDefault(a => a.PropertyName == "平行电缆位号");
+ var model2 = new propertyModel()
+ {
+ Id = tag2.EngineDataID,
+ DisplayText = pro2.PropertyName,
+ PropertyValue = tag2.PropertyValue,
+ DetailId = tag2.EngineDataPropertyID,
+ Unit = "",
+ IsRefreshUI = true
+ };
+
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ para.Add(GlobalObject.dialogPar.info.ToString(), res[0]);
+ para.Add(GlobalObject.dialogPar.para1.ToString(), model1);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), model2);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogParallelCable), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ #endregion
+ });
+ btnParallel.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Parallel.png");
+ btnParallel.Id = "平行电缆";
+ ribbonRowPanel.Items.Add(btnParallel);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 电缆连接
+ RibbonButton btnCableConnect = new RibbonButton();
+ btnCableConnect.ToolTip = "电缆连接";
+ btnCableConnect.Text = "电缆连接";
+ btnCableConnect.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableConnect.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ #region 电缆连接
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ Document doc = Application.DocumentManager.MdiActiveDocument;
+ Database db = doc.Database;
+ Editor ed = doc.Editor;
+ //选择的元素返回的属性信息
+ var ResTagInfosByPixels = new Model.ec_objecttype();
+ var listPropertys = new List();
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var _iOModuleService = GlobalObject.container.Resolve();
+ // 持续选择直到获取有效电缆
+ bool isValidCable = false;
+
+ try
+ {
+ // 创建选择选项(禁用回车确认)
+ PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: ");
+ options.AllowNone = false; // 禁止空选
+
+ // 执行选择(直接单击生效)
+ PromptEntityResult resultEntity = ed.GetEntity(options);
+ //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ while (resultEntity.Status == PromptStatus.OK)
+ {
+ using (Transaction tr = db.TransactionManager.StartTransaction())
+ {
+ // 获取选中的电缆实体
+ Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ //if (cable != null&&cable.XData != null)
+ if (cable != null)
+ {
+ // 获取句柄(Handle 是字符串类型)
+ var handId = (cable.Handle.ToString());
+ _objectTypeService = GlobalObject.container.Resolve();
+ var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ if (res != null)
+ {
+ if (res.Count == 1)
+ {
+ var item = res[0];
+ var objTypeName = item.ObjectTypeName;
+ if (objTypeName.Contains("电缆"))
+ {
+ ResTagInfosByPixels = item;
+ isValidCable = true; // 校验通过
+ ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ }
+
+ }
+ }
+
+ }
+ tr.Commit();
+ }
+ if (isValidCable)
+ {
+ break;
+ }
+ else
+ {
+ ed.WriteMessage($"\n已选择电缆:");
+ resultEntity = ed.GetEntity(options);
+ }
+
+ }
+
+ //Thread.Sleep(2000);
+ if (isValidCable)
+ {
+ var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
+ CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
+ var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ //获取位号的电缆属性,判断是否设置电缆规格
+ var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
+ if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ {
+ System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
+
+ }
+ var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ //如果配置不存在
+ if (ResCableEngID == null)
+ {
+ listPropertys = new List();
+ System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
+ if (result == System.Windows.MessageBoxResult.OK)
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "homerun";//母线
+ ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault();
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ else
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "conventional";//常规电缆
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ }
+ if (ResCableEngID != null)
+ {
+
+ IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle;
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ //para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb");
+ para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle);
+
+ para.Add(GlobalObject.dialogPar.para1.ToString(), dwgFile.Id);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogCableConnection), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ ed.WriteMessage($"\n错误: {ex.Message}");
+ }
+
+
+ #endregion
+ });
+ btnCableConnect.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableConnect.png");
+ btnCableConnect.Id = "电缆连接";
+ ribbonRowPanel.Items.Add(btnCableConnect);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons IO分配
+ RibbonButton btnIO = new RibbonButton();
+ btnIO.ToolTip = "IO分配";
+ btnIO.Text = "IO分配";
+ btnIO.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnIO.CommandHandler = new DelegateCommand(x =>
+ {
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogIODistribution), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ });
+ btnIO.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"IO.png");
+ btnIO.Id = "IO分配";
+ ribbonRowPanel.Items.Add(btnIO);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 信号管理
+ RibbonButton btnSinalManage = new RibbonButton();
+ btnSinalManage.ToolTip = "信号管理";
+ btnSinalManage.Text = "信号管理";
+ btnSinalManage.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnSinalManage.CommandHandler = new DelegateCommand(x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(SWS.WPF.Views.DialogSignalManagement), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ });
+ btnSinalManage.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SinalManage.png");
+ btnSinalManage.Id = "信号管理";
+ ribbonRowPanel.Items.Add(btnSinalManage);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 信号预分配
+ RibbonButton btnCableSinal = new RibbonButton();
+ btnCableSinal.ToolTip = "信号预分配";
+ btnCableSinal.Text = "信号预分配";
+ btnCableSinal.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableSinal.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ Document doc = Application.DocumentManager.MdiActiveDocument;
+ Database db = doc.Database;
+ Editor ed = doc.Editor;
+ //选择的元素返回的属性信息
+ var ResTagInfosByPixels = new Model.ec_objecttype();
+ var listPropertys = new List();
+ //获取服务接口
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var _iOModuleService = GlobalObject.container.Resolve();
+ // 持续选择直到获取有效电缆
+ bool isValidCable = false;
+
+ try
+ {
+ #region 选择电缆
+ // 创建选择选项(禁用回车确认)
+ PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: ");
+ options.AllowNone = false; // 禁止空选
+
+ // 执行选择(直接单击生效)
+ PromptEntityResult resultEntity = ed.GetEntity(options);
+ //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ while (resultEntity.Status == PromptStatus.OK)
+ {
+ using (Transaction tr = db.TransactionManager.StartTransaction())
+ {
+ // 获取选中的电缆实体
+ Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ //if (cable != null&&cable.XData != null)
+ if (cable != null)
+ {
+ // 获取句柄(Handle 是字符串类型)
+ var handId = (cable.Handle.ToString());
+ var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ if (res != null)
+ {
+ if (res.Count == 1)
+ {
+ var item = res[0];
+ var objTypeName = item.ObjectTypeName;
+ if (objTypeName.Contains("电缆"))
+ {
+ ResTagInfosByPixels = item;
+ isValidCable = true; // 校验通过
+ ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ }
+
+ }
+ }
+
+ }
+ tr.Commit();
+ }
+ if (isValidCable)
+ {
+ break;
+ }
+ else
+ {
+ ed.WriteMessage($"\n已选择电缆:");
+ resultEntity = ed.GetEntity(options);
+ }
+
+ }
+ #endregion
+
+
+ //Thread.Sleep(2000);
+ if (isValidCable)
+ {
+ var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
+ CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
+ var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ //获取位号的电缆属性,判断是否设置电缆规格
+ var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
+ if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ {
+ System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
+
+ }
+ var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ //如果配置不存在
+ if (ResCableEngID == null)
+ {
+ listPropertys = new List();
+ System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
+ if (result == System.Windows.MessageBoxResult.OK)
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "homerun";//母线
+ ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault();
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ else
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "conventional";//常规电缆
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号"://所有的电缆对中的电芯一起编号
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号"://一个电缆对中线号按顺序编号,另一个电缆对中线号重新从1开始编号
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ }
+ if (ResCableEngID != null)
+ {
+
+ IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle;
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ //para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb");
+ para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle);
+
+ para.Add(GlobalObject.dialogPar.para1.ToString(), ResCableEngID);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogSignalPredistribution), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ ed.WriteMessage($"\n错误: {ex.Message}");
+ }
+ });
+ btnCableSinal.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableSinal.png");
+ btnCableSinal.Id = "信号预分配";
+ ribbonRowPanel.Items.Add(btnCableSinal);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 批量反向关联
+ RibbonButton btnRelevancy = new RibbonButton();
+ btnRelevancy.ToolTip = "批量反向关联";
+ btnRelevancy.Text = "批量反向关联";
+ btnRelevancy.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRelevancy.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRelevancy.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"relevancy.png");
+ btnRelevancy.Id = "批量反向关联";
+ ribbonRowPanel.Items.Add(btnRelevancy);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 系统图识别
+ RibbonButton btnGraphRec = new RibbonButton();
+ btnGraphRec.ToolTip = "系统图识别";
+ btnGraphRec.Text = "系统图识别";
+ btnGraphRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnGraphRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnGraphRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"GraphRec.png");
+ btnGraphRec.Id = "系统图识别";
+ ribbonRowPanel.Items.Add(btnGraphRec);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 竖向图识别
+ RibbonButton btnVerticalRec = new RibbonButton();
+ btnVerticalRec.ToolTip = "竖向图识别";
+ btnVerticalRec.Text = "竖向图识别";
+ btnVerticalRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnVerticalRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnVerticalRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"VerticalRec.png");
+ btnVerticalRec.Id = "竖向图识别";
+ ribbonRowPanel.Items.Add(btnVerticalRec);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 链路图识别
+ RibbonButton btnLightLineRec = new RibbonButton();
+ btnLightLineRec.ToolTip = "链路图识别";
+ btnLightLineRec.Text = "链路图识别";
+ btnLightLineRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnLightLineRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnLightLineRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"lightLine.png");
+ btnLightLineRec.Id = "链路图识别";
+ ribbonRowPanel.Items.Add(btnLightLineRec);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 图形刷新
+ RibbonPanelSource dwgRefreshSource = new RibbonPanelSource();
+ dwgRefreshSource.Title = "图形刷新";
+ dwgRefreshSource.Id = "图形刷新";
+ RibbonPanel dwgRefreshPanel = new RibbonPanel();
+ dwgRefreshPanel.Source = dwgRefreshSource;
+ tab1.Panels.Add(dwgRefreshPanel);
+ //大按钮
+ #region buttons 刷新标注
+ RibbonButton btnRefreshText = new RibbonButton();
+ btnRefreshText.ToolTip = "刷新标注";
+ btnRefreshText.Text = "刷新标注";
+ btnRefreshText.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnRefreshText.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshText.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshText.png");
+ btnRefreshText.Id = "刷新标注";
+ dwgRefreshSource.Items.Add(btnRefreshText);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 刷新元件
+ RibbonButton btnRefreshBlock = new RibbonButton();
+ btnRefreshBlock.ToolTip = "刷新元件";
+ btnRefreshBlock.Text = "刷新元件";
+ btnRefreshBlock.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshBlock.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshBlock.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshBlock.png");
+ btnRefreshBlock.Id = "刷新元件";
+ ribbonRowPanel.Items.Add(btnRefreshBlock);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新图框
+ RibbonButton btnRefreshFrame = new RibbonButton();
+ btnRefreshFrame.ToolTip = "刷新图框";
+ btnRefreshFrame.Text = "刷新图框";
+ btnRefreshFrame.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshFrame.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshFrame.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshFrame.png");
+ btnRefreshFrame.Id = "刷新图框";
+ ribbonRowPanel.Items.Add(btnRefreshFrame);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新连接
+ RibbonButton btnRefreshLink = new RibbonButton();
+ btnRefreshLink.ToolTip = "刷新连接";
+ btnRefreshLink.Text = "刷新连接";
+ btnRefreshLink.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshLink.CommandHandler = new DelegateCommand(x =>
+ {
+ var configView = GlobalObject.container.Resolve();
+ Application.ShowModalWindow(Application.MainWindow.Handle, configView);
+ });
+ btnRefreshLink.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshLink.png");
+ btnRefreshLink.Id = "刷新连接";
+ ribbonRowPanel.Items.Add(btnRefreshLink);
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 查看链路
+ RibbonButton btnShowLink = new RibbonButton();
+ btnShowLink.ToolTip = "查看链路";
+ btnShowLink.Text = "查看链路";
+ btnShowLink.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnShowLink.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnShowLink.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"ShowLink.png");
+ btnShowLink.Id = "查看链路";
+ ribbonRowPanel.Items.Add(btnShowLink);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新位置
+ RibbonButton btnUpdatePosition = new RibbonButton();
+ btnUpdatePosition.ToolTip = "刷新位置";
+ btnUpdatePosition.Text = "刷新位置";
+ btnUpdatePosition.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnUpdatePosition.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnUpdatePosition.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"UpdatePosition.png");
+ btnUpdatePosition.Id = "刷新位置";
+ ribbonRowPanel.Items.Add(btnUpdatePosition);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新坐标
+ RibbonButton btnRefreshPosition = new RibbonButton();
+ btnRefreshPosition.ToolTip = "刷新坐标";
+ btnRefreshPosition.Text = "刷新坐标";
+ btnRefreshPosition.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshPosition.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshPosition.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshPosition.png");
+ btnRefreshPosition.Id = "刷新坐标";
+ ribbonRowPanel.Items.Add(btnRefreshPosition);
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 图元高亮
+ RibbonButton btnActiveObject = new RibbonButton();
+ btnActiveObject.ToolTip = "图元高亮";
+ btnActiveObject.Text = "图元高亮";
+ btnActiveObject.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnActiveObject.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnActiveObject.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"ActiveObject.png");
+ btnActiveObject.Id = "图元高亮";
+ ribbonRowPanel.Items.Add(btnActiveObject);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 数据交换
+ RibbonPanelSource dataExchangeSource = new RibbonPanelSource();
+ dataExchangeSource.Title = "数据交换";
+ dataExchangeSource.Id = "数据交换";
+ RibbonPanel dataExchangePanel = new RibbonPanel();
+ dataExchangePanel.Source = dataExchangeSource;
+ tab1.Panels.Add(dataExchangePanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 元件导入
+ RibbonButton btnImput = new RibbonButton();
+ btnImput.ToolTip = "元件导入";
+ btnImput.Text = "元件导入";
+ btnImput.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnImput.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnImput.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Imput.png");
+ btnImput.Id = "元件导入";
+ ribbonRowPanel.Items.Add(btnImput);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 元件导出
+ RibbonButton btnExport = new RibbonButton();
+ btnExport.ToolTip = "元件导出";
+ btnExport.Text = "元件导出";
+ btnExport.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnExport.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnExport.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Export.png");
+ btnExport.Id = "元件导出";
+ ribbonRowPanel.Items.Add(btnExport);
+ #endregion
+ dataExchangeSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 电缆检查
+ RibbonButton btnCheckCable = new RibbonButton();
+ btnCheckCable.ToolTip = "电缆检查";
+ btnCheckCable.Text = "电缆检查";
+ btnCheckCable.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCheckCable.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCheckCable.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CheckCable.png");
+ btnCheckCable.Id = "电缆检查";
+ ribbonRowPanel.Items.Add(btnCheckCable);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 属性检查
+ RibbonButton btnPropertyCheck = new RibbonButton();
+ btnPropertyCheck.ToolTip = "属性检查";
+ btnPropertyCheck.Text = "属性检查";
+ btnPropertyCheck.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnPropertyCheck.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnPropertyCheck.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Property.png");
+ btnPropertyCheck.Id = "属性检查";
+ ribbonRowPanel.Items.Add(btnPropertyCheck);
+ #endregion
+ dataExchangeSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 软件配置
+ RibbonPanelSource systemSource = new RibbonPanelSource();
+ systemSource.Title = "软件配置";
+ systemSource.Id = "软件配置";
+ RibbonPanel systemPanel = new RibbonPanel();
+ systemPanel.Source = systemSource;
+ tab1.Panels.Add(systemPanel);
+ //下拉按钮列表
+ RibbonSplitButton splitButton = new RibbonSplitButton();
+ splitButton.Text = "软件配置";
+ splitButton.ShowText = true;
+ splitButton.ShowImage = true;
+ splitButton.IsVisible = true;
+ splitButton.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ #region buttons 绘图配置
+ RibbonButton btnDwgConfig = new RibbonButton();
+ btnDwgConfig.ToolTip = "绘图配置";
+ btnDwgConfig.Text = "绘图配置";
+ btnDwgConfig.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnDwgConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnDwgConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"DConfig.png");
+ btnDwgConfig.Id = "绘图配置";
+ splitButton.Items.Add(btnDwgConfig);
+ #endregion
+ #region buttons 标注配置
+ RibbonButton btnAaConfig = new RibbonButton();
+ btnAaConfig.ToolTip = "标注配置";
+ btnAaConfig.Text = "标注配置";
+ btnAaConfig.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnAaConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnAaConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"TConfig.png");
+ btnAaConfig.Id = "标注配置";
+ splitButton.Items.Add(btnAaConfig);
+ #endregion
+ #region buttons 系统配置
+ RibbonButton btnSystemConfig = new RibbonButton();
+ btnSystemConfig.ToolTip = "系统配置";
+ btnSystemConfig.Text = "系统配置";
+ btnSystemConfig.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnSystemConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ var configView = GlobalObject.container.Resolve();
+ Application.ShowModalWindow(Application.MainWindow.Handle, configView);
+ });
+ btnSystemConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SConfig.png");
+ btnSystemConfig.Id = "系统配置";
+ splitButton.Items.Add(btnSystemConfig);
+ #endregion
+ systemSource.Items.Add(splitButton);
+
+ #endregion
+ }
+
+ }
+}
+
+
+
+
+
diff --git a/newFront/c#前端/SWS.CAD/Commands_BACKUP_608.cs b/newFront/c#前端/SWS.CAD/Commands_BACKUP_608.cs
new file mode 100644
index 00000000..39f172cf
--- /dev/null
+++ b/newFront/c#前端/SWS.CAD/Commands_BACKUP_608.cs
@@ -0,0 +1,1643 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Forms;
+using Bricscad.ApplicationServices;
+using Bricscad.EditorInput;
+using Bricscad.Ribbon;
+using Bricscad.Windows;
+using Prism.Events;
+using Prism.Ioc;
+using Prism.Services.Dialogs;
+using SWS.CAD;
+using SWS.CAD.CADFunc;
+using SWS.CAD.Event;
+using SWS.CAD.Views;
+using SWS.CAD.Views.Dialog;
+using Teigha.DatabaseServices;
+using Teigha.Runtime;
+using Telerik.Windows.Controls;
+using Unity;
+using Application = Bricscad.ApplicationServices.Application;
+using Panel = Bricscad.Windows.Panel;
+using GlobalObject = SWS.Commons.GlobalObject;
+using SWS.Model;
+using SWS.Service;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
+<<<<<<< HEAD
+using SWS.CAD.ViewModels;
+using SWS.CAD.Base;
+=======
+using System.Windows;
+using MessageBox = System.Windows.Forms.MessageBox;
+>>>>>>> c78178035f19e4ed599c777c75da005f0d2787ad
+
+
+[assembly: CommandClass(typeof(Commands))]
+[assembly: ExtensionApplication(typeof(Commands))]
+namespace SWS.CAD
+{
+ public partial class Commands : IExtensionApplication
+ {
+
+ public void Initialize()
+ {
+
+ try
+ {
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+ if (RibbonServices.RibbonPaletteSet == null)
+ RibbonServices.CreateRibbonPaletteSet(); //needed for ribbon samples
+ Start.RegisterTypes();
+ DockingTemplate dockTemplate = new DockingTemplate();
+ dockTemplate.DefaultStackId = "DI-ELEC_LDock"; //default stack is RDOCK panelset
+ dockTemplate.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate.DefaultDock = DockSides.Left; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView = GlobalObject.container.Resolve();
+ Panel panel = new Panel(nameof(LeftPanel), dockTemplate, drawingView);
+ panel.Title = "DI_左面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ AddTab();
+
+ DockingTemplate dockTemplate2 = new DockingTemplate();
+ dockTemplate2.DefaultStackId = "RDOCK"; //default stack is RDOCK panelset
+ dockTemplate2.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate2.DefaultDock = DockSides.Right; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView2 = GlobalObject.container.Resolve();
+ panel = new Panel(nameof(RightPanel), dockTemplate2, drawingView2);
+ panel.Title = "DI_右面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ if (System.Windows.Application.Current == null)
+ {
+ var app = new System.Windows.Application
+ {
+ // 设置为显式关闭,防止窗口关闭时 Application 被自动终结
+ ShutdownMode = ShutdownMode.OnExplicitShutdown
+ };
+ }
+ GlobalObject.ClearLog();
+ }
+ catch (System.Exception e)
+ {
+ Application.ShowAlertDialog(" An exception occurred in Initialize():\n" + e.ToString());
+ }
+ }
+
+
+
+ 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()
+ {
+ }
+
+ #region 显示属性弹窗
+ ///
+ /// 显示属性弹窗
+ ///
+ private ObservableCollection ShowPropertyMessage(string title, List listPropertys)
+ {
+
+ ObservableCollection ReslistPro = new ObservableCollection();
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ para.Add(GlobalObject.dialogPar.title.ToString(), title);
+ para.Add(GlobalObject.dialogPar.para1.ToString(), listPropertys);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogNewPositional), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+ ReslistPro = RES.Parameters.GetValue>(GlobalObject.dialogPar.para1.ToString());
+ }
+ else if (RES.Result == ButtonResult.No)
+ {
+ }
+ });
+ return ReslistPro;
+ }
+ #endregion
+
+ void AddTab()
+ {
+ RibbonControl rbnCtrl = ComponentManager.Ribbon; //整个上面都是ribbon,比如莫工做的电气系统,就是ribbon中的一个tab
+
+ if (rbnCtrl == null) return;
+ #region create Ribbon tab
+ RibbonTab tab1 = new RibbonTab();
+ tab1.Title = "智设电气(2)";
+ tab1.Id = "智设电气(2)";
+ rbnCtrl.Tabs.Add(tab1);//一个就行了
+ #endregion
+ //RibbonControl - RibbonTab - RibbonPanel - RibbonPanelSource - RibbonButton
+ #region Ribbon 项目操作
+ RibbonPanelSource userSource = new RibbonPanelSource();
+ userSource.Title = "项目操作";
+ userSource.Id = "项目操作";
+ RibbonPanel userPanel = new RibbonPanel();
+ userPanel.Source = userSource;
+ tab1.Panels.Add(userPanel);
+ #region buttons 选择项目
+ RibbonButton project = new RibbonButton();
+ project.ToolTip = "选择项目";
+ project.Text = "选择项目";
+ project.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ project.CommandHandler = new DelegateCommand(x =>
+ {
+ var projectView = GlobalObject.container.Resolve();
+ if (GlobalObject.userInfo != null)
+ {
+ Application.ShowModalWindow(Application.MainWindow.Handle, projectView);
+ }
+
+ });
+ project.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"OpenProject.png");
+ project.Id = "选择项目";
+ userSource.Items.Add(project);
+ #endregion
+ #region buttons 刷新项目
+ RibbonButton btnRefresh = new RibbonButton();
+ btnRefresh.ToolTip = "刷新项目";
+ btnRefresh.Text = "刷新项目";
+ btnRefresh.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnRefresh.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefresh.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshProject.png");
+ btnRefresh.Id = "刷新项目";
+ userSource.Items.Add(btnRefresh);
+ #endregion
+
+ //垂直排列按钮panel
+ RibbonRowPanel ribbonRowPanel = new RibbonRowPanel();
+
+ #region buttons 用户登录
+
+ RibbonButton login = new RibbonButton();
+ login.ToolTip = "用户登录";
+ login.Text = "用户登录";
+ login.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ login.CommandHandler = new DelegateCommand(x =>
+ {
+ try
+ {
+ var loginView = GlobalObject.container.Resolve();
+ //Application.ShowModalDialog(Application.MainWindow,);// 用来显示WinForms对话框
+ Application.ShowModalWindow(Application.MainWindow.Handle, loginView);//用来显示WPF的对话框,任务栏里可以看到2个Windows
+
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ });
+ login.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Login.png");
+ login.Id = "用户登录";
+ //userSource.Items.Add(login);
+ ribbonRowPanel.Items.Add(login);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 属性窗口
+ RibbonButton btnProperty = new RibbonButton();
+ btnProperty.ToolTip = "属性窗口";
+ btnProperty.Text = "属性窗口";
+ btnProperty.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnProperty.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnProperty.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Message.png");
+ btnProperty.Id = "属性窗口";
+ ribbonRowPanel.Items.Add(btnProperty);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 项目消息
+ RibbonButton UserNotification = new RibbonButton();
+ UserNotification.ToolTip = "项目消息";
+ UserNotification.Text = "项目消息";
+ UserNotification.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ UserNotification.CommandHandler = new DelegateCommand(x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ try
+ {
+ var View = GlobalObject.container.Resolve();
+ var eventAggregator = GlobalObject.container.Resolve();
+ eventAggregator.GetEvent().Publish(new List());
+ Application.ShowModalWindow(Application.MainWindow.Handle, View);
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+
+ });
+ UserNotification.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Message.png");
+ UserNotification.Id = "项目消息";
+ //userSource.Items.Add(UserNotification);
+ ribbonRowPanel.Items.Add(UserNotification);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+
+ userSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 快速计算
+ RibbonPanelSource calcSource = new RibbonPanelSource();
+ calcSource.Title = "快速计算";
+ calcSource.Id = "快速计算";
+ RibbonPanel calcPanel = new RibbonPanel();
+ calcPanel.Source = calcSource;
+ tab1.Panels.Add(calcPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 电缆压降
+ RibbonButton btnCableDrop = new RibbonButton();
+ btnCableDrop.ToolTip = "电缆压降";
+ btnCableDrop.Text = "电缆压降";
+ btnCableDrop.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableDrop.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCableDrop.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CalCable.png");
+ btnCableDrop.Id = "电缆压降";
+ ribbonRowPanel.Items.Add(btnCableDrop);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 启动顺序
+ RibbonButton btnCalBoot = new RibbonButton();
+ btnCalBoot.ToolTip = "启动顺序";
+ btnCalBoot.Text = "启动顺序";
+ btnCalBoot.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCalBoot.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCalBoot.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CalBoot.png");
+ btnCalBoot.Id = "启动顺序";
+ ribbonRowPanel.Items.Add(btnCalBoot);
+ #endregion
+ calcSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 设计成图
+ RibbonPanelSource designSource = new RibbonPanelSource();
+ designSource.Title = "设计成图";
+ designSource.Id = "设计成图";
+ RibbonPanel designPanel = new RibbonPanel();
+ designPanel.Source = designSource;
+ tab1.Panels.Add(designPanel);
+ //大按钮
+ #region buttons 绘照明线路
+ RibbonButton btnLightLine = new RibbonButton();
+ btnLightLine.ToolTip = "绘照明线路";
+ btnLightLine.Text = "绘照明线路";
+ btnLightLine.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnLightLine.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnLightLine.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"lightLine.png");
+ btnLightLine.Id = "绘照明线路";
+ designSource.Items.Add(btnLightLine);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 生成端子图
+ RibbonButton btnEquipmentjoin = new RibbonButton();
+ btnEquipmentjoin.ToolTip = "生成端子图";
+ btnEquipmentjoin.Text = "生成端子图";
+ btnEquipmentjoin.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnEquipmentjoin.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnEquipmentjoin.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Equipmentjoin.png");
+ btnEquipmentjoin.Id = "生成端子图";
+ ribbonRowPanel.Items.Add(btnEquipmentjoin);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成系统图
+ RibbonButton btnJoinSys = new RibbonButton();
+ btnJoinSys.ToolTip = "生成系统图";
+ btnJoinSys.Text = "生成系统图";
+ btnJoinSys.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnJoinSys.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnJoinSys.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"joinsys.png");
+ btnJoinSys.Id = "生成系统图";
+ ribbonRowPanel.Items.Add(btnJoinSys);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成OPC
+ RibbonButton btnOPC = new RibbonButton();
+ btnOPC.ToolTip = "生成OPC";
+ btnOPC.Text = "生成OPC";
+ btnOPC.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnOPC.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnOPC.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"OPC.png");
+ btnOPC.Id = "生成OPC";
+ ribbonRowPanel.Items.Add(btnOPC);
+ #endregion
+ designSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 生成布置图
+ RibbonButton btnPlaneLayout = new RibbonButton();
+ btnPlaneLayout.ToolTip = "生成布置图";
+ btnPlaneLayout.Text = "生成布置图";
+ btnPlaneLayout.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnPlaneLayout.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnPlaneLayout.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"PlaneLayout.png");
+ btnPlaneLayout.Id = "生成布置图";
+ ribbonRowPanel.Items.Add(btnPlaneLayout);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成链路系统图
+ RibbonButton btnEquipmentSys = new RibbonButton();
+ btnEquipmentSys.ToolTip = "生成链路系统图";
+ btnEquipmentSys.Text = "生成链路系统图";
+ btnEquipmentSys.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnEquipmentSys.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnEquipmentSys.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"EquipmentSys.png");
+ btnEquipmentSys.Id = "生成链路系统图";
+ ribbonRowPanel.Items.Add(btnEquipmentSys);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 照明回路开关
+ RibbonButton btnBatchSwitch = new RibbonButton();
+ btnBatchSwitch.ToolTip = "照明回路开关";
+ btnBatchSwitch.Text = "照明回路开关";
+ btnBatchSwitch.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnBatchSwitch.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnBatchSwitch.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"BatchSwitch.png");
+ btnBatchSwitch.Id = "照明回路开关";
+ ribbonRowPanel.Items.Add(btnBatchSwitch);
+ #endregion
+ designSource.Items.Add(ribbonRowPanel);
+
+ #endregion
+
+ #region Ribbon 数据管理
+ RibbonPanelSource dataSource = new RibbonPanelSource();
+ dataSource.Title = "数据管理";
+ dataSource.Id = "数据管理";
+ RibbonPanel dataPanel = new RibbonPanel();
+ dataPanel.Source = dataSource;
+ tab1.Panels.Add(dataPanel);
+ //大按钮
+ #region buttons 分电箱
+ RibbonButton btnSwitchbox = new RibbonButton();
+ btnSwitchbox.ToolTip = "分电箱";
+ btnSwitchbox.Text = "分电箱";
+ btnSwitchbox.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnSwitchbox.CommandHandler = new DelegateCommand(async x =>
+ {
+ //if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ //{
+ // MessageBox.Show("请先登录系统并选择项目!");
+ // return;
+ //}
+ ////在SWS系统内打开且不是只读的图纸才可
+ //var dwgName = General.GetDwgName();
+ //var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ //if (dwgFile == null)
+ //{ return; }
+ //Document doc = Application.DocumentManager.MdiActiveDocument;
+ //Database db = doc.Database;
+ //Editor ed = doc.Editor;
+ ////选择的元素返回的属性信息
+ //var ResTagInfosByPixels = new Model.ec_objecttype();
+ //var listPropertys = new List();
+ ////获取服务接口
+ //var _objectTypeService = GlobalObject.container.Resolve();
+ //var _iOModuleService = GlobalObject.container.Resolve();
+ //// 持续选择直到获取有效电缆
+ //bool isValidCable = false;
+
+ //try
+ //{
+ // #region 选择电缆
+ // // 创建选择选项(禁用回车确认)
+ // PromptEntityOptions options = new PromptEntityOptions("\n请单击选择对象: ");
+ // options.AllowNone = false; // 禁止空选
+
+ // // 执行选择(直接单击生效)
+ // PromptEntityResult resultEntity = ed.GetEntity(options);
+ // //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ // while (resultEntity.Status == PromptStatus.OK)
+ // {
+ // using (Transaction tr = db.TransactionManager.StartTransaction())
+ // {
+ // // 获取选中的电缆实体
+ // Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ // //if (cable != null&&cable.XData != null)
+ // if (cable != null)
+ // {
+ // // 获取句柄(Handle 是字符串类型)
+ // var handId = (cable.Handle.ToString());
+ // var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ // if (res != null)
+ // {
+ // if (res.Count == 1)
+ // {
+ // var item = res[0];
+ // var objTypeName = item.ObjectTypeName;
+ // if (!objTypeName.Contains("电缆"))
+ // {
+ // ResTagInfosByPixels = item;
+ // isValidCable = true; // 校验通过
+ // ed.WriteMessage($"\n已选择对象:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ // }
+
+ // }
+ // }
+
+ // }
+ // tr.Commit();
+ // }
+ // if (isValidCable)
+ // {
+ // break;
+ // }
+ // else
+ // {
+ // ed.WriteMessage($"\n已选择电缆:");
+ // resultEntity = ed.GetEntity(options);
+ // }
+
+ // }
+ // #endregion
+ //}
+ //catch (System.Exception ex)
+ //{
+ // ed.WriteMessage($"\n错误: {ex.Message}");
+ //}
+
+ if (true)
+ {
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogSectionBox), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ });
+ btnSwitchbox.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Switchbox.png");
+ btnSwitchbox.Id = "分电箱";
+ dataSource.Items.Add(btnSwitchbox);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 平行电缆
+ RibbonButton btnParallel = new RibbonButton();
+ btnParallel.ToolTip = "平行电缆";
+ btnParallel.Text = "平行电缆";
+ btnParallel.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnParallel.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ #region 平行电缆
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ if (string.IsNullOrEmpty(GlobalObject.currentTagNumber))
+ { return; }
+ //选择集数量只有1才行
+ int count = General.SelectedCount();
+ if (count != 1)
+ {
+ MessageBox.Show("请选择1个电缆!");
+ return;
+ }
+ //var listHandid = General.GetSelectedHandles();
+ //if (listHandid.Count != 1)
+ //{
+ // MessageBox.Show("请选择1个电缆!");
+ // return;
+ //}
+ //var tagNumber = listHandid[0];
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var res = await _objectTypeService.GetTagInfosByTags(GlobalObject.currentTagNumber);
+ if (!res.Any())
+ {
+ //MessageBox.Show("获取位号数据异常:");
+ return;
+ }
+ if (!GlobalObject.IsCable(res[0]))
+ {
+ MessageBox.Show("选中的元素不是电缆!");
+ return;
+ }
+ //取“平行电缆”和“平行电缆位号”属性
+
+ var listPro = res[0].props;
+ var listTaginfo = res[0].tags[0].EngineDataProperty;
+ var pro1 = listPro.FirstOrDefault(a => a.PropertyName == "平行电缆");
+ var tag1 = listTaginfo.FirstOrDefault(a => a.PropertyName == "平行电缆");
+ var model1 = new propertyModel()
+ {
+ Id = tag1.EngineDataID,
+ DisplayText = pro1.PropertyName,
+ PropertyValue = tag1.PropertyValue,
+ DetailId = tag1.EngineDataPropertyID
+ };
+ var pro2 = listPro.FirstOrDefault(a => a.PropertyName == "平行电缆位号");
+ var tag2 = listTaginfo.FirstOrDefault(a => a.PropertyName == "平行电缆位号");
+ var model2 = new propertyModel()
+ {
+ Id = tag2.EngineDataID,
+ DisplayText = pro2.PropertyName,
+ PropertyValue = tag2.PropertyValue,
+ DetailId = tag2.EngineDataPropertyID,
+ Unit = "",
+ IsRefreshUI = true
+ };
+
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ para.Add(GlobalObject.dialogPar.info.ToString(), res[0]);
+ para.Add(GlobalObject.dialogPar.para1.ToString(), model1);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), model2);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogParallelCable), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ #endregion
+ });
+ btnParallel.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Parallel.png");
+ btnParallel.Id = "平行电缆";
+ ribbonRowPanel.Items.Add(btnParallel);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 电缆连接
+ RibbonButton btnCableConnect = new RibbonButton();
+ btnCableConnect.ToolTip = "电缆连接";
+ btnCableConnect.Text = "电缆连接";
+ btnCableConnect.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableConnect.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ #region 电缆连接
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ Document doc = Application.DocumentManager.MdiActiveDocument;
+ Database db = doc.Database;
+ Editor ed = doc.Editor;
+ //选择的元素返回的属性信息
+ var ResTagInfosByPixels = new Model.ec_objecttype();
+ var listPropertys = new List();
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var _iOModuleService = GlobalObject.container.Resolve();
+ // 持续选择直到获取有效电缆
+ bool isValidCable = false;
+
+ try
+ {
+ // 创建选择选项(禁用回车确认)
+ PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: ");
+ options.AllowNone = false; // 禁止空选
+
+ // 执行选择(直接单击生效)
+ PromptEntityResult resultEntity = ed.GetEntity(options);
+ //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ while (resultEntity.Status == PromptStatus.OK)
+ {
+ using (Transaction tr = db.TransactionManager.StartTransaction())
+ {
+ // 获取选中的电缆实体
+ Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ //if (cable != null&&cable.XData != null)
+ if (cable != null)
+ {
+ // 获取句柄(Handle 是字符串类型)
+ var handId = (cable.Handle.ToString());
+ _objectTypeService = GlobalObject.container.Resolve();
+ var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ if (res != null)
+ {
+ if (res.Count == 1)
+ {
+ var item = res[0];
+ var objTypeName = item.ObjectTypeName;
+ if (objTypeName.Contains("电缆"))
+ {
+ ResTagInfosByPixels = item;
+ isValidCable = true; // 校验通过
+ ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ }
+
+ }
+ }
+
+ }
+ tr.Commit();
+ }
+ if (isValidCable)
+ {
+ break;
+ }
+ else
+ {
+ ed.WriteMessage($"\n已选择电缆:");
+ resultEntity = ed.GetEntity(options);
+ }
+
+ }
+
+ //Thread.Sleep(2000);
+ if (isValidCable)
+ {
+ var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
+ CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
+ var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ //获取位号的电缆属性,判断是否设置电缆规格
+ var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
+ if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ {
+ System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
+
+ }
+ var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ //如果配置不存在
+ if (ResCableEngID == null)
+ {
+ listPropertys = new List();
+ System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
+ if (result == System.Windows.MessageBoxResult.OK)
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "homerun";//母线
+ ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault();
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ else
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "conventional";//常规电缆
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ }
+ if (ResCableEngID != null)
+ {
+
+ IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle;
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ //para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb");
+ para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle);
+
+ para.Add(GlobalObject.dialogPar.para1.ToString(), dwgFile.Id);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogCableConnection), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ ed.WriteMessage($"\n错误: {ex.Message}");
+ }
+
+
+ #endregion
+ });
+ btnCableConnect.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableConnect.png");
+ btnCableConnect.Id = "电缆连接";
+ ribbonRowPanel.Items.Add(btnCableConnect);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons IO分配
+ RibbonButton btnIO = new RibbonButton();
+ btnIO.ToolTip = "IO分配";
+ btnIO.Text = "IO分配";
+ btnIO.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnIO.CommandHandler = new DelegateCommand(x =>
+ {
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogIODistribution), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ });
+ btnIO.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"IO.png");
+ btnIO.Id = "IO分配";
+ ribbonRowPanel.Items.Add(btnIO);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 信号管理
+ RibbonButton btnSinalManage = new RibbonButton();
+ btnSinalManage.ToolTip = "信号管理";
+ btnSinalManage.Text = "信号管理";
+ btnSinalManage.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnSinalManage.CommandHandler = new DelegateCommand(x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(SWS.WPF.Views.DialogSignalManagement), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ });
+ btnSinalManage.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SinalManage.png");
+ btnSinalManage.Id = "信号管理";
+ ribbonRowPanel.Items.Add(btnSinalManage);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 信号预分配
+ RibbonButton btnCableSinal = new RibbonButton();
+ btnCableSinal.ToolTip = "信号预分配";
+ btnCableSinal.Text = "信号预分配";
+ btnCableSinal.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableSinal.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ Document doc = Application.DocumentManager.MdiActiveDocument;
+ Database db = doc.Database;
+ Editor ed = doc.Editor;
+ //选择的元素返回的属性信息
+ var ResTagInfosByPixels = new Model.ec_objecttype();
+ var listPropertys = new List();
+ //获取服务接口
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var _iOModuleService = GlobalObject.container.Resolve();
+ // 持续选择直到获取有效电缆
+ bool isValidCable = false;
+
+ try
+ {
+ #region 选择电缆
+ // 创建选择选项(禁用回车确认)
+ PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: ");
+ options.AllowNone = false; // 禁止空选
+
+ // 执行选择(直接单击生效)
+ PromptEntityResult resultEntity = ed.GetEntity(options);
+ //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ while (resultEntity.Status == PromptStatus.OK)
+ {
+ using (Transaction tr = db.TransactionManager.StartTransaction())
+ {
+ // 获取选中的电缆实体
+ Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ //if (cable != null&&cable.XData != null)
+ if (cable != null)
+ {
+ // 获取句柄(Handle 是字符串类型)
+ var handId = (cable.Handle.ToString());
+ var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ if (res != null)
+ {
+ if (res.Count == 1)
+ {
+ var item = res[0];
+ var objTypeName = item.ObjectTypeName;
+ if (objTypeName.Contains("电缆"))
+ {
+ ResTagInfosByPixels = item;
+ isValidCable = true; // 校验通过
+ ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ }
+
+ }
+ }
+
+ }
+ tr.Commit();
+ }
+ if (isValidCable)
+ {
+ break;
+ }
+ else
+ {
+ ed.WriteMessage($"\n已选择电缆:");
+ resultEntity = ed.GetEntity(options);
+ }
+
+ }
+ #endregion
+
+
+ //Thread.Sleep(2000);
+ if (isValidCable)
+ {
+ var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
+ CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
+ var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ //获取位号的电缆属性,判断是否设置电缆规格
+ var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
+ if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ {
+ System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
+
+ }
+ var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ //如果配置不存在
+ if (ResCableEngID == null)
+ {
+ listPropertys = new List();
+ System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
+ if (result == System.Windows.MessageBoxResult.OK)
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "homerun";//母线
+ ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault();
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ else
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "conventional";//常规电缆
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号"://所有的电缆对中的电芯一起编号
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号"://一个电缆对中线号按顺序编号,另一个电缆对中线号重新从1开始编号
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ }
+ if (ResCableEngID != null)
+ {
+
+ IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle;
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ //para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb");
+ para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle);
+
+ para.Add(GlobalObject.dialogPar.para1.ToString(), ResCableEngID);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogSignalPredistribution), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ ed.WriteMessage($"\n错误: {ex.Message}");
+ }
+ });
+ btnCableSinal.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableSinal.png");
+ btnCableSinal.Id = "信号预分配";
+ ribbonRowPanel.Items.Add(btnCableSinal);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 批量反向关联
+ RibbonButton btnRelevancy = new RibbonButton();
+ btnRelevancy.ToolTip = "批量反向关联";
+ btnRelevancy.Text = "批量反向关联";
+ btnRelevancy.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRelevancy.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRelevancy.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"relevancy.png");
+ btnRelevancy.Id = "批量反向关联";
+ ribbonRowPanel.Items.Add(btnRelevancy);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 系统图识别
+ RibbonButton btnGraphRec = new RibbonButton();
+ btnGraphRec.ToolTip = "系统图识别";
+ btnGraphRec.Text = "系统图识别";
+ btnGraphRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnGraphRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnGraphRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"GraphRec.png");
+ btnGraphRec.Id = "系统图识别";
+ ribbonRowPanel.Items.Add(btnGraphRec);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 竖向图识别
+ RibbonButton btnVerticalRec = new RibbonButton();
+ btnVerticalRec.ToolTip = "竖向图识别";
+ btnVerticalRec.Text = "竖向图识别";
+ btnVerticalRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnVerticalRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnVerticalRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"VerticalRec.png");
+ btnVerticalRec.Id = "竖向图识别";
+ ribbonRowPanel.Items.Add(btnVerticalRec);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 链路图识别
+ RibbonButton btnLightLineRec = new RibbonButton();
+ btnLightLineRec.ToolTip = "链路图识别";
+ btnLightLineRec.Text = "链路图识别";
+ btnLightLineRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnLightLineRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnLightLineRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"lightLine.png");
+ btnLightLineRec.Id = "链路图识别";
+ ribbonRowPanel.Items.Add(btnLightLineRec);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 图形刷新
+ RibbonPanelSource dwgRefreshSource = new RibbonPanelSource();
+ dwgRefreshSource.Title = "图形刷新";
+ dwgRefreshSource.Id = "图形刷新";
+ RibbonPanel dwgRefreshPanel = new RibbonPanel();
+ dwgRefreshPanel.Source = dwgRefreshSource;
+ tab1.Panels.Add(dwgRefreshPanel);
+ //大按钮
+ #region buttons 刷新标注
+ RibbonButton btnRefreshText = new RibbonButton();
+ btnRefreshText.ToolTip = "刷新标注";
+ btnRefreshText.Text = "刷新标注";
+ btnRefreshText.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnRefreshText.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshText.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshText.png");
+ btnRefreshText.Id = "刷新标注";
+ dwgRefreshSource.Items.Add(btnRefreshText);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 刷新元件
+ RibbonButton btnRefreshBlock = new RibbonButton();
+ btnRefreshBlock.ToolTip = "刷新元件";
+ btnRefreshBlock.Text = "刷新元件";
+ btnRefreshBlock.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshBlock.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshBlock.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshBlock.png");
+ btnRefreshBlock.Id = "刷新元件";
+ ribbonRowPanel.Items.Add(btnRefreshBlock);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新图框
+ RibbonButton btnRefreshFrame = new RibbonButton();
+ btnRefreshFrame.ToolTip = "刷新图框";
+ btnRefreshFrame.Text = "刷新图框";
+ btnRefreshFrame.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshFrame.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshFrame.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshFrame.png");
+ btnRefreshFrame.Id = "刷新图框";
+ ribbonRowPanel.Items.Add(btnRefreshFrame);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新连接
+ RibbonButton btnRefreshLink = new RibbonButton();
+ btnRefreshLink.ToolTip = "刷新连接";
+ btnRefreshLink.Text = "刷新连接";
+ btnRefreshLink.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshLink.CommandHandler = new DelegateCommand(x =>
+ {
+ var configView = GlobalObject.container.Resolve();
+ Application.ShowModalWindow(Application.MainWindow.Handle, configView);
+ });
+ btnRefreshLink.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshLink.png");
+ btnRefreshLink.Id = "刷新连接";
+ ribbonRowPanel.Items.Add(btnRefreshLink);
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 查看链路
+ RibbonButton btnShowLink = new RibbonButton();
+ btnShowLink.ToolTip = "查看链路";
+ btnShowLink.Text = "查看链路";
+ btnShowLink.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnShowLink.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnShowLink.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"ShowLink.png");
+ btnShowLink.Id = "查看链路";
+ ribbonRowPanel.Items.Add(btnShowLink);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新位置
+ RibbonButton btnUpdatePosition = new RibbonButton();
+ btnUpdatePosition.ToolTip = "刷新位置";
+ btnUpdatePosition.Text = "刷新位置";
+ btnUpdatePosition.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnUpdatePosition.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnUpdatePosition.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"UpdatePosition.png");
+ btnUpdatePosition.Id = "刷新位置";
+ ribbonRowPanel.Items.Add(btnUpdatePosition);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新坐标
+ RibbonButton btnRefreshPosition = new RibbonButton();
+ btnRefreshPosition.ToolTip = "刷新坐标";
+ btnRefreshPosition.Text = "刷新坐标";
+ btnRefreshPosition.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshPosition.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshPosition.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshPosition.png");
+ btnRefreshPosition.Id = "刷新坐标";
+ ribbonRowPanel.Items.Add(btnRefreshPosition);
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 图元高亮
+ RibbonButton btnActiveObject = new RibbonButton();
+ btnActiveObject.ToolTip = "图元高亮";
+ btnActiveObject.Text = "图元高亮";
+ btnActiveObject.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnActiveObject.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnActiveObject.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"ActiveObject.png");
+ btnActiveObject.Id = "图元高亮";
+ ribbonRowPanel.Items.Add(btnActiveObject);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 数据交换
+ RibbonPanelSource dataExchangeSource = new RibbonPanelSource();
+ dataExchangeSource.Title = "数据交换";
+ dataExchangeSource.Id = "数据交换";
+ RibbonPanel dataExchangePanel = new RibbonPanel();
+ dataExchangePanel.Source = dataExchangeSource;
+ tab1.Panels.Add(dataExchangePanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 元件导入
+ RibbonButton btnImput = new RibbonButton();
+ btnImput.ToolTip = "元件导入";
+ btnImput.Text = "元件导入";
+ btnImput.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnImput.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnImput.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Imput.png");
+ btnImput.Id = "元件导入";
+ ribbonRowPanel.Items.Add(btnImput);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 元件导出
+ RibbonButton btnExport = new RibbonButton();
+ btnExport.ToolTip = "元件导出";
+ btnExport.Text = "元件导出";
+ btnExport.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnExport.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnExport.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Export.png");
+ btnExport.Id = "元件导出";
+ ribbonRowPanel.Items.Add(btnExport);
+ #endregion
+ dataExchangeSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 电缆检查
+ RibbonButton btnCheckCable = new RibbonButton();
+ btnCheckCable.ToolTip = "电缆检查";
+ btnCheckCable.Text = "电缆检查";
+ btnCheckCable.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCheckCable.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCheckCable.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CheckCable.png");
+ btnCheckCable.Id = "电缆检查";
+ ribbonRowPanel.Items.Add(btnCheckCable);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 属性检查
+ RibbonButton btnPropertyCheck = new RibbonButton();
+ btnPropertyCheck.ToolTip = "属性检查";
+ btnPropertyCheck.Text = "属性检查";
+ btnPropertyCheck.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnPropertyCheck.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnPropertyCheck.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Property.png");
+ btnPropertyCheck.Id = "属性检查";
+ ribbonRowPanel.Items.Add(btnPropertyCheck);
+ #endregion
+ dataExchangeSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 软件配置
+ RibbonPanelSource systemSource = new RibbonPanelSource();
+ systemSource.Title = "软件配置";
+ systemSource.Id = "软件配置";
+ RibbonPanel systemPanel = new RibbonPanel();
+ systemPanel.Source = systemSource;
+ tab1.Panels.Add(systemPanel);
+ //下拉按钮列表
+ RibbonSplitButton splitButton = new RibbonSplitButton();
+ splitButton.Text = "软件配置";
+ splitButton.ShowText = true;
+ splitButton.ShowImage = true;
+ splitButton.IsVisible = true;
+ splitButton.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ #region buttons 绘图配置
+ RibbonButton btnDwgConfig = new RibbonButton();
+ btnDwgConfig.ToolTip = "绘图配置";
+ btnDwgConfig.Text = "绘图配置";
+ btnDwgConfig.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnDwgConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnDwgConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"DConfig.png");
+ btnDwgConfig.Id = "绘图配置";
+ splitButton.Items.Add(btnDwgConfig);
+ #endregion
+ #region buttons 标注配置
+ RibbonButton btnAaConfig = new RibbonButton();
+ btnAaConfig.ToolTip = "标注配置";
+ btnAaConfig.Text = "标注配置";
+ btnAaConfig.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnAaConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnAaConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"TConfig.png");
+ btnAaConfig.Id = "标注配置";
+ splitButton.Items.Add(btnAaConfig);
+ #endregion
+ #region buttons 系统配置
+ RibbonButton btnSystemConfig = new RibbonButton();
+ btnSystemConfig.ToolTip = "系统配置";
+ btnSystemConfig.Text = "系统配置";
+ btnSystemConfig.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnSystemConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ var configView = GlobalObject.container.Resolve();
+ Application.ShowModalWindow(Application.MainWindow.Handle, configView);
+ });
+ btnSystemConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SConfig.png");
+ btnSystemConfig.Id = "系统配置";
+ splitButton.Items.Add(btnSystemConfig);
+ #endregion
+ systemSource.Items.Add(splitButton);
+
+ #endregion
+ }
+
+ }
+}
+
+
+
+
+
diff --git a/newFront/c#前端/SWS.CAD/Commands_BACKUP_669.cs b/newFront/c#前端/SWS.CAD/Commands_BACKUP_669.cs
new file mode 100644
index 00000000..39f172cf
--- /dev/null
+++ b/newFront/c#前端/SWS.CAD/Commands_BACKUP_669.cs
@@ -0,0 +1,1643 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Forms;
+using Bricscad.ApplicationServices;
+using Bricscad.EditorInput;
+using Bricscad.Ribbon;
+using Bricscad.Windows;
+using Prism.Events;
+using Prism.Ioc;
+using Prism.Services.Dialogs;
+using SWS.CAD;
+using SWS.CAD.CADFunc;
+using SWS.CAD.Event;
+using SWS.CAD.Views;
+using SWS.CAD.Views.Dialog;
+using Teigha.DatabaseServices;
+using Teigha.Runtime;
+using Telerik.Windows.Controls;
+using Unity;
+using Application = Bricscad.ApplicationServices.Application;
+using Panel = Bricscad.Windows.Panel;
+using GlobalObject = SWS.Commons.GlobalObject;
+using SWS.Model;
+using SWS.Service;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
+<<<<<<< HEAD
+using SWS.CAD.ViewModels;
+using SWS.CAD.Base;
+=======
+using System.Windows;
+using MessageBox = System.Windows.Forms.MessageBox;
+>>>>>>> c78178035f19e4ed599c777c75da005f0d2787ad
+
+
+[assembly: CommandClass(typeof(Commands))]
+[assembly: ExtensionApplication(typeof(Commands))]
+namespace SWS.CAD
+{
+ public partial class Commands : IExtensionApplication
+ {
+
+ public void Initialize()
+ {
+
+ try
+ {
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+ if (RibbonServices.RibbonPaletteSet == null)
+ RibbonServices.CreateRibbonPaletteSet(); //needed for ribbon samples
+ Start.RegisterTypes();
+ DockingTemplate dockTemplate = new DockingTemplate();
+ dockTemplate.DefaultStackId = "DI-ELEC_LDock"; //default stack is RDOCK panelset
+ dockTemplate.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate.DefaultDock = DockSides.Left; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView = GlobalObject.container.Resolve();
+ Panel panel = new Panel(nameof(LeftPanel), dockTemplate, drawingView);
+ panel.Title = "DI_左面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ AddTab();
+
+ DockingTemplate dockTemplate2 = new DockingTemplate();
+ dockTemplate2.DefaultStackId = "RDOCK"; //default stack is RDOCK panelset
+ dockTemplate2.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate2.DefaultDock = DockSides.Right; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView2 = GlobalObject.container.Resolve();
+ panel = new Panel(nameof(RightPanel), dockTemplate2, drawingView2);
+ panel.Title = "DI_右面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ if (System.Windows.Application.Current == null)
+ {
+ var app = new System.Windows.Application
+ {
+ // 设置为显式关闭,防止窗口关闭时 Application 被自动终结
+ ShutdownMode = ShutdownMode.OnExplicitShutdown
+ };
+ }
+ GlobalObject.ClearLog();
+ }
+ catch (System.Exception e)
+ {
+ Application.ShowAlertDialog(" An exception occurred in Initialize():\n" + e.ToString());
+ }
+ }
+
+
+
+ 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()
+ {
+ }
+
+ #region 显示属性弹窗
+ ///
+ /// 显示属性弹窗
+ ///
+ private ObservableCollection ShowPropertyMessage(string title, List listPropertys)
+ {
+
+ ObservableCollection ReslistPro = new ObservableCollection();
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ para.Add(GlobalObject.dialogPar.title.ToString(), title);
+ para.Add(GlobalObject.dialogPar.para1.ToString(), listPropertys);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogNewPositional), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+ ReslistPro = RES.Parameters.GetValue>(GlobalObject.dialogPar.para1.ToString());
+ }
+ else if (RES.Result == ButtonResult.No)
+ {
+ }
+ });
+ return ReslistPro;
+ }
+ #endregion
+
+ void AddTab()
+ {
+ RibbonControl rbnCtrl = ComponentManager.Ribbon; //整个上面都是ribbon,比如莫工做的电气系统,就是ribbon中的一个tab
+
+ if (rbnCtrl == null) return;
+ #region create Ribbon tab
+ RibbonTab tab1 = new RibbonTab();
+ tab1.Title = "智设电气(2)";
+ tab1.Id = "智设电气(2)";
+ rbnCtrl.Tabs.Add(tab1);//一个就行了
+ #endregion
+ //RibbonControl - RibbonTab - RibbonPanel - RibbonPanelSource - RibbonButton
+ #region Ribbon 项目操作
+ RibbonPanelSource userSource = new RibbonPanelSource();
+ userSource.Title = "项目操作";
+ userSource.Id = "项目操作";
+ RibbonPanel userPanel = new RibbonPanel();
+ userPanel.Source = userSource;
+ tab1.Panels.Add(userPanel);
+ #region buttons 选择项目
+ RibbonButton project = new RibbonButton();
+ project.ToolTip = "选择项目";
+ project.Text = "选择项目";
+ project.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ project.CommandHandler = new DelegateCommand(x =>
+ {
+ var projectView = GlobalObject.container.Resolve();
+ if (GlobalObject.userInfo != null)
+ {
+ Application.ShowModalWindow(Application.MainWindow.Handle, projectView);
+ }
+
+ });
+ project.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"OpenProject.png");
+ project.Id = "选择项目";
+ userSource.Items.Add(project);
+ #endregion
+ #region buttons 刷新项目
+ RibbonButton btnRefresh = new RibbonButton();
+ btnRefresh.ToolTip = "刷新项目";
+ btnRefresh.Text = "刷新项目";
+ btnRefresh.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnRefresh.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefresh.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshProject.png");
+ btnRefresh.Id = "刷新项目";
+ userSource.Items.Add(btnRefresh);
+ #endregion
+
+ //垂直排列按钮panel
+ RibbonRowPanel ribbonRowPanel = new RibbonRowPanel();
+
+ #region buttons 用户登录
+
+ RibbonButton login = new RibbonButton();
+ login.ToolTip = "用户登录";
+ login.Text = "用户登录";
+ login.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ login.CommandHandler = new DelegateCommand(x =>
+ {
+ try
+ {
+ var loginView = GlobalObject.container.Resolve();
+ //Application.ShowModalDialog(Application.MainWindow,);// 用来显示WinForms对话框
+ Application.ShowModalWindow(Application.MainWindow.Handle, loginView);//用来显示WPF的对话框,任务栏里可以看到2个Windows
+
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+ });
+ login.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Login.png");
+ login.Id = "用户登录";
+ //userSource.Items.Add(login);
+ ribbonRowPanel.Items.Add(login);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 属性窗口
+ RibbonButton btnProperty = new RibbonButton();
+ btnProperty.ToolTip = "属性窗口";
+ btnProperty.Text = "属性窗口";
+ btnProperty.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnProperty.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnProperty.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Message.png");
+ btnProperty.Id = "属性窗口";
+ ribbonRowPanel.Items.Add(btnProperty);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 项目消息
+ RibbonButton UserNotification = new RibbonButton();
+ UserNotification.ToolTip = "项目消息";
+ UserNotification.Text = "项目消息";
+ UserNotification.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ UserNotification.CommandHandler = new DelegateCommand(x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ try
+ {
+ var View = GlobalObject.container.Resolve();
+ var eventAggregator = GlobalObject.container.Resolve();
+ eventAggregator.GetEvent().Publish(new List());
+ Application.ShowModalWindow(Application.MainWindow.Handle, View);
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+
+ });
+ UserNotification.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Message.png");
+ UserNotification.Id = "项目消息";
+ //userSource.Items.Add(UserNotification);
+ ribbonRowPanel.Items.Add(UserNotification);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+
+ userSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 快速计算
+ RibbonPanelSource calcSource = new RibbonPanelSource();
+ calcSource.Title = "快速计算";
+ calcSource.Id = "快速计算";
+ RibbonPanel calcPanel = new RibbonPanel();
+ calcPanel.Source = calcSource;
+ tab1.Panels.Add(calcPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 电缆压降
+ RibbonButton btnCableDrop = new RibbonButton();
+ btnCableDrop.ToolTip = "电缆压降";
+ btnCableDrop.Text = "电缆压降";
+ btnCableDrop.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableDrop.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCableDrop.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CalCable.png");
+ btnCableDrop.Id = "电缆压降";
+ ribbonRowPanel.Items.Add(btnCableDrop);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 启动顺序
+ RibbonButton btnCalBoot = new RibbonButton();
+ btnCalBoot.ToolTip = "启动顺序";
+ btnCalBoot.Text = "启动顺序";
+ btnCalBoot.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCalBoot.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCalBoot.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CalBoot.png");
+ btnCalBoot.Id = "启动顺序";
+ ribbonRowPanel.Items.Add(btnCalBoot);
+ #endregion
+ calcSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 设计成图
+ RibbonPanelSource designSource = new RibbonPanelSource();
+ designSource.Title = "设计成图";
+ designSource.Id = "设计成图";
+ RibbonPanel designPanel = new RibbonPanel();
+ designPanel.Source = designSource;
+ tab1.Panels.Add(designPanel);
+ //大按钮
+ #region buttons 绘照明线路
+ RibbonButton btnLightLine = new RibbonButton();
+ btnLightLine.ToolTip = "绘照明线路";
+ btnLightLine.Text = "绘照明线路";
+ btnLightLine.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnLightLine.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnLightLine.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"lightLine.png");
+ btnLightLine.Id = "绘照明线路";
+ designSource.Items.Add(btnLightLine);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 生成端子图
+ RibbonButton btnEquipmentjoin = new RibbonButton();
+ btnEquipmentjoin.ToolTip = "生成端子图";
+ btnEquipmentjoin.Text = "生成端子图";
+ btnEquipmentjoin.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnEquipmentjoin.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnEquipmentjoin.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Equipmentjoin.png");
+ btnEquipmentjoin.Id = "生成端子图";
+ ribbonRowPanel.Items.Add(btnEquipmentjoin);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成系统图
+ RibbonButton btnJoinSys = new RibbonButton();
+ btnJoinSys.ToolTip = "生成系统图";
+ btnJoinSys.Text = "生成系统图";
+ btnJoinSys.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnJoinSys.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnJoinSys.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"joinsys.png");
+ btnJoinSys.Id = "生成系统图";
+ ribbonRowPanel.Items.Add(btnJoinSys);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成OPC
+ RibbonButton btnOPC = new RibbonButton();
+ btnOPC.ToolTip = "生成OPC";
+ btnOPC.Text = "生成OPC";
+ btnOPC.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnOPC.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnOPC.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"OPC.png");
+ btnOPC.Id = "生成OPC";
+ ribbonRowPanel.Items.Add(btnOPC);
+ #endregion
+ designSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 生成布置图
+ RibbonButton btnPlaneLayout = new RibbonButton();
+ btnPlaneLayout.ToolTip = "生成布置图";
+ btnPlaneLayout.Text = "生成布置图";
+ btnPlaneLayout.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnPlaneLayout.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnPlaneLayout.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"PlaneLayout.png");
+ btnPlaneLayout.Id = "生成布置图";
+ ribbonRowPanel.Items.Add(btnPlaneLayout);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成链路系统图
+ RibbonButton btnEquipmentSys = new RibbonButton();
+ btnEquipmentSys.ToolTip = "生成链路系统图";
+ btnEquipmentSys.Text = "生成链路系统图";
+ btnEquipmentSys.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnEquipmentSys.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnEquipmentSys.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"EquipmentSys.png");
+ btnEquipmentSys.Id = "生成链路系统图";
+ ribbonRowPanel.Items.Add(btnEquipmentSys);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 照明回路开关
+ RibbonButton btnBatchSwitch = new RibbonButton();
+ btnBatchSwitch.ToolTip = "照明回路开关";
+ btnBatchSwitch.Text = "照明回路开关";
+ btnBatchSwitch.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnBatchSwitch.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnBatchSwitch.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"BatchSwitch.png");
+ btnBatchSwitch.Id = "照明回路开关";
+ ribbonRowPanel.Items.Add(btnBatchSwitch);
+ #endregion
+ designSource.Items.Add(ribbonRowPanel);
+
+ #endregion
+
+ #region Ribbon 数据管理
+ RibbonPanelSource dataSource = new RibbonPanelSource();
+ dataSource.Title = "数据管理";
+ dataSource.Id = "数据管理";
+ RibbonPanel dataPanel = new RibbonPanel();
+ dataPanel.Source = dataSource;
+ tab1.Panels.Add(dataPanel);
+ //大按钮
+ #region buttons 分电箱
+ RibbonButton btnSwitchbox = new RibbonButton();
+ btnSwitchbox.ToolTip = "分电箱";
+ btnSwitchbox.Text = "分电箱";
+ btnSwitchbox.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnSwitchbox.CommandHandler = new DelegateCommand(async x =>
+ {
+ //if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ //{
+ // MessageBox.Show("请先登录系统并选择项目!");
+ // return;
+ //}
+ ////在SWS系统内打开且不是只读的图纸才可
+ //var dwgName = General.GetDwgName();
+ //var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ //if (dwgFile == null)
+ //{ return; }
+ //Document doc = Application.DocumentManager.MdiActiveDocument;
+ //Database db = doc.Database;
+ //Editor ed = doc.Editor;
+ ////选择的元素返回的属性信息
+ //var ResTagInfosByPixels = new Model.ec_objecttype();
+ //var listPropertys = new List();
+ ////获取服务接口
+ //var _objectTypeService = GlobalObject.container.Resolve();
+ //var _iOModuleService = GlobalObject.container.Resolve();
+ //// 持续选择直到获取有效电缆
+ //bool isValidCable = false;
+
+ //try
+ //{
+ // #region 选择电缆
+ // // 创建选择选项(禁用回车确认)
+ // PromptEntityOptions options = new PromptEntityOptions("\n请单击选择对象: ");
+ // options.AllowNone = false; // 禁止空选
+
+ // // 执行选择(直接单击生效)
+ // PromptEntityResult resultEntity = ed.GetEntity(options);
+ // //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ // while (resultEntity.Status == PromptStatus.OK)
+ // {
+ // using (Transaction tr = db.TransactionManager.StartTransaction())
+ // {
+ // // 获取选中的电缆实体
+ // Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ // //if (cable != null&&cable.XData != null)
+ // if (cable != null)
+ // {
+ // // 获取句柄(Handle 是字符串类型)
+ // var handId = (cable.Handle.ToString());
+ // var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ // if (res != null)
+ // {
+ // if (res.Count == 1)
+ // {
+ // var item = res[0];
+ // var objTypeName = item.ObjectTypeName;
+ // if (!objTypeName.Contains("电缆"))
+ // {
+ // ResTagInfosByPixels = item;
+ // isValidCable = true; // 校验通过
+ // ed.WriteMessage($"\n已选择对象:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ // }
+
+ // }
+ // }
+
+ // }
+ // tr.Commit();
+ // }
+ // if (isValidCable)
+ // {
+ // break;
+ // }
+ // else
+ // {
+ // ed.WriteMessage($"\n已选择电缆:");
+ // resultEntity = ed.GetEntity(options);
+ // }
+
+ // }
+ // #endregion
+ //}
+ //catch (System.Exception ex)
+ //{
+ // ed.WriteMessage($"\n错误: {ex.Message}");
+ //}
+
+ if (true)
+ {
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogSectionBox), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ });
+ btnSwitchbox.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Switchbox.png");
+ btnSwitchbox.Id = "分电箱";
+ dataSource.Items.Add(btnSwitchbox);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 平行电缆
+ RibbonButton btnParallel = new RibbonButton();
+ btnParallel.ToolTip = "平行电缆";
+ btnParallel.Text = "平行电缆";
+ btnParallel.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnParallel.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ #region 平行电缆
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ if (string.IsNullOrEmpty(GlobalObject.currentTagNumber))
+ { return; }
+ //选择集数量只有1才行
+ int count = General.SelectedCount();
+ if (count != 1)
+ {
+ MessageBox.Show("请选择1个电缆!");
+ return;
+ }
+ //var listHandid = General.GetSelectedHandles();
+ //if (listHandid.Count != 1)
+ //{
+ // MessageBox.Show("请选择1个电缆!");
+ // return;
+ //}
+ //var tagNumber = listHandid[0];
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var res = await _objectTypeService.GetTagInfosByTags(GlobalObject.currentTagNumber);
+ if (!res.Any())
+ {
+ //MessageBox.Show("获取位号数据异常:");
+ return;
+ }
+ if (!GlobalObject.IsCable(res[0]))
+ {
+ MessageBox.Show("选中的元素不是电缆!");
+ return;
+ }
+ //取“平行电缆”和“平行电缆位号”属性
+
+ var listPro = res[0].props;
+ var listTaginfo = res[0].tags[0].EngineDataProperty;
+ var pro1 = listPro.FirstOrDefault(a => a.PropertyName == "平行电缆");
+ var tag1 = listTaginfo.FirstOrDefault(a => a.PropertyName == "平行电缆");
+ var model1 = new propertyModel()
+ {
+ Id = tag1.EngineDataID,
+ DisplayText = pro1.PropertyName,
+ PropertyValue = tag1.PropertyValue,
+ DetailId = tag1.EngineDataPropertyID
+ };
+ var pro2 = listPro.FirstOrDefault(a => a.PropertyName == "平行电缆位号");
+ var tag2 = listTaginfo.FirstOrDefault(a => a.PropertyName == "平行电缆位号");
+ var model2 = new propertyModel()
+ {
+ Id = tag2.EngineDataID,
+ DisplayText = pro2.PropertyName,
+ PropertyValue = tag2.PropertyValue,
+ DetailId = tag2.EngineDataPropertyID,
+ Unit = "",
+ IsRefreshUI = true
+ };
+
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ para.Add(GlobalObject.dialogPar.info.ToString(), res[0]);
+ para.Add(GlobalObject.dialogPar.para1.ToString(), model1);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), model2);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogParallelCable), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ #endregion
+ });
+ btnParallel.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Parallel.png");
+ btnParallel.Id = "平行电缆";
+ ribbonRowPanel.Items.Add(btnParallel);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 电缆连接
+ RibbonButton btnCableConnect = new RibbonButton();
+ btnCableConnect.ToolTip = "电缆连接";
+ btnCableConnect.Text = "电缆连接";
+ btnCableConnect.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableConnect.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ #region 电缆连接
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ Document doc = Application.DocumentManager.MdiActiveDocument;
+ Database db = doc.Database;
+ Editor ed = doc.Editor;
+ //选择的元素返回的属性信息
+ var ResTagInfosByPixels = new Model.ec_objecttype();
+ var listPropertys = new List();
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var _iOModuleService = GlobalObject.container.Resolve();
+ // 持续选择直到获取有效电缆
+ bool isValidCable = false;
+
+ try
+ {
+ // 创建选择选项(禁用回车确认)
+ PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: ");
+ options.AllowNone = false; // 禁止空选
+
+ // 执行选择(直接单击生效)
+ PromptEntityResult resultEntity = ed.GetEntity(options);
+ //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ while (resultEntity.Status == PromptStatus.OK)
+ {
+ using (Transaction tr = db.TransactionManager.StartTransaction())
+ {
+ // 获取选中的电缆实体
+ Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ //if (cable != null&&cable.XData != null)
+ if (cable != null)
+ {
+ // 获取句柄(Handle 是字符串类型)
+ var handId = (cable.Handle.ToString());
+ _objectTypeService = GlobalObject.container.Resolve();
+ var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ if (res != null)
+ {
+ if (res.Count == 1)
+ {
+ var item = res[0];
+ var objTypeName = item.ObjectTypeName;
+ if (objTypeName.Contains("电缆"))
+ {
+ ResTagInfosByPixels = item;
+ isValidCable = true; // 校验通过
+ ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ }
+
+ }
+ }
+
+ }
+ tr.Commit();
+ }
+ if (isValidCable)
+ {
+ break;
+ }
+ else
+ {
+ ed.WriteMessage($"\n已选择电缆:");
+ resultEntity = ed.GetEntity(options);
+ }
+
+ }
+
+ //Thread.Sleep(2000);
+ if (isValidCable)
+ {
+ var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
+ CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
+ var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ //获取位号的电缆属性,判断是否设置电缆规格
+ var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
+ if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ {
+ System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
+
+ }
+ var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ //如果配置不存在
+ if (ResCableEngID == null)
+ {
+ listPropertys = new List();
+ System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
+ if (result == System.Windows.MessageBoxResult.OK)
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "homerun";//母线
+ ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault();
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ else
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "conventional";//常规电缆
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ }
+ if (ResCableEngID != null)
+ {
+
+ IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle;
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ //para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb");
+ para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle);
+
+ para.Add(GlobalObject.dialogPar.para1.ToString(), dwgFile.Id);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogCableConnection), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ ed.WriteMessage($"\n错误: {ex.Message}");
+ }
+
+
+ #endregion
+ });
+ btnCableConnect.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableConnect.png");
+ btnCableConnect.Id = "电缆连接";
+ ribbonRowPanel.Items.Add(btnCableConnect);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons IO分配
+ RibbonButton btnIO = new RibbonButton();
+ btnIO.ToolTip = "IO分配";
+ btnIO.Text = "IO分配";
+ btnIO.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnIO.CommandHandler = new DelegateCommand(x =>
+ {
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogIODistribution), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ });
+ btnIO.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"IO.png");
+ btnIO.Id = "IO分配";
+ ribbonRowPanel.Items.Add(btnIO);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 信号管理
+ RibbonButton btnSinalManage = new RibbonButton();
+ btnSinalManage.ToolTip = "信号管理";
+ btnSinalManage.Text = "信号管理";
+ btnSinalManage.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnSinalManage.CommandHandler = new DelegateCommand(x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(SWS.WPF.Views.DialogSignalManagement), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ });
+ btnSinalManage.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SinalManage.png");
+ btnSinalManage.Id = "信号管理";
+ ribbonRowPanel.Items.Add(btnSinalManage);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 信号预分配
+ RibbonButton btnCableSinal = new RibbonButton();
+ btnCableSinal.ToolTip = "信号预分配";
+ btnCableSinal.Text = "信号预分配";
+ btnCableSinal.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableSinal.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ Document doc = Application.DocumentManager.MdiActiveDocument;
+ Database db = doc.Database;
+ Editor ed = doc.Editor;
+ //选择的元素返回的属性信息
+ var ResTagInfosByPixels = new Model.ec_objecttype();
+ var listPropertys = new List();
+ //获取服务接口
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var _iOModuleService = GlobalObject.container.Resolve();
+ // 持续选择直到获取有效电缆
+ bool isValidCable = false;
+
+ try
+ {
+ #region 选择电缆
+ // 创建选择选项(禁用回车确认)
+ PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: ");
+ options.AllowNone = false; // 禁止空选
+
+ // 执行选择(直接单击生效)
+ PromptEntityResult resultEntity = ed.GetEntity(options);
+ //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ while (resultEntity.Status == PromptStatus.OK)
+ {
+ using (Transaction tr = db.TransactionManager.StartTransaction())
+ {
+ // 获取选中的电缆实体
+ Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ //if (cable != null&&cable.XData != null)
+ if (cable != null)
+ {
+ // 获取句柄(Handle 是字符串类型)
+ var handId = (cable.Handle.ToString());
+ var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ if (res != null)
+ {
+ if (res.Count == 1)
+ {
+ var item = res[0];
+ var objTypeName = item.ObjectTypeName;
+ if (objTypeName.Contains("电缆"))
+ {
+ ResTagInfosByPixels = item;
+ isValidCable = true; // 校验通过
+ ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ }
+
+ }
+ }
+
+ }
+ tr.Commit();
+ }
+ if (isValidCable)
+ {
+ break;
+ }
+ else
+ {
+ ed.WriteMessage($"\n已选择电缆:");
+ resultEntity = ed.GetEntity(options);
+ }
+
+ }
+ #endregion
+
+
+ //Thread.Sleep(2000);
+ if (isValidCable)
+ {
+ var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
+ CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
+ var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ //获取位号的电缆属性,判断是否设置电缆规格
+ var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
+ if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ {
+ System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
+
+ }
+ var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ //如果配置不存在
+ if (ResCableEngID == null)
+ {
+ listPropertys = new List();
+ System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
+ if (result == System.Windows.MessageBoxResult.OK)
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "homerun";//母线
+ ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault();
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ else
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "conventional";//常规电缆
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号"://所有的电缆对中的电芯一起编号
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号"://一个电缆对中线号按顺序编号,另一个电缆对中线号重新从1开始编号
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ }
+ if (ResCableEngID != null)
+ {
+
+ IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle;
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ //para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb");
+ para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle);
+
+ para.Add(GlobalObject.dialogPar.para1.ToString(), ResCableEngID);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogSignalPredistribution), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ ed.WriteMessage($"\n错误: {ex.Message}");
+ }
+ });
+ btnCableSinal.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableSinal.png");
+ btnCableSinal.Id = "信号预分配";
+ ribbonRowPanel.Items.Add(btnCableSinal);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 批量反向关联
+ RibbonButton btnRelevancy = new RibbonButton();
+ btnRelevancy.ToolTip = "批量反向关联";
+ btnRelevancy.Text = "批量反向关联";
+ btnRelevancy.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRelevancy.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRelevancy.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"relevancy.png");
+ btnRelevancy.Id = "批量反向关联";
+ ribbonRowPanel.Items.Add(btnRelevancy);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 系统图识别
+ RibbonButton btnGraphRec = new RibbonButton();
+ btnGraphRec.ToolTip = "系统图识别";
+ btnGraphRec.Text = "系统图识别";
+ btnGraphRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnGraphRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnGraphRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"GraphRec.png");
+ btnGraphRec.Id = "系统图识别";
+ ribbonRowPanel.Items.Add(btnGraphRec);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 竖向图识别
+ RibbonButton btnVerticalRec = new RibbonButton();
+ btnVerticalRec.ToolTip = "竖向图识别";
+ btnVerticalRec.Text = "竖向图识别";
+ btnVerticalRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnVerticalRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnVerticalRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"VerticalRec.png");
+ btnVerticalRec.Id = "竖向图识别";
+ ribbonRowPanel.Items.Add(btnVerticalRec);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 链路图识别
+ RibbonButton btnLightLineRec = new RibbonButton();
+ btnLightLineRec.ToolTip = "链路图识别";
+ btnLightLineRec.Text = "链路图识别";
+ btnLightLineRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnLightLineRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnLightLineRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"lightLine.png");
+ btnLightLineRec.Id = "链路图识别";
+ ribbonRowPanel.Items.Add(btnLightLineRec);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 图形刷新
+ RibbonPanelSource dwgRefreshSource = new RibbonPanelSource();
+ dwgRefreshSource.Title = "图形刷新";
+ dwgRefreshSource.Id = "图形刷新";
+ RibbonPanel dwgRefreshPanel = new RibbonPanel();
+ dwgRefreshPanel.Source = dwgRefreshSource;
+ tab1.Panels.Add(dwgRefreshPanel);
+ //大按钮
+ #region buttons 刷新标注
+ RibbonButton btnRefreshText = new RibbonButton();
+ btnRefreshText.ToolTip = "刷新标注";
+ btnRefreshText.Text = "刷新标注";
+ btnRefreshText.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnRefreshText.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshText.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshText.png");
+ btnRefreshText.Id = "刷新标注";
+ dwgRefreshSource.Items.Add(btnRefreshText);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 刷新元件
+ RibbonButton btnRefreshBlock = new RibbonButton();
+ btnRefreshBlock.ToolTip = "刷新元件";
+ btnRefreshBlock.Text = "刷新元件";
+ btnRefreshBlock.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshBlock.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshBlock.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshBlock.png");
+ btnRefreshBlock.Id = "刷新元件";
+ ribbonRowPanel.Items.Add(btnRefreshBlock);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新图框
+ RibbonButton btnRefreshFrame = new RibbonButton();
+ btnRefreshFrame.ToolTip = "刷新图框";
+ btnRefreshFrame.Text = "刷新图框";
+ btnRefreshFrame.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshFrame.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshFrame.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshFrame.png");
+ btnRefreshFrame.Id = "刷新图框";
+ ribbonRowPanel.Items.Add(btnRefreshFrame);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新连接
+ RibbonButton btnRefreshLink = new RibbonButton();
+ btnRefreshLink.ToolTip = "刷新连接";
+ btnRefreshLink.Text = "刷新连接";
+ btnRefreshLink.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshLink.CommandHandler = new DelegateCommand(x =>
+ {
+ var configView = GlobalObject.container.Resolve();
+ Application.ShowModalWindow(Application.MainWindow.Handle, configView);
+ });
+ btnRefreshLink.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshLink.png");
+ btnRefreshLink.Id = "刷新连接";
+ ribbonRowPanel.Items.Add(btnRefreshLink);
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 查看链路
+ RibbonButton btnShowLink = new RibbonButton();
+ btnShowLink.ToolTip = "查看链路";
+ btnShowLink.Text = "查看链路";
+ btnShowLink.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnShowLink.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnShowLink.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"ShowLink.png");
+ btnShowLink.Id = "查看链路";
+ ribbonRowPanel.Items.Add(btnShowLink);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新位置
+ RibbonButton btnUpdatePosition = new RibbonButton();
+ btnUpdatePosition.ToolTip = "刷新位置";
+ btnUpdatePosition.Text = "刷新位置";
+ btnUpdatePosition.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnUpdatePosition.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnUpdatePosition.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"UpdatePosition.png");
+ btnUpdatePosition.Id = "刷新位置";
+ ribbonRowPanel.Items.Add(btnUpdatePosition);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新坐标
+ RibbonButton btnRefreshPosition = new RibbonButton();
+ btnRefreshPosition.ToolTip = "刷新坐标";
+ btnRefreshPosition.Text = "刷新坐标";
+ btnRefreshPosition.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshPosition.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshPosition.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshPosition.png");
+ btnRefreshPosition.Id = "刷新坐标";
+ ribbonRowPanel.Items.Add(btnRefreshPosition);
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 图元高亮
+ RibbonButton btnActiveObject = new RibbonButton();
+ btnActiveObject.ToolTip = "图元高亮";
+ btnActiveObject.Text = "图元高亮";
+ btnActiveObject.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnActiveObject.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnActiveObject.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"ActiveObject.png");
+ btnActiveObject.Id = "图元高亮";
+ ribbonRowPanel.Items.Add(btnActiveObject);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 数据交换
+ RibbonPanelSource dataExchangeSource = new RibbonPanelSource();
+ dataExchangeSource.Title = "数据交换";
+ dataExchangeSource.Id = "数据交换";
+ RibbonPanel dataExchangePanel = new RibbonPanel();
+ dataExchangePanel.Source = dataExchangeSource;
+ tab1.Panels.Add(dataExchangePanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 元件导入
+ RibbonButton btnImput = new RibbonButton();
+ btnImput.ToolTip = "元件导入";
+ btnImput.Text = "元件导入";
+ btnImput.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnImput.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnImput.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Imput.png");
+ btnImput.Id = "元件导入";
+ ribbonRowPanel.Items.Add(btnImput);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 元件导出
+ RibbonButton btnExport = new RibbonButton();
+ btnExport.ToolTip = "元件导出";
+ btnExport.Text = "元件导出";
+ btnExport.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnExport.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnExport.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Export.png");
+ btnExport.Id = "元件导出";
+ ribbonRowPanel.Items.Add(btnExport);
+ #endregion
+ dataExchangeSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 电缆检查
+ RibbonButton btnCheckCable = new RibbonButton();
+ btnCheckCable.ToolTip = "电缆检查";
+ btnCheckCable.Text = "电缆检查";
+ btnCheckCable.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCheckCable.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCheckCable.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CheckCable.png");
+ btnCheckCable.Id = "电缆检查";
+ ribbonRowPanel.Items.Add(btnCheckCable);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 属性检查
+ RibbonButton btnPropertyCheck = new RibbonButton();
+ btnPropertyCheck.ToolTip = "属性检查";
+ btnPropertyCheck.Text = "属性检查";
+ btnPropertyCheck.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnPropertyCheck.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnPropertyCheck.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Property.png");
+ btnPropertyCheck.Id = "属性检查";
+ ribbonRowPanel.Items.Add(btnPropertyCheck);
+ #endregion
+ dataExchangeSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 软件配置
+ RibbonPanelSource systemSource = new RibbonPanelSource();
+ systemSource.Title = "软件配置";
+ systemSource.Id = "软件配置";
+ RibbonPanel systemPanel = new RibbonPanel();
+ systemPanel.Source = systemSource;
+ tab1.Panels.Add(systemPanel);
+ //下拉按钮列表
+ RibbonSplitButton splitButton = new RibbonSplitButton();
+ splitButton.Text = "软件配置";
+ splitButton.ShowText = true;
+ splitButton.ShowImage = true;
+ splitButton.IsVisible = true;
+ splitButton.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ #region buttons 绘图配置
+ RibbonButton btnDwgConfig = new RibbonButton();
+ btnDwgConfig.ToolTip = "绘图配置";
+ btnDwgConfig.Text = "绘图配置";
+ btnDwgConfig.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnDwgConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnDwgConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"DConfig.png");
+ btnDwgConfig.Id = "绘图配置";
+ splitButton.Items.Add(btnDwgConfig);
+ #endregion
+ #region buttons 标注配置
+ RibbonButton btnAaConfig = new RibbonButton();
+ btnAaConfig.ToolTip = "标注配置";
+ btnAaConfig.Text = "标注配置";
+ btnAaConfig.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnAaConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnAaConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"TConfig.png");
+ btnAaConfig.Id = "标注配置";
+ splitButton.Items.Add(btnAaConfig);
+ #endregion
+ #region buttons 系统配置
+ RibbonButton btnSystemConfig = new RibbonButton();
+ btnSystemConfig.ToolTip = "系统配置";
+ btnSystemConfig.Text = "系统配置";
+ btnSystemConfig.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnSystemConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ var configView = GlobalObject.container.Resolve();
+ Application.ShowModalWindow(Application.MainWindow.Handle, configView);
+ });
+ btnSystemConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SConfig.png");
+ btnSystemConfig.Id = "系统配置";
+ splitButton.Items.Add(btnSystemConfig);
+ #endregion
+ systemSource.Items.Add(splitButton);
+
+ #endregion
+ }
+
+ }
+}
+
+
+
+
+
diff --git a/newFront/c#前端/SWS.CAD/Commands_BASE_547.cs b/newFront/c#前端/SWS.CAD/Commands_BASE_547.cs
new file mode 100644
index 00000000..a28f2dcd
--- /dev/null
+++ b/newFront/c#前端/SWS.CAD/Commands_BASE_547.cs
@@ -0,0 +1,1521 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Forms;
+using Bricscad.ApplicationServices;
+using Bricscad.EditorInput;
+using Bricscad.Ribbon;
+using Bricscad.Windows;
+using Prism.Events;
+using Prism.Ioc;
+using Prism.Services.Dialogs;
+using SWS.CAD;
+using SWS.CAD.CADFunc;
+using SWS.CAD.Event;
+using SWS.CAD.Views;
+using SWS.CAD.Views.Dialog;
+using Teigha.DatabaseServices;
+using Teigha.Runtime;
+using Telerik.Windows.Controls;
+using Unity;
+using Application = Bricscad.ApplicationServices.Application;
+using Panel = Bricscad.Windows.Panel;
+using GlobalObject = SWS.Commons.GlobalObject;
+using SWS.Model;
+using SWS.Service;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
+
+
+[assembly: CommandClass(typeof(Commands))]
+[assembly: ExtensionApplication(typeof(Commands))]
+namespace SWS.CAD
+{
+ public partial class Commands : IExtensionApplication
+ {
+
+ public void Initialize()
+ {
+
+ try
+ {
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+ if (RibbonServices.RibbonPaletteSet == null)
+ RibbonServices.CreateRibbonPaletteSet(); //needed for ribbon samples
+ Start.RegisterTypes();
+ DockingTemplate dockTemplate = new DockingTemplate();
+ dockTemplate.DefaultStackId = "DI-ELEC_LDock"; //default stack is RDOCK panelset
+ dockTemplate.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate.DefaultDock = DockSides.Left; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView = GlobalObject.container.Resolve();
+ Panel panel = new Panel(nameof(LeftPanel), dockTemplate, drawingView);
+ panel.Title = "DI_左面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ AddTab();
+
+ DockingTemplate dockTemplate2 = new DockingTemplate();
+ dockTemplate2.DefaultStackId = "RDOCK"; //default stack is RDOCK panelset
+ dockTemplate2.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate2.DefaultDock = DockSides.Right; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView2 = GlobalObject.container.Resolve();
+ panel = new Panel(nameof(RightPanel), dockTemplate2, drawingView2);
+ panel.Title = "DI_右面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ }
+ catch (System.Exception e)
+ {
+ Application.ShowAlertDialog(" An exception occurred in Initialize():\n" + e.ToString());
+ }
+ }
+
+
+
+ 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()
+ {
+ }
+
+ #region 显示属性弹窗
+ ///
+ /// 显示属性弹窗
+ ///
+ private ObservableCollection ShowPropertyMessage(string title, List listPropertys)
+ {
+
+ ObservableCollection ReslistPro = new ObservableCollection();
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ para.Add(GlobalObject.dialogPar.title.ToString(), title);
+ para.Add(GlobalObject.dialogPar.para1.ToString(), listPropertys);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogNewPositional), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+ ReslistPro = RES.Parameters.GetValue>(GlobalObject.dialogPar.para1.ToString());
+ }
+ else if (RES.Result == ButtonResult.No)
+ {
+ }
+ });
+ return ReslistPro;
+ }
+ #endregion
+
+ void AddTab()
+ {
+ RibbonControl rbnCtrl = ComponentManager.Ribbon; //整个上面都是ribbon,比如莫工做的电气系统,就是ribbon中的一个tab
+
+ if (rbnCtrl == null) return;
+ #region create Ribbon tab
+ RibbonTab tab1 = new RibbonTab();
+ tab1.Title = "智设电气(2)";
+ tab1.Id = "智设电气(2)";
+ rbnCtrl.Tabs.Add(tab1);//一个就行了
+ #endregion
+ //RibbonControl - RibbonTab - RibbonPanel - RibbonPanelSource - RibbonButton
+ #region Ribbon 项目操作
+ RibbonPanelSource userSource = new RibbonPanelSource();
+ userSource.Title = "项目操作";
+ userSource.Id = "项目操作";
+ RibbonPanel userPanel = new RibbonPanel();
+ userPanel.Source = userSource;
+ tab1.Panels.Add(userPanel);
+ #region buttons 选择项目
+ RibbonButton project = new RibbonButton();
+ project.ToolTip = "选择项目";
+ project.Text = "选择项目";
+ project.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ project.CommandHandler = new DelegateCommand(x =>
+ {
+ var projectView = GlobalObject.container.Resolve();
+ if (GlobalObject.userInfo != null)
+ {
+ Application.ShowModalWindow(Application.MainWindow.Handle, projectView);
+ }
+
+ });
+ project.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"OpenProject.png");
+ project.Id = "选择项目";
+ userSource.Items.Add(project);
+ #endregion
+ #region buttons 刷新项目
+ RibbonButton btnRefresh = new RibbonButton();
+ btnRefresh.ToolTip = "刷新项目";
+ btnRefresh.Text = "刷新项目";
+ btnRefresh.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnRefresh.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefresh.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshProject.png");
+ btnRefresh.Id = "刷新项目";
+ userSource.Items.Add(btnRefresh);
+ #endregion
+
+ //垂直排列按钮panel
+ RibbonRowPanel ribbonRowPanel = new RibbonRowPanel();
+
+ #region buttons 用户登录
+
+ RibbonButton login = new RibbonButton();
+ login.ToolTip = "用户登录";
+ login.Text = "用户登录";
+ login.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ login.CommandHandler = new DelegateCommand(x =>
+ {
+ var loginView = GlobalObject.container.Resolve();
+ //Application.ShowModalDialog(Application.MainWindow,);// 用来显示WinForms对话框
+ Application.ShowModalWindow(Application.MainWindow.Handle, loginView);//用来显示WPF的对话框,任务栏里可以看到2个Windows
+ });
+ login.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Login.png");
+ login.Id = "用户登录";
+ //userSource.Items.Add(login);
+ ribbonRowPanel.Items.Add(login);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 属性窗口
+ RibbonButton btnProperty = new RibbonButton();
+ btnProperty.ToolTip = "属性窗口";
+ btnProperty.Text = "属性窗口";
+ btnProperty.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnProperty.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnProperty.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Message.png");
+ btnProperty.Id = "属性窗口";
+ ribbonRowPanel.Items.Add(btnProperty);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 项目消息
+ RibbonButton UserNotification = new RibbonButton();
+ UserNotification.ToolTip = "项目消息";
+ UserNotification.Text = "项目消息";
+ UserNotification.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ UserNotification.CommandHandler = new DelegateCommand(x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ try
+ {
+ var View = GlobalObject.container.Resolve();
+ var eventAggregator = GlobalObject.container.Resolve();
+ eventAggregator.GetEvent().Publish(new List());
+ Application.ShowModalWindow(Application.MainWindow.Handle, View);
+ }
+ catch (System.Exception ex)
+ {
+ MessageBox.Show(ex.Message);
+ }
+
+ });
+ UserNotification.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Message.png");
+ UserNotification.Id = "项目消息";
+ //userSource.Items.Add(UserNotification);
+ ribbonRowPanel.Items.Add(UserNotification);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+
+ userSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 快速计算
+ RibbonPanelSource calcSource = new RibbonPanelSource();
+ calcSource.Title = "快速计算";
+ calcSource.Id = "快速计算";
+ RibbonPanel calcPanel = new RibbonPanel();
+ calcPanel.Source = calcSource;
+ tab1.Panels.Add(calcPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 电缆压降
+ RibbonButton btnCableDrop = new RibbonButton();
+ btnCableDrop.ToolTip = "电缆压降";
+ btnCableDrop.Text = "电缆压降";
+ btnCableDrop.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableDrop.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCableDrop.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CalCable.png");
+ btnCableDrop.Id = "电缆压降";
+ ribbonRowPanel.Items.Add(btnCableDrop);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 启动顺序
+ RibbonButton btnCalBoot = new RibbonButton();
+ btnCalBoot.ToolTip = "启动顺序";
+ btnCalBoot.Text = "启动顺序";
+ btnCalBoot.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCalBoot.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCalBoot.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CalBoot.png");
+ btnCalBoot.Id = "启动顺序";
+ ribbonRowPanel.Items.Add(btnCalBoot);
+ #endregion
+ calcSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 设计成图
+ RibbonPanelSource designSource = new RibbonPanelSource();
+ designSource.Title = "设计成图";
+ designSource.Id = "设计成图";
+ RibbonPanel designPanel = new RibbonPanel();
+ designPanel.Source = designSource;
+ tab1.Panels.Add(designPanel);
+ //大按钮
+ #region buttons 绘照明线路
+ RibbonButton btnLightLine = new RibbonButton();
+ btnLightLine.ToolTip = "绘照明线路";
+ btnLightLine.Text = "绘照明线路";
+ btnLightLine.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnLightLine.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnLightLine.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"lightLine.png");
+ btnLightLine.Id = "绘照明线路";
+ designSource.Items.Add(btnLightLine);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 生成端子图
+ RibbonButton btnEquipmentjoin = new RibbonButton();
+ btnEquipmentjoin.ToolTip = "生成端子图";
+ btnEquipmentjoin.Text = "生成端子图";
+ btnEquipmentjoin.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnEquipmentjoin.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnEquipmentjoin.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Equipmentjoin.png");
+ btnEquipmentjoin.Id = "生成端子图";
+ ribbonRowPanel.Items.Add(btnEquipmentjoin);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成系统图
+ RibbonButton btnJoinSys = new RibbonButton();
+ btnJoinSys.ToolTip = "生成系统图";
+ btnJoinSys.Text = "生成系统图";
+ btnJoinSys.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnJoinSys.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnJoinSys.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"joinsys.png");
+ btnJoinSys.Id = "生成系统图";
+ ribbonRowPanel.Items.Add(btnJoinSys);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成OPC
+ RibbonButton btnOPC = new RibbonButton();
+ btnOPC.ToolTip = "生成OPC";
+ btnOPC.Text = "生成OPC";
+ btnOPC.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnOPC.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnOPC.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"OPC.png");
+ btnOPC.Id = "生成OPC";
+ ribbonRowPanel.Items.Add(btnOPC);
+ #endregion
+ designSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 生成布置图
+ RibbonButton btnPlaneLayout = new RibbonButton();
+ btnPlaneLayout.ToolTip = "生成布置图";
+ btnPlaneLayout.Text = "生成布置图";
+ btnPlaneLayout.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnPlaneLayout.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnPlaneLayout.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"PlaneLayout.png");
+ btnPlaneLayout.Id = "生成布置图";
+ ribbonRowPanel.Items.Add(btnPlaneLayout);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 生成链路系统图
+ RibbonButton btnEquipmentSys = new RibbonButton();
+ btnEquipmentSys.ToolTip = "生成链路系统图";
+ btnEquipmentSys.Text = "生成链路系统图";
+ btnEquipmentSys.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnEquipmentSys.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnEquipmentSys.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"EquipmentSys.png");
+ btnEquipmentSys.Id = "生成链路系统图";
+ ribbonRowPanel.Items.Add(btnEquipmentSys);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 照明回路开关
+ RibbonButton btnBatchSwitch = new RibbonButton();
+ btnBatchSwitch.ToolTip = "照明回路开关";
+ btnBatchSwitch.Text = "照明回路开关";
+ btnBatchSwitch.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnBatchSwitch.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnBatchSwitch.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"BatchSwitch.png");
+ btnBatchSwitch.Id = "照明回路开关";
+ ribbonRowPanel.Items.Add(btnBatchSwitch);
+ #endregion
+ designSource.Items.Add(ribbonRowPanel);
+
+ #endregion
+
+ #region Ribbon 数据管理
+ RibbonPanelSource dataSource = new RibbonPanelSource();
+ dataSource.Title = "数据管理";
+ dataSource.Id = "数据管理";
+ RibbonPanel dataPanel = new RibbonPanel();
+ dataPanel.Source = dataSource;
+ tab1.Panels.Add(dataPanel);
+ //大按钮
+ #region buttons 分电箱
+ RibbonButton btnSwitchbox = new RibbonButton();
+ btnSwitchbox.ToolTip = "分电箱";
+ btnSwitchbox.Text = "分电箱";
+ btnSwitchbox.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnSwitchbox.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnSwitchbox.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Switchbox.png");
+ btnSwitchbox.Id = "分电箱";
+ dataSource.Items.Add(btnSwitchbox);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 平行电缆
+ RibbonButton btnParallel = new RibbonButton();
+ btnParallel.ToolTip = "平行电缆";
+ btnParallel.Text = "平行电缆";
+ btnParallel.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnParallel.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ #region 平行电缆
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ if (string.IsNullOrEmpty(GlobalObject.currentTagNumber))
+ { return; }
+ //选择集数量只有1才行
+ int count = General.SelectedCount();
+ if (count != 1)
+ {
+ MessageBox.Show("请选择1个电缆!");
+ return;
+ }
+ //var listHandid = General.GetSelectedHandles();
+ //if (listHandid.Count != 1)
+ //{
+ // MessageBox.Show("请选择1个电缆!");
+ // return;
+ //}
+ //var tagNumber = listHandid[0];
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var res = await _objectTypeService.GetTagInfosByTags(GlobalObject.currentTagNumber);
+ if (!res.Any())
+ {
+ //MessageBox.Show("获取位号数据异常:");
+ return;
+ }
+ if (!GlobalObject.IsCable(res[0]))
+ {
+ MessageBox.Show("选中的元素不是电缆!");
+ return;
+ }
+ //取“平行电缆”和“平行电缆位号”属性
+
+ var listPro = res[0].props;
+ var listTaginfo = res[0].tags[0].EngineDataProperty;
+ var pro1 = listPro.FirstOrDefault(a => a.PropertyName == "平行电缆");
+ var tag1 = listTaginfo.FirstOrDefault(a => a.PropertyName == "平行电缆");
+ var model1 = new propertyModel()
+ {
+ Id = tag1.EngineDataID,
+ DisplayText = pro1.PropertyName,
+ PropertyValue = tag1.PropertyValue,
+ DetailId = tag1.EngineDataPropertyID
+ };
+ var pro2 = listPro.FirstOrDefault(a => a.PropertyName == "平行电缆位号");
+ var tag2 = listTaginfo.FirstOrDefault(a => a.PropertyName == "平行电缆位号");
+ var model2 = new propertyModel()
+ {
+ Id = tag2.EngineDataID,
+ DisplayText = pro2.PropertyName,
+ PropertyValue = tag2.PropertyValue,
+ DetailId = tag2.EngineDataPropertyID,
+ Unit = "",
+ IsRefreshUI = true
+ };
+
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ para.Add(GlobalObject.dialogPar.info.ToString(), res[0]);
+ para.Add(GlobalObject.dialogPar.para1.ToString(), model1);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), model2);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogParallelCable), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ #endregion
+ });
+ btnParallel.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Parallel.png");
+ btnParallel.Id = "平行电缆";
+ ribbonRowPanel.Items.Add(btnParallel);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 电缆连接
+ RibbonButton btnCableConnect = new RibbonButton();
+ btnCableConnect.ToolTip = "电缆连接";
+ btnCableConnect.Text = "电缆连接";
+ btnCableConnect.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableConnect.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ #region 电缆连接
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ Document doc = Application.DocumentManager.MdiActiveDocument;
+ Database db = doc.Database;
+ Editor ed = doc.Editor;
+ //选择的元素返回的属性信息
+ var ResTagInfosByPixels = new Model.ec_objecttype();
+ var listPropertys = new List();
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var _iOModuleService = GlobalObject.container.Resolve();
+ // 持续选择直到获取有效电缆
+ bool isValidCable = false;
+
+ try
+ {
+ // 创建选择选项(禁用回车确认)
+ PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: ");
+ options.AllowNone = false; // 禁止空选
+
+ // 执行选择(直接单击生效)
+ PromptEntityResult resultEntity = ed.GetEntity(options);
+ //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ while (resultEntity.Status == PromptStatus.OK)
+ {
+ using (Transaction tr = db.TransactionManager.StartTransaction())
+ {
+ // 获取选中的电缆实体
+ Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ //if (cable != null&&cable.XData != null)
+ if (cable != null)
+ {
+ // 获取句柄(Handle 是字符串类型)
+ var handId = (cable.Handle.ToString());
+ _objectTypeService = GlobalObject.container.Resolve();
+ var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ if (res != null)
+ {
+ if (res.Count == 1)
+ {
+ var item = res[0];
+ var objTypeName = item.ObjectTypeName;
+ if (objTypeName.Contains("电缆"))
+ {
+ ResTagInfosByPixels = item;
+ isValidCable = true; // 校验通过
+ ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ }
+
+ }
+ }
+
+ }
+ tr.Commit();
+ }
+ if (isValidCable)
+ {
+ break;
+ }
+ else
+ {
+ ed.WriteMessage($"\n已选择电缆:");
+ resultEntity = ed.GetEntity(options);
+ }
+
+ }
+
+ //Thread.Sleep(2000);
+ if (isValidCable)
+ {
+ var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
+ CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
+ var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ //获取位号的电缆属性,判断是否设置电缆规格
+ var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
+ if (string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ {
+ System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
+
+ }
+ var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ //如果配置不存在
+ if (ResCableEngID == null)
+ {
+ listPropertys = new List();
+ System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
+ if (result == System.Windows.MessageBoxResult.OK)
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "homerun";//母线
+ ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault();
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ else
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "conventional";//常规电缆
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ }
+ if (ResCableEngID != null)
+ {
+
+ IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle;
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ //para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb");
+ para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle);
+
+ para.Add(GlobalObject.dialogPar.para1.ToString(), dwgFile.Id);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogCableConnection), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ ed.WriteMessage($"\n错误: {ex.Message}");
+ }
+
+
+ #endregion
+ });
+ btnCableConnect.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableConnect.png");
+ btnCableConnect.Id = "电缆连接";
+ ribbonRowPanel.Items.Add(btnCableConnect);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons IO分配
+ RibbonButton btnIO = new RibbonButton();
+ btnIO.ToolTip = "IO分配";
+ btnIO.Text = "IO分配";
+ btnIO.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnIO.CommandHandler = new DelegateCommand(x =>
+ {
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogIODistribution), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ });
+ btnIO.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"IO.png");
+ btnIO.Id = "IO分配";
+ ribbonRowPanel.Items.Add(btnIO);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 信号管理
+ RibbonButton btnSinalManage = new RibbonButton();
+ btnSinalManage.ToolTip = "信号管理";
+ btnSinalManage.Text = "信号管理";
+ btnSinalManage.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnSinalManage.CommandHandler = new DelegateCommand(x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(SWS.WPF.Views.DialogSignalManagement), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ });
+ btnSinalManage.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SinalManage.png");
+ btnSinalManage.Id = "信号管理";
+ ribbonRowPanel.Items.Add(btnSinalManage);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 信号预分配
+ RibbonButton btnCableSinal = new RibbonButton();
+ btnCableSinal.ToolTip = "信号预分配";
+ btnCableSinal.Text = "信号预分配";
+ btnCableSinal.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCableSinal.CommandHandler = new DelegateCommand(async x =>
+ {
+ if (GlobalObject.userInfo == null || GlobalObject.curProject == null)
+ {
+ MessageBox.Show("请先登录系统并选择项目!");
+ return;
+ }
+
+ //在SWS系统内打开且不是只读的图纸才可
+ var dwgName = General.GetDwgName();
+ var dwgFile = GlobalObject.ListDwgOpened.FirstOrDefault(a => a.Path == dwgName && a.IsReadOnly == false);
+ if (dwgFile == null)
+ { return; }
+ Document doc = Application.DocumentManager.MdiActiveDocument;
+ Database db = doc.Database;
+ Editor ed = doc.Editor;
+ //选择的元素返回的属性信息
+ var ResTagInfosByPixels = new Model.ec_objecttype();
+ var listPropertys = new List();
+ var _objectTypeService = GlobalObject.container.Resolve();
+ var _iOModuleService = GlobalObject.container.Resolve();
+ // 持续选择直到获取有效电缆
+ bool isValidCable = false;
+
+ try
+ {
+ #region 选择电缆
+ // 创建选择选项(禁用回车确认)
+ PromptEntityOptions options = new PromptEntityOptions("\n请单击选择电缆: ");
+ options.AllowNone = false; // 禁止空选
+
+ // 执行选择(直接单击生效)
+ PromptEntityResult resultEntity = ed.GetEntity(options);
+ //WindowVisibility = System.Windows.Visibility.Hidden;
+
+ while (resultEntity.Status == PromptStatus.OK)
+ {
+ using (Transaction tr = db.TransactionManager.StartTransaction())
+ {
+ // 获取选中的电缆实体
+ Entity cable = tr.GetObject(resultEntity.ObjectId, OpenMode.ForRead) as Entity;
+ //if (cable != null&&cable.XData != null)
+ if (cable != null)
+ {
+ // 获取句柄(Handle 是字符串类型)
+ var handId = (cable.Handle.ToString());
+ var res = await _objectTypeService.GetTagInfosByPixels(dwgFile.Id, handId);
+ if (res != null)
+ {
+ if (res.Count == 1)
+ {
+ var item = res[0];
+ var objTypeName = item.ObjectTypeName;
+ if (objTypeName.Contains("电缆"))
+ {
+ ResTagInfosByPixels = item;
+ isValidCable = true; // 校验通过
+ ed.WriteMessage($"\n已选择电缆:{ResTagInfosByPixels.tags.FirstOrDefault().TagNumber}");
+ }
+
+ }
+ }
+
+ }
+ tr.Commit();
+ }
+ if (isValidCable)
+ {
+ break;
+ }
+ else
+ {
+ ed.WriteMessage($"\n已选择电缆:");
+ resultEntity = ed.GetEntity(options);
+ }
+
+ }
+ #endregion
+
+
+ //Thread.Sleep(2000);
+ if (isValidCable)
+ {
+ var ResTagNumberById = await _objectTypeService.GetTagNumberById(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ var ObjectTypePListBy = await _objectTypeService.GetObjectTypePListByIds(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ string CableSpecification = ObjectTypePListBy.Where(q => q.PropertyName.Equals("电缆规格")).Select(s => s.EnumDataCode).FirstOrDefault();
+ CableSpecification = CableSpecification.Substring(0, CableSpecification.Length - 1);
+ var LatestSerialNumber = await _objectTypeService.GetLatestSerialNumber(ResTagInfosByPixels.tags.FirstOrDefault().ObjectTypeID);
+ //获取位号的电缆属性,判断是否设置电缆规格
+ var TagNumberBys = await _objectTypeService.GetEngineDataListByTags(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var TagNumberBy = TagNumberBys.Where(t => t.TagNumber.Equals(ResTagInfosByPixels.tags.FirstOrDefault().TagNumber)).FirstOrDefault();
+ if(string.IsNullOrEmpty(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ //if (!CableSpecification.Split(',').ToList().Contains(TagNumberBy.EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault()))
+ {
+ System.Windows.MessageBox.Show("无法获取电缆对信息,请在电缆\"属性面版“输入电缆”电缆规格”属性\r\n如:“1x2x0.75”", "KunHengCAD", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Warning); return;
+
+ }
+ var ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ //如果配置不存在
+ if (ResCableEngID == null)
+ {
+ listPropertys = new List();
+ System.Windows.MessageBoxResult result = System.Windows.MessageBox.Show($"是否为通讯母线?", "KunHengCAD", System.Windows.MessageBoxButton.OKCancel, System.Windows.MessageBoxImage.Question);
+ if (result == System.Windows.MessageBoxResult.OK)
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "1", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "homerun";//母线
+ ec_Cable.Cable_Format = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataProperty.Where(e => e.PropertyName.Equals("电缆规格")).Select(e => e.PropertyValue).FirstOrDefault();
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n - 1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + n.ToString();
+ }
+ break;
+ case "按电缆对编号":
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i + 1) + "-" + (j + 1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ else
+ {
+ listPropertys = new List();
+ Dictionary pulldownlist;
+
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对数", GroupName = "基本参数", PropertyValue = "10", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "每电缆对芯数", GroupName = "基本参数", PropertyValue = "2", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电缆对编号前缀", GroupName = "基本参数", PropertyValue = "Set", ControlTypeName = PROPERTYType.TextBox, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("数字", "数字");
+ pulldownlist.Add("字母", "字母");
+ pulldownlist.Add("电缆对序号", "电缆对序号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ pulldownlist = new Dictionary();
+ pulldownlist.Add("按电缆编号", "按电缆编号");
+ pulldownlist.Add("按电缆对编号", "按电缆对编号");
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号规则", GroupName = "电芯参数", PropertyValue = "按电缆对编号", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "电芯编号前缀", GroupName = "电芯参数", PropertyValue = "C", ControlTypeName = PROPERTYType.TextBox, });
+ listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "极性", GroupName = "电芯参数", PropertyValue = "+,-,s", ControlTypeName = PROPERTYType.TextBox, });
+ //显示属性弹窗
+ var ReslistPro = ShowPropertyMessage("新建" + ResTagInfosByPixels.tags.FirstOrDefault().TagNumber + "电缆配置", listPropertys);
+ if (ReslistPro == null || ReslistPro.Count() == 0) return;
+ ec_Cable ec_Cable = new ec_Cable();
+ ec_Cable.CableClass = "conventional";//常规电缆
+ ec_Cable.EngineerDataID = ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID;
+ ec_Cable.Sets = new List();
+ int CableSetCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("电缆对数")).Select(p => p.PropertyValue).FirstOrDefault(), out CableSetCount) ? CableSetCount : 0;
+ int n = 0;
+ for (int i = 0; i < CableSetCount; i++)
+ {
+ ec_CableSet ec_CableSet = new ec_CableSet();
+ ec_CableSet.CableSetName = ReslistPro.Where(p => p.DisplayText.Equals("电缆对编号前缀")).Select(p => p.PropertyValue).FirstOrDefault() + (i + 1);
+ ec_CableSet.CableSetSeq = i + 1;
+ ec_CableSet.Wires = new List();
+ int WireCount = int.TryParse(ReslistPro.Where(p => p.DisplayText.Equals("每电缆对芯数")).Select(p => p.PropertyValue).FirstOrDefault(), out WireCount) ? WireCount : 0;
+ for (int j = 0; j < WireCount; j++)
+ {
+ n++;
+ ec_CableSetWire ec_CableSetWire = new ec_CableSetWire();
+ ec_CableSetWire.Polarity = ReslistPro.Where(p => p.DisplayText.Equals("极性")).Select(p => p.PropertyValue).FirstOrDefault().Split(',')[Math.Abs(j % 3)];
+ ec_CableSetWire.SetLevel = j + 1;
+ string a = ReslistPro.Where(p => p.DisplayText.Equals("电芯编号前缀")).Select(p => p.PropertyValue).FirstOrDefault();//组成线号名的前缀
+ string Tag = "";//线号名的中间部分
+ switch (ReslistPro.Where(p => p.DisplayText.Equals("编号规则")).Select(p => p.PropertyValue).FirstOrDefault())
+ {
+ case "按电缆编号"://所有的电缆对中的电芯一起编号
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = n.ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + (n-1));
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i+1)+"-"+ n.ToString();
+ }
+ break;
+ case "按电缆对编号"://一个电缆对中线号按顺序编号,另一个电缆对中线号重新从1开始编号
+ if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("数字"))
+ {
+ Tag = (j + 1).ToString();
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("字母"))
+ {
+ Tag = Tag + (char)('A' + j);
+ }
+ else if (ReslistPro.Where(p => p.DisplayText.Equals("编号类型")).Select(p => p.PropertyValue).FirstOrDefault().Equals("电缆对序号"))
+ {
+ Tag = (i+1) + "-" + (j+1).ToString();
+ }
+ break;
+ }
+ ec_CableSetWire.Wire_Tag = a + Tag;
+ ec_CableSet.Wires.Add(ec_CableSetWire);
+ }
+ ec_Cable.Sets.Add(ec_CableSet);
+ }
+ var httpres = await _iOModuleService.CreateCableByProfile(ec_Cable);
+ ResCableEngID = await _iOModuleService.GetCableByEngID(ResTagInfosByPixels.tags.FirstOrDefault().EngineDataID);
+ }
+ }
+ if (ResCableEngID != null)
+ {
+
+ IntPtr cadHandle = Bricscad.ApplicationServices.Application.MainWindow.Handle;
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ //para.Add(GlobalObject.dialogPar.para1.ToString(), "6e2919e4-28cd-4fb6-9035-10b2ff0e30fb");
+ para.Add(GlobalObject.dialogPar.info.ToString(), cadHandle);
+
+ para.Add(GlobalObject.dialogPar.para1.ToString(), ResCableEngID);
+ para.Add(GlobalObject.dialogPar.para2.ToString(), ResTagInfosByPixels.tags.FirstOrDefault().TagNumber);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogSignalPredistribution), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+
+ }
+ else if (RES.Result == ButtonResult.No)
+ { }
+ });
+ }
+
+ }
+
+ }
+ catch (System.Exception ex)
+ {
+ ed.WriteMessage($"\n错误: {ex.Message}");
+ }
+ });
+ btnCableSinal.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CableSinal.png");
+ btnCableSinal.Id = "信号预分配";
+ ribbonRowPanel.Items.Add(btnCableSinal);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 批量反向关联
+ RibbonButton btnRelevancy = new RibbonButton();
+ btnRelevancy.ToolTip = "批量反向关联";
+ btnRelevancy.Text = "批量反向关联";
+ btnRelevancy.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRelevancy.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRelevancy.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"relevancy.png");
+ btnRelevancy.Id = "批量反向关联";
+ ribbonRowPanel.Items.Add(btnRelevancy);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 系统图识别
+ RibbonButton btnGraphRec = new RibbonButton();
+ btnGraphRec.ToolTip = "系统图识别";
+ btnGraphRec.Text = "系统图识别";
+ btnGraphRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnGraphRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnGraphRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"GraphRec.png");
+ btnGraphRec.Id = "系统图识别";
+ ribbonRowPanel.Items.Add(btnGraphRec);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 竖向图识别
+ RibbonButton btnVerticalRec = new RibbonButton();
+ btnVerticalRec.ToolTip = "竖向图识别";
+ btnVerticalRec.Text = "竖向图识别";
+ btnVerticalRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnVerticalRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnVerticalRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"VerticalRec.png");
+ btnVerticalRec.Id = "竖向图识别";
+ ribbonRowPanel.Items.Add(btnVerticalRec);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 链路图识别
+ RibbonButton btnLightLineRec = new RibbonButton();
+ btnLightLineRec.ToolTip = "链路图识别";
+ btnLightLineRec.Text = "链路图识别";
+ btnLightLineRec.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnLightLineRec.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnLightLineRec.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"lightLine.png");
+ btnLightLineRec.Id = "链路图识别";
+ ribbonRowPanel.Items.Add(btnLightLineRec);
+ #endregion
+ dataSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 图形刷新
+ RibbonPanelSource dwgRefreshSource = new RibbonPanelSource();
+ dwgRefreshSource.Title = "图形刷新";
+ dwgRefreshSource.Id = "图形刷新";
+ RibbonPanel dwgRefreshPanel = new RibbonPanel();
+ dwgRefreshPanel.Source = dwgRefreshSource;
+ tab1.Panels.Add(dwgRefreshPanel);
+ //大按钮
+ #region buttons 刷新标注
+ RibbonButton btnRefreshText = new RibbonButton();
+ btnRefreshText.ToolTip = "刷新标注";
+ btnRefreshText.Text = "刷新标注";
+ btnRefreshText.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnRefreshText.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshText.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshText.png");
+ btnRefreshText.Id = "刷新标注";
+ dwgRefreshSource.Items.Add(btnRefreshText);
+ #endregion
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 刷新元件
+ RibbonButton btnRefreshBlock = new RibbonButton();
+ btnRefreshBlock.ToolTip = "刷新元件";
+ btnRefreshBlock.Text = "刷新元件";
+ btnRefreshBlock.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshBlock.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshBlock.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshBlock.png");
+ btnRefreshBlock.Id = "刷新元件";
+ ribbonRowPanel.Items.Add(btnRefreshBlock);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新图框
+ RibbonButton btnRefreshFrame = new RibbonButton();
+ btnRefreshFrame.ToolTip = "刷新图框";
+ btnRefreshFrame.Text = "刷新图框";
+ btnRefreshFrame.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshFrame.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshFrame.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshFrame.png");
+ btnRefreshFrame.Id = "刷新图框";
+ ribbonRowPanel.Items.Add(btnRefreshFrame);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新连接
+ RibbonButton btnRefreshLink = new RibbonButton();
+ btnRefreshLink.ToolTip = "刷新连接";
+ btnRefreshLink.Text = "刷新连接";
+ btnRefreshLink.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshLink.CommandHandler = new DelegateCommand(x =>
+ {
+ var configView = GlobalObject.container.Resolve();
+ Application.ShowModalWindow(Application.MainWindow.Handle, configView);
+ });
+ btnRefreshLink.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshLink.png");
+ btnRefreshLink.Id = "刷新连接";
+ ribbonRowPanel.Items.Add(btnRefreshLink);
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 查看链路
+ RibbonButton btnShowLink = new RibbonButton();
+ btnShowLink.ToolTip = "查看链路";
+ btnShowLink.Text = "查看链路";
+ btnShowLink.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnShowLink.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnShowLink.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"ShowLink.png");
+ btnShowLink.Id = "查看链路";
+ ribbonRowPanel.Items.Add(btnShowLink);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新位置
+ RibbonButton btnUpdatePosition = new RibbonButton();
+ btnUpdatePosition.ToolTip = "刷新位置";
+ btnUpdatePosition.Text = "刷新位置";
+ btnUpdatePosition.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnUpdatePosition.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnUpdatePosition.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"UpdatePosition.png");
+ btnUpdatePosition.Id = "刷新位置";
+ ribbonRowPanel.Items.Add(btnUpdatePosition);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 刷新坐标
+ RibbonButton btnRefreshPosition = new RibbonButton();
+ btnRefreshPosition.ToolTip = "刷新坐标";
+ btnRefreshPosition.Text = "刷新坐标";
+ btnRefreshPosition.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnRefreshPosition.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnRefreshPosition.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"RefreshPosition.png");
+ btnRefreshPosition.Id = "刷新坐标";
+ ribbonRowPanel.Items.Add(btnRefreshPosition);
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 图元高亮
+ RibbonButton btnActiveObject = new RibbonButton();
+ btnActiveObject.ToolTip = "图元高亮";
+ btnActiveObject.Text = "图元高亮";
+ btnActiveObject.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnActiveObject.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnActiveObject.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"ActiveObject.png");
+ btnActiveObject.Id = "图元高亮";
+ ribbonRowPanel.Items.Add(btnActiveObject);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ dwgRefreshSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 数据交换
+ RibbonPanelSource dataExchangeSource = new RibbonPanelSource();
+ dataExchangeSource.Title = "数据交换";
+ dataExchangeSource.Id = "数据交换";
+ RibbonPanel dataExchangePanel = new RibbonPanel();
+ dataExchangePanel.Source = dataExchangeSource;
+ tab1.Panels.Add(dataExchangePanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 元件导入
+ RibbonButton btnImput = new RibbonButton();
+ btnImput.ToolTip = "元件导入";
+ btnImput.Text = "元件导入";
+ btnImput.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnImput.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnImput.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Imput.png");
+ btnImput.Id = "元件导入";
+ ribbonRowPanel.Items.Add(btnImput);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 元件导出
+ RibbonButton btnExport = new RibbonButton();
+ btnExport.ToolTip = "元件导出";
+ btnExport.Text = "元件导出";
+ btnExport.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnExport.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnExport.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Export.png");
+ btnExport.Id = "元件导出";
+ ribbonRowPanel.Items.Add(btnExport);
+ #endregion
+ dataExchangeSource.Items.Add(ribbonRowPanel);
+ //垂直排列按钮panel
+ ribbonRowPanel = new RibbonRowPanel();
+ #region buttons 电缆检查
+ RibbonButton btnCheckCable = new RibbonButton();
+ btnCheckCable.ToolTip = "电缆检查";
+ btnCheckCable.Text = "电缆检查";
+ btnCheckCable.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnCheckCable.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnCheckCable.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CheckCable.png");
+ btnCheckCable.Id = "电缆检查";
+ ribbonRowPanel.Items.Add(btnCheckCable);
+ ribbonRowPanel.Items.Add(new RibbonRowBreak());//换行,这样可以使按钮多行排列
+ #endregion
+ #region buttons 属性检查
+ RibbonButton btnPropertyCheck = new RibbonButton();
+ btnPropertyCheck.ToolTip = "属性检查";
+ btnPropertyCheck.Text = "属性检查";
+ btnPropertyCheck.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnPropertyCheck.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnPropertyCheck.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"Property.png");
+ btnPropertyCheck.Id = "属性检查";
+ ribbonRowPanel.Items.Add(btnPropertyCheck);
+ #endregion
+ dataExchangeSource.Items.Add(ribbonRowPanel);
+ #endregion
+
+ #region Ribbon 软件配置
+ RibbonPanelSource systemSource = new RibbonPanelSource();
+ systemSource.Title = "软件配置";
+ systemSource.Id = "软件配置";
+ RibbonPanel systemPanel = new RibbonPanel();
+ systemPanel.Source = systemSource;
+ tab1.Panels.Add(systemPanel);
+ //下拉按钮列表
+ RibbonSplitButton splitButton = new RibbonSplitButton();
+ splitButton.Text = "软件配置";
+ splitButton.ShowText = true;
+ splitButton.ShowImage = true;
+ splitButton.IsVisible = true;
+ splitButton.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ #region buttons 绘图配置
+ RibbonButton btnDwgConfig = new RibbonButton();
+ btnDwgConfig.ToolTip = "绘图配置";
+ btnDwgConfig.Text = "绘图配置";
+ btnDwgConfig.ButtonStyle = RibbonButtonStyle.LargeWithText;
+ btnDwgConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnDwgConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"DConfig.png");
+ btnDwgConfig.Id = "绘图配置";
+ splitButton.Items.Add(btnDwgConfig);
+ #endregion
+ #region buttons 标注配置
+ RibbonButton btnAaConfig = new RibbonButton();
+ btnAaConfig.ToolTip = "标注配置";
+ btnAaConfig.Text = "标注配置";
+ btnAaConfig.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnAaConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ MessageBox.Show("功能开发中...");
+ });
+ btnAaConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"TConfig.png");
+ btnAaConfig.Id = "标注配置";
+ splitButton.Items.Add(btnAaConfig);
+ #endregion
+ #region buttons 系统配置
+ RibbonButton btnSystemConfig = new RibbonButton();
+ btnSystemConfig.ToolTip = "系统配置";
+ btnSystemConfig.Text = "系统配置";
+ btnSystemConfig.ButtonStyle = RibbonButtonStyle.SmallWithText;
+ btnSystemConfig.CommandHandler = new DelegateCommand(x =>
+ {
+ var configView = GlobalObject.container.Resolve();
+ Application.ShowModalWindow(Application.MainWindow.Handle, configView);
+ });
+ btnSystemConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SConfig.png");
+ btnSystemConfig.Id = "系统配置";
+ splitButton.Items.Add(btnSystemConfig);
+ #endregion
+ systemSource.Items.Add(splitButton);
+
+ #endregion
+ }
+
+ }
+}
+
+
+
+
+
diff --git a/newFront/c#前端/SWS.CAD/Commands_BASE_608.cs b/newFront/c#前端/SWS.CAD/Commands_BASE_608.cs
new file mode 100644
index 00000000..a28f2dcd
--- /dev/null
+++ b/newFront/c#前端/SWS.CAD/Commands_BASE_608.cs
@@ -0,0 +1,1521 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Windows.Forms;
+using Bricscad.ApplicationServices;
+using Bricscad.EditorInput;
+using Bricscad.Ribbon;
+using Bricscad.Windows;
+using Prism.Events;
+using Prism.Ioc;
+using Prism.Services.Dialogs;
+using SWS.CAD;
+using SWS.CAD.CADFunc;
+using SWS.CAD.Event;
+using SWS.CAD.Views;
+using SWS.CAD.Views.Dialog;
+using Teigha.DatabaseServices;
+using Teigha.Runtime;
+using Telerik.Windows.Controls;
+using Unity;
+using Application = Bricscad.ApplicationServices.Application;
+using Panel = Bricscad.Windows.Panel;
+using GlobalObject = SWS.Commons.GlobalObject;
+using SWS.Model;
+using SWS.Service;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
+
+
+[assembly: CommandClass(typeof(Commands))]
+[assembly: ExtensionApplication(typeof(Commands))]
+namespace SWS.CAD
+{
+ public partial class Commands : IExtensionApplication
+ {
+
+ public void Initialize()
+ {
+
+ try
+ {
+ AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+ if (RibbonServices.RibbonPaletteSet == null)
+ RibbonServices.CreateRibbonPaletteSet(); //needed for ribbon samples
+ Start.RegisterTypes();
+ DockingTemplate dockTemplate = new DockingTemplate();
+ dockTemplate.DefaultStackId = "DI-ELEC_LDock"; //default stack is RDOCK panelset
+ dockTemplate.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate.DefaultDock = DockSides.Left; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView = GlobalObject.container.Resolve();
+ Panel panel = new Panel(nameof(LeftPanel), dockTemplate, drawingView);
+ panel.Title = "DI_左面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ AddTab();
+
+ DockingTemplate dockTemplate2 = new DockingTemplate();
+ dockTemplate2.DefaultStackId = "RDOCK"; //default stack is RDOCK panelset
+ dockTemplate2.DefaultStackZ = 20; //default to position 20 (bottom of the stack)
+ dockTemplate2.DefaultDock = DockSides.Right; //dock alone at right in case RDOCK panelset isn't available
+
+ var drawingView2 = GlobalObject.container.Resolve();
+ panel = new Panel(nameof(RightPanel), dockTemplate2, drawingView2);
+ panel.Title = "DI_右面板";
+ panel.Icon = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"CSharp.ico");
+ panel.Visible = true;
+
+ }
+ catch (System.Exception e)
+ {
+ Application.ShowAlertDialog(" An exception occurred in Initialize():\n" + e.ToString());
+ }
+ }
+
+
+
+ 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()
+ {
+ }
+
+ #region 显示属性弹窗
+ ///
+ /// 显示属性弹窗
+ ///
+ private ObservableCollection ShowPropertyMessage(string title, List listPropertys)
+ {
+
+ ObservableCollection ReslistPro = new ObservableCollection();
+ //打开窗体
+ var para = new Prism.Services.Dialogs.DialogParameters();
+ para.Add(GlobalObject.dialogPar.title.ToString(), title);
+ para.Add(GlobalObject.dialogPar.para1.ToString(), listPropertys);
+ var _dialogService = GlobalObject._prismContainer.Resolve();
+ _dialogService.ShowDialog(nameof(DialogNewPositional), para, (RES) =>
+ {
+ if (RES.Result == ButtonResult.Yes)
+ {
+ ReslistPro = RES.Parameters.GetValue