
# Conflicts: # newFront/c#前端/SWS.CAD/Commands.cs # newFront/c#前端/SWS.Electrical/obj/Debug/Views/DialogTest2.g.i.cs # newFront/c#前端/SWS.Electrical/obj/Debug/Views/SWSDialogWindow.g.cs # newFront/c#前端/SWS.Electrical/obj/Debug/Views/SWSDialogWindow.g.i.cs # newFront/c#前端/SWS.WPF/obj/Debug/Views/CustomDialogWindow.g.cs # newFront/c#前端/SWS.WPF/obj/Debug/Views/CustomDialogWindow.g.i.cs
1522 lines
91 KiB
C#
1522 lines
91 KiB
C#
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<LeftPanel>();
|
||
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<RightPanel>();
|
||
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 显示属性弹窗
|
||
/// <summary>
|
||
/// 显示属性弹窗
|
||
/// </summary>
|
||
private ObservableCollection<propertyModel> ShowPropertyMessage(string title, List<propertyModel> listPropertys)
|
||
{
|
||
|
||
ObservableCollection<propertyModel> ReslistPro = new ObservableCollection<propertyModel>();
|
||
//打开窗体
|
||
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<IDialogService>();
|
||
_dialogService.ShowDialog(nameof(DialogNewPositional), para, (RES) =>
|
||
{
|
||
if (RES.Result == ButtonResult.Yes)
|
||
{
|
||
ReslistPro = RES.Parameters.GetValue<ObservableCollection<propertyModel>>(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<Project>();
|
||
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<Login>();
|
||
//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<UserNotification>();
|
||
var eventAggregator = GlobalObject.container.Resolve<IEventAggregator>();
|
||
eventAggregator.GetEvent<SelectProjectEvent>().Publish(new List<SWS.Model.ec_notification>());
|
||
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<ObjectTypeService>();
|
||
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<IDialogService>();
|
||
_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<propertyModel>();
|
||
var _objectTypeService = GlobalObject.container.Resolve<ObjectTypeService>();
|
||
var _iOModuleService = GlobalObject.container.Resolve<IOModuleService>();
|
||
// 持续选择直到获取有效电缆
|
||
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<ObjectTypeService>();
|
||
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<propertyModel>();
|
||
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<propertyModel>();
|
||
Dictionary<string, string> 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<string, string>();
|
||
pulldownlist.Add("数字", "数字");
|
||
pulldownlist.Add("字母", "字母");
|
||
pulldownlist.Add("电缆对序号", "电缆对序号");
|
||
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
|
||
pulldownlist = new Dictionary<string, string>();
|
||
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<ec_CableSet>();
|
||
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<ec_CableSetWire>();
|
||
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<propertyModel>();
|
||
Dictionary<string, string> 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<string, string>();
|
||
pulldownlist.Add("数字", "数字");
|
||
pulldownlist.Add("字母", "字母");
|
||
pulldownlist.Add("电缆对序号", "电缆对序号");
|
||
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
|
||
pulldownlist = new Dictionary<string, string>();
|
||
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<ec_CableSet>();
|
||
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<ec_CableSetWire>();
|
||
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<IDialogService>();
|
||
_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<IDialogService>();
|
||
_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<IDialogService>();
|
||
_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<propertyModel>();
|
||
var _objectTypeService = GlobalObject.container.Resolve<ObjectTypeService>();
|
||
var _iOModuleService = GlobalObject.container.Resolve<IOModuleService>();
|
||
// 持续选择直到获取有效电缆
|
||
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<propertyModel>();
|
||
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<propertyModel>();
|
||
Dictionary<string, string> 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<string, string>();
|
||
pulldownlist.Add("数字", "数字");
|
||
pulldownlist.Add("字母", "字母");
|
||
pulldownlist.Add("电缆对序号", "电缆对序号");
|
||
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
|
||
pulldownlist = new Dictionary<string, string>();
|
||
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<ec_CableSet>();
|
||
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<ec_CableSetWire>();
|
||
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<propertyModel>();
|
||
Dictionary<string, string> 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<string, string>();
|
||
pulldownlist.Add("数字", "数字");
|
||
pulldownlist.Add("字母", "字母");
|
||
pulldownlist.Add("电缆对序号", "电缆对序号");
|
||
listPropertys.Add(new propertyModel() { Id = "1", DisplayText = "编号类型", GroupName = "电芯参数", PropertyValue = "数字", ControlTypeName = PROPERTYType.ComboBox, Item = pulldownlist, });
|
||
pulldownlist = new Dictionary<string, string>();
|
||
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<ec_CableSet>();
|
||
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<ec_CableSetWire>();
|
||
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<IDialogService>();
|
||
_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<Config>();
|
||
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<Config>();
|
||
Application.ShowModalWindow(Application.MainWindow.Handle, configView);
|
||
});
|
||
btnSystemConfig.Image = GlobalObject.ImageSourceFromEmbeddedResourceStream(@"SConfig.png");
|
||
btnSystemConfig.Id = "系统配置";
|
||
splitButton.Items.Add(btnSystemConfig);
|
||
#endregion
|
||
systemSource.Items.Add(splitButton);
|
||
|
||
#endregion
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|