public void CreateNewDatabase()
        {
            Crawler.Stop();
            TrackWriter.Stop();

            if (rg != null)
            {
                rg.Cancel();
            }

            iTunes.Cancel = true;

            System.Threading.Thread.Sleep(200);

            normal.AllowEvents = false;
            normal.ReleaseAllFilters();
            normal.AllowEvents = true;

            artwork.CurrentTrack          = null;
            artwork.TemporaryTrack        = null;
            normal.Artwork.CurrentTrack   = null;
            normal.Artwork.TemporaryTrack = null;

            Database.CreateNewDatabase(false);

            TargetPlaylistName = Localization.MY_PLAYLIST;

            normal.RefreshAll(true);
        }
        public void Close()
        {
            exiting = true;

            Lib.EnableNavKeys(true);
            normal.RemoveFilterIndex();

            Crawler.Stop();
            TrackWriter.Stop();

            if (rg != null)
            {
                rg.Cancel();
            }

            iTunes.Cancel = true;

            if (notifyIcon != null)
            {
                notifyIcon.Visible = false;
                notifyIcon         = null;
            }

            if (normal.Queue.Reordered && normal.Queue.PlaylistBasis.Length > 0 && (Database.GetPlaylistType(normal.Queue.PlaylistBasis) == PlaylistType.Standard))
            {
                Database.SaveStandardPlaylist(normal.Queue);
            }

            player.Dispose();

            Database.SaveSetting(SettingType.ShowSpectrumGrid, spectrumView.ShowGrid);
            Database.SaveSetting(SettingType.SpectrumGain, spectrumView.Gain);
            Database.SaveSetting(SettingType.ViewMode, (HTPCMode == HTPCMode.Normal ? "Normal" : "HTPC"));
            Database.SaveSetting(SettingType.CurrentFilter, normal.CurrentFilterName);
            Database.SaveSetting(SettingType.DecoderGain, DecoderGainDB);
            Database.SaveSetting(SettingType.ColumnStatus, normal.SerializeColumnStatus(HTPCMode.Normal));
            Database.SaveSetting(SettingType.ColumnStatusHTPC, normal.SerializeColumnStatus(HTPCMode.HTPC));
            Database.SaveSetting(SettingType.AskAboutMissingFiles, askAboutMissingFiles);
            Database.SaveSetting(SettingType.EqualizerOn, equalizer.On);
            Database.SaveSetting(SettingType.EqualizerTenBands, equalizer.NumBands == 10);
            Database.SaveSetting(SettingType.EqualizerFineControl, equalizer.FineControl);
            Database.SaveSetting(SettingType.CurrentEqualizer, equalizer.CurrentEqualizer.Name);
            Database.SaveSetting(SettingType.DownloadAlbumCovers, Track.DownloadCoverArt);
            Database.SaveSetting(SettingType.UseGlobalHotKeys, UseGlobalHotKeys);
            Database.SaveSetting(SettingType.FullScreen, Lib.FullScreen || !Lib.ManualReleaseFullScreen);
            Database.SaveSetting(SettingType.SpectrumSmall, (player.SpectrumMode == SpectrumMode.Small));
            Database.SaveSetting(SettingType.ArtSave, (int)ArtSaveOption);
            Database.SaveSetting(SettingType.TwitterOn, Twitter.On);
            Database.SaveSetting(SettingType.TwitterUserName, Twitter.UserName);
            Database.SaveSetting(SettingType.TwitterPassword, Twitter.Password);

            Database.SaveSetting(SettingType.LocalVolumeControlOnly, LocalVolumeControl);
            Database.SaveSetting(SettingType.LocalVolumeLevel, localVolumeLevel);
            Database.SaveSetting(SettingType.RunNumber, runNumber);
            Database.SaveSetting(SettingType.OutputDeviceName, player.OutputDeviceName);
            Database.SaveSetting(SettingType.TwitterMode, (int)Twitter.TwitterMode);
            Database.SaveSetting(SettingType.TagCloudMaxItems, tagCloud.MaxItems);
            Database.SaveSetting(SettingType.TagCloudColor, tagCloud.UseColor);
            Setting.Save();

            System.Drawing.Rectangle r;
            if (!Lib.FullScreen && mainForm.WindowState == FormWindowState.Normal)
            {
                r = mainForm.Bounds;
            }
            else
            {
                r = System.Drawing.Rectangle.Empty;
            }

            Database.SaveSetting(SettingType.NormalWindowBoundsX, r.X);
            Database.SaveSetting(SettingType.NormalWindowBoundsY, r.Y);
            Database.SaveSetting(SettingType.NormalWindowBoundsWidth, r.Width);
            Database.SaveSetting(SettingType.NormalWindowBoundsHeight, r.Height);

            Database.SaveSetting(SettingType.LastFMOn, lastFMOn);
            Database.SaveSetting(SettingType.LastFMUserName, lastFMUserName);
            Database.SaveSetting(SettingType.LastFMPassword, lastFMPassword);

            Database.SaveSetting(SettingType.MiniPlayerXPos, frmMiniPlayer.DefaultLocation.X);
            Database.SaveSetting(SettingType.MiniPlayerYPos, frmMiniPlayer.DefaultLocation.Y);

            Database.Close(mainForm);

            Clock.DoOnNewThreadNotBackground(TrackWriter.DeleteItemsLastChance);

            Clock.Close();
        }
Exemplo n.º 3
0
        public Organizer(Callback DoneCallback) : base()
        {
            TrackWriter.Stop();

            done = DoneCallback;

            invalidPath      = Localization.Get(UI_Key.Organize_Invalid_Path);
            sample           = Localization.Get(UI_Key.Organize_Sample);
            tokenMyMusic     = Localization.Get(UI_Key.Organize_Token_My_Music);
            tokenMyDocuments = Localization.Get(UI_Key.Organize_Token_My_Documents);
            tokenDesktop     = Localization.Get(UI_Key.Organize_Token_Desktop);

            font     = Styles.FontSmaller;
            boldFont = new Font(font, FontStyle.Bold);

            btnOK     = new QButton(Localization.OK, false, true);
            btnCancel = new QButton(Localization.CANCEL, false, true);

            btnHelp = new QButton(Localization.Get(UI_Key.Organize_Help), false, true);
            AddButton(btnHelp, help);

            lblTitle = new QLabel(Localization.Get(UI_Key.Organize_Title), font);
            this.Controls.Add(lblTitle);
            lblTitle.Location = new System.Drawing.Point(MARGIN, MARGIN);

            lblDirectory = new QLabel(Localization.Get(UI_Key.Organize_Top_Folder), font);
            lblDirectory.ShowAccellerator();
            this.Controls.Add(lblDirectory);

            txtDirectory      = new QTextBox();
            txtDirectory.Font = font;
            this.Controls.Add(txtDirectory);

            if (Setting.TopLevelDirectory.Length == 0)
            {
                Setting.TopLevelDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyMusic);
            }

            oldRoot           = Setting.TopLevelDirectory;
            txtDirectory.Text = simplify(oldRoot);

            btnBrowse = new QButton(Localization.Get(UI_Key.Organize_Browse), false, false);
            btnBrowse.ShowAccellerator(Keys.B);
            AddButton(btnBrowse, browse);

            lblSubdirectory = new QLabel(Localization.Get(UI_Key.Organize_Folder_Structure), font);
            lblSubdirectory.ShowAccellerator();
            this.Controls.Add(lblSubdirectory);

            cboSubdirectory      = new QComboBox(false);
            cboSubdirectory.Font = font;
            cboSubdirectory.Items.AddRange(TrackWriter.GetDirFormats().ToArray());
            string sub = TrackWriter.GetDirFormat(Setting.DefaultDirectoryFormat);

            if (cboSubdirectory.Items.Contains(sub))
            {
                cboSubdirectory.SelectedIndex = cboSubdirectory.FindStringExact(sub);
            }
            else
            {
                cboSubdirectory.SelectedIndex = 0;
            }
            this.Controls.Add(cboSubdirectory);
            cboSubdirectory.AutoSetWidth();

            lblRename = new QLabel(Localization.Get(UI_Key.Organize_Rename), font);
            lblRename.ShowAccellerator();
            this.Controls.Add(lblRename);

            cboRename      = new QComboBox(false);
            cboRename.Font = font;
            string[] renames = TrackWriter.GetRenames().ToArray();
            renames[0] = Localization.Get(UI_Key.Organize_Dont_Change);
            cboRename.Items.AddRange(renames);
            string ren = TrackWriter.GetRenameFormat(Setting.DefaultRenameFormat);

            if (cboRename.Items.Contains(ren))
            {
                cboRename.SelectedIndex = cboRename.FindStringExact(ren);
            }
            else
            {
                cboRename.SelectedIndex = 0;
            }
            this.Controls.Add(cboRename);

            cboRename.AutoSetWidth();

            chkKeepOrganized = new QCheckBox(Localization.Get(UI_Key.Organize_Keep_Organized), this.BackColor);
            chkKeepOrganized.ShowAccellerator();
            chkKeepOrganized.Font    = font;
            chkKeepOrganized.Checked = Setting.KeepOrganized;
            this.Controls.Add(chkKeepOrganized);

            chkMoveIntoTopFolder         = new QCheckBox(Localization.Get(UI_Key.Organize_Move_Into_Top_Folder), this.BackColor);
            chkMoveIntoTopFolder.Font    = font;
            chkMoveIntoTopFolder.Checked = Setting.MoveNewFilesIntoMain;
            this.Controls.Add(chkMoveIntoTopFolder);

            btnOK.Text     = Localization.Get(UI_Key.Organize_Organize);
            btnCancel.Text = Localization.Get(UI_Key.Organize_Dont_Organize);
            btnOK.ShowAccellerator(Keys.O);
            btnCancel.ShowAccellerator(Keys.D);

            AddButton(btnOK, ok);
            AddButton(btnCancel, cancel);

            sampleTrack = new Track(-1,
                                    Localization.Get(UI_Key.Organize_Sample_Track_Path),
                                    Track.FileType.MP3,
                                    Localization.Get(UI_Key.Organize_Sample_Track_Title),
                                    Localization.Get(UI_Key.Organize_Sample_Track_Album),
                                    Localization.Get(UI_Key.Organize_Sample_Track_Artist),
                                    String.Empty,
                                    String.Empty,
                                    Localization.Get(UI_Key.Organize_Sample_Track_Grouping),
                                    Localization.Get(UI_Key.Organize_Sample_Track_Genre),
                                    (6 * 60 + 24) * 1000,
                                    5,
                                    0,
                                    1973,
                                    0,
                                    5,
                                    320000,
                                    0,
                                    false,
                                    DateTime.Today,
                                    DateTime.Today,
                                    DateTime.Today,
                                    String.Empty,
                                    2,
                                    44100,
                                    ChangeType.None,
                                    null,
                                    float.MinValue,
                                    float.MinValue);

            resize();
            this.Height = chkKeepOrganized.Bottom + MARGIN;

            cboSubdirectory.SelectedIndexChanged += (s, e) => { updateSample(); };
            cboRename.SelectedIndexChanged       += (s, e) => { updateSample(); };
            txtDirectory.TextChanged             += (s, e) => { updateSample(); };

            updateSample();

            int tabIndex = 0;

            lblDirectory.TabIndex         = tabIndex++;
            txtDirectory.TabIndex         = tabIndex++;
            btnBrowse.TabIndex            = tabIndex++;
            lblSubdirectory.TabIndex      = tabIndex++;
            cboSubdirectory.TabIndex      = tabIndex++;
            lblRename.TabIndex            = tabIndex++;
            cboRename.TabIndex            = tabIndex++;
            chkKeepOrganized.TabIndex     = tabIndex++;
            chkMoveIntoTopFolder.TabIndex = tabIndex++;
            btnHelp.TabIndex   = tabIndex++;
            btnCancel.TabIndex = tabIndex++;
            btnOK.TabIndex     = tabIndex++;

            setWrapAroundTabControl(tabIndex, txtDirectory, null);

            initialized = true;
        }