예제 #1
0
        public void AdvanceFilter(bool Forward)
        {
            FilterButton toSelect = null;

            switch (currentFilter.FilterType)
            {
            case FilterType.Playlist:
                toSelect = Forward ? fltGenre : fltGrouping;
                break;

            case FilterType.Genre:
                toSelect = Forward ? fltArtist : fltPlaylist;
                break;

            case FilterType.Artist:
                toSelect = Forward ? fltAlbum : fltGenre;
                break;

            case FilterType.Album:
                toSelect = Forward ? fltYear : fltArtist;
                break;

            case FilterType.Year:
                toSelect = Forward ? fltGrouping : fltAlbum;
                break;

            default:     // grouping
                toSelect = Forward ? fltPlaylist : fltYear;
                break;
            }
            toSelect.Select();
        }
예제 #2
0
        public void RestoreFilterButton(FilterButton Button)
        {
            FilterState fs = filters[Button.FilterType];

            Button.FilterValue = fs.Value;
            Button.ValueType   = fs.ValueType;
            Button.StartChar   = fs.StartChar;
        }
예제 #3
0
        public void AddFilterInfo(FilterType FilterType, FilterButton Button)
        {
            FilterState fs = new FilterState();

            fs.Value     = Button.FilterValue;
            fs.ValueType = Button.ValueType;
            fs.StartChar = Button.StartChar;
            filters.Add(FilterType, fs);
        }
예제 #4
0
        private void setupControls()
        {
            txtFilter = new QTextBox();
            txtFilter.EnableWatermark(this, Localization.Get(UI_Key.Filter_Search), String.Empty);

            fltPlaylist = new FilterButton(FilterType.Playlist);
            fltGenre    = new FilterButton(FilterType.Genre);
            fltArtist   = new FilterButton(FilterType.Artist);
            fltAlbum    = new FilterButton(FilterType.Album);
            fltYear     = new FilterButton(FilterType.Year);
            fltGrouping = new FilterButton(FilterType.Grouping);

            filterButtons = new Dictionary <FilterType, FilterButton>();

            filterButtons.Add(fltPlaylist.FilterType, fltPlaylist);
            filterButtons.Add(fltGenre.FilterType, fltGenre);
            filterButtons.Add(fltArtist.FilterType, fltArtist);
            filterButtons.Add(fltAlbum.FilterType, fltAlbum);
            filterButtons.Add(fltYear.FilterType, fltYear);
            filterButtons.Add(fltGrouping.FilterType, fltGrouping);

            txtFilter.Bounds = new Rectangle(8, 5, 135, 12);

            clearTextFilterRectangle = new Rectangle(150, 0, 15, this.ClientRectangle.Height);

            fltPlaylist.Left = 175;

            fltPlaylist.FilterName = Localization.Get(UI_Key.Filter_Playlist);
            fltGenre.FilterName    = Localization.Get(UI_Key.Filter_Genre);
            fltArtist.FilterName   = Localization.Get(UI_Key.Filter_Artist);
            fltAlbum.FilterName    = Localization.Get(UI_Key.Filter_Album);
            fltYear.FilterName     = Localization.Get(UI_Key.Filter_Year);
            fltGrouping.FilterName = Localization.Get(UI_Key.Filter_Grouping);

            foreach (KeyValuePair <FilterType, FilterButton> kvp in filterButtons)
            {
                kvp.Value.SelectedEvent          += filterSelected;
                kvp.Value.FilterValueChanged     += filterChanged;
                kvp.Value.IndexSelected          += showFilterIndex;
                kvp.Value.ClickedWithoutSelected += (s) => { RemoveFilterIndex(); };
                kvp.Value.ReleaseFilter();
            }

            txtFilter.Enter       += (s, e) => { txtFilterFocus = true; controller.RequestAction(QActionType.KeyPreviewChange); };
            txtFilter.Leave       += (s, e) => { txtFilterFocus = false; controller.RequestAction(QActionType.KeyPreviewChange); };
            txtFilter.TextChanged += new EventHandler(txtFilter_TextChanged);

            this.Controls.AddRange(new Control[] { txtFilter, fltPlaylist, fltGenre, fltArtist, fltAlbum, fltYear, fltGrouping });
        }
예제 #5
0
        private void showFilterIndex(FilterButton Button)
        {
            bool show = indexForm == null || indexForm.FilterTypeBasis != Button.FilterType;

            if (indexForm != null)
            {
                RemoveFilterIndex();
            }

            if (show)
            {
                CurrentFilterType = Button.FilterType;

                indexForm = new frmIndex(this,
                                         new Point(Button.Left + Button.Width / 2, Button.Bottom),
                                         showFilterIndexCallback,
                                         Button);
            }
        }
예제 #6
0
        private void filterSelected(FilterButton FilterButton)
        {
            RemoveFilterIndex();

            if (!FilterButton.Equals(currentFilter))
            {
                currentFilter = FilterButton;

                foreach (KeyValuePair <FilterType, FilterButton> kvp in filterButtons)
                {
                    if (kvp.Key != FilterButton.FilterType)
                    {
                        kvp.Value.Selected = false;
                    }
                }

                if (AllowEvents)
                {
                    controller.RequestAction(QActionType.LoadFilterValues);
                }

                arrangeControls();
            }
        }
예제 #7
0
        private void filterChanged(FilterButton FilterButton, bool WasOff)
        {
            RemoveFilterIndex();

            switch (FilterButton.ValueType)
            {
            case FilterValueType.StartChar:
                FilterButton.ValueType = FilterValueType.StartChar;
                switch (FilterButton.FilterType)
                {
                case FilterType.Playlist:
                    ply = t => Database.GetPlaylistTracks(FilterButton.StartChar);
                    break;

                case FilterType.Genre:
                    gen = t => t.FindAll(ti => ti.Genre.Length > 0 && Char.ToUpperInvariant(ti.Genre[0]) == fltGenre.StartChar);
                    break;

                case FilterType.Artist:
                    art = t => t.FindAll(ti => ti.MainGroupNoThe.Length > 0 && Char.ToUpperInvariant(ti.MainGroupNoThe[0]) == fltArtist.StartChar);
                    break;

                case FilterType.Album:
                    alb = t => t.FindAll(ti => ti.Album.Length > 0 && Char.ToUpperInvariant(ti.Album[0]) == fltAlbum.StartChar);
                    break;

                case FilterType.Year:
                    yr = t => t.FindAll(ti => ti.DecadeChar == fltYear.StartChar);
                    break;

                case FilterType.Grouping:
                    gpg = t => t.FindAll(ti => ti.Grouping.Length > 0 && Char.ToUpperInvariant(ti.Grouping[0]) == fltGrouping.StartChar);
                    break;
                }
                if (AllowEvents)
                {
                    FilterValueChanged.Invoke(FilterButton.FilterType, FilterButton.FilterValue, WasOff, true);
                }
                break;

            case FilterValueType.SpecificValue:
                switch (FilterButton.FilterType)
                {
                case FilterType.Playlist:
                    ply = t => Database.GetPlaylistTracks(fltPlaylist.FilterValue);
                    break;

                case FilterType.Genre:
                    gen = t => t.FindAll(ti => ti.Genre == fltGenre.FilterValue);
                    break;

                case FilterType.Artist:
                    art = t => t.FindAll(ti => ti.MainGroup == fltArtist.FilterValue);
                    break;

                case FilterType.Album:
                    alb = t => t.FindAll(ti => ti.Album == fltAlbum.FilterValue);
                    break;

                case FilterType.Year:
                    yr = t => t.FindAll(ti => ti.YearString == fltYear.FilterValue);
                    break;

                case FilterType.Grouping:
                    gpg = t => t.FindAll(ti => ti.Grouping == fltGrouping.FilterValue);
                    break;
                }

                if (AllowEvents)
                {
                    FilterValueChanged.Invoke(FilterButton.FilterType, FilterButton.FilterValue, WasOff, false);
                }

                break;

            case FilterValueType.None:
                switch (FilterButton.FilterType)
                {
                case FilterType.Playlist:
                    ply = t => t;
                    break;

                case FilterType.Genre:
                    gen = t => t;
                    break;

                case FilterType.Artist:
                    art = t => t;
                    break;

                case FilterType.Album:
                    alb = t => t;
                    break;

                case FilterType.Year:
                    yr = t => t;
                    break;

                case FilterType.Grouping:
                    gpg = t => t;
                    break;
                }

                if (AllowEvents)
                {
                    FilterReleased.Invoke(FilterButton.FilterType);
                }

                break;
            }
            arrangeControls();
        }
예제 #8
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;
        }