Example #1
0
        private void RefreshListView()
        {
            watcherListView.Items.Clear();
            List <ListViewItem> watcherList = new List <ListViewItem>();

            using (var ctx = new FilesContext())
            {
                foreach (var watcher in ctx.Watchers)
                {
                    var item = new ListViewItem(new[] {
                        watcher.Name,
                        watcher.Enabled.ToString(),
                        watcher.Directory,
                        Watcher.HashToExtensionString(watcher.Whitelist),
                        watcher.ScanSubdirectories.ToString(),
                        watcher.GenerateVideoThumbnails.ToString(),
                        watcher.ShortcutKeys == Keys.None ? "None" : _keysConverter.ConvertToString(watcher.ShortcutKeys),
                        watcher.GlobalShortcut.ToString()
                    });
                    item.Tag = watcher.Id;
                    watcherList.Add(item);
                }
            }
            watcherListView.Items.AddRange(watcherList.ToArray());
        }
Example #2
0
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity <Watcher>()
            .Property(b => b.Whitelist)
            .HasDefaultValue(new HashSet <string>());

            modelBuilder.Entity <Watcher>()
            .Property(b => b.Enabled)
            .HasDefaultValue(true);

            modelBuilder.Entity <Watcher>()
            .Property(b => b.GenerateVideoThumbnails)
            .HasDefaultValue(true);

            modelBuilder.Entity <Watcher>()
            .Property(b => b.ScanSubdirectories)
            .HasDefaultValue(true);

            modelBuilder.Entity <File>()
            .Property(b => b.CreatedTime)
            .HasDefaultValueSql("CURRENT_TIMESTAMP");

            modelBuilder.Entity <File>()
            .Property(b => b.TimesAccessed)
            .HasDefaultValue(0);

            modelBuilder.Entity <File>()
            .Property(b => b.Directory_fts)
            .HasDefaultValue("");

            modelBuilder.Entity <File>()
            .Property(b => b.Name_fts)
            .HasDefaultValue("");

            modelBuilder.Entity <File>()
            .Property(b => b.Name_tokenized_fts)
            .HasDefaultValue("");

            modelBuilder.Entity <File>()
            .Property(b => b.Extension_fts)
            .HasDefaultValue("");

            modelBuilder.Entity <File>()
            .Property(b => b.Custom_fts)
            .HasDefaultValue(new ObservableHashSet <string>())
            .HasConversion(
                h => File.EnumToTagString(h),
                s => File.TagStringToHash(s));

            modelBuilder.Entity <File>()
            .Property(b => b.XMPTags_fts)
            .HasConversion(
                h => File.EnumToTagString(h),
                s => File.TagStringToHash(s));

            modelBuilder.Entity <File>()
            .Property(b => b.Comment)
            .HasDefaultValue("");

            modelBuilder.Entity <File>()
            .HasIndex(b => b.FullName);

            modelBuilder.Entity <File>()
            .HasIndex(b => new { b.FullName, b.WatcherId })
            .IsUnique();

            modelBuilder.Entity <File>()
            .HasIndex(b => b.Directory);

            modelBuilder.Entity <File>()
            .HasIndex(b => b.CreatedTime);

            modelBuilder.Entity <File>()
            .HasIndex(b => b.FileCreatedTime);

            modelBuilder.Entity <File>()
            .HasIndex(b => b.FileModifiedTime);
            modelBuilder.Entity <File>()
            .HasIndex(b => b.LastChangeTime);

            modelBuilder.Entity <File>()
            .HasIndex(b => b.LastUseTime);

            modelBuilder.Entity <File>()
            .HasIndex(b => b.TimesAccessed);

            modelBuilder.Entity <Watcher>()
            .Property(b => b.Whitelist)
            .HasConversion(
                h => Watcher.HashToExtensionString(h),
                s => Watcher.ExtensionStringToHash(s));

            modelBuilder.Entity <Watcher>()
            .Property(b => b.ShortcutKeys)
            .HasConversion(
                v => (int)v,
                v => (Keys)v);
        }