美文网首页狮猿社Tecnomatix_PDPS
Tecnomatix PDPS 开发:selection

Tecnomatix PDPS 开发:selection

作者: 锦囊喵 | 来源:发表于2020-03-02 16:04 被阅读0次

Tecnomatix PDPS selection

using Tecnomatix.Engineering.Ui.Forms;
using Tecnomatix.Engineering;
public class Form1 : TxForm
{
    //Edit box that will get the selection object.
    private System.Windows.Forms.TextBox textBox1;
    //Object in the text edit box control.
    private ITxObject obj = null;
    //Initialize the selection object.
     private TxSelection sel = TxApplication.ActiveSelection;

     private void InitializeComponent()
    {
        //Register to the selection events.
         sel.Cleared+= new TxSelection_ClearedEventHandler(this.Form1_Cleared);
         sel.ItemsSet+= new TxSelection_ItemsSetEventHandler(this.Form1_ItemsSet);
         sel.ItemsAdded+=new TxSelection_ItemsAddedEventHandler(this.Form1_ItemsAdded);
         sel.ItemsRemoved+= new TxSelection_ItemsRemovedEventHandler(this.Form1_ItemsRemoved);
         this.textBox1 = new System.Windows.Forms.TextBox();
     }
     
    //Selection was cleared. So, remove the text in the edit box control.
    private void Form1_Cleared (object sender, TxSelection_ClearedEventArgs e)
     {
         this.textBox1.Text = "";
         obj = null;
     }

     //New objects were added into the selection.
     private void Form1_ItemsAdded (object sender, TxSelection_ItemsAddedEventArgs e)
     {
         //If one object in the selection, i.e. like "Pick"
         if(e.ObjectList.Count == 1)
         {
            obj = e.ObjectList[0];
             this.textBox1.Text = obj.Name;
        }
     }

     //Some of the selection items were removed.
     private void Form1_ItemsRemoved (object sender, TxSelection_ItemsRemovedEventArgs e)
     {
        //if the object in the text was one of the removed object
        if(e.ObjectList.Contains(obj))
         {
             textBox1.Text = "";
             obj = null;
         }
     }

     //Selection was set to new items.
     private void Form1_ItemsSet (object sender, TxSelection_ItemsSetEventArgs e)
     {
         if(e.ObjectList.Count == 1)
         {
             obj = e.ObjectList[0];
             this.textBox1.Text = obj.Name;
         }
     }
}

相关文章

网友评论

    本文标题:Tecnomatix PDPS 开发:selection

    本文链接:https://www.haomeiwen.com/subject/bqsvkhtx.html