Exemplo n.º 1
0
        public void KbdData(string param, string data)
        {
            XElement cfg = Program.curr_cfg;

            if (param == "entersys")
            {
                if (Password.compare_pwd("admin", data))
                {
                    Process app = new Process();
                    app.StartInfo.FileName  = "Explorer.exe";
                    app.StartInfo.Arguments = "";
                    app.Start();
                    Thread.Sleep(2000);
                    Program.kbdwnd.Hide();
//                    Type shellType = Type.GetTypeFromProgID("Shell.Application");
//                    object shellObject = System.Activator.CreateInstance(shellType);
//                    shellType.InvokeMember("ToggleDesktop", System.Reflection.BindingFlags.InvokeMethod, null, shellObject, null);
                }

                return;
            }
            if (param == "quitlock")
            {
                if (Password.compare_pwd("lock", data))
                {
                    b_lockon = false;
                    Password.set_pwd("lock", "0");
                    b_lockon = false;
                    Program.runwnd.Disable(true);
                    Program.singlewnd.Disable(true);
                    UpdateDisplay(true);
                }
            }
            if (param == "enterlock")
            {
                //App should expire after desired packer number reached , data is the actual packer count
                Password.set_pwd("lock_on", data);
                DeleteRegist("lock_on");
                WTRegedit("lock_on", data);
                Password.set_pwd("lock", data);
                Program.SaveAppConfig();
                b_lockon = true;
                UpdateDisplay(false);
            }
            if (param.IndexOf("reg_") == 0)
            {
                SubNode n = null;
                if (curr_sel == -1)
                {
                    return;
                }
                Byte i = Convert.ToByte(curr_sel);
                NodeMaster.SetNodeReg(i, new string[] { param.Remove(0, 4) }, new UInt32[] { UInt32.Parse(data) });

                btn_refreshreg_Click(null, null);
            }
            if (param.IndexOf("chgnd_") == 0)
            {
                Byte oldaddr = Byte.Parse(param.Remove(0, 6));
                Byte newaddr = Byte.Parse(data);
                NodeMaster.ChangeAddress(oldaddr, newaddr);
            }
            if (param != "cali0" && (param.IndexOf("cali") == 0)) //cali1 to cali10
            {
                string msg = StringResource.str("put_poise") + "(" + data + StringResource.str("gram") + ")";

                Program.MsgShow(msg);
                int i = RunModeWnd.StringToId(param) - 1;
                if (curr_sel >= 0)
                {
                    NodeMaster.RefreshNodeReg((byte)curr_sel, new string[] { "cs_mtrl" });
                    UInt32 cs_mtrl_val = NodeMaster.GetNodeReg((byte)curr_sel, "cs_mtrl");
                    if (cs_mtrl_val <= WeighNode.MAX_VALID_WEIGHT)
                    {
                        if (i < 5)
                        {
                            NodeMaster.SetNodeReg((byte)curr_sel, new string[] { "poise_weight_gram" + i.ToString() }, new UInt32[] { cs_mtrl_val });
                        }
                        else
                        {
                            NodeMaster.SetNodeReg((byte)curr_sel, new string[] { "cs_poise" + (i - 5).ToString() }, new UInt32[] { cs_mtrl_val });
                        }
                        NodeMaster.Action(new byte[] { (byte)curr_sel }, "flash");
                        Program.MsgShow(StringResource.str("calidone"));
                        label3_MouseLeftButtonUp(null, null);
                        return;
                    }
                    Program.MsgShow(StringResource.str("tryagain"));
                }
                return;
            }
        }