private void btn_spotifyLink_Click(object sender, RoutedEventArgs e) { // Links Spotify Settings.RefreshToken = ""; try { APIHandler.DoAuthAsync(); SetControls(); } catch (Exception ex) { Logger.LogExc(ex); } }
private void MetroWindowLoaded(object sender, RoutedEventArgs e) { AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += new UnhandledExceptionEventHandler(MyHandler); if (File.Exists(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "/log.log")) { File.Delete(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "/log.log"); } if (Settings.AutoClearQueue) { ReqList.Clear(); WebHelper.UpdateWebQueue("", "", "", "", "", "1", "c"); } Settings.MsgLoggingEnabled = false; // Load Config file if one exists if (File.Exists(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "/config.xml")) { ConfigHandler.LoadConfig(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "/config.xml"); } // Add sources to combobox AddSourcesToSourceBox(); // Create systray menu and icon and show it _menuItem1.Text = @"Exit"; _menuItem1.Click += MenuItem1Click; _menuItem2.Text = @"Show"; _menuItem2.Click += MenuItem2Click; _contextMenu.MenuItems.AddRange(new[] { _menuItem2, _menuItem1 }); NotifyIcon.Icon = Properties.Resources.songify; NotifyIcon.ContextMenu = _contextMenu; NotifyIcon.Visible = true; NotifyIcon.DoubleClick += MenuItem2Click; NotifyIcon.Text = @"Songify"; // set the current theme ThemeHandler.ApplyTheme(); // start minimized in systray (hide) if (WindowState == WindowState.Minimized) { MinimizeToSysTray(); } // get the software version from assembly Assembly assembly = Assembly.GetExecutingAssembly(); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); Version = fvi.FileVersion; // generate UUID if not exists, expand the window and show the telemetrydisclaimer if (Settings.Uuid == "") { Width = 588 + 200; Height = 247.881 + 200; Settings.Uuid = Guid.NewGuid().ToString(); TelemetryDisclaimer(); } else { // start the timer that sends telemetry every 5 Minutes TelemetryTimer(); } // check for update WorkerUpdate.RunWorkerAsync(); // set the cbx index to the correct source cbx_Source.SelectedIndex = Settings.Source; _selectedSource = cbx_Source.SelectedValue.ToString(); cbx_Source.SelectionChanged += Cbx_Source_SelectionChanged; // text in the bottom right LblCopyright.Content = "Songify v" + Version.Substring(0, 5) + " Copyright © Jan \"Inzaniity\" Blömacher"; if (_selectedSource == PlayerType.SpotifyWeb) { if (string.IsNullOrEmpty(Settings.AccessToken) && string.IsNullOrEmpty(Settings.RefreshToken)) { TxtblockLiveoutput.Text = "Please link your Spotify account\nSettings -> Integration"; } else { APIHandler.DoAuthAsync(); } img_cover.Visibility = Visibility.Visible; } else { img_cover.Visibility = Visibility.Hidden; } if (Settings.TwAutoConnect) { TwitchHandler.BotConnect(); } // automatically start fetching songs SetFetchTimer(); }