コード例 #1
0
 private void Add_Button(int x, int y)
 {
     NormalControls.MyButton button = new NormalControls.MyButton();
     this.Controls.Add(button);
     //button.Button_Press += new EventHandler(Press_Button);
     button.Left = x - button.Width / 2;
     button.Top  = y - button.Top / 2;
 }
コード例 #2
0
        private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // 普通标签
            #region
            if (CopyType == "Normal")
            {
                string    where_cmd = "labelname='" + CopyObject_Name + "'";
                DataTable dt        = MainView.Main_DataBase_Builder.Select_Table("Alllabel", where_cmd);
                if (dt != null)
                {
                    if (dt.Rows.Count >= 1)
                    {
                        DataRow dr = dt.Rows[0];
                        NormalControls.MyLabel label = new NormalControls.MyLabel("Normal");
                        this.Controls.Add(label);
                        label.Left = 300;
                        label.Top  = 300;
                        label.Set_Text(dr[1].ToString());
                        label.Width  = int.Parse(dr[4].ToString());
                        label.Height = int.Parse(dr[5].ToString());
                        label.Set_BackColor(dr[6].ToString());
                        label.Set_FontSize(int.Parse(dr[8].ToString()));
                        label.Set_ForeColor(dr[9].ToString());
                        label.BringToFront();
                    }
                }
            }
            #endregion

            // 按钮
            #region
            if (CopyType == "Button")
            {
                string    where_cmd = "buttonname='" + CopyObject_Name + "'";
                DataTable dt        = MainView.Main_DataBase_Builder.Select_Table("AllButton", where_cmd);
                if (dt != null)
                {
                    if (dt.Rows.Count >= 1)
                    {
                        DataRow dr = dt.Rows[0];
                        NormalControls.MyButton button = new NormalControls.MyButton();
                        this.Controls.Add(button);
                        button.Left = 300;
                        button.Top  = 300;
                        button.SetText(dr[1].ToString());
                        button.Width  = int.Parse(dr[4].ToString());
                        button.Height = int.Parse(dr[5].ToString());
                        button.Set_BackColor(dr[6].ToString());
                        button.Set_FontSize(int.Parse(dr[8].ToString()));
                        button.Set_ForeColor(dr[9].ToString());
                        button.BringToFront();
                        //button.Button_Press += new EventHandler(Press_Button);
                    }
                }
            }
            #endregion
        }
コード例 #3
0
        public void Press_Button(object sender, EventArgs e)
        {
            NormalControls.MyButton button = (NormalControls.MyButton)sender;
            if (MainView.Is_Edit == false)
            {
                // 在运行状态下
                DataTable buttondt = MainView.Main_DataBase_Builder.Select_Table(button.MyName);
                if (buttondt != null)
                {
                    if (buttondt.Rows.Count > 0)
                    {
                        foreach (DataRow dr in buttondt.Rows)
                        {
                            // 数据设定
                            #region
                            if (dr[1].ToString() == "数据设定")
                            {
                                string data_name = dr[2].ToString();
                                double value     = 0;
                                try
                                {
                                    value = double.Parse(dr[3].ToString());
                                }
                                catch { break; }

                                // 寻找这个量的内部地址
                                string    where_cmd = "dataname='" + data_name + "'";
                                DataTable datatable = MainView.Main_DataBase_Builder.Select_Table("AllData", where_cmd);
                                if (datatable != null)
                                {
                                    if (datatable.Rows.Count > 0)
                                    {
                                        DataRow datarow = datatable.Rows[0];
                                        try
                                        {
                                            if (datarow[4].ToString() == "内部数据")
                                            {
                                                int machine_num = int.Parse(datarow[5].ToString());
                                                int address     = int.Parse(datarow[6].ToString());
                                                if (datarow[1].ToString() == "整型")
                                                {
                                                    Data.Int_Data[machine_num, address] = (int)value;
                                                }
                                            }
                                        }
                                        catch { break; }
                                    }
                                }
                            }
                            #endregion

                            // 刷新
                            if (dr[1].ToString() == "刷新本页面")
                            {
                                Read_Run_View(Selected_View_Name);
                            }
                        }
                    }
                }
            }
        }
コード例 #4
0
        private void Show_Windows_Control(Form view)
        {
            view.Controls.Clear();
            DataTable dt = Main_DataBase_Builder.Select_Table(Selected_View_Name);

            if (dt != null)
            {
                foreach (DataRow dr in dt.Rows)
                {
                    // 解析所有的标签
                    #region
                    if (dr[1].ToString() == "NormalLabel")
                    {
                        string    where_cmd = "labelname='" + dr[0].ToString() + "'";
                        DataTable labeldt   = Main_DataBase_Builder.Select_Table("Alllabel", where_cmd);
                        if (labeldt != null)
                        {
                            if (labeldt.Rows.Count > 0)
                            {
                                try
                                {
                                    DataRow labeldr = labeldt.Rows[0];
                                    NormalControls.MyLabel mylabel = new NormalControls.MyLabel("Normal");
                                    mylabel.MyName   = labeldr[0].ToString();
                                    mylabel.ViewName = view.Name;
                                    mylabel.Set_Text(labeldr[1].ToString());
                                    mylabel.Left   = int.Parse(labeldr[2].ToString());
                                    mylabel.Top    = int.Parse(labeldr[3].ToString());
                                    mylabel.Width  = int.Parse(labeldr[4].ToString());
                                    mylabel.Height = int.Parse(labeldr[5].ToString());
                                    mylabel.Set_BackColor(labeldr[6].ToString());
                                    mylabel.Set_FontSize(int.Parse(labeldr[8].ToString()));
                                    mylabel.Set_ForeColor(labeldr[9].ToString());
                                    view.Controls.Add(mylabel);
                                    //mylabel
                                }
                                catch { }
                            }
                        }
                    }
                    #endregion
                    // 解析所有的数据标签
                    #region
                    if (dr[1].ToString() == "ValueLabel")
                    {
                        NormalControls.MyLabel label = get_valuelabel(dr[0].ToString());
                        if (label != null)
                        {
                            view.Controls.Add(label);
                        }
                    }
                    #endregion

                    // 解析所有的按钮
                    #region
                    if (dr[1].ToString() == "Button")
                    {
                        string    where_cmd = "buttonname='" + dr[0].ToString() + "'";
                        DataTable buttondt  = Main_DataBase_Builder.Select_Table("AllButton", where_cmd);
                        if (buttondt != null)
                        {
                            if (buttondt.Rows.Count > 0)
                            {
                                try
                                {
                                    DataRow buttondr = buttondt.Rows[0];
                                    NormalControls.MyButton mybutton = new NormalControls.MyButton();
                                    mybutton.MyName   = buttondr[0].ToString();
                                    mybutton.ViewName = view.Name;
                                    mybutton.SetText(buttondr[1].ToString());
                                    mybutton.Left   = int.Parse(buttondr[2].ToString());
                                    mybutton.Top    = int.Parse(buttondr[3].ToString());
                                    mybutton.Width  = int.Parse(buttondr[4].ToString());
                                    mybutton.Height = int.Parse(buttondr[5].ToString());
                                    mybutton.Set_BackColor(buttondr[6].ToString());
                                    mybutton.Set_FontSize(int.Parse(buttondr[8].ToString()));
                                    mybutton.Set_ForeColor(buttondr[9].ToString());
                                    view.Controls.Add(mybutton);
                                    mybutton.Button_Press += new EventHandler(Press_Button);
                                    //mylabel
                                }
                                catch { }
                            }
                        }
                    }
                    #endregion
                }
            }
        }