public MainForm() { InitializeComponent(); var basepath = APPFOLDER; if (Directory.Exists(APPFOLDER)) { basepath = APPFOLDER; } else if (Directory.Exists(SKYFOLDER)) { basepath = SKYFOLDER; } else if (Directory.Exists(DOCFOLDER)) { basepath = DOCFOLDER; } var configFile = Path.Combine(basepath, "config", "aqara.json"); AqaraConfig config = null; if (File.Exists(configFile)) { config = AqaraConfig.Parse(File.ReadAllText(configFile)); } client = new AqaraClient(config); timerRefresh = new Timer(); timerRefresh.Interval = 1000; timerRefresh.Tick += TimerRefresh_Tick; var column = new DataColumn() { Unique = true }; table.Columns.Add("sid", typeof(string)); table.Columns.Add("short_id", typeof(string)); table.Columns.Add("name", typeof(string)); table.Columns.Add("model", typeof(string)); table.Columns.Add("data", typeof(string)); table.Columns.Add("timestamp", typeof(string)); table.Columns.Add("DateUpdated", typeof(DateTime)); table.PrimaryKey = new DataColumn[] { table.Columns["sid"] }; dataGridView1.DataSource = table; }
public MainForm() { InitializeComponent(); string basePath = Path.Combine( KnownFolderPaths.KnownFolders.GetPath(KnownFolderPaths.KnownFolder.SkyDrive), @"ApplicationData\ConnectedHome\"); if (!Directory.Exists(basePath)) { Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.CommonDocuments), @"Elton\ConnectedHome\"); } var configFile = Path.Combine(basePath, "config", "aqara.json"); AqaraConfig config = null; if (File.Exists(configFile)) { config = AqaraConfig.Parse(File.ReadAllText(configFile)); } client = new AqaraClient(config); timerRefresh = new Timer(); timerRefresh.Interval = 1000; timerRefresh.Tick += TimerRefresh_Tick; var column = new DataColumn() { Unique = true }; table.Columns.Add("sid", typeof(string)); table.Columns.Add("short_id", typeof(string)); table.Columns.Add("name", typeof(string)); table.Columns.Add("model", typeof(string)); table.Columns.Add("data", typeof(string)); table.Columns.Add("timestamp", typeof(string)); table.Columns.Add("DateUpdated", typeof(DateTime)); table.PrimaryKey = new DataColumn[] { table.Columns["sid"] }; dataGridView1.DataSource = table; }