Пример #1
0
        public FrmEspionSpotify()
        {
            SuspendLayout();

            Instance = this;
            InitializeComponent();

            _userSettings = new UserSettings();
            Rm            = new ResourceManager(typeof(en));
            BackImage     = Resources.spytify_logo;

            if (Settings.Default.Directory.Equals(string.Empty))
            {
                Settings.Default.Directory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
                Settings.Default.Save();
            }

            if (Settings.Default.AnalyticsCID.Equals(string.Empty))
            {
                Settings.Default.AnalyticsCID = Analytics.GenerateCID();
                Settings.Default.Save();
            }

            _analytics = new Analytics(Settings.Default.AnalyticsCID, Assembly.GetExecutingAssembly().GetName().Version.ToString());
            Task.Run(async() => await _analytics.LogAction("launch"));

            var clientId = Settings.Default.SpotifyAPIClientId;
            var secretId = Settings.Default.SpotifyAPISecretId;

            if (!string.IsNullOrEmpty(clientId) && !string.IsNullOrEmpty(secretId))
            {
                ExternalAPI.Instance = new MediaTags.SpotifyAPI(clientId, secretId);
            }

            var indexLanguage            = Settings.Default.Language;
            var indexBitRate             = Settings.Default.Bitrate;
            var indexAudioEndPointDevice = Settings.Default.AudioEndPointDeviceIndex.ToNullableInt();

            tcMenu.SelectedIndex = Settings.Default.TabNo;

            rbMp3.Checked             = Settings.Default.MediaFormat == 0;
            rbWav.Checked             = Settings.Default.MediaFormat == 1;
            tbMinTime.Value           = Settings.Default.MinimumRecordedLengthSeconds / 5;
            tgEndingSongDelay.Checked = Settings.Default.EndingSongDelayEnabled;
            tgAddSeparators.Checked   = Settings.Default.TrackTitleSeparatorEnabled;
            tgNumTracks.Checked       = Settings.Default.OrderNumberInMediaTagEnabled;
            tgNumFiles.Checked        = Settings.Default.OrderNumberInfrontOfFileEnabled;
            tgAddFolders.Checked      = Settings.Default.GroupByFoldersEnabled;
            txtPath.Text         = Settings.Default.Directory;
            tgDisableAds.Checked = ManageHosts.AreAdsDisabled(ManageHosts.HostsSystemPath);
            tgMuteAds.Checked    = Settings.Default.MuteAdsEnabled;
            tgDuplicateAlreadyRecordedTrack.Checked = Settings.Default.DuplicateAlreadyRecordedTrack;
            folderBrowserDialog.SelectedPath        = Settings.Default.Directory;

            SetLanguageDropDown();

            var language = (LanguageType)indexLanguage;

            SetLanguage(language);

            cbBitRate.SelectedIndex  = indexBitRate;
            cbLanguage.SelectedIndex = indexLanguage;

            _userSettings.OutputPath  = Settings.Default.Directory;
            _userSettings.Bitrate     = ((KeyValuePair <LAMEPreset, string>)cbBitRate.SelectedItem).Key;
            _userSettings.MediaFormat = (MediaFormat)Settings.Default.MediaFormat;
            _userSettings.MinimumRecordedLengthSeconds    = Settings.Default.MinimumRecordedLengthSeconds;
            _userSettings.GroupByFoldersEnabled           = Settings.Default.GroupByFoldersEnabled;
            _userSettings.TrackTitleSeparator             = Settings.Default.TrackTitleSeparatorEnabled ? "_" : " ";
            _userSettings.OrderNumberInMediaTagEnabled    = Settings.Default.OrderNumberInMediaTagEnabled;
            _userSettings.OrderNumberInfrontOfFileEnabled = Settings.Default.OrderNumberInfrontOfFileEnabled;
            _userSettings.EndingTrackDelayEnabled         = Settings.Default.EndingSongDelayEnabled;
            _userSettings.DuplicateAlreadyRecordedTrack   = Settings.Default.DuplicateAlreadyRecordedTrack;
            _userSettings.AudioEndPointDeviceIndex        = indexAudioEndPointDevice; // TODO: settings default stay last saved

            txtRecordingNum.Text = _userSettings.InternalOrderNumber.ToString("000");

            _audioSession = new MainAudioSession(indexAudioEndPointDevice);
            SetAudioEndPointDevicesDropDown();
            UpdateAudioEndPointFields();

            var lastVersionPrompted = Settings.Default.LastVersionPrompted.ToVersion();

            lnkRelease.Visible = lastVersionPrompted != null && lastVersionPrompted > Assembly.GetExecutingAssembly().GetName().Version;

            ResumeLayout();

            GitHub.GetVersion();
        }