async void Connect() { if (IsVisible) { Dispatcher.Invoke(() => { snackbarMessage.MessageQueue.Enqueue("Connecting you to the world"); }); } var connect = await hotspot.Connect(Settings.Default.Hotspot); Dispatcher.Invoke(() => { switch (connect) { case Hotspot.Status.Connected: snackbarMessage.MessageQueue.Enqueue($"You are now connected with Alien ( ͡° ͜ʖ ͡°)"); break; case Hotspot.Status.NoWifi: Error($"Cannot find wifi {Settings.Default.Hotspot.Device}"); break; case Hotspot.Status.FailWifi: Error($"Unable to connect to wifi {Settings.Default.Hotspot.Device}"); break; case Hotspot.Status.FailHotspot: Error("Unable to login to hotspot"); break; } }); }
void Starting(object sender, StartupEventArgs e) { string[] args = Environment.GetCommandLineArgs(); if (args.Length > 1) { switch (args[1]) { case "--nextbackground": try { var wallpaper = (IDesktopWallpaper) new DesktopWallpaper(); wallpaper.AdvanceSlideshow(null, DesktopSlideshowDirection.Forward); } catch (System.Runtime.InteropServices.COMException ex) { } Environment.Exit(0); break; case "--autostart": lazyStart = true; break; } } if (lazyStart) { if (Settings.Default.Hotspot == null) { return; } hotspot = new Hotspot(null); Task.Delay(5000).ContinueWith(async(dontCare) => { var connect = await hotspot.Connect(Settings.Default.Hotspot); if (connect != Hotspot.Status.Connected) { DebugHelper.File("Fail to auto hotspot"); } Environment.Exit(0); }); } else { MainWindow mainWindow = new MainWindow(); MainWindow = mainWindow; mainWindow.Show(); } }