private void bt_loadlog_Click(object sender, EventArgs e) { if (!File.Exists(logfilename)) { using (OpenFileDialog openFileDialog1 = new OpenFileDialog()) { openFileDialog1.Filter = "Log Files|*.log;*.bin;*.BIN;*.LOG"; openFileDialog1.FilterIndex = 2; openFileDialog1.Multiselect = true; openFileDialog1.InitialDirectory = lastLogDir ?? Settings.Instance.LogDir; if (openFileDialog1.ShowDialog() == DialogResult.OK) { lastLogDir = Path.GetDirectoryName(openFileDialog1.FileName); int a = 0; foreach (var fileName in openFileDialog1.FileNames) { Loading.ShowLoading(fileName, this); if (a == 0) { // load first file logfilename = fileName; ThreadPool.QueueUserWorkItem(o => LoadLog(logfilename)); } else { // load additional files in new windows if (File.Exists(fileName)) { LogBrowse browse = new LogBrowse(); browse.logfilename = fileName; browse.Show(this); } } a++; } } else { this.BeginInvoke((Action) delegate { this.Close(); }); return; } } } else { ThreadPool.QueueUserWorkItem(o => LoadLog(logfilename)); } }
private void BUT_logbrowse_Click(object sender, EventArgs e) { Form logbrowse = new LogBrowse(); ThemeManager.ApplyThemeTo(logbrowse); logbrowse.Show(); }
private void LogBrowse_Load(object sender, EventArgs e) { mapoverlay.Clear(); markeroverlay.Clear(); logdatafilter.Clear(); m_dtCSV.Clear(); if (logdata != null) logdata.Clear(); GC.Collect(); ErrorCache = new List<TextObj>(); ModeCache = new List<TextObj>(); TimeCache = new List<TextObj>(); seenmessagetypes = new Hashtable(); if (!File.Exists(logfilename)) { using (OpenFileDialog openFileDialog1 = new OpenFileDialog()) { openFileDialog1.Filter = "Log Files|*.log;*.bin"; openFileDialog1.FilterIndex = 2; openFileDialog1.RestoreDirectory = true; openFileDialog1.Multiselect = true; openFileDialog1.InitialDirectory = Settings.Instance.LogDir; if (openFileDialog1.ShowDialog() == DialogResult.OK) { int a = 0; foreach (var fileName in openFileDialog1.FileNames) { if (a == 0) { // load first file logfilename = fileName; ThreadPool.QueueUserWorkItem(o => LoadLog(logfilename)); } else { // load additional files in new windows if (File.Exists(fileName)) { LogBrowse browse = new LogBrowse(); browse.logfilename = fileName; browse.Show(this); } } a++; } } else { this.Close(); return; } } } else { ThreadPool.QueueUserWorkItem(o => LoadLog(logfilename)); } }
protected override void OnLoad(EventArgs e) { // check if its defined, and force to show it if not known about if (Settings.Instance["menu_autohide"] == null) { Settings.Instance["menu_autohide"] = "false"; } try { AutoHideMenu(Settings.Instance.GetBoolean("menu_autohide")); } catch { } MyView.AddScreen(new MainSwitcher.Screen("FlightData", FlightData, true)); MyView.AddScreen(new MainSwitcher.Screen("FlightPlanner", FlightPlanner, true)); MyView.AddScreen(new MainSwitcher.Screen("HWConfig", typeof(GCSViews.InitialSetup), false)); MyView.AddScreen(new MainSwitcher.Screen("SWConfig", typeof(GCSViews.SoftwareConfig), false)); MyView.AddScreen(new MainSwitcher.Screen("Simulation", Simulation, true)); MyView.AddScreen(new MainSwitcher.Screen("Terminal", typeof(GCSViews.Terminal), false)); MyView.AddScreen(new MainSwitcher.Screen("Help", typeof(GCSViews.Help), false)); try { if (Control.ModifierKeys == Keys.Shift) { } else { log.Info("Load Pluggins"); Plugin.PluginLoader.LoadAll(); log.Info("Load Pluggins Done"); } } catch (Exception ex) { log.Error(ex); } if (Program.Logo != null && Program.name == "VVVVZ") { this.PerformLayout(); MenuFlightPlanner_Click(this, e); MainMenu_ItemClicked(this, new ToolStripItemClickedEventArgs(MenuFlightPlanner)); } else { this.PerformLayout(); MenuFlightData_Click(this, e); MainMenu_ItemClicked(this, new ToolStripItemClickedEventArgs(MenuFlightData)); } // for long running tasks using own threads. // for short use threadpool this.SuspendLayout(); // setup http server try { httpthread = new Thread(new httpserver().listernforclients) { Name = "motion jpg stream-network kml", IsBackground = true }; httpthread.Start(); } catch (Exception ex) { log.Error("Error starting TCP listener thread: ", ex); CustomMessageBox.Show(ex.ToString()); } // setup joystick packet sender joystickthread = new Thread(new ThreadStart(joysticksend)) { IsBackground = true, Priority = ThreadPriority.AboveNormal, Name = "Main joystick sender" }; joystickthread.Start(); // setup main serial reader serialreaderthread = new Thread(SerialReader) { IsBackground = true, Name = "Main Serial reader", Priority = ThreadPriority.AboveNormal }; serialreaderthread.Start(); // setup main plugin thread pluginthread = new Thread(PluginThread) { IsBackground = true, Name = "plugin runner thread", Priority = ThreadPriority.BelowNormal }; pluginthread.Start(); ThreadPool.QueueUserWorkItem(BGLoadAirports); ThreadPool.QueueUserWorkItem(BGCreateMaps); //ThreadPool.QueueUserWorkItem(BGGetAlmanac); ThreadPool.QueueUserWorkItem(BGgetTFR); ThreadPool.QueueUserWorkItem(BGNoFly); ThreadPool.QueueUserWorkItem(BGGetKIndex); // update firmware version list - only once per day ThreadPool.QueueUserWorkItem(BGFirmwareCheck); try { new Utilities.AltitudeAngel.AltitudeAngel(); // setup as a prompt once dialog if (!Settings.Instance.GetBoolean("AACheck")) { if (CustomMessageBox.Show( "Do you wish to enable Altitude Angel airspace management data?\nFor more information visit [link;http://www.altitudeangel.com;www.altitudeangel.com]", "Altitude Angel - Enable", MessageBoxButtons.YesNo) == DialogResult.Yes) { Utilities.AltitudeAngel.AltitudeAngel.service.SignInAsync(); } Settings.Instance["AACheck"] = true.ToString(); } } catch (TypeInitializationException) // windows xp lacking patch level { CustomMessageBox.Show("Please update your .net version. kb2468871"); } catch (Exception ex) { Tracking.AddException(ex); } this.ResumeLayout(); Program.Splash.Close(); MissionPlanner.Utilities.Tracking.AddTiming("AppLoad", "Load Time", (DateTime.Now - Program.starttime).TotalMilliseconds, ""); try { // single update check per day - in a seperate thread if (Settings.Instance["update_check"] != DateTime.Now.ToShortDateString()) { System.Threading.ThreadPool.QueueUserWorkItem(checkupdate); Settings.Instance["update_check"] = DateTime.Now.ToShortDateString(); } else if (Settings.Instance.GetBoolean("beta_updates") == true) { MissionPlanner.Utilities.Update.dobeta = true; System.Threading.ThreadPool.QueueUserWorkItem(checkupdate); } } catch (Exception ex) { log.Error("Update check failed", ex); } // play a tlog that was passed to the program/ load a bin log passed if (Program.args.Length > 0) { if (File.Exists(Program.args[0]) && Program.args[0].ToLower().EndsWith(".tlog")) { FlightData.LoadLogFile(Program.args[0]); FlightData.BUT_playlog_Click(null, null); } else if (File.Exists(Program.args[0]) && Program.args[0].ToLower().EndsWith(".bin")) { LogBrowse logbrowse = new LogBrowse(); ThemeManager.ApplyThemeTo(logbrowse); logbrowse.logfilename = Program.args[0]; logbrowse.Show(this); logbrowse.TopMost = true; } } // show wizard on first use if (Settings.Instance["newuser"] == null) { if (CustomMessageBox.Show("This is your first run, Do you wish to use the setup wizard?\nRecomended for new users.", "Wizard", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { Wizard.Wizard wiz = new Wizard.Wizard(); wiz.ShowDialog(this); } CustomMessageBox.Show("To use the wizard please goto the initial setup screen, and click the wizard icon.", "Wizard"); Settings.Instance["newuser"] = DateTime.Now.ToShortDateString(); } }
protected override void OnLoad(EventArgs e) { // check if its defined, and force to show it if not known about if (Settings.Instance["menu_autohide"] == null) { Settings.Instance["menu_autohide"] = "false"; } try { AutoHideMenu(Settings.Instance.GetBoolean("menu_autohide")); } catch { } MyView.AddScreen(new MainSwitcher.Screen("FlightData", FlightData, true)); MyView.AddScreen(new MainSwitcher.Screen("FlightPlanner", FlightPlanner, true)); MyView.AddScreen(new MainSwitcher.Screen("HWConfig", typeof (GCSViews.InitialSetup), false)); MyView.AddScreen(new MainSwitcher.Screen("SWConfig", typeof (GCSViews.SoftwareConfig), false)); MyView.AddScreen(new MainSwitcher.Screen("Simulation", Simulation, true)); MyView.AddScreen(new MainSwitcher.Screen("Terminal", typeof (GCSViews.Terminal), false)); MyView.AddScreen(new MainSwitcher.Screen("Help", typeof (GCSViews.Help), false)); try { if (Control.ModifierKeys == Keys.Shift) { } else { log.Info("Load Pluggins"); Plugin.PluginLoader.LoadAll(); log.Info("Load Pluggins Done"); } } catch (Exception ex) { log.Error(ex); } if (Program.Logo != null && Program.name == "VVVVZ") { this.PerformLayout(); MenuFlightPlanner_Click(this, e); MainMenu_ItemClicked(this, new ToolStripItemClickedEventArgs(MenuFlightPlanner)); } else { this.PerformLayout(); MenuFlightData_Click(this, e); MainMenu_ItemClicked(this, new ToolStripItemClickedEventArgs(MenuFlightData)); } // for long running tasks using own threads. // for short use threadpool this.SuspendLayout(); // setup http server try { httpthread = new Thread(new httpserver().listernforclients) { Name = "motion jpg stream-network kml", IsBackground = true }; httpthread.Start(); } catch (Exception ex) { log.Error("Error starting TCP listener thread: ", ex); CustomMessageBox.Show(ex.ToString()); } // setup joystick packet sender joystickthread = new Thread(new ThreadStart(joysticksend)) { IsBackground = true, Priority = ThreadPriority.AboveNormal, Name = "Main joystick sender" }; joystickthread.Start(); // setup main serial reader serialreaderthread = new Thread(SerialReader) { IsBackground = true, Name = "Main Serial reader", Priority = ThreadPriority.AboveNormal }; serialreaderthread.Start(); // setup main plugin thread pluginthread = new Thread(PluginThread) { IsBackground = true, Name = "plugin runner thread", Priority = ThreadPriority.BelowNormal }; pluginthread.Start(); ThreadPool.QueueUserWorkItem(BGLoadAirports); ThreadPool.QueueUserWorkItem(BGCreateMaps); //ThreadPool.QueueUserWorkItem(BGGetAlmanac); ThreadPool.QueueUserWorkItem(BGgetTFR); ThreadPool.QueueUserWorkItem(BGNoFly); ThreadPool.QueueUserWorkItem(BGGetKIndex); // update firmware version list - only once per day ThreadPool.QueueUserWorkItem(BGFirmwareCheck); this.ResumeLayout(); Program.Splash.Close(); MissionPlanner.Utilities.Tracking.AddTiming("AppLoad", "Load Time", (DateTime.Now - Program.starttime).TotalMilliseconds, ""); try { // single update check per day - in a seperate thread if (Settings.Instance["update_check"] != DateTime.Now.ToShortDateString()) { System.Threading.ThreadPool.QueueUserWorkItem(checkupdate); Settings.Instance["update_check"] = DateTime.Now.ToShortDateString(); } else if (Settings.Instance.GetBoolean("beta_updates") == true) { MissionPlanner.Utilities.Update.dobeta = true; System.Threading.ThreadPool.QueueUserWorkItem(checkupdate); } } catch (Exception ex) { log.Error("Update check failed", ex); } // play a tlog that was passed to the program/ load a bin log passed if (Program.args.Length > 0) { if (File.Exists(Program.args[0]) && Program.args[0].ToLower().EndsWith(".tlog")) { FlightData.LoadLogFile(Program.args[0]); FlightData.BUT_playlog_Click(null, null); } else if (File.Exists(Program.args[0]) && Program.args[0].ToLower().EndsWith(".bin")) { LogBrowse logbrowse = new LogBrowse(); ThemeManager.ApplyThemeTo(logbrowse); logbrowse.logfilename = Program.args[0]; logbrowse.Show(this); logbrowse.TopMost = true; } } }