Ejemplo n.º 1
0
        public MainForm(MediaIndex index)
        {
            this.index = index ?? throw new ArgumentNullException(nameof(index));
            this.InitializeComponent();

            this.listView = new VirtualSearchResultsView(index)
            {
                Dock           = DockStyle.Fill,
                Margin         = new Padding(0),
                Name           = "listView",
                SmallImageList = this.fileTypeImages,
                TabIndex       = 4,
                UseCompatibleStateImageBehavior = false,
            };
            this.listView.MouseClick           += this.ListView_MouseClick;
            this.listView.MouseDoubleClick     += this.ListView_DoubleClick;
            this.listView.SelectedIndexChanged += this.ListView_SelectedIndexChanged;

            this.preview = new PreviewControl(index)
            {
                Dock     = DockStyle.Fill,
                Name     = "preview",
                TabIndex = 5,
            };

            this.splitContainer.Panel1.Controls.Add(this.listView);
            this.splitContainer.Panel2.Controls.Add(this.preview);

            this.ApplySettings();
        }
Ejemplo n.º 2
0
        public static int Main(string[] args)
        {
            Options options = null;
            var     result  = Parser.Default.ParseArguments <Options>(args)
                              .WithParsed(o =>
            {
                PopulateDefaults(options = o);
            });

            if (options == null)
            {
                return(1);
            }

            Directory.CreateDirectory(Path.GetDirectoryName(options.IndexPath));

            var index   = new MediaIndex(options.IndexPath);
            var startup = new Startup(index);

            using (WebApp.Start(options.BaseUri, startup.Configuration))
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm(index));
                return(0);
            }
        }
Ejemplo n.º 3
0
        public SlideShowForm(MediaIndex index, IEnumerable <SearchResult> searchResults, bool shuffle = false, bool autoPlay = false)
        {
            this.index = index ?? throw new ArgumentNullException(nameof(index));
            var searchResultsList = searchResults.ToList();

            this.searchResults   = searchResultsList.ToDictionary(r => r.Hash);
            this.playlistManager = PlaylistManager.Create(searchResultsList.Select(r => r.Hash));
            this.InitializeComponent();

            this.LastMouseMove = Stopwatch.StartNew();
            var mouseMoveEvents = new MouseMoveEventFilter();

            mouseMoveEvents.MouseMove += (sender, args) => this.LastMouseMove = Stopwatch.StartNew();
            this.Shown      += (sender, args) => Application.AddMessageFilter(mouseMoveEvents);
            this.FormClosed += (sender, args) => Application.RemoveMessageFilter(mouseMoveEvents);

            this.index.HashPersonAdded   += this.Index_HashPersonAdded;
            this.index.HashPersonRemoved += this.Index_HashPersonRemoved;
            this.index.HashTagAdded      += this.Index_HashTagAdded;
            this.index.HashTagRemoved    += this.Index_HashTagRemoved;

            this.shuffleButton.Checked   = shuffle;
            this.playPauseButton.Checked = !autoPlay;
            if (autoPlay)
            {
                this.PlayPauseButton_Click(this, new EventArgs());
            }
            else
            {
                this.playPauseCancel.Cancel();
            }
        }
Ejemplo n.º 4
0
        private async Task <bool> SafeDelete(string expectedHash, List <string> keep, List <string> remove)
        {
            if (keep == null)
            {
                throw new ArgumentNullException(nameof(keep));
            }
            else if (remove == null)
            {
                throw new ArgumentNullException(nameof(remove));
            }
            else if (keep.Count == 0)
            {
                return(false);
            }
            else if (remove.Count == 0)
            {
                return(true);
            }

            foreach (var k in keep)
            {
                if ((await MediaIndex.HashFileAsync(k).ConfigureAwait(false)).Hash != expectedHash)
                {
                    return(false);
                }
            }

            var removed = new HashSet <string>();

            foreach (var r in remove)
            {
                try
                {
                    if ((await MediaIndex.HashFileAsync(r).ConfigureAwait(false)).Hash != expectedHash)
                    {
                        return(false);
                    }
                }
                catch (FileNotFoundException)
                {
                    removed.Add(r);
                    continue;
                }
            }

            foreach (var r in remove)
            {
                if (removed.Add(r))
                {
                    NativeMethods.DeleteToRecycleBin(r);
                }
            }

            foreach (var file in removed)
            {
                await this.index.RemoveFilePath(file).ConfigureAwait(false);
            }

            return(true);
        }
Ejemplo n.º 5
0
 public AddPeopleForm(MediaIndex index, IList <SearchResult> searchResults)
 {
     this.InitializeComponent();
     this.index         = index;
     this.searchResults = searchResults;
     this.PopulateExistingPeople();
     this.PopulatePeopleCombo();
 }
Ejemplo n.º 6
0
 public TagsController(EventStoreService eventStore, CacheDatabaseManager db, InMemoryCache cache)
 {
     _eventStore      = eventStore;
     _db              = db;
     _entityIndex     = cache.Index <EntityIndex>();
     _mediaIndex      = cache.Index <MediaIndex>();
     _tagIndex        = cache.Index <TagIndex>();
     _referencesIndex = cache.Index <ReferencesIndex>();
 }
Ejemplo n.º 7
0
 public RoutesController(EventStoreService eventStore, CacheDatabaseManager db, IEnumerable <IDomainIndex> indices)
 {
     _eventStore      = eventStore;
     _db              = db;
     _mediaIndex      = indices.OfType <MediaIndex>().First();
     _entityIndex     = indices.OfType <EntityIndex>().First();
     _referencesIndex = indices.OfType <ReferencesIndex>().First();
     _ratingIndex     = indices.OfType <RatingIndex>().First();
 }
Ejemplo n.º 8
0
 public MediaController(EventStoreService eventStore, CacheDatabaseManager db, InMemoryCache cache,
                        IOptions <UploadFilesConfig> uploadConfig, IOptions <EndpointConfig> endpointConfig,
                        ILogger <MediaController> logger)
 {
     _logger          = logger;
     _eventStore      = eventStore;
     _db              = db;
     _entityIndex     = cache.Index <EntityIndex>();
     _mediaIndex      = cache.Index <MediaIndex>();
     _referencesIndex = cache.Index <ReferencesIndex>();
     _uploadConfig    = uploadConfig.Value;
     _endpointConfig  = endpointConfig.Value;
 }
Ejemplo n.º 9
0
 public ExhibitPagesController(
     IOptions <ExhibitPagesConfig> exhibitPagesConfig,
     EventStoreService eventStore,
     CacheDatabaseManager db,
     InMemoryCache cache)
 {
     _exhibitPagesConfig = exhibitPagesConfig;
     _eventStore         = eventStore;
     _db               = db;
     _mediaIndex       = cache.Index <MediaIndex>();
     _entityIndex      = cache.Index <EntityIndex>();
     _referencesIndex  = cache.Index <ReferencesIndex>();
     _exhibitPageIndex = cache.Index <ExhibitPageIndex>();
 }
Ejemplo n.º 10
0
 public MainForm(MediaIndex index)
 {
     this.index = index ?? throw new ArgumentNullException(nameof(index));
     this.InitializeComponent();
     this.nameColumn.Name             = "Name";
     this.pathColumn.Name             = "Path";
     this.peopleColumn.Name           = "People";
     this.tagsColumn.Name             = "Tags";
     this.fileSizeColumn.Name         = "FileSize";
     this.listView.ListViewItemSorter = this.sorter = new MainFormListSorter();
     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.ApplySettings();
 }
Ejemplo n.º 11
0
 public SavedSearchesController(MediaIndex index)
 {
     this.index = index;
 }
Ejemplo n.º 12
0
 public EditPeopleForm(MediaIndex index)
 {
     this.InitializeComponent();
     this.index = index;
     this.PopulatePeopleSearchBox();
 }
Ejemplo n.º 13
0
 public Startup(MediaIndex index)
 {
     this.index = index;
 }
Ejemplo n.º 14
0
 public AddIndexedPathForm(MediaIndex index)
 {
     this.index = index;
     this.InitializeComponent();
 }
Ejemplo n.º 15
0
 public FileTagsController(MediaIndex index)
 {
     this.index = index;
 }
Ejemplo n.º 16
0
 public EditTagRulesForm(MediaIndex index)
 {
     this.index = index;
     this.InitializeComponent();
 }
Ejemplo n.º 17
0
 public EditTagsForm(MediaIndex index, IList <SearchResult> searchResults)
 {
     this.InitializeComponent();
     this.index         = index;
     this.searchResults = searchResults;
 }