Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using NXOpen;
- using NXOpen.BlockStyler;
- namespace DesignUi
- {
- class DesignUi
- {
- private static Session theSession = null;
- private static UI theUI = null;
- private string theDlxFileName;
- private NXOpen.BlockStyler.BlockDialog theDialog;
- private NXOpen.BlockStyler.Label lblLogo;// Block type: Label
- private NXOpen.BlockStyler.Label EmptyLabel;// Block type: Label
- private NXOpen.BlockStyler.Group grpStatus;// Block type: Group
- private NXOpen.BlockStyler.Label lblRawMaterial;// Block type: Label
- private NXOpen.BlockStyler.Label lblShank;// Block type: Label
- private NXOpen.BlockStyler.Label lblInternalCoolant;// Block type: Label
- private NXOpen.BlockStyler.Label lblToolInformations;// Block type: Label
- private NXOpen.BlockStyler.Separator separator0;// Block type: Separator
- private NXOpen.BlockStyler.Label lblChecksCompleted;// Block type: Label
- private NXOpen.BlockStyler.Label lblEmpty01;// Block type: Label
- private NXOpen.BlockStyler.Button btnRunAutoCheck;// Block type: Button
- private NXOpen.BlockStyler.Group grpRawMaterial;// Block type: Group
- private NXOpen.BlockStyler.Enumeration enumMaterial;// Block type: Enumeration
- private NXOpen.BlockStyler.Enumeration enumHeatTreatment;// Block type: Enumeration
- private NXOpen.BlockStyler.Enumeration enumCoating;// Block type: Enumeration
- private NXOpen.BlockStyler.Label lblEmpty001;// Block type: Label
- private NXOpen.BlockStyler.Label lblDimensions;// Block type: Label
- private NXOpen.BlockStyler.DoubleBlock dblMaxDiameter;// Block type: Double
- private NXOpen.BlockStyler.DoubleBlock dblMaxLength;// Block type: Double
- private NXOpen.BlockStyler.Label SpaceItem;// Block type: Label
- private NXOpen.BlockStyler.Group grpShank;// Block type: Group
- private NXOpen.BlockStyler.Enumeration enumShank;// Block type: Enumeration
- private NXOpen.BlockStyler.Label lblNumberOfClampingDevices;// Block type: Label
- private NXOpen.BlockStyler.Group grpInternalCoolant;// Block type: Group
- private NXOpen.BlockStyler.Toggle chkInternalCoolant;// Block type: Toggle
- private NXOpen.BlockStyler.Label lblInternalCoolantDimensions;// Block type: Label
- private NXOpen.BlockStyler.DoubleBlock dblInternalCoolantDiameter;// Block type: Double
- private NXOpen.BlockStyler.DoubleBlock dblInternalCoolantLength;// Block type: Double
- private NXOpen.BlockStyler.Group grpToolInformation;// Block type: Group
- private NXOpen.BlockStyler.Enumeration enumToolCategory;// Block type: Enumeration
- private NXOpen.BlockStyler.Label EmptyLabel2;// Block type: Label
- private NXOpen.BlockStyler.IntegerBlock intNumberOfInsertSeats;// Block type: Integer
- private NXOpen.BlockStyler.Label EmptyLabel3;// Block type: Label
- private NXOpen.BlockStyler.IntegerBlock intNumberOfCartridgeSeats;// Block type: Integer
- private NXOpen.BlockStyler.Group grpInformation;// Block type: Group
- private NXOpen.BlockStyler.MultilineString strInformation;// Block type: Multiline String
- private NXOpen.BlockStyler.Label EmptyLabel4;// Block type: Label
- private NXOpen.BlockStyler.MultilineString strProblems;// Block type: Multiline String
- private NXOpen.BlockStyler.Button btnReportProblem;// Block type: Button
- //------------------------------------------------------------------------------
- //Constructor for NX Styler class
- //------------------------------------------------------------------------------
- public DesignUi()
- {
- try
- {
- theSession = Session.GetSession();
- theUI = UI.GetUI();
- theDlxFileName = @"C:\Users\OneDrive\SmartModel\SmartModel\UI.Design.dlx";
- theDialog = theUI.CreateDialog(theDlxFileName);
- theDialog.AddOkHandler(new NXOpen.BlockStyler.BlockDialog.Ok(ok_cb));
- theDialog.AddUpdateHandler(new NXOpen.BlockStyler.BlockDialog.Update(update_cb));
- theDialog.AddInitializeHandler(new NXOpen.BlockStyler.BlockDialog.Initialize(initialize_cb));
- theDialog.AddDialogShownHandler(new NXOpen.BlockStyler.BlockDialog.DialogShown(dialogShown_cb));
- }
- catch (Exception ex)
- {
- throw ex;
- }
- }
- public static void Main()
- {
- DesignUi theMainView = null;
- try
- {
- theMainView = new DesignUi();
- theMainView.Show();
- }
- catch (Exception ex)
- {
- theUI.NXMessageBox.Show("SmartModel - Error", NXMessageBox.DialogType.Error, ex.ToString());
- }
- finally
- {
- if (theMainView != null)
- theMainView.Dispose();
- theMainView = null;
- }
- }
- public static int GetUnloadOption(string arg)
- {
- return Convert.ToInt32(Session.LibraryUnloadOption.Immediately);
- }
- public static void UnloadLibrary(string arg)
- {
- try
- {
- }
- catch (Exception ex)
- {
- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
- }
- }
- //------------------------------------------------------------------------------
- //This method shows the dialog on the screen
- //------------------------------------------------------------------------------
- public NXOpen.UIStyler.DialogResponse Show()
- {
- try
- {
- theDialog.Show();
- }
- catch (Exception ex)
- {
- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
- }
- return 0;
- }
- //------------------------------------------------------------------------------
- //Method Name: Dispose
- //------------------------------------------------------------------------------
- public void Dispose()
- {
- if (theDialog != null)
- {
- theDialog.Dispose();
- theDialog = null;
- }
- }
- //------------------------------------------------------------------------------
- //Callback Name: initialize_cb
- //------------------------------------------------------------------------------
- public void initialize_cb()
- {
- try
- {
- lblLogo = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblLogo");
- EmptyLabel = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("EmptyLabel");
- grpStatus = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpStatus");
- lblRawMaterial = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblRawMaterial");
- lblShank = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblShank");
- lblInternalCoolant = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblInternalCoolant");
- lblToolInformations = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblToolType");
- separator0 = (NXOpen.BlockStyler.Separator)theDialog.TopBlock.FindBlock("separator0");
- lblChecksCompleted = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblChecksCompleted");
- lblEmpty01 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblEmpty01");
- btnRunAutoCheck = (NXOpen.BlockStyler.Button)theDialog.TopBlock.FindBlock("btnRunAutoCheck");
- grpRawMaterial = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpRawMaterial");
- enumMaterial = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumMaterial");
- enumHeatTreatment = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumHeatTreatment");
- enumCoating = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumCoating");
- lblEmpty001 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblEmpty001");
- lblDimensions = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblDimensions");
- dblMaxDiameter = (NXOpen.BlockStyler.DoubleBlock)theDialog.TopBlock.FindBlock("dblMaxDiameter");
- dblMaxLength = (NXOpen.BlockStyler.DoubleBlock)theDialog.TopBlock.FindBlock("dblMaxLength");
- SpaceItem = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("SpaceItem");
- grpShank = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpShank");
- enumShank = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumShank");
- lblNumberOfClampingDevices = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblNumberOfClampingDevices");
- grpInternalCoolant = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpInternalCoolant");
- chkInternalCoolant = (NXOpen.BlockStyler.Toggle)theDialog.TopBlock.FindBlock("chkInternalCoolant");
- lblInternalCoolantDimensions = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("lblInternalCoolantDimensions");
- dblInternalCoolantDiameter = (NXOpen.BlockStyler.DoubleBlock)theDialog.TopBlock.FindBlock("dblInternalCoolantDiameter");
- dblInternalCoolantLength = (NXOpen.BlockStyler.DoubleBlock)theDialog.TopBlock.FindBlock("dblInternalCoolantLength");
- grpToolInformation = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpToolInformation");
- enumToolCategory = (NXOpen.BlockStyler.Enumeration)theDialog.TopBlock.FindBlock("enumToolCategory");
- EmptyLabel2 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("EmptyLabel2");
- intNumberOfInsertSeats = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("intNumberOfInsertSeats");
- EmptyLabel3 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("EmptyLabel3");
- intNumberOfCartridgeSeats = (NXOpen.BlockStyler.IntegerBlock)theDialog.TopBlock.FindBlock("intNumberOfCartridgeSeats2");
- grpInformation = (NXOpen.BlockStyler.Group)theDialog.TopBlock.FindBlock("grpInformation");
- strInformation = (NXOpen.BlockStyler.MultilineString)theDialog.TopBlock.FindBlock("strInformation");
- EmptyLabel4 = (NXOpen.BlockStyler.Label)theDialog.TopBlock.FindBlock("EmptyLabel4");
- strProblems = (NXOpen.BlockStyler.MultilineString)theDialog.TopBlock.FindBlock("strProblems");
- btnReportProblem = (NXOpen.BlockStyler.Button)theDialog.TopBlock.FindBlock("btnReportProblem");
- }
- catch (Exception ex)
- {
- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
- }
- }
- //------------------------------------------------------------------------------
- //Callback Name: dialogShown_cb
- //This callback is executed just before the dialog launch. Thus any value set
- //here will take precedence and dialog will be launched showing that value.
- //------------------------------------------------------------------------------
- public void dialogShown_cb()
- {
- try
- {
- }
- catch (Exception ex)
- {
- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
- }
- }
- //------------------------------------------------------------------------------
- //Callback Name: update_cb
- //------------------------------------------------------------------------------
- public int update_cb(NXOpen.BlockStyler.UIBlock block)
- {
- try
- {
- if (block == btnRunAutoCheck)
- {
- }
- else if (block == enumMaterial)
- {
- }
- else if (block == enumHeatTreatment)
- {
- }
- else if (block == enumCoating)
- {
- }
- else if (block == dblMaxDiameter)
- {
- }
- else if (block == dblMaxLength)
- {
- }
- else if (block == enumShank)
- {
- }
- else if (block == chkInternalCoolant)
- {
- }
- else if (block == dblInternalCoolantDiameter)
- {
- }
- else if (block == dblInternalCoolantLength)
- {
- }
- else if (block == enumToolCategory)
- {
- }
- else if (block == intNumberOfInsertSeats)
- {
- }
- else if (block == intNumberOfCartridgeSeats)
- {
- }
- else if (block == strInformation)
- {
- }
- else if (block == strProblems)
- {
- }
- else if (block == btnReportProblem)
- {
- }
- }
- catch (Exception ex)
- {
- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
- }
- return 0;
- }
- //------------------------------------------------------------------------------
- //Callback Name: ok_cb
- //------------------------------------------------------------------------------
- public int ok_cb()
- {
- int errorCode = 0;
- try
- {
- //EndRoutine();
- }
- catch (Exception ex)
- {
- errorCode = 1;
- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
- }
- return errorCode;
- }
- //------------------------------------------------------------------------------
- //Function Name: GetBlockProperties
- //Returns the propertylist of the specified BlockID
- //------------------------------------------------------------------------------
- public PropertyList GetBlockProperties(string blockID)
- {
- PropertyList plist = null;
- try
- {
- plist = theDialog.GetBlockProperties(blockID);
- }
- catch (Exception ex)
- {
- theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
- }
- return plist;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement