示例#1
0
        private void tvCommands_AfterSelect(object sender, TreeViewEventArgs e)
        {
            TreeNode nd = tvCommands.SelectedNode;

            if (nd != null)
            {
                if (nd.Tag is DeviceCommand)
                {
                    DeviceCommand cmd = (DeviceCommand)nd.Tag;
                    lbCommandDes.Text = cmd.Description;
                }
                else if (nd.Tag is DeviceGUICommand)
                {
                    DeviceGUICommand cmd = (DeviceGUICommand)nd.Tag;
                    lbCommandDes.Text = cmd.Description + "\r\n" + cmd.GUIPath;
                }
            }
        }
示例#2
0
        private void tvCommands_DoubleClick(object sender, EventArgs e)
        {
            TreeNode nd = tvCommands.SelectedNode;

            if (nd != null)
            {
                if (nd.Tag is DeviceCommand)
                {
                    DeviceCommand cmd = (DeviceCommand)nd.Tag;
                    txtQuickSend.Text   = cmd.GetSendDataString(GetFormat() == emViewFormat.Hex);
                    chkWrite.Checked    = cmd.Write;
                    chkRead.Checked     = cmd.ReadDataLength > 0;
                    numReadLength.Value = cmd.ReadDataLength;
                    Send();
                }
                else if (nd.Tag is DeviceGUICommand)
                {
                    string path = "";
                    try
                    {
                        DeviceGUICommand cmd = (DeviceGUICommand)nd.Tag;
                        path = System.IO.Directory.GetParent(Application.ExecutablePath) + "\\" + cmd.GUIPath;
                        Assembly guiLib = Assembly.LoadFile(path);
                        //Type t = guiLib.GetType("I2CDIO8.MyGUI");
                        Type         t   = guiLib.GetType(cmd.TypeName);
                        GuiInterface gui = (GuiInterface)Activator.CreateInstance(t);
                        CommObj      obj = new CommObj(this);

                        gui.Show(obj);
                    }
                    catch
                    {
                        MessageBox.Show("Fail to load GUI " + path);
                    }
                }
            }
        }