Exemple #1
0
        private static IEnumerable <char> getChars(FilterBar FilterBar, FilterType FilterType)
        {
            switch (FilterType)
            {
            case FilterType.Playlist:
                return(from pl in Database.GetPlaylists(FilterBar.GetTracksWithoutFiltering(FilterType.Playlist, false))
                       group pl by Char.ToUpperInvariant(pl[0])
                       into g
                       select g.Key);

            case FilterType.Artist:
                return(from t in FilterBar.GetTracksWithoutFiltering(FilterType.Artist, false)
                       where t.MainGroupNoThe.Length > 0
                       group t by Char.ToUpperInvariant(t.MainGroupNoThe[0])
                       into g
                       select g.Key);

            case FilterType.Album:
                return(from t in FilterBar.GetTracksWithoutFiltering(FilterType.Album, false)
                       where t.Album.Length > 0
                       group t by Char.ToUpperInvariant(t.Album[0])
                       into g
                       select g.Key);

            case FilterType.Genre:
                return(from t in FilterBar.GetTracksWithoutFiltering(FilterType.Genre, false)
                       where t.Genre.Length > 0
                       group t by Char.ToUpperInvariant(t.Genre[0])
                       into g
                       select g.Key);

            case FilterType.Year:
                return(from t in FilterBar.GetTracksWithoutFiltering(FilterType.Year, false)
                       group t by t.DecadeChar
                       into g
                       select g.Key);

            case FilterType.Grouping:
                return(from t in FilterBar.GetTracksWithoutFiltering(FilterType.Grouping, false)
                       where t.Grouping.Length > 0
                       group t by Char.ToUpperInvariant(t.Grouping[0])
                       into g
                       select g.Key);

            default:
                return(new List <char>());
            }
        }
Exemple #2
0
        public NormalView(frmMain MainForm)
        {
            this.mainForm = MainForm;
            instance      = this;

            this.trackList       = new TrackList(this);
            this.filterValueList = new FilterValueList();
            this.filterBar       = new FilterBar();
            this.artwork         = new Artwork();

            this.splMain = new QSplitContainer();

            this.splMain.Panel1.Controls.Add(filterValueList);
            this.splMain.Panel2.Controls.Add(trackList);
            this.Controls.Add(splMain);
            this.Controls.Add(filterBar);

            splMain.Resize         += (s, e) => { arrangeSplitterControls(); };
            splMain.SplitterMoved  += (s, e) => { arrangeSplitterControls(); };
            splMain.VisibleChanged += (s, e) =>
            {
                if (splMain.Visible)
                {
                    splMain.SplitterDistance = Setting.SplitterDistance;
                }
            };

            this.artwork = Artwork;

            splMain.Panel1.Controls.Add(artwork);

            filterBar.FilterReleased     += filterBarFilterCleared;
            filterBar.FilterValueChanged += filterBarFilterValueChanged;

            filterValueList.FilterValueSelected += new FilterValueList.FilterValueSelect(filterValueChanged);
            filterValueList.ValueChanged        += (oldVal, newVal) => { changePlaylistName(oldVal, newVal); };

            arrangeSplitterControls();
            splMain.Panel1.Paint += new PaintEventHandler(Panel1_Paint);
            artwork.Click        += (s, e) => { controller.RequestAction(QActionType.FindPlayingTrack); };
        }
Exemple #3
0
        public frmIndex(FilterBar Parent, Point Anchor, IndexCallback Callback, FilterButton Button) : base(String.Empty, ButtonCreateType.None)
        {
            this.DoubleBuffered = true;

            callback = Callback;
            button   = Button;

            this.filterChar = '\0';

            this.FormBorderStyle = FormBorderStyle.None;
            this.StartPosition   = FormStartPosition.Manual;
            this.KeyPreview      = true;
            this.FilterTypeBasis = button.FilterType;

            setCaption();

            buttons = new List <QButton>();

            var aa = getChars(Parent, Button.FilterType).ToList();

            aa.RemoveAll(c => c <= ' ' || c == CLEAR_CHAR);

            if (aa.Count() == 0)
            {
                this.NoData = true;
                this.Close();
                this.callback(this);
                return;
            }

            this.NoData = false;

            aa.Sort();

            if (button.ValueType != FilterValueType.None)
            {
                aa.Add(CLEAR_CHAR);
            }

            aa = aa.Take(55).ToList();

            bool filterBadChars;

            switch (System.Globalization.CultureInfo.CurrentCulture.TwoLetterISOLanguageName)
            {
            case "en":
            case "de":
            case "it":
            case "cs":
            case "fr":
            case "pt":
                filterBadChars = true;
                break;

            default:
                filterBadChars = false;
                break;
            }

            foreach (char c in aa)
            {
                QButton b;
                if (Button.FilterType == FilterType.Year && c != CLEAR_CHAR)
                {
                    b = new QButton(c.ToString() + "0s", false, true);
                }
                else
                {
                    b = new QButton(c.ToString(), false, true);
                }

                if ((!filterBadChars) || (c < 0xFF))
                {
                    b.Tag = c;
                    buttons.Add(b);
                    b.BackColor      = this.BackColor;
                    b.ButtonPressed += new QButton.ButtonDelegate(click);
                    this.Controls.Add(b);
                }
            }

            this.MinimumSize = Size.Empty;

            buttons.Add(new QButton("~", false, true)); // placeholder for close button

            desiredWidth = arrangeButtons() + BORDER_WIDTH + 2;

            closeButtonRect = new Rectangle(buttons[buttons.Count - 1].Location, Properties.Resources.filter_index_close_hover.Size);

            buttons.RemoveAt(buttons.Count - 1);

            this.ClientSize = new System.Drawing.Size(desiredWidth,
                                                      rows * buttons[0].Height + BORDER_WIDTH * 2);


            Point p = Parent.PointToScreen(new Point(Math.Min(Anchor.X - this.Width / 2, Parent.Right - this.Width), Anchor.Y));

            p             = new Point(Math.Max(0, p.X), p.Y);
            this.Location = p;

            this.Owner = Lib.MainForm;

            this.Show(Lib.MainForm);

            QButton lastButton = buttons[buttons.Count - 1];

            if (lastButton.Text[0] == '_')
            {
                QToolTip clearToolTip = new QToolTip(lastButton, String.Empty);
                clearToolTip.SetToolTip(lastButton, Localization.Get(UI_Key.Filter_Index_Clear));
            }
            tooltip        = new QToolTip(this, Localization.Get(UI_Key.Filter_Index_Cancel));
            tooltip.Active = false;
        }