public void SetControls()
        {
            // Sets all the controls from settings
            ThemeToggleSwitch.IsOn    = Settings.Theme == "BaseDark" || Settings.Theme == "Dark";
            TxtbxOutputdirectory.Text = Assembly.GetEntryAssembly()?.Location ?? throw new InvalidOperationException();
            if (!string.IsNullOrEmpty(Settings.Directory))
            {
                TxtbxOutputdirectory.Text = Settings.Directory;
            }
            ChbxAutostart.IsOn            = Settings.Autostart;
            ChbxMinimizeSystray.IsOn      = Settings.Systray;
            ChbxCustomPause.IsOn          = Settings.CustomPauseTextEnabled;
            ChbxTelemetry.IsOn            = Settings.Telemetry;
            TxtbxCustompausetext.Text     = Settings.CustomPauseText;
            TxtbxOutputformat.Text        = Settings.OutputString;
            ChbxUpload.IsOn               = Settings.Upload;
            NudChrome.Value               = Settings.ChromeFetchRate;
            ChbxCover.IsOn                = Settings.DownloadCover;
            ChbxSplit.IsOn                = Settings.SplitOutput;
            txtbx_twChannel.Text          = Settings.TwChannel;
            txtbx_twOAuth.Password        = Settings.TwOAuth;
            txtbx_twUser.Text             = Settings.TwAcc;
            txtbx_RewardID.Text           = Settings.TwRewardId;
            Chbx_TwReward.IsOn            = Settings.TwSrReward;
            Chbx_TwCommand.IsOn           = Settings.TwSrCommand;
            NudMaxReq.Value               = Settings.TwSrMaxReq;
            NudCooldown.Value             = Settings.TwSrCooldown;
            Chbx_MessageLogging.IsChecked = Settings.MsgLoggingEnabled;
            Chbx_TwAutoconnect.IsOn       = Settings.TwAutoConnect;
            Chbx_AutoClear.IsOn           = Settings.AutoClearQueue;
            ChbxSpaces.IsChecked          = Settings.AppendSpaces;
            nud_Spaces.Value              = Settings.SpaceCount;
            tb_ClientID.Text              = Settings.ClientId;
            tb_ClientSecret.Password      = Settings.ClientSecret;
            Tglsw_Spotify.IsOn            = Settings.UseOwnApp;
            NudMaxlength.Value            = Settings.MaxSongLength;
            tgl_AnnounceInChat.IsOn       = Settings.AnnounceInChat;

            if (ApiHandler.Spotify != null)
            {
                lbl_SpotifyAcc.Content = Properties.Resources.sw_Integration_SpotifyLinked + " " +
                                         ApiHandler.Spotify.GetPrivateProfile().DisplayName;
            }

            ThemeHandler.ApplyTheme();

            cbx_Language.SelectionChanged -= ComboBox_SelectionChanged;
            switch (Settings.Language)
            {
            case "en":
                cbx_Language.SelectedIndex = 0;
                break;

            case "de-DE":
                cbx_Language.SelectedIndex = 1;
                break;

            case "ru-RU":
                cbx_Language.SelectedIndex = 2;
                break;

            case "es":
                cbx_Language.SelectedIndex = 3;
                break;

            case "fr":
                cbx_Language.SelectedIndex = 4;
                break;
            }

            cbx_Language.SelectionChanged += ComboBox_SelectionChanged;
        }
Esempio n. 2
0
        private void MetroWindowLoaded(object sender, RoutedEventArgs e)
        {
            AppDomain currentDomain = AppDomain.CurrentDomain;

            currentDomain.UnhandledException += MyHandler;

            if (File.Exists(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "/log.log"))
            {
                File.Delete(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "/log.log");
            }

            if (File.Exists(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "/Debug.log"))
            {
                File.Delete(Path.GetDirectoryName(Assembly.GetEntryAssembly()?.Location) + "/Debug.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 (Settings.Systray)
            {
                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
            AutoUpdater.Mandatory        = true;
            AutoUpdater.UpdateMode       = Mode.ForcedDownload;
            AutoUpdater.AppTitle         = "Songify";
            AutoUpdater.RunUpdateAsAdmin = false;

            AutoUpdater.Start("https://songify.rocks/update.xml");

            // 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 ©";

            if (_selectedSource == PlayerType.SpotifyWeb)
            {
                if (string.IsNullOrEmpty(Settings.AccessToken) && string.IsNullOrEmpty(Settings.RefreshToken))
                {
                    TxtblockLiveoutput.Text = "Please link your Spotify account\nSettings -> Spotify";
                }
                else
                {
                    ApiHandler.DoAuthAsync();
                }

                img_cover.Visibility = Visibility.Visible;
            }
            else
            {
                img_cover.Visibility = Visibility.Hidden;
            }

            if (Settings.TwAutoConnect)
            {
                TwitchHandler.BotConnect();
            }

            // automatically start fetching songs
            SetFetchTimer();
        }
Esempio n. 3
0
        public void SetControls()
        {
            // Sets all the controls from settings
            ThemeToggleSwitch.IsChecked = Settings.Theme == "BaseDark";
            TxtbxOutputdirectory.Text   = Assembly.GetEntryAssembly()?.Location ?? throw new InvalidOperationException();
            if (!string.IsNullOrEmpty(Settings.Directory))
            {
                TxtbxOutputdirectory.Text = Settings.Directory;
            }
            ChbxAutostart.IsChecked       = Settings.Autostart;
            ChbxMinimizeSystray.IsChecked = Settings.Systray;
            ChbxCustomPause.IsChecked     = Settings.CustomPauseTextEnabled;
            ChbxTelemetry.IsChecked       = Settings.Telemetry;
            TxtbxCustompausetext.Text     = Settings.CustomPauseText;
            TxtbxOutputformat.Text        = Settings.OutputString;
            txtbx_nbuser.Text             = Settings.NbUser;
            ChbxUpload.IsChecked          = Settings.Upload;
            NudChrome.Value               = Settings.ChromeFetchRate;
            ChbxCover.IsChecked           = Settings.DownloadCover;
            ChbxSplit.IsChecked           = Settings.SplitOutput;
            txtbx_twChannel.Text          = Settings.TwChannel;
            txtbx_twOAuth.Password        = Settings.TwOAuth;
            txtbx_twUser.Text             = Settings.TwAcc;
            txtbx_RewardID.Text           = Settings.TwRewardID;
            Chbx_TwReward.IsChecked       = Settings.TwSRReward;
            Chbx_TwCommand.IsChecked      = Settings.TwSRCommand;
            NudMaxReq.Value               = Settings.TwSRMaxReq;
            NudCooldown.Value             = Settings.TwSRCooldown;
            Chbx_MessageLogging.IsChecked = Settings.MsgLoggingEnabled;
            Chbx_TwAutoconnect.IsChecked  = Settings.TwAutoConnect;
            ChbxSplit.IsChecked           = Settings.SplitOutput;
            Chbx_AutoClear.IsChecked      = Settings.AutoClearQueue;
            ChbxSpaces.IsChecked          = Settings.AppendSpaces;
            nud_Spaces.Value              = Settings.SpaceCount;

            if (Settings.NbUserId != null)
            {
                lbl_nightbot.Content = "Nightbot (ID: " + Settings.NbUserId + ")";
            }
            if (APIHandler.spotify != null)
            {
                lbl_SpotifyAcc.Content = Properties.Resources.sw_Integration_SpotifyLinked + " " + APIHandler.spotify.GetPrivateProfile().DisplayName;
            }

            ThemeHandler.ApplyTheme();

            cbx_Language.SelectionChanged -= ComboBox_SelectionChanged;
            switch (Settings.Language)
            {
            case "en":
                cbx_Language.SelectedIndex = 0;
                break;

            case "de-DE":
                cbx_Language.SelectedIndex = 1;
                break;

            default:
                break;
            }

            cbx_Language.SelectionChanged += ComboBox_SelectionChanged;
        }