zoukankan      html  css  js  c++  java
  • AutoCAD.Net/C#.Net QQ群:193522571 同一套窗体代码,同时用在Winform、PvBox和PvTools中

    1.在Test文件夹中增加新的Winform项目P1,并且进行前期的窗体调试;

    注意需要把tlpMain设置为public:

    public System.Windows.Forms.TableLayoutPanel tlpMain;

    2.在PressureVessel项目中链接P1;

    修改P1项目代码:

    namespace PressureVessel
    {
        public partial class FrmGasketMy : Form
        {
            public FrmGasketMy()
            {
    #if !PVBOX
                InitializeComponent();
    #endif
            }
    
            DataTable dtMain;
            string sGasketType, sMatType;
            string sM, sY;
            string sImageName;
    
    #if PVBOX
            public void FormLoad()
            {
                InitializeComponent();
                btnExit.Visible = false;
    #else
            private void FrmGasketMy_Load(object sender, EventArgs e)
            {
    #endif

    修改P1.designer.cs中的代码:

            private void InitializeComponent()
            {
    #if !PVBOX
                this.tlpMain = new System.Windows.Forms.TableLayoutPanel();
    #endif
    #if !PVBOX
                this.Controls.Add(this.tlpMain);
                this.Load += new System.EventHandler(this.FrmGasketMy_Load);
    #endif

    3.在PvBox项目中按如下:

    //新增加ToolName枚举值
            public enum ToolName
            {
                MaterialAllowanceASME = 1,
                MaterialAllowanceGB,
                GbCategory,
                ToxicityDegree,
                Pipe,
                Flange,
                Fitting,
                Upipe,
                ExpansionJoint,
                Saddle,
                SupportLug,
                BracketSupport,
                HeatExchanger,
                Head,
                PipeLengthCal,
                BoltForce,
                Sanitory,
                LiquidLevel,
                CalWorld,
                Shape,
                HgFastener,
                Fastener,
                ReinforcePlate,
                GasketMy,
            }
            /// <summary>
            /// 垫片MY值
            /// </summary>
            TableLayoutPanel tlpGasketMy = new TableLayoutPanel();
            bool isGasketMyLoad = false;
            FrmGasketMy GasketMy;
                        case ToolName.GasketMy:
                            //垫片MY值
                            UpdateUserRecord();
                            if (!isGasketMyLoad)
                            {
                                scMain.Panel2.Controls.Add(tlpGasketMy);
                                GasketMy.tlpMain = tlpGasketMy;
                                GasketMy.FormLoad();
    
                                isGasketMyLoad = true;
                                tlpGasketMy.Dock = DockStyle.Fill;
                            }
                            else
                            {
                                scMain.Panel2.Controls.Add(tlpGasketMy);
                            }
                            break;

    4.PvTools中:

    SearchOut.cs

            /// <summary>
            /// 查垫片MY
            /// <summary>
            public void CDPMY()
            {
                FrmGasketMy frm = new FrmGasketMy();
                frm.SetFrmCenter();
                var result = Autodesk.AutoCAD.ApplicationServices.Application.ShowModalDialog(frm);
            }

    Command.cs

            /// <summary>
            ///查垫片MY:查询垫片的M、Y值
            /// <summary>
            [CommandMethod("CDPMY")]
        public static void CDPMY()
        {
          if (IsModelOk("CDPMY"))
          {
            SearchOut.CDPMY();
          }
        }

    这样同一个Form就可以在多个项目中使用了,如下图:

    a、Winform中:

    b、PvBox中:

     c、PvTools中:

  • 相关阅读:
    转换数值
    ASCII十进制字符集
    Metropolis-Hastings算法
    python + django 搭建网页(2)
    写一个脚本,循环运行 Projected-Hartree-Fock程序,然后提取结果
    写一个脚本,循环运行壳模型程序 bigstick.x,收集结果
    python画点线图
    python制作叠起来的柱状图,并且加上error bar
    python画散点图、大箭头
    python画柱状图,并且返回统计数据
  • 原文地址:https://www.cnblogs.com/swtool/p/14950290.html
Copyright © 2011-2022 走看看