|
马上注册登录,享用更多网站功能!
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Runtime.InteropServices;
using NXOpen;
using NXOpen.Utilities;
using NXOpen.UF;
namespace SnagImage
{
/// <summary>
/// Summary description for SnagImage.
/// </summary>
public class SnagImage : System.Windows.Forms.Form
{
static Session m_session ;
static UI m_UI ;
static UFSession m_openSession ;
string ext=".bmp";
string ImageFileName="MyPart";
UFDisp.ImageFormat image_format=UFDisp.ImageFormat.Bmp;
UFDisp.BackgroundColor background_color=UFDisp.BackgroundColor.Original;
private System.Windows.Forms.Button btnSnag;
private System.Windows.Forms.OpenFileDialog openFileDialog1;
private System.Windows.Forms.GroupBox gbImageType;
private System.Windows.Forms.RadioButton rbBMP;
private System.Windows.Forms.RadioButton rbGIF;
private System.Windows.Forms.RadioButton rbPNG;
private System.Windows.Forms.RadioButton rbTIFF;
private System.Windows.Forms.RadioButton rbJPEG;
private System.Windows.Forms.RadioButton rbComTIFF;
private System.Windows.Forms.GroupBox groupBox1;
private System.Windows.Forms.RadioButton rbWhite;
private System.Windows.Forms.RadioButton rbOriginal;
private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1;
private System.Windows.Forms.Button btnExit;
private System.Windows.Forms.SaveFileDialog saveFileDialog1;
private System.Windows.Forms.GroupBox groupBox2;
private System.Windows.Forms.TextBox txtFileName;
private System.Windows.Forms.Button btnSelectFile;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;
public static void Main(string[] args)
{
SnagImage createImage= new SnagImage();
createImage.Show();
}
public static int GetUnloadOption(string dummy)
{
return UFConstants.UF_UNLOAD_SEL_DIALOG;
}
public SnagImage()
{
// \
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
m_session = Session.GetSession();
m_UI = UI.GetUI();
m_openSession = UFSession.GetUFSession();
ImageFileName="MyPartImage";
txtFileName.Text = ImageFileName + ext ;
NXOpenUI.FormUtilities.SetApplicationIcon(this);
NXOpenUI.FormUtilities.ReparentForm(this);
}
/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.btnSnag = new System.Windows.Forms.Button();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.gbImageType = new System.Windows.Forms.GroupBox();
this.rbComTIFF = new System.Windows.Forms.RadioButton();
this.rbJPEG = new System.Windows.Forms.RadioButton();
this.rbTIFF = new System.Windows.Forms.RadioButton();
this.rbPNG = new System.Windows.Forms.RadioButton();
this.rbGIF = new System.Windows.Forms.RadioButton();
this.rbBMP = new System.Windows.Forms.RadioButton();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.rbWhite = new System.Windows.Forms.RadioButton();
this.rbOriginal = new System.Windows.Forms.RadioButton();
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.btnExit = new System.Windows.Forms.Button();
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
this.groupBox2 = new System.Windows.Forms.GroupBox();
this.txtFileName = new System.Windows.Forms.TextBox();
this.btnSelectFile = new System.Windows.Forms.Button();
this.gbImageType.SuspendLayout();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.SuspendLayout();
//
// btnSnag
//
this.btnSnag.Location = new System.Drawing.Point(64, 320);
this.btnSnag.Name = "btnSnag";
this.btnSnag.Size = new System.Drawing.Size(120, 32);
this.btnSnag.TabIndex = 0;
this.btnSnag.Text = "Snag It";
this.btnSnag.Click += new System.EventHandler(this.btnSnag_Click);
//
// gbImageType
//
this.gbImageType.Controls.Add(this.rbComTIFF);
this.gbImageType.Controls.Add(this.rbJPEG);
this.gbImageType.Controls.Add(this.rbTIFF);
this.gbImageType.Controls.Add(this.rbPNG);
this.gbImageType.Controls.Add(this.rbGIF);
this.gbImageType.Controls.Add(this.rbBMP);
this.gbImageType.Location = new System.Drawing.Point(16, 16);
this.gbImageType.Name = "gbImageType";
this.gbImageType.Size = new System.Drawing.Size(376, 128);
this.gbImageType.TabIndex = 4;
this.gbImageType.TabStop = false;
this.gbImageType.Text = "Image Format";
//
// rbComTIFF
//
this.rbComTIFF.Location = new System.Drawing.Point(224, 88);
this.rbComTIFF.Name = "rbComTIFF";
this.rbComTIFF.Size = new System.Drawing.Size(136, 24);
this.rbComTIFF.TabIndex = 5;
this.rbComTIFF.Text = "COMPRESSED TIFF";
this.rbComTIFF.CheckedChanged += new System.EventHandler(this.rbComTIFF_CheckedChanged);
//
// rbJPEG
//
this.rbJPEG.Location = new System.Drawing.Point(64, 88);
this.rbJPEG.Name = "rbJPEG";
this.rbJPEG.TabIndex = 4;
this.rbJPEG.Text = "JPEG";
this.rbJPEG.CheckedChanged += new System.EventHandler(this.rbJPEG_CheckedChanged);
//
// rbTIFF
//
this.rbTIFF.Location = new System.Drawing.Point(224, 56);
this.rbTIFF.Name = "rbTIFF";
this.rbTIFF.TabIndex = 3;
this.rbTIFF.Text = "TIFF";
this.rbTIFF.CheckedChanged += new System.EventHandler(this.rbTIFF_CheckedChanged);
//
// rbPNG
//
this.rbPNG.Location = new System.Drawing.Point(224, 24);
this.rbPNG.Name = "rbPNG";
this.rbPNG.TabIndex = 2;
this.rbPNG.Text = "PNG";
this.rbPNG.CheckedChanged += new System.EventHandler(this.rbPNG_CheckedChanged);
//
// rbGIF
//
this.rbGIF.Location = new System.Drawing.Point(64, 56);
this.rbGIF.Name = "rbGIF";
this.rbGIF.TabIndex = 1;
this.rbGIF.Text = "GIF";
this.rbGIF.CheckedChanged += new System.EventHandler(this.rbGIF_CheckedChanged);
//
// rbBMP
//
this.rbBMP.Checked = true;
this.rbBMP.Location = new System.Drawing.Point(64, 24);
this.rbBMP.Name = "rbBMP";
this.rbBMP.TabIndex = 0;
this.rbBMP.TabStop = true;
this.rbBMP.Text = "BMP";
this.rbBMP.CheckedChanged += new System.EventHandler(this.rbBMP_CheckedChanged);
//
// groupBox1
//
this.groupBox1.Controls.Add(this.rbWhite);
this.groupBox1.Controls.Add(this.rbOriginal);
this.groupBox1.Location = new System.Drawing.Point(16, 160);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(376, 56);
this.groupBox1.TabIndex = 5;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "Background Color";
//
// rbWhite
//
this.rbWhite.Location = new System.Drawing.Point(224, 24);
this.rbWhite.Name = "rbWhite";
this.rbWhite.TabIndex = 4;
this.rbWhite.Text = "White";
this.rbWhite.CheckedChanged += new System.EventHandler(this.rbWhite_CheckedChanged);
|
|