コード例 #1
0
ファイル: ExtTagEdit.cs プロジェクト: locke-li/imagecat
        private void SetupTagGrid(ImageLink link)
        {
            xamlGridTags.RowDefinitions.Clear();
            xamlGridTags.RowDefinitions.Add(new RowDefinition());
            xamlGridTags.Children.Clear();
            double border = 5;
            double x = 0, lx = 0;
            double xm  = xamlGridTags.ActualWidth;
            int    row = 0;

            Console.Write("tags:");
            foreach (StringTag tag in link.tags)
            {
                Label tagE = TagElement(tag);
                xamlGridTags.Children.Add(tagE);
                tagE.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
                tagE.Arrange(new Rect(tagE.DesiredSize));
                x += tagE.ActualWidth + border;
                if (x > xm)
                {
                    xamlGridTags.RowDefinitions.Add(new RowDefinition());
                    ++row;
                    x  = 0;
                    lx = 0;
                }
                Grid.SetRow(tagE, row);
                tagE.Margin = new Thickness(lx, 0, 0, 0);
                Console.Write(tag + "(" + row + "," + lx + ")" + ", ");
                lx = x;
            }
            Console.WriteLine();
        }
コード例 #2
0
 private void ClearPreview()
 {
     previewLink                = null;
     previewName                = null;
     xamlTextFileName.Text      = null;
     xamlTextFileName.IsEnabled = false;
     xamlTextFileTags.Text      = null;
     xamlTextFileTags.IsEnabled = false;
 }
コード例 #3
0
 private void Preview(ImageLink link)
 {
     if (previewLink != null)
     {
         previewLink.grid.Background = Brushes.Transparent;
     }
     previewLink                 = link;
     previewName                 = link.name;
     xamlTextFileName.Text       = previewName;
     xamlTextFileName.IsEnabled  = true;
     xamlTextFileTags.Text       = link.alltags;
     xamlTextFileTags.IsEnabled  = true;
     xamlImagePreview.Source     = previewLink.Sample(0);
     previewLink.grid.Background = Brushes.LightSkyBlue;
 }
コード例 #4
0
 private void FillImageList()
 {
     imageLinks.Clear();
     xamlGridListImage.Dispatcher.Invoke(() => xamlGridListImage.Children.Clear());
     for (int r = 0; r < files.Count; ++r)
     {
         xamlGridListImage.Dispatcher.Invoke(() => {
             ImageLink link = new ImageLink(files[r]);
             Image img      = new Image()
             {
                 Margin = new Thickness(10), Visibility = Visibility.Visible
             };
             img.Unloaded += (object sender, RoutedEventArgs e) =>
             {
                 if (link.stream == null)
                 {
                     return;
                 }
                 link.stream.Close();
                 link.stream.Dispose();
             };
             link.preview = img;
             Grid imgGrid = new Grid()
             {
                 Margin = new Thickness(0), Visibility = Visibility.Collapsed
             };
             imgGrid.Children.Add(img);
             imgGrid.MouseLeftButtonDown += (object sender, MouseButtonEventArgs e) =>
             {
                 e.Handled = true;
                 Preview(link);
             };
             xamlGridListImage.Children.Add(imgGrid);
             link.grid = imgGrid;
             imageLinks.Add(link);
         });
     }
 }
コード例 #5
0
ファイル: StringTag.cs プロジェクト: locke-li/imagecat
 public static bool ShouldFilter(ImageLink link)
 {
     //Console.WriteLine(link.file.Name + " = " + link.tags.Any(t => tagFilter.Any(f => t.name.Contains(f.name))));
     return(tagFilter.Count > 0 && tagFilter.Any(f => link.tags.All(l => !l.name.StartsWith(f.name))));
 }