Sfoglia il codice sorgente

Add support for displaying EXIF comments: introduce `Comment` property in view models, update EXIF handlers to extract user comments, adjust UI for comment visualization, and localize "Comment" across all supported languages.

Ruben 4 mesi fa
parent
commit
10d9ed2e40

+ 2 - 2
src/PicView.Avalonia/Navigation/ExifHandling.cs

@@ -1,6 +1,5 @@
 using Avalonia.Media.Imaging;
 using ImageMagick;
-using PicView.Avalonia.ImageHandling;
 using PicView.Avalonia.Resizing;
 using PicView.Avalonia.UI;
 using PicView.Avalonia.ViewModels;
@@ -158,6 +157,7 @@ public static class ExifHandling
             vm.Exif.ExifVersion = EXIFHelper.GetExifVersion(profile);
             vm.Exif.LensModel = profile?.GetValue(ExifTag.LensModel)?.Value ?? string.Empty;
             vm.Exif.LensMaker = profile?.GetValue(ExifTag.LensMake)?.Value ?? string.Empty;
+            vm.Exif.Comment = EXIFHelper.GetUserComment(profile);
         }
         catch (Exception e)
         {
@@ -167,4 +167,4 @@ public static class ExifHandling
             #endif
         }
     }
-}
+}

+ 31 - 0
src/PicView.Avalonia/Views/ExifView.axaml

@@ -21,6 +21,8 @@
             <Style Selector="TextBox.x">
                 <Setter Property="Background" Value="{DynamicResource DisabledBackgroundColor}" />
                 <Setter Property="Foreground" Value="{StaticResource SecondaryTextColor}" />
+                <Setter Property="TextWrapping" Value="Wrap" />
+                <Setter Property="MaxHeight" Value="66" />
             </Style>
         </Styles>
     </UserControl.Styles>
@@ -718,6 +720,35 @@
                         </StackPanel>
                     </StackPanel>
                 </StackPanel>
+
+                <!--  Comment  -->
+                <StackPanel Margin="0,10,0,10" Orientation="Horizontal">
+                    <TextBlock
+                        Classes="txt"
+                        Margin="0,8,2,0"
+                        Text="Comment"
+                        Width="100" />
+                    <customControls:FuncTextBox
+                        Classes=" TStyle x"
+                        IsReadOnly="True"
+                        MaxHeight="600"
+                        Text="{CompiledBinding Exif.Comment,
+                                               Mode=OneWay}"
+                        Width="630" />
+                    <customControls:CopyButton
+                        Classes="altHover BorderStyle"
+                        CopyText="{CompiledBinding Exif.Comment,
+                                                   Mode=OneWay}"
+                        ToolTip.Tip="{CompiledBinding Translation.Copy,
+                                                      Mode=OneWay}">
+                        <Path
+                            Data="{StaticResource CopyGeometry}"
+                            Fill="{StaticResource SecondaryTextColor}"
+                            Height="16"
+                            Stretch="Fill"
+                            Width="16" />
+                    </customControls:CopyButton>
+                </StackPanel>
             </StackPanel>
 
             <StackPanel

+ 0 - 2
src/PicView.Avalonia/Views/ExifView.axaml.cs

@@ -54,8 +54,6 @@ public partial class ExifView : UserControl
                 return;
             }
             
-            ExifHandling.UpdateExifValues(vm);
-            
             _imageUpdateSubscription = vm.PicViewer.WhenAnyValue(x => x.FileInfo).Select(x => x is not null).Subscribe(_ =>
             {
                 ExifHandling.UpdateExifValues(vm);

+ 1 - 0
src/PicView.Core/Config/Languages/da.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Vælg en farve fra billedet",
   "ColorRepresentation": "Farverepræsentation",
   "ColorTone": "Farve Tone",
+  "Comment": "Kommentar",
   "CompressedBitsPixel": "Komprimerede bits pr. pixel",
   "Compression": "Kompression",
   "ConstrainBackgroundToImage": "Begræns baggrundsfarve til billedet",

+ 1 - 0
src/PicView.Core/Config/Languages/de.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Farbe aus Bild auswählen",
   "ColorRepresentation": "Farbdarstellung",
   "ColorTone": "Farbton",
+  "Comment": "Kommentar",
   "CompressedBitsPixel": "Komprimierte Bits pro Pixel",
   "Compression": "Komprimierung",
   "ConstrainBackgroundToImage": "Hintergrundfarbe auf Bild beschränken",

+ 1 - 0
src/PicView.Core/Config/Languages/en.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Pick color from image",
   "ColorRepresentation": "Color representation",
   "ColorTone": "Color Tone",
+  "Comment": "Comment",
   "CompressedBitsPixel": "Compressed bits per pixel",
   "Compression": "Compression",
   "ConstrainBackgroundToImage": "Constrain background color to image",

+ 1 - 0
src/PicView.Core/Config/Languages/es.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Elegir color desde imagen",
   "ColorRepresentation": "Representación de color",
   "ColorTone": "Tono de Color",
+  "Comment": "Comentario",
   "CompressedBitsPixel": "Bits por píxel comprimidos",
   "Compression": "Compresión",
   "ConstrainBackgroundToImage": "Restringir color de fondo a la imagen",

+ 1 - 0
src/PicView.Core/Config/Languages/fr.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Choisir la couleur de l'image",
   "ColorRepresentation": "Représentation des couleurs",
   "ColorTone": "Tonalité des couleurs",
+  "Comment": "Commentaire",
   "CompressedBitsPixel": "Bits de pixel compressés",
   "Compression": "Compression",
   "ConstrainBackgroundToImage": "Limiter la couleur d’arrière-plan à l’image",

+ 1 - 0
src/PicView.Core/Config/Languages/he.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "בחר צבע מהתמונה",
   "ColorRepresentation": "ייצוג צבע",
   "ColorTone": "גוון צבע",
+  "Comment": "תגובה",
   "CompressedBitsPixel": "סיביות דחוסות לפיקסל",
   "Compression": "דחיסה",
   "ConstrainBackgroundToImage": "הגבל צבע רקע לתמונה",

+ 1 - 0
src/PicView.Core/Config/Languages/hu.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Válasszon színt a képről",
   "ColorRepresentation": "Színes ábrázolás",
   "ColorTone": "Színtónus",
+  "Comment": "Megjegyzés",
   "CompressedBitsPixel": "Tömörített bitek pixelenként",
   "Compression": "Tömörítés",
   "ConstrainBackgroundToImage": "Háttérszín igazítása a képhez",

+ 1 - 0
src/PicView.Core/Config/Languages/it.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Scegli il colore dall'immagine",
   "ColorRepresentation": "Rappresentazione del colore",
   "ColorTone": "Tonalità di colore",
+  "Comment": "Commento",
   "CompressedBitsPixel": "Bit per pixel compressi",
   "Compression": "Compressione",
   "ConstrainBackgroundToImage": "Limita il colore di sfondo all'immagine",

+ 1 - 0
src/PicView.Core/Config/Languages/ja.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "画像から色を選択",
   "ColorRepresentation": "色彩表現",
   "ColorTone": "色調",
+  "Comment": "コメント",
   "CompressedBitsPixel": "圧縮されたピクセルあたりのビット数",
   "Compression": "圧縮",
   "ConstrainBackgroundToImage": "背景色を画像に制限する",

+ 1 - 0
src/PicView.Core/Config/Languages/ko.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "이미지에서 색 선택",
   "ColorRepresentation": "색상 표현",
   "ColorTone": "색조",
+  "Comment": "댓글",
   "CompressedBitsPixel": "픽셀당 압축 비트",
   "Compression": "압축",
   "ConstrainBackgroundToImage": "배경색을 이미지에만 적용",

+ 1 - 0
src/PicView.Core/Config/Languages/nl.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Kleur kiezen uit afbeelding",
   "ColorRepresentation": "Kleurenrepresentatie",
   "ColorTone": "Kleurtoon",
+  "Comment": "Opmerking",
   "CompressedBitsPixel": "Gecomprimeerde bits per pixel",
   "Compression": "Compressie",
   "ConstrainBackgroundToImage": "Beperk achtergrondkleur tot afbeelding",

+ 1 - 0
src/PicView.Core/Config/Languages/pl.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Wybierz kolor ze zdjęcia",
   "ColorRepresentation": "Reprezentacja kolorów",
   "ColorTone": "Odcień",
+  "Comment": "Komentarz",
   "CompressedBitsPixel": "Kompresja bitów na piksel",
   "Compression": "Kompresja",
   "ConstrainBackgroundToImage": "Ogranicz kolor tła do obrazu",

+ 1 - 0
src/PicView.Core/Config/Languages/pt-br.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Escolha a cor da imagem",
   "ColorRepresentation": "Representação de cores",
   "ColorTone": "Tonalidade da cor",
+  "Comment": "Comentário",
   "CompressedBitsPixel": "Bits compactados por pixel",
   "Compression": "Compressão",
   "ConstrainBackgroundToImage": "Restringir cor de fundo à imagem",

+ 1 - 0
src/PicView.Core/Config/Languages/ro.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Alegere culoare din imagine",
   "ColorRepresentation": "Reprezentare color",
   "ColorTone": "Ton de culoare",
+  "Comment": "Comentariu",
   "CompressedBitsPixel": "Biți compresați pe pixel",
   "Compression": "Compresie",
   "ConstrainBackgroundToImage": "Restricționează culoarea de fundal la imagine",

+ 1 - 0
src/PicView.Core/Config/Languages/ru.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Выберите цвет из изображения",
   "ColorRepresentation": "Цветовое представление",
   "ColorTone": "Цветовой тон",
+  "Comment": "Комментарий",
   "CompressedBitsPixel": "Сжатые биты на пиксель",
   "Compression": "Сжатие",
   "ConstrainBackgroundToImage": "Ограничить цвет фона изображением",

+ 1 - 0
src/PicView.Core/Config/Languages/sv.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Ta färgprov i bilden",
   "ColorRepresentation": "Färgrepresentation",
   "ColorTone": "Färgton",
+  "Comment": "Kommentar",
   "CompressedBitsPixel": "Komprimerade bitar per pixel",
   "Compression": "Kompression",
   "ConstrainBackgroundToImage": "Begränsa bakgrundsfärg till bilden",

+ 1 - 0
src/PicView.Core/Config/Languages/tr.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "Resimden renk seç",
   "ColorRepresentation": "Renk temsili",
   "ColorTone": "Renk Tonu",
+  "Comment": "Yorum",
   "CompressedBitsPixel": "Piksel başına sıkıştırılmış bit",
   "Compression": "Sıkıştırma",
   "ConstrainBackgroundToImage": "Arka plan rengini yalnızca görselle sınırla",

+ 1 - 0
src/PicView.Core/Config/Languages/zh-CN.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "从图片中选取颜色",
   "ColorRepresentation": "颜色表示",
   "ColorTone": "色调",
+  "Comment": "评论",
   "CompressedBitsPixel": "压缩位像素",
   "Compression": "压缩",
   "ConstrainBackgroundToImage": "将背景颜色限制为图像区域",

+ 1 - 0
src/PicView.Core/Config/Languages/zh-TW.json

@@ -57,6 +57,7 @@
   "ColorPickerToolTooltip": "從圖片中選取顏色",
   "ColorRepresentation": "色彩表示",
   "ColorTone": "色調",
+  "Comment": "評論",
   "CompressedBitsPixel": "壓縮位元像素",
   "Compression": "壓縮",
   "ConstrainBackgroundToImage": "將背景顏色限制為圖片區域",

+ 12 - 0
src/PicView.Core/ImageDecoding/EXIFHelper.cs

@@ -488,4 +488,16 @@ public static class EXIFHelper
         var subjectTag = profile?.GetValue(ExifTag.XPSubject)?.Value;
         return subjectTag?.GetValue(0)?.ToString() ?? string.Empty;
     }
+    
+    public static string GetUserComment(IExifProfile? profile)
+    {
+        var commentBytes = profile?.GetValue(ExifTag.UserComment)?.Value;
+        var decodedComment = commentBytes is null ? string.Empty : Encoding.ASCII.GetString(commentBytes);
+        if (string.IsNullOrEmpty(decodedComment))
+        {
+            return string.Empty;
+        }
+
+        return decodedComment.StartsWith("UNICODE") ? decodedComment.Replace("UNICODE", "") : decodedComment;;
+    }
 }

+ 1 - 0
src/PicView.Core/Localization/LanguageModel.cs

@@ -70,6 +70,7 @@ public class LanguageModel
     public string? ColorPickerToolTooltip { get; set; }
     public string? ColorRepresentation { get; set; }
     public string? ColorTone { get; set; }
+    public string? Comment {get; set; }
     public string? CompressedBitsPixel { get; set; }
     public string? Compression { get; set; }
     public string? ConstrainBackgroundToImage { get; set; }

+ 6 - 0
src/PicView.Core/ViewModels/ExifViewModel.cs

@@ -135,6 +135,12 @@ public class ExifViewModel : ReactiveObject
         get;
         set => this.RaiseAndSetIfChanged(ref field, value);
     }
+    
+    public string? Comment
+    {
+        get;
+        set => this.RaiseAndSetIfChanged(ref field, value);
+    }
 
     public string? CompressedBitsPixel
     {

+ 7 - 0
src/PicView.Core/ViewModels/TranslationViewModel.cs

@@ -291,6 +291,7 @@ public class TranslationViewModel : ReactiveObject
         MouseSideButtons = t.MouseSideButtons;
         NavigateFileHistory = t.NavigateFileHistory;
         NavigateBetweenDirectories = t.NavigateBetweenDirectories;
+        Comment = t.Comment;
     }
 
     #region Static Translation Strings
@@ -577,6 +578,12 @@ public class TranslationViewModel : ReactiveObject
         set => this.RaiseAndSetIfChanged(ref field, value);
     }
 
+    public string? Comment
+    {
+        get;
+        set => this.RaiseAndSetIfChanged(ref field, value);
+    }
+
     public string? CompressedBitsPixel
     {
         get;