private void ShowUntagged_Click(object sender, RoutedEventArgs e) { using (var ctx = AkyuuContext.Create()) { var tagged = (from t in ctx.ScreenshotTags select t.File).Distinct(); var files = Utils.ListImageFiles(Config.Current.ScreenshotPath).Except(tagged); if (cxSortDesc.IsChecked is true) { files = from t in files orderby t descending select t; } else { files = from t in files orderby t ascending select t; } lsBrowser.ItemsSource = from t in files.ToList() select Screenshot.FromFile(t); } }
private void TagSearch_Click(object sender, RoutedEventArgs e) { var tagName = from t in allTags where t.Selected select t.Name; int tagCount = tagName.Count(); using (var ctx = AkyuuContext.Create()) { var files = from t in ctx.ScreenshotTags where tagName.Contains(t.TagName) group t by t.File into g where g.Count() >= tagCount select g.Key; if (cxSortDesc.IsChecked is true) { files = from t in files orderby t descending select t; } else { files = from t in files orderby t ascending select t; } lsBrowser.ItemsSource = from t in files.ToList() select Screenshot.FromFile(t); } }
private void RemoveTags() { if (lsTags.SelectedItem is ScreenshotTag tag) { using (var ctx = AkyuuContext.Create()) { ctx.ScreenshotTags.Attach(tag); ctx.ScreenshotTags.Remove(tag); ctx.SaveChanges(); } Tags.Remove(tag); } }
public SearchPage() { InitializeComponent(); DataContext = this; using (var ctx = AkyuuContext.Create()) { allTags = (from t in ctx.ScreenshotTags group t by t.TagName into g orderby g.Key select new TagInfo { Name = g.Key, }).ToList(); lsTagList.ItemsSource = allTags; } }
private void AddTags() { var window = new AddTagsWindow(Screenshot.File); if (window.ShowDialog(this) is true) { using (var ctx = AkyuuContext.Create()) { ctx.ScreenshotTags.AddRange(window.Tags); ctx.SaveChanges(); } foreach (var tag in window.Tags) { Tags.Add(tag); } } }
public ImageViewWindow(Screenshot screenshot) { InitializeComponent(); DataContext = this; Screenshot = screenshot; using (var ctx = AkyuuContext.Create()) { var tags = from t in ctx.ScreenshotTags where t.File == screenshot.File orderby t.TagName select t; Tags = new ObservableCollection <ScreenshotTag>(tags); } lsTags.Focus(); }
private void App_Startup(object sender, StartupEventArgs e) { string exepath = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); Directory.SetCurrentDirectory(exepath); if (File.Exists(ConfigFilePath)) { using (var fs = new FileStream(ConfigFilePath, FileMode.Open)) { var ser = new DataContractJsonSerializer(typeof(Models.Config)); Config = ser.ReadObject(fs) as Models.Config; } } else { Config = new Models.Config { // Default config values ScreenshotPath = Path.Combine(Directory.GetCurrentDirectory(), "Screenshots"), ThumbnailSize = 64, }; } if (e.Args.Length > 0) { string file = Path.GetFileName(e.Args[0]); if (!File.Exists(Path.Combine(Config.ScreenshotPath, file))) { MessageBox.Show($"Invalid filename '{file}' provided, exiting.", "Error", MessageBoxButton.OK, MessageBoxImage.Error); Environment.Exit(-1); } var window = new AddTagsWindow(file); if (window.ShowDialog() is true) { using (var ctx = AkyuuContext.Create()) { ctx.ScreenshotTags.AddRange(window.Tags); ctx.SaveChanges(); } } Environment.Exit(0); } }