iCAx开思工具箱

 找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 1216|回复: 1
打印 上一主题 下一主题

[技术交流] C# winfrom 嵌入式NX 二次开发

[复制链接]
跳转到指定楼层
楼主
发表于 2018-12-20 11:20:15 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

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);
        

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享淘帖 支持支持
沙发
 楼主| 发表于 2018-12-20 11:23:05 | 只看该作者

马上注册登录,享用更多网站功能!

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手板模型制作,在线3D打印服务

QQ|小黑屋|手机版|开思工具箱 CAD工具箱_CAM工具箱  

GMT+8, 2024-4-24 12:52 , Processed in 0.011858 second(s), 6 queries , Gzip On, Redis On.

Powered by Discuz! X3.3

© 2002-2024 www.iCAx.org

快速回复 返回顶部 返回列表