Exemple #1
0
 public FindDuplicatesForm(IMediaIndex index)
 {
     this.index            = index ?? throw new ArgumentNullException(nameof(index));
     this.searchCompiler   = new PredicateSearchCompiler(index.TagEngine, excludeHidden: false, _ => null); // TODO: Support saved searches.
     this.visiblePredicate = x => true;
     this.InitializeComponent();
 }
Exemple #2
0
 public AddPeopleForm(IMediaIndex index, IList <SearchResult> searchResults)
 {
     this.InitializeComponent();
     this.index         = index;
     this.searchResults = searchResults;
     this.PopulateExistingPeople();
     this.PopulatePeopleCombo();
 }
 public SearchResultsTags(IMediaIndex index)
 {
     this.index = index ?? throw new ArgumentNullException(nameof(index));
     this.index.HashTagAdded   += this.Index_HashTagAdded;
     this.index.HashTagRemoved += this.Index_HashTagRemoved;
     this.AutoSize              = true;
     this.AutoSizeMode          = AutoSizeMode.GrowAndShrink;
 }
        public PreviewControl(IMediaIndex index)
        {
            this.InitializeComponent();

            this.existingTags          = new SearchResultsTags(index);
            this.existingTags.Dock     = DockStyle.Bottom;
            this.existingTags.Name     = "existingTags";
            this.existingTags.TabIndex = 2;
            this.Controls.Add(this.existingTags);

            this.ResetMediaPlayer();
        }
Exemple #5
0
 public EditTagRulesForm(IMediaIndex index)
 {
     this.index = index;
     this.InitializeComponent();
 }
Exemple #6
0
 public EditTagsForm(IMediaIndex index, IList <SearchResult> searchResults)
 {
     this.InitializeComponent();
     this.index         = index;
     this.searchResults = searchResults;
 }
Exemple #7
0
 public EditPeopleForm(IMediaIndex index)
 {
     this.InitializeComponent();
     this.index = index;
     this.PopulatePeopleSearchBox();
 }
Exemple #8
0
        public VirtualSearchResultsView(IMediaIndex index)
        {
            this.index = index ?? throw new ArgumentNullException(nameof(index));
            this.AllowColumnReorder = true;
            this.FullRowSelect      = true;
            this.View = View.Details;

            this.columnDefinitions = new ColumnDefinitionList
            {
                {
                    Column.Path,
                    GetBestPath,
                    value => value == null ? string.Empty : Path.GetDirectoryName(value),
                    (a, b) => PathComparer.Instance.Compare(GetBestPath(a), GetBestPath(b))
                },
                {
                    Column.Name,
                    r =>
                    {
                        var path = GetBestPath(r);
                        return(path == null ? string.Empty : Path.GetFileNameWithoutExtension(path));
                    },
                    value => value,
                    (a, b) =>
                    {
                        var aPath = GetBestPath(a);
                        var bPath = GetBestPath(b);
                        return(StringComparer.CurrentCultureIgnoreCase.Compare(
                                   aPath == null ? null : Path.GetFileNameWithoutExtension(aPath),
                                   bPath == null ? null : Path.GetFileNameWithoutExtension(bPath)));
                    },
                    r => GetImageKey(r.FileType)
                },
                {
                    Column.People,
                    r => r.People,
                    value => string.Join("; ", value.Select(p => p.Name)),
                    (a, b) => a.People.Count.CompareTo(b.People.Count)
                },
                {
                    Column.Tags,
                    r => r.Tags,
                    value => string.Join("; ", value),
                    (a, b) => this.TagComparer.Compare(a.Tags, b.Tags),
                    (g, bounds, r) =>
                    {
                        var tagComparer = this.TagComparer;
                        var baseSize    = g.MeasureString("#", this.Font);
                        var padding     = (int)Math.Floor((bounds.Height - baseSize.Height) / 2);

                        var xOffset = 0f;
                        if (r.Tags.Contains("favorite"))
                        {
                            var size = bounds.Height - padding * 2;
                            g.DrawImage(Resources.love_it_filled, new RectangleF(bounds.Left + xOffset, bounds.Top + padding, size, size));
                            xOffset += size + padding;
                        }

                        foreach (var tag in r.Tags.Where(t => t != "favorite").OrderBy(t => t, tagComparer))
                        {
                            var backgroundColor = tagComparer.GetTagColor(tag) ?? SystemColors.Info;
                            var textColor       = ColorService.ContrastColor(backgroundColor);
                            var size            = g.MeasureString(tag, this.Font);
                            using (var backgroundBrush = new SolidBrush(backgroundColor))
                                using (var textBrush = new SolidBrush(textColor))
                                {
                                    var topLeft = new PointF(bounds.Left + xOffset, bounds.Top + padding);
                                    g.FillRectangle(backgroundBrush, new RectangleF(topLeft, size));
                                    g.DrawString(tag, this.Font, textBrush, topLeft);
                                }

                            // TODO: Break on out-of-bounds.
                            xOffset += size.Width + padding;
                        }
                    }
                },
                {
                    Column.FileSize,
                    HorizontalAlignment.Right,
                    r => r.FileSize,
                    value => ByteSize.FromBytes(value).ToString(),
                    (a, b) => a.FileSize.CompareTo(b.FileSize)
                },
                {
                    Column.Rating,
                    HorizontalAlignment.Right,
                    r => r.Rating,
                    value => value != null ? $"{Math.Round(value.Value)}{(value.Count < 15 ? "?" : string.Empty)}" : string.Empty,
                    (a, b) => Rating.Compare(a.Rating, b.Rating)
                },
            }.ToImmutableDictionary(c => c.Column);

            this.VirtualListDataSource = new DataSource(this, this.columnDefinitions);

            this.index.HashTagAdded      += this.Index_HashTagAdded;
            this.index.HashTagRemoved    += this.Index_HashTagRemoved;
            this.index.HashPersonAdded   += this.Index_HashPersonAdded;
            this.index.HashPersonRemoved += this.Index_HashPersonRemoved;
            this.index.RatingUpdated     += this.Index_RatingUpdated;
            this.index.TagRulesUpdated   += this.Index_TagRulesUpdated;

            foreach (var column in this.columnDefinitions.Values.OrderBy(c => c.Index))
            {
                var columnHeader = this.columns[column.Column] = new OLVColumn();
                columnHeader.Name                    = column.Column.ToString();
                columnHeader.Text                    = column.Name;
                columnHeader.TextAlign               = column.HorizontalAlignment;
                columnHeader.AspectGetter            = row => row == null ? null : column.GetValue((SearchResult)row);
                columnHeader.AspectToStringConverter = value => value == null ? null : column.FormatValue(value);

                if (column.DrawSubItem != null)
                {
                    columnHeader.Renderer = new ColumnRenderer(column.DrawSubItem)
                    {
                        ListView = this,
                    };
                }

                if (column.GetImage != null)
                {
                    columnHeader.ImageGetter = row => row == null ? null : column.GetImage((SearchResult)row);
                }

                this.Columns.Add(columnHeader);
            }

            this.ColumnWidthChanged += this.Internal_ColumnWidthChanged;
            this.BeforeSorting      += this.Internal_BeforeSorting;
        }