public MainWindow() { try { string dirPath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Data"); Directory.CreateDirectory(dirPath); } catch (IOException e) { MessageBox.Show("Nelze vytvorit adresar Data. Zkontrolujte moznost zapisu ve slozce" + e); } InitializeComponent(); MessageBox.Show("Copyright(c) 2019 Jan Koranda\n\n" + "Permission is hereby granted, free of charge, to any person\n" + "obtaining a copy of this software and associated documentation\n" + "files(the 'Software'), to deal in the Software without\n" + "restriction, including without limitation the rights to use,\n" + "copy, modify, merge, publish, distribute, sublicense, and / or sell\n" + "copies of the Software, and to permit persons to whom the\n" + "Software is furnished to do so, subject to the following\n" + "conditions:\n" + "\n" + "The above copyright notice and this permission notice shall be included\n" + " in all copies or substantial portions of the Software.\n\n" + "THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\n" + "EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n" + "OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n" + "NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n" + "HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n" + "WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n" + "FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n" + "OTHER DEALINGS IN THE SOFTWARE."); Globals.previous = 0; //Dont know how to execute download on timer start, so using this again here WhazzupDownloader whazzupDownload = new WhazzupDownloader(); whazzupDownload.downloadWhazzup("https://api.ivao.aero/getdata/whazzup/whazzup.txt"); //Timer to execute download after 5 minutes and reset time tracker Timer t = new Timer(TimeSpan.FromMinutes(1).TotalMilliseconds); // Set the time (1 mins in this case) t.AutoReset = true; t.Elapsed += new ElapsedEventHandler(timer_Elapsed); t.Start(); }
private void timer_Elapsed(object sender, ElapsedEventArgs e) { WhazzupDownloader whazzupDownload = new WhazzupDownloader(); whazzupDownload.downloadWhazzup("https://api.ivao.aero/getdata/whazzup/whazzup.txt"); }