示例#1
0
        /// <summary>
        /// Инициализация переменных.
        /// </summary>
        public void Init()
        {
            Version = "v1.0.1";

            InitTime = DateTime.Now;

            string fileName = Path.GetFileNameWithoutExtension(System.Reflection.Assembly.GetEntryAssembly().Location);

            varXml = new VarXml(string.Format("{0}.xml", fileName));
            varXml.LoadFromXML();

            CollectionWithUnits = new XPCollectionWithUnits();
            DeviceCollection    = (CollectionWithUnits.Add(typeof(Device))).Collection;

            DeviceRealCollection = new Collection <DeviceReal>();

            CopyDataToReal();

            // Отправка значений на интерфейс.
            foreach (DeviceReal deviceReal in DeviceRealCollection)
            {
                deviceReal.SendDataToXPObject();
            }

            ThreadMain              = new ThreadTimer();
            ThreadMain.Period       = varXml.ThreadMainPeriod;
            ThreadMain.WorkChanged += new EventHandler(ThreadMain_WorkChanged);
            ThreadMain.Run();

            ThreadMainDelay = varXml.ThreadMainDelay;
            AppName         = varXml.AppName;

            WorkerReboot         = new BackgroundWorker();
            WorkerReboot.DoWork += new DoWorkEventHandler(WorkerReboot_DoWork);
        }
示例#2
0
        /// <summary>
        /// Загрузить данные из XML-файла.
        /// </summary>
        /// <returns></returns>
        public void LoadFromXML()
        {
            if (File.Exists(FilePath))
            {
                XmlSerializer deserializer = new XmlSerializer(typeof(VarXml));
                TextReader    textReader   = new StreamReader(FilePath);
                VarXml        obj          = (VarXml)deserializer.Deserialize(textReader);
                textReader.Close();

                ThreadMainPeriod = obj.ThreadMainPeriod;
                ThreadMainDelay  = obj.ThreadMainDelay;
                AppName          = obj.AppName;
            }
        }
示例#3
0
 public SettingView()
 {
     InitializeComponent();
     varXml = new VarXml("Config.xml");
 }