Smart3D Hierarchy选择对话框
我们需要利用系统的这个对话框
using Ingr.SP3D.Common.Client.Controls;
using Ingr.SP3D.Common.Middle;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ClassLibrary1
{
public partial class FromSelectHierarchy : Form
{
private static HierarchyComboBoxType _hierarchyType { get; set; }
public BusinessObject SelectedObject { get; set; } = null;
public FromSelectHierarchy(HierarchyComboBoxType HierarchyType,Filter filter=null)
{
InitializeComponent();
_hierarchyType = HierarchyType;
this.Text = $"Select {HierarchyType}";
this.label2.Text = $"{HierarchyType}:";
if (filter!=null) this.hierarchyComboBox1.Filter = filter;
this.hierarchyComboBox1.Show();
}
private void hierarchyComboBox1_DropDown(object sender, EventArgs e)
{
this.hierarchyComboBox1.HierarchyType = _hierarchyType;
this.hierarchyComboBox1.EnableMore = true;
}
private void hierarchyComboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.hierarchyComboBox1.SelectedIndex!=-1)
{
SelectedObject = (this.hierarchyComboBox1.SelectedItem as HierarchyComboBox.HierarchyComboBoxItem).BusinessObject;
}
}
private void button1_Click(object sender, EventArgs e)
{
if (SelectedObject != null)
{
this.DialogResult = DialogResult.Yes;
this.Close();
}
else
{
this.DialogResult = DialogResult.No;
this.Close();
}
}
private void FromSelectHierarchy_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
{
this.DialogResult = DialogResult.No;
this.Close();
}
}
}
}
public override void OnStart(int instanceId, object argument)
{
base.OnStart(instanceId, argument);
var ft = new Filter();
ft.Definition.AddObjectType("GeneralAssembly\\PlanningHierarchyItem\\PlanningAssembly");//IJPlatePart//A1000001(CAssembly)
var pv = new PropertyValueCodelist("IJAssemblyBase", "Type",6);//IJAssemblyBase
//base.WriteStatusBarMsg("pv:" + pv.PropertyInfo.CodeListInfo.CodelistMembers.SelectMany(c=>c.DisplayName));
ft.Definition.AddWhereProperty(pv, PropertyComparisonOperators.EQ);
var frm = new FromSelectHierarchy(HierarchyComboBoxType.Assembly,ft);
if (frm.ShowDialog()== System.Windows.Forms.DialogResult.Yes)
{
ClientServiceProvider.SelectSet.SelectedObjects.Clear();
ClientServiceProvider.SelectSet.SelectedObjects.Add(frm.SelectedObject);
}
}


浙公网安备 33010602011771号