Exemplo n.º 1
0
 protected override void OnGotFocus(EventArgs e)
 {
     base.OnGotFocus(e);
     txtTitle.Focus();
 }
Exemplo n.º 2
0
 public void FocusSearchBox()
 {
     txtFilter.Focus();
 }
Exemplo n.º 3
0
        public TagEditor(TrackList TrackList, List <Track> Tracks, TagEditComplete TEC)
        {
            this.tec    = TEC;
            this.MARGIN = 4;

            this.SuspendLayout();

            System.Diagnostics.Debug.Assert(Tracks.Count > 0);

            tracks = Tracks;

            template = new Track(tracks[0]);

            tracklist = TrackList;

            isMultiple = (tracks.Count > 1);

            labels     = new Dictionary <IEditControl, QLabel>();
            checkboxes = new Dictionary <IEditControl, QCheckBox>();

            setupTextBox(out txtTitle, Localization.Get(UI_Key.Edit_Tags_Title), getDefaultText(new Func <Track, string>(t => t.Title)), false);
            setupTextBox(out txtArtist, Localization.Get(UI_Key.Edit_Tags_Artist), getDefaultText(new Func <Track, string>(t => t.Artist)), isMultiple);
            setupTextBox(out txtAlbum, Localization.Get(UI_Key.Edit_Tags_Album), getDefaultText(new Func <Track, string>(t => t.Album)), isMultiple);
            setupTextBox(out txtAlbumArtist, Localization.Get(UI_Key.Edit_Tags_Album_Artist), getDefaultText(new Func <Track, string>(t => t.AlbumArtist)), isMultiple);
            setupTextBox(out txtComposer, Localization.Get(UI_Key.Edit_Tags_Composer), getDefaultText(new Func <Track, string>(t => t.Composer)), isMultiple);
            setupComboBox(out cboGrouping, Localization.Get(UI_Key.Edit_Tags_Grouping), getDefaultText(new Func <Track, string>(t => t.Grouping)), Database.GetGroupings().ToArray(), isMultiple);
            setupComboBox(out cboGenre, Localization.Get(UI_Key.Edit_Tags_Genre), getDefaultText(new Func <Track, string>(t => t.GenreAllowBlank)), Database.GetGenres().ToArray(), isMultiple);
            setupRename(Localization.Get(UI_Key.Edit_Tags_Rename), isMultiple);
            setupTextBox(out txtYear, Localization.Get(UI_Key.Edit_Tags_Year), getDefaultText(new Func <Track, string>(t => t.YearString)), isMultiple);
            setupTextBox(out txtTrackNum, Localization.Get(UI_Key.Edit_Tags_Track_Num), getDefaultText(new Func <Track, string>(t => t.TrackNumString)), isMultiple);
            setupTextBox(out txtDiskNum, Localization.Get(UI_Key.Edit_Tags_Disk_Num), getDefaultText(new Func <Track, string>(t => t.DiskNumString)), isMultiple);
            setupCompilation(out cboCompilation, Localization.Get(UI_Key.Edit_Tags_Compilation), isMultiple);

            txtTitle.MaxLength       = 100;
            txtArtist.MaxLength      = 100;
            txtAlbumArtist.MaxLength = 100;
            txtAlbum.MaxLength       = 100;
            cboGenre.MaxLength       = 100;
            cboGrouping.MaxLength    = 100;
            txtComposer.MaxLength    = 100;

            this.Height = (txtTitle.Height + labels[txtTitle].Height) * 4 + MARGIN + MARGIN;

            setupArtwork();

            setupAutoComplete();

            if (isMultiple)
            {
                labels[txtTitle].Enabled = false;
                txtTitle.Enabled         = false;
            }

            txtYear.NumericOnly = true;
            txtYear.MaxLength   = 4;

            txtTrackNum.NumericOnly = true;
            txtTrackNum.MaxLength   = 4;

            txtDiskNum.NumericOnly = true;
            txtDiskNum.MaxLength   = 4;

            btnOK = new QButton(Localization.Get(UI_Key.Edit_Tags_Save), false, true);
            btnOK.ShowAccellerator(Keys.S);
            AddButton(btnOK, ok);

            btnCancel = new QButton(Localization.Get(UI_Key.Edit_Tags_Done), false, true);
            AddButton(btnCancel, cancel);

            if (!isMultiple && tracklist.Queue.Count > 1)
            {
                btnPrevious = new QButton(Localization.Get(UI_Key.Edit_Tags_Previous), false, true);
                btnPrevious.ShowAccellerator(Keys.P);
                AddButton(btnPrevious, previous);

                btnNext = new QButton(Localization.Get(UI_Key.Edit_Tags_Next), false, true);
                btnNext.ShowAccellerator(Keys.N);
                AddButton(btnNext, next);

                int i = tracklist.Queue.IndexOf(tracks[0]);

                if (i < 1)
                {
                    btnPrevious.Enabled = false;
                }
                if (i >= tracklist.Queue.Count - 1)
                {
                    btnNext.Enabled = false;
                }
            }
            else if (isMultiple && Tracks.Count <= 200)
            {
                btnAutoNumber = new QButton(Localization.Get(UI_Key.Edit_Tags_AutoNumber), false, true);
                AddButton(btnAutoNumber, autoNumber);
            }

            if (isMultiple)
            {
                foreach (KeyValuePair <IEditControl, QCheckBox> kvp in checkboxes)
                {
                    kvp.Value.Checked = false;
                }
            }

            saveCurrentValues();

            this.ResumeLayout();

            Dirty = false;

            setTabIndexes();

            resize();

            if (isMultiple)
            {
                txtArtist.Focus();
            }
            else
            {
                txtTitle.Focus();
            }

            if (!isMultiple)
            {
                txtTitle.TextChanged                += (s, e) => { template.Title = txtTitle.Text.Trim(); updateFilenames(cboRename.SelectedIndex); };
                txtArtist.TextChanged               += (s, e) => { template.Artist = txtArtist.Text.Trim(); updateFilenames(cboRename.SelectedIndex); };
                txtAlbum.TextChanged                += (s, e) => { template.Album = txtAlbum.Text.Trim(); updateFilenames(cboRename.SelectedIndex); };
                txtAlbumArtist.TextChanged          += (s, e) => { template.AlbumArtist = txtAlbumArtist.Text.Trim(); updateFilenames(cboRename.SelectedIndex); };
                cboCompilation.SelectedIndexChanged += (s, e) => { template.Compilation = ((cboCompilation.Text == Localization.YES) ? true : false); updateFilenames(cboRename.SelectedIndex); };
                txtTrackNum.TextChanged             += (s, e) =>
                {
                    int tn = template.TrackNum;
                    Int32.TryParse(txtTrackNum.Text.Trim(), out tn);
                    template.TrackNum = tn;
                    updateFilenames(cboRename.SelectedIndex);
                };
            }
            initialized = true;
        }
Exemplo n.º 4
0
 protected override void OnEnter(EventArgs e)
 {
     base.OnEnter(e);
     txtMain.Focus();
 }
Exemplo n.º 5
0
        protected override void ok()
        {
            if (createDir())
            {
                this.Enabled = false;

                saveSettings();

                string r = complexify(root());

                List <Track> outsideTracks = Database.FindAllTracks(t => !((oldRoot.Length > 0 && t.FilePath.StartsWith(oldRoot, StringComparison.OrdinalIgnoreCase)) || (t.FilePath.StartsWith(r, StringComparison.OrdinalIgnoreCase))));
                List <Track> tracks        = Database.LibrarySnapshot;

                foreach (Track t in tracks)
                {
                    t.ChangeType |= (ChangeType.Move | ChangeType.IgnoreContainment);
                }

                System.Diagnostics.Debug.WriteLine("num: " + tracks.Count(t => (t.ChangeType & ChangeType.IgnoreContainment) != 0));

                if (outsideTracks.Any(t => t.ConfirmExists))
                {
                    List <frmTaskDialog.Option> options = new List <frmTaskDialog.Option>();
                    options.Add(new frmTaskDialog.Option("Move all my files", "All files in your library will be relocated within the top folder. (Files on different drives than your top folder's drive will be copied instead of moved.)", 0));
                    options.Add(new frmTaskDialog.Option("Don't move outside files", "Only files already under the top folder will be organized.", 1));
                    options.Add(new frmTaskDialog.Option("Cancel", "Go back to the organizer panel.", 2));

                    frmTaskDialog td = new frmTaskDialog(Localization.Get(UI_Key.Organize_Move_Files_Title),
                                                         Localization.Get(UI_Key.Organize_Move_Files),
                                                         options);

                    System.Diagnostics.Debug.WriteLine("num: " + tracks.Count(t => (t.ChangeType & ChangeType.IgnoreContainment) != 0));

                    td.ShowDialog(this);

                    switch (td.ResultIndex)
                    {
                    case 0:
                        break;

                    case 1:
                        foreach (Track t in outsideTracks)
                        {
                            t.ChangeType &= ~ChangeType.IgnoreContainment;
                        }
                        break;

                    case 2:
                        this.Enabled = true;
                        txtDirectory.Focus();
                        return;
                    }
                }

                foreach (Track t in tracks)
                {
                    t.RenameFormat = renameFormat;
                    if (renameFormat != TrackWriter.RenameFormat.None)
                    {
                        t.ChangeType |= ChangeType.Rename;
                    }
                }

                TrackWriter.AddToUnsavedTracks(tracks);

                done();
            }
        }