예제 #1
0
        public UserSettingForm()
        {
            SetStyle(
                ControlStyles.AllPaintingInWmPaint | //不闪烁
                ControlStyles.OptimizedDoubleBuffer  //支持双缓存
                , true);
            InitializeComponent();

            AutoScale(this);
            //加载上次保存的用户设置
            comboBox1.Text       = INIhelp.GetValue("当前用户");
            textBox1.Text        = INIhelp.GetValue("背光时间");
            dateTimePicker2.Text = INIhelp.GetValue("时钟设置");
            textBox2.Text        = INIhelp.GetValue("修改密码");
            comboBox2.Text       = INIhelp.GetValue("蜂鸣器");
            textBox3.Text        = INIhelp.GetValue("修改加密锁");
        }
예제 #2
0
        public MainSettingForm()
        {
            SetStyle(
                ControlStyles.AllPaintingInWmPaint | //不闪烁
                ControlStyles.OptimizedDoubleBuffer  //支持双缓存
                , true);
            InitializeComponent();
            AutoScale(this);

            HomeForm.xinlei = false;
            if (INIhelp.GetValue("当前用户") != "管理员权限")
            {
                flag = true;
            }
            else
            {
                flag = false;
            }
        }
예제 #3
0
        public RuanxianweiForm()
        {
            SetStyle(
                ControlStyles.AllPaintingInWmPaint | //不闪烁
                ControlStyles.OptimizedDoubleBuffer  //支持双缓存
                , true);
            InitializeComponent();
            AutoScale(this);
            //加载软限位设置(读上次保存)
            textBox1.Text = INIhelp.GetValue("X轴上限位");
            textBox4.Text = INIhelp.GetValue("X轴下限位");

            textBox2.Text = INIhelp.GetValue("Z轴上限位");
            textBox5.Text = INIhelp.GetValue("Z轴下限位");

            textBox8.Text = INIhelp.GetValue("Y轴上限位");
            textBox6.Text = INIhelp.GetValue("Y轴下限位");

            textBox9.Text = INIhelp.GetValue("O轴上限位");
            textBox7.Text = INIhelp.GetValue("O轴下限位");
        }
예제 #4
0
        private void ret_btn3_Click(object sender, EventArgs e)
        {
            //点击返回保存用户设置
            INIhelp.SetValue("当前用户", comboBox1.Text);
            INIhelp.SetValue("背光时间", textBox1.Text);
            INIhelp.SetValue("时钟设置", dateTimePicker2.Text);
            INIhelp.SetValue("修改密码", textBox2.Text);
            INIhelp.SetValue("蜂鸣器", comboBox2.Text);
            INIhelp.SetValue("修改加密锁", textBox3.Text);

            if (INIhelp.GetValue("当前用户") != "管理员权限")
            {
                MainSettingForm.flag = true;
            }
            else
            {
                MainSettingForm.flag = false;
            }

            this.Close();
            this.DialogResult = DialogResult.OK;
        }
예제 #5
0
        /// <summary>
        /// 保存设置(下发指令并且设置保存)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button1_Click(object sender, EventArgs e)
        {
            //统统往下丢指令
            //X轴上限
            string str1 = textBox1.Text;

            if (str1 == "")
            {
                return;
            }
            int id1 = Convert.ToInt32(str1);

            byte[] iByte1 = toBytes.intToBytes(id1);//4位

            //X轴下限
            string str2 = textBox4.Text;

            if (str2 == "")
            {
                return;
            }
            int id2 = Convert.ToInt32(str2);

            byte[] iByte2 = toBytes.intToBytes(id2);//4位

            //Y轴上限
            string str5 = textBox8.Text;

            if (str5 == "")
            {
                return;
            }
            int id5 = Convert.ToInt32(str5);

            byte[] iByte5 = toBytes.intToBytes(id5);//4位

            //Y轴下限
            string str6 = textBox6.Text;

            if (str6 == "")
            {
                return;
            }
            int id6 = Convert.ToInt32(str6);

            byte[] iByte6 = toBytes.intToBytes(id6);//4位

            //Z轴上限

            string str3 = textBox2.Text;

            if (str3 == "")
            {
                return;
            }
            int id3 = Convert.ToInt32(str3);

            byte[] iByte3 = toBytes.intToBytes(id3);//4位

            //Z轴下限
            string str4 = textBox5.Text;

            if (str4 == "")
            {
                return;
            }
            int id4 = Convert.ToInt32(str4);

            byte[] iByte4 = toBytes.intToBytes(id4);//4位

            //O轴上限
            string str7 = textBox9.Text;

            if (str7 == "")
            {
                return;
            }
            int id7 = Convert.ToInt32(str7);

            byte[] iByte7 = toBytes.intToBytes(id7);//4位


            //O轴下限
            string str8 = textBox7.Text;

            if (str8 == "")
            {
                return;
            }
            int id8 = Convert.ToInt32(str8);

            byte[] iByte8 = toBytes.intToBytes(id8);//4位



            ////将四轴的开关状态写进一个字节发送出去
            //string[] status = new string[4];
            //try
            //{
            //    if (comboBox2.Text.Equals("开"))
            //    {
            //        status[0] = "1";
            //    }
            //    if (comboBox2.Text.Equals("关"))
            //    {
            //        status[0] = "0";
            //    }
            //    if (comboBox1.Text.Equals("开"))
            //    {
            //        status[1] = "1";
            //    }
            //    if (comboBox1.Text.Equals("关"))
            //    {
            //        status[1] = "0";
            //    }
            //    if (comboBox3.Text.Equals("开"))
            //    {
            //        status[2] = "1";
            //    }
            //    if (comboBox3.Text.Equals("关"))
            //    {
            //        status[2] = "0";
            //    }
            //    if (comboBox4.Text.Equals("开"))
            //    {
            //        status[3] = "1";
            //    }
            //    if (comboBox4.Text.Equals("关"))
            //    {
            //        status[3] = "0";
            //    }
            //}
            //catch
            //{

            //}
            //string status2 = string.Join("",status);
            //int a = Convert.ToInt32(status2, 2);
            //byte[] b = toBytes.intToBytes(a);

            BF.sendbuf[0]  = 0xFA;
            BF.sendbuf[1]  = 0x21;
            BF.sendbuf[2]  = 0x0B;
            BF.sendbuf[3]  = iByte1[3];
            BF.sendbuf[4]  = iByte1[2];
            BF.sendbuf[5]  = iByte1[1];
            BF.sendbuf[6]  = iByte1[0];
            BF.sendbuf[7]  = iByte2[3];
            BF.sendbuf[8]  = iByte2[2];
            BF.sendbuf[9]  = iByte2[1];
            BF.sendbuf[10] = iByte2[0];
            BF.sendbuf[11] = iByte5[3];
            BF.sendbuf[12] = iByte5[2];
            BF.sendbuf[13] = iByte5[1];
            BF.sendbuf[14] = iByte5[0];
            BF.sendbuf[15] = iByte6[3];
            BF.sendbuf[16] = iByte6[2];
            BF.sendbuf[17] = iByte6[1];
            BF.sendbuf[18] = iByte6[0];
            BF.sendbuf[19] = iByte3[3];
            BF.sendbuf[20] = iByte3[2];
            BF.sendbuf[21] = iByte3[1];
            BF.sendbuf[22] = iByte3[0];
            BF.sendbuf[23] = iByte4[3];
            BF.sendbuf[24] = iByte4[2];
            BF.sendbuf[25] = iByte4[1];
            BF.sendbuf[26] = iByte4[0];
            BF.sendbuf[27] = iByte7[3];
            BF.sendbuf[28] = iByte7[2];
            BF.sendbuf[29] = iByte7[1];
            BF.sendbuf[30] = iByte7[0];
            BF.sendbuf[31] = iByte8[3];
            BF.sendbuf[32] = iByte8[2];
            BF.sendbuf[33] = iByte8[1];
            BF.sendbuf[34] = iByte8[0];
            BF.sendbuf[35] = 0xF5;
            SendMenuCommand(BF.sendbuf, 36);

            //更新到配置文件里
            INIhelp.SetValue("X轴上限位", textBox1.Text);
            INIhelp.SetValue("X轴下限位", textBox4.Text);

            INIhelp.SetValue("Z轴上限位", textBox2.Text);
            INIhelp.SetValue("Z轴下限位", textBox5.Text);

            INIhelp.SetValue("Y轴上限位", textBox8.Text);
            INIhelp.SetValue("Y轴下限位", textBox6.Text);

            INIhelp.SetValue("O轴上限位", textBox9.Text);
            INIhelp.SetValue("O轴下限位", textBox7.Text);
        }
예제 #6
0
        /// <summary>
        /// 获取指示灯状态
        /// </summary>
        private void getStatus()
        {
            if (INIhelp.GetValue(GlobalV.sts3) == "1")
            {
                button3.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts3) == "0")
            {
                button3.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts4) == "1")
            {
                button4.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts4) == "0")
            {
                button4.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts5) == "1")
            {
                button5.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts5) == "0")
            {
                button5.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts6) == "1")
            {
                button6.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts6) == "0")
            {
                button6.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts7) == "1")
            {
                button7.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts7) == "0")
            {
                button7.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts8) == "1")
            {
                button8.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts8) == "0")
            {
                button8.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts9) == "1")
            {
                button9.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts9) == "0")
            {
                button9.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts10) == "1")
            {
                button10.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts10) == "0")
            {
                button10.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts11) == "1")
            {
                button11.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts11) == "0")
            {
                button11.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts12) == "1")
            {
                button12.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts12) == "0")
            {
                button12.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts13) == "1")
            {
                button13.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts13) == "0")
            {
                button13.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts14) == "1")
            {
                button14.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts14) == "0")
            {
                button14.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts15) == "1")
            {
                button15.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts15) == "0")
            {
                button15.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts16) == "1")
            {
                button16.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts16) == "0")
            {
                button16.BackColor = Color.Transparent;
            }

            if (INIhelp.GetValue(GlobalV.sts17) == "1")
            {
                button17.BackColor = Color.Red;
            }
            if (INIhelp.GetValue(GlobalV.sts17) == "0")
            {
                button17.BackColor = Color.Transparent;
            }
        }
예제 #7
0
        /// <summary>
        /// 保存指示灯状态,怎么遍历简化代码?
        /// </summary>

        private void saveStatus()
        {
            if (button3.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts3, "0");
            }
            if (button3.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts3, "1");
            }

            if (button4.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts4, "0");
            }
            if (button4.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts4, "1");
            }

            if (button5.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts5, "0");
            }
            if (button5.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts5, "1");
            }

            if (button6.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts6, "0");
            }
            if (button6.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts6, "1");
            }

            if (button7.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts7, "0");
            }
            if (button7.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts7, "1");
            }

            if (button8.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts8, "0");
            }
            if (button8.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts8, "1");
            }

            if (button9.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts9, "0");
            }
            if (button9.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts9, "1");
            }

            if (button10.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts10, "0");
            }
            if (button10.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts10, "1");
            }

            if (button11.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts11, "0");
            }
            if (button11.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts11, "1");
            }

            if (button12.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts12, "0");
            }
            if (button12.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts12, "1");
            }

            if (button13.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts13, "0");
            }
            if (button13.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts13, "1");
            }

            if (button14.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts14, "0");
            }
            if (button14.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts14, "1");
            }

            if (button15.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts15, "0");
            }
            if (button15.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts15, "1");
            }

            if (button16.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts16, "0");
            }
            if (button16.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts16, "1");
            }

            if (button17.BackColor == Color.Transparent)
            {
                INIhelp.SetValue(GlobalV.sts17, "0");
            }
            if (button17.BackColor == Color.Red)
            {
                INIhelp.SetValue(GlobalV.sts17, "1");
            }
        }