예제 #1
0
파일: frmMain.cs 프로젝트: taylor-an/AnyI2C
        /// <summary>
        /// Fill command tree
        /// </summary>
        /// <param name="node"></param>
        /// <param name="cmd"></param>
        private TreeNode FillCommandsTreeSubNode(DeviceCommandBase cmd)
        {
            TreeNode nd = new TreeNode();

            nd.Tag = cmd;
            if (cmd is DeviceCommandsGroup)
            {
                DeviceCommandsGroup g = (DeviceCommandsGroup)cmd;
                nd.Text = g.ToString();
                if (g.Commands != null)
                {
                    foreach (DeviceCommandBase c in g.Commands)
                    {
                        nd.Nodes.Add(FillCommandsTreeSubNode(c));
                    }
                }
            }
            else if (cmd is DeviceCommand)
            {
                nd.Text = cmd.ToString();
            }
            else if (cmd is DeviceGUICommand)
            {
                nd.Text = cmd.ToString();
            }
            return(nd);
        }
예제 #2
0
파일: frmMain.cs 프로젝트: taylor-an/AnyI2C
        /// <summary>
        /// Fill Commands tree with
        /// </summary>
        private void FillCommandsTree(DeviceConfig dev)
        {
            tvCommands.Nodes.Clear();
            DeviceCommandsGroup cmds = dev.Commands;

            if (cmds.Commands != null)
            {
                foreach (DeviceCommandBase cmd in cmds.Commands)
                {
                    TreeNode node = FillCommandsTreeSubNode(cmd);
                    tvCommands.Nodes.Add(node);
                }
            }
            ctlI2CAddress1.Addr7 = dev.Address;
        }
예제 #3
0
        public bool Load(string filename)
        {
            try
            {
                XmlReader     reader     = XmlReader.Create(filename);
                XmlSerializer serializer = new XmlSerializer(typeof(DeviceConfig));
                DeviceConfig  temp       = (DeviceConfig)serializer.Deserialize(reader);
                Type              = temp.Type;
                path              = filename;
                Name              = temp.Name;
                Manufactory       = temp.Manufactory;
                GeneralCall       = temp.GeneralCall;
                Address           = temp.Address;
                AddressCollection = temp.AddressCollection;
                Commands          = temp.Commands;

                reader.Close();
            }
            catch (Exception e)
            {
                Debug.Print("Fail to load configure file.");
            }
            return(false);
        }
예제 #4
0
        public bool Load(string filename)
        {
            try
            {
                XmlReader reader = XmlReader.Create(filename);
                XmlSerializer serializer = new XmlSerializer(typeof(DeviceConfig));
                DeviceConfig temp = (DeviceConfig)serializer.Deserialize(reader);
                Type = temp.Type;
                path = filename;
                Name = temp.Name;
                Manufactory = temp.Manufactory;
                GeneralCall = temp.GeneralCall;
                Address = temp.Address;
                AddressCollection = temp.AddressCollection;
                Commands = temp.Commands;

                reader.Close();
            }
            catch (Exception e)
            {
                Debug.Print("Fail to load configure file.");
            }
            return false;
        }