Wince 创新布局

如果你的项目是用wince开发并且机器是小型的pda,你可以考虑有这种布局方式。

IDE上布局,如图

Wince 创新布局

         /// <summary>
         /// 显示层
         /// </summary>
         /// <param name="name"></param>
         private void ShowPnl(string name)
         {
             foreach (Control c in this.Controls)
             {
                 if (c is Panel && !String.Equals(c.Name, name))
                 {
                     Panel p = (Panel)c;
                     p.Visible = false;
                 }
                 else if (c is Panel && String.Equals(c.Name, name))
                 {
                     Panel p = (Panel)c;
                     p.Visible = true;
                     p.Location = , );
                 }
             }
             pnlTopBar.Visible = true;
             if (!String.Equals(name, "pnlLogin"))
             {
                 pnlButtomBar.Location = , );
                 pnlButtomBar.Visible = true;
             }
         }
         /// <summary>
         /// 添加所有层里面的按钮点击事件
         /// </summary>
         private void LoadBtnClick()
         {
             foreach (Control c1 in this.Controls)
             {
                 if (c1 is Panel)
                 {
                     foreach (Control c2 in c1.Controls)
                     {
                         if (c2 is Button)
                         {
                             c2.Click += new EventHandler(btn_Click);
                         }
                     }
                 }
             }
         }
         /// <summary>
         /// Button事件
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
         void btn_Click(object sender, EventArgs e)
         {
             Button btn = sender as Button;
             btn.Enabled = false;
             switch (btn.Name)
             {
                 case "btnLogin":
                 case "btnMain_ButtomBar":
                     ShowPnl(pnlMain.Name);
                     break;
                 case "btnShowPnl1":
                 case "btnShowPnl1_ButtomBar":
                     ShowPnl(pnl1.Name);
                     break;
                 case "btnShowPnl2":
                 case "btnShowPnl2_ButtomBar":
                     ShowPnl(pnl2.Name);
                     break;
                 case "btnShowPnl3":
                 case "btnShowPnl3_ButtomBar":
                     ShowPnl(pnl3.Name);
                     break;
                 case "btnShowPnl4":
                 case "btnShowPnl4_ButtomBar":
                     ShowPnl(pnl4.Name);
                     break;
                 case "btnLoginOut":
                     ShowPnl(pnlLogin.Name);
                     break;
                 default:
                     break;
             }
             btn.Enabled = true;
         }

Demo地址:XyzDemoPro

上一篇:Android 框架学习之 第一天 okhttp & Retrofit


下一篇:解决 react-router / react-router-dom v4 history不能访问的问题