Example #1
0
        public DetailsBrowserToolStrip(DetailsBrowserFilter detailsBrowserFilter, DetailsModel detailsModel, SearchHandler searchHandler)
        {
            InitializeComponent();

            DetailsBrowserFilter = detailsBrowserFilter;
            DetailsModel         = detailsModel;
            SearchHandler        = searchHandler;

            searchComboBox = new ToolStripSpringComboBox();
            toolStrip      = new ToolStrip();

            SuspendLayout();

            //
            // searchComboBox
            //
            searchComboBox.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            searchComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
            searchComboBox.DropDownStyle      = ComboBoxStyle.DropDown;
            // WORKAROUND: bug since win7 - selectedindex is wrong when a datasource is bound
//			searchComboBox.ComboBox.DataSource = DetailsModel.Searches;
//			searchComboBox.DataSource = DetailsModel.Searches;
            searchComboBox.Dock   = DockStyle.Fill;
            searchComboBox.Margin = new Padding(0, 0, 6, 0);
            searchComboBox.ComboBox.SelectionChangeCommitted += SearchComboBox_SelectionChangeCommitted;
            searchComboBox.KeyDown += SearchComboBox_KeyDown;
            searchComboBox.ComboBox.OverrideMouseWheelBehaviour();
            searchComboBox.OverrideUpDownKeys();

            //
            // toolStrip
            //
            toolStrip.Dock        = DockStyle.Fill;
            toolStrip.CanOverflow = false;
            toolStrip.Items.Add(searchComboBox);

            //
            // this
            //
            Controls.Add(toolStrip);

            //DetailsModel.Searches.ListChanged += Searches_ListChanged;
            DetailsModel.SearchesChanged += DetailsModel_SearchesChanged;

            ResumeLayout(false);
        }
Example #2
0
        public GalleryBrowserToolStrip(GalleryBrowserFilter galleryBrowserFilter, GalleryModel galleryModel, Configuration.ConfigGalleryBrowserView galleryBrowserSettings, SearchHandler searchHandler)
        {
            InitializeComponent();

            GalleryBrowserFilter   = galleryBrowserFilter;
            GalleryModel           = galleryModel;
            GalleryBrowserSettings = galleryBrowserSettings;
            SearchHandler          = searchHandler;

            toolStrip         = new ToolStrip();
            searchComboBox    = new ToolStripSpringComboBox();
            filterComboBox    = new ToolStripSpringComboBox();
            sortTypeComboBox  = new ToolStripComboBox();
            sortOrderComboBox = new ToolStripComboBox();

            SuspendLayout();

            //
            // searchComboBox
            //
            searchComboBox.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            searchComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
            searchComboBox.DropDownStyle      = ComboBoxStyle.DropDown;
            searchComboBox.Dock     = DockStyle.Fill;
            searchComboBox.Margin   = new Padding(0, 0, 6, 0);
            searchComboBox.KeyDown += SearchComboBox_KeyDown;
            searchComboBox.ComboBox.SelectionChangeCommitted += SearchComboBox_SelectionChangeCommitted;
            // WORKAROUND: bug since win7 - selectedindex is wrong when a datasource is bound
            //searchComboBox.ComboBox.DataSource = galleryModel.Searches;
            searchComboBox.ComboBox.OverrideMouseWheelBehaviour();
            searchComboBox.OverrideUpDownKeys();

            //
            // filterComboBox
            //
            filterComboBox.AutoCompleteMode   = AutoCompleteMode.SuggestAppend;
            filterComboBox.AutoCompleteSource = AutoCompleteSource.ListItems;
            filterComboBox.DropDownStyle      = ComboBoxStyle.DropDown;
            filterComboBox.Dock     = DockStyle.Fill;
            filterComboBox.Margin   = new Padding(0, 0, 6, 0);
            filterComboBox.KeyDown += FilterComboBox_KeyDown;
            filterComboBox.ComboBox.SelectedIndexChanged     += ComboBox_SelectedIndexChanged;
            filterComboBox.ComboBox.SelectionChangeCommitted += FilterComboBox_SelectionChangeCommitted;
            filterComboBox.ComboBox.OverrideMouseWheelBehaviour();
            filterComboBox.EnableMiddleClickToClear();
            filterComboBox.OverrideUpDownKeys();

            //
            // sortTypeComboBox
            //
            sortTypeComboBox.Text          = "&Sort";
            sortTypeComboBox.FlatStyle     = FlatStyle.Flat;
            sortTypeComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            List <ComboBoxItem> sortTypeItems = new List <ComboBoxItem>
            {
                new ComboBoxItem("orderByNone", "None", SortTypeComboBox_None, GallerySortType.None),
                new ComboBoxItem("orderByTitle", "Title", SortTypeComboBox_Title, GallerySortType.Title),
                new ComboBoxItem("orderByLanguage", "Language", SortTypeComboBox_Language, GallerySortType.Language),
                new ComboBoxItem("orderByArtist", "Artist", SortTypeComboBox_Artist, GallerySortType.Artist),
                new ComboBoxItem("orderByGroup", "Group", SortTypeComboBox_Group, GallerySortType.Group),
                new ComboBoxItem("orderByTag", "Tag", SortTypeComboBox_Tag, GallerySortType.Tag),
                new ComboBoxItem("orderByParody", "Parody", SortTypeComboBox_Parody, GallerySortType.Parody),
                new ComboBoxItem("orderByCharacter", "Character", SortTypeComboBox_Character, GallerySortType.Character),
                new ComboBoxItem("orderByCategory", "Category", SortTypeComboBox_Category, GallerySortType.Category),
                new ComboBoxItem("orderByScanlator", "Scanlator", SortTypeComboBox_Scanlator, GallerySortType.Scanlator),
                new ComboBoxItem("orderByUploadDate", "Upload Date", SortTypeComboBox_UploadDate, GallerySortType.UploadDate),
                new ComboBoxItem("orderByNumPages", "Num Pages", SortTypeComboBox_NumPages, GallerySortType.NumPages),
                new ComboBoxItem("orderByNumFavorites", "Num Favorites", SortTypeComboBox_NumFavorites, GallerySortType.NumFavorites),
                new ComboBoxItem("orderById", "Id", SortTypeComboBox_Id, GallerySortType.Id),
                //new SortItem("orderByComiket", "Comiket", SortTypeComboBox_Comiket, GallerySortType.Comiket),
                //new SortItem("orderByVersion", "Version", SortTypeComboBox_Version, GallerySortType.Version),
                //new SortItem("orderByCensorship", "Censorship", SortTypeComboBox_Censorship, GallerySortType.Censorship),
            };

            sortTypeComboBox.Items.AddRange(sortTypeItems.Cast <object>().ToArray());
            sortTypeComboBox.ComboBox.SelectionChangeCommitted += SortTypeComboBox_SelectionChangeCommitted;
            sortTypeComboBox.SelectedItem = sortTypeItems.First(x => (GallerySortType)x.Tag == GalleryBrowserFilter.SortType);
            sortTypeComboBox.ComboBox.OverrideMouseWheelBehaviour();
            sortTypeComboBox.OverrideUpDownKeys();

            //
            // sortOrderComboBox
            //
            sortOrderComboBox.Text          = "&Sort";
            sortOrderComboBox.FlatStyle     = FlatStyle.Flat;
            sortOrderComboBox.DropDownStyle = ComboBoxStyle.DropDownList;
            List <ComboBoxItem> sortOrderItems = new List <ComboBoxItem>
            {
                new ComboBoxItem("orderByAscending", "Ascending", SortOrderComboBox_Ascending, SortOrder.Ascending),
                new ComboBoxItem("orderByDescending", "Descending", SortOrderComboBox_Descending, SortOrder.Descending)
            };

            sortOrderComboBox.Items.AddRange(sortOrderItems.Cast <object>().ToArray());
            sortOrderComboBox.ComboBox.SelectionChangeCommitted += SortOrderComboBox_SelectionChangeCommitted;
            sortOrderComboBox.SelectedItem = sortOrderItems.First(x => (SortOrder)x.Tag == GalleryBrowserFilter.SortOrder);
            sortOrderComboBox.ComboBox.OverrideMouseWheelBehaviour();
            sortOrderComboBox.Enabled = GalleryBrowserFilter.SortType != GallerySortType.None;
            sortOrderComboBox.OverrideUpDownKeys();

            //
            // toolStrip
            //
            toolStrip.Dock        = DockStyle.Fill;
            toolStrip.CanOverflow = false;
            toolStrip.Items.Add(searchComboBox);
            toolStrip.Items.Add(filterComboBox);
            toolStrip.Items.Add(sortTypeComboBox);
            toolStrip.Items.Add(sortOrderComboBox);

            //
            // this
            //
            Controls.Add(toolStrip);

            //GalleryModel.Searches.ListChanged += Searches_ListChanged;
            GalleryModel.SearchesChanged += GalleryModel_SearchesChanged;
            GalleryModel.FiltersChanged  += GalleryModel_FiltersChanged;

            galleryBrowserFilter.SortTypeChanged  += GalleryBrowserFilter_SortTypeChanged;
            galleryBrowserFilter.SortOrderChanged += GalleryBrowserFilter_SortOrderChanged;

            ResumeLayout(false);
        }