/// <summary>
        /// Factory method that finds and loads any available image collections
        /// </summary>
        public static ImageCollectionManager FromStandardLocations(string searchLanguageId = "en")
        {
            var manager = new ImageCollectionManager(searchLanguageId);

            manager.FindAndLoadCollections();
            if (manager.Collections.Any())
            {
                return(manager);
            }
            return(null);
        }
Esempio n. 2
0
        private void ArtOfReadingChooser_Load(object sender, EventArgs e)
        {
            if (DesignMode)
            {
                return;
            }

            _imageCollectionManager      = ImageCollectionManager.FromStandardLocations(SearchLanguage);
            _collectionToolStrip.Visible = false;
            if (_imageCollectionManager == null)
            {
                _messageLabel.Visible          = true;
                _messageLabel.Text             = "This computer doesn't appear to have any galleries installed yet.".Localize("ImageToolbox.NoGalleries");
                _downloadInstallerLink.Visible = true;
                _searchTermsBox.Enabled        = false;
                _searchButton.Enabled          = false;
            }
            else
            {
#if DEBUG
                //  _searchTermsBox.Text = @"flower";
#endif
                SetupSearchLanguageChoice();
                _messageLabel.Visible = string.IsNullOrEmpty(_searchTermsBox.Text);
                // Adjust size to avoid text truncation
                _messageLabel.Height = 200;
                SetMessageLabelText();
                _thumbnailViewer.SelectedIndexChanged += new EventHandler(_thumbnailViewer_SelectedIndexChanged);
                if (_imageCollectionManager.Collections.Count() > 1)
                {
                    _collectionToolStrip.Visible = true;
                    _collectionDropDown.Visible  = true;
                    _collectionDropDown.Text     =
                        "Galleries".Localize("ImageToolbox.Galleries");
                    if (ImageToolboxSettings.Default.DisabledImageCollections == null)
                    {
                        ImageToolboxSettings.Default.DisabledImageCollections = new StringCollection();
                    }

                    foreach (var collection in _imageCollectionManager.Collections)
                    {
                        if (ImageToolboxSettings.Default.DisabledImageCollections.Contains(collection.FolderPath))
                        {
                            collection.Enabled = false;
                        }
                        var text = Path.GetFileNameWithoutExtension(collection.Name);
                        var item = new ToolStripMenuItem(text);
                        _collectionDropDown.DropDownItems.Add(item);
                        item.CheckOnClick    = true;
                        item.CheckState      = collection.Enabled ? CheckState.Checked : CheckState.Unchecked;
                        item.CheckedChanged += (o, args) =>
                        {
                            if (_collectionDropDown.DropDownItems.Cast <ToolStripMenuItem>().Count(x => x.Checked) == 0)
                            {
                                item.Checked = true;                         // tried to uncheck the last one, don't allow it.
                            }
                            else
                            {
                                collection.Enabled = item.Checked;
                                var disabledSettings = ImageToolboxSettings.Default.DisabledImageCollections;
                                if (disabledSettings == null)
                                {
                                    ImageToolboxSettings.Default.DisabledImageCollections = disabledSettings = new StringCollection();
                                }
                                if (item.Checked && disabledSettings.Contains(collection.FolderPath))
                                {
                                    disabledSettings.Remove(collection.FolderPath);
                                }
                                if (!item.Checked && !disabledSettings.Contains(collection.FolderPath))
                                {
                                    disabledSettings.Add(collection.FolderPath);
                                }
                                ImageToolboxSettings.Default.Save();
                            }
                        };
                    }
                }
                else
                {
                    // otherwise, just leave them all enabled
                }
            }
            _messageLabel.Font = new Font(SystemFonts.DialogFont.FontFamily, 10);

#if DEBUG
            //if (!HaveImageCollectionOnThisComputer)
            //	return;
            //when just testing, I just want to see some choices.
            // _searchTermsBox.Text = @"flower";
            //_searchButton_Click(this,null);
#endif
        }
Esempio n. 3
0
 /// <summary>
 /// Get images that exactly match one or more search terms.
 /// </summary>
 public IEnumerable <string> GetMatchingImages(string searchTermsCsv)
 {
     searchTermsCsv = ImageCollectionManager.GetCleanedUpSearchString(searchTermsCsv);
     return(GetMatchingImages(searchTermsCsv.SplitTrimmed(' ')));
 }