]> granicus.if.org Git - handbrake/commitdiff
WinGui: Display Source Names in the Title Dropdown (only when open), when we are...
authorsr55 <sr55.hb@outlook.com>
Mon, 25 Dec 2017 17:01:17 +0000 (17:01 +0000)
committersr55 <sr55.hb@outlook.com>
Mon, 25 Dec 2017 17:01:17 +0000 (17:01 +0000)
win/CS/HandBrakeWPF/Services/Scan/LibScan.cs
win/CS/HandBrakeWPF/Services/Scan/Model/Title.cs
win/CS/HandBrakeWPF/Views/MainView.xaml

index beceb9361fc50f8a7bc37c80fca2d058eba7303d..7558bc163cb09e358969ab77870885b135b0578b 100644 (file)
@@ -388,7 +388,8 @@ namespace HandBrakeWPF.Services.Scan
                         MainTitle = titles.MainFeature == title.Index,
                         Playlist = title.Type == 1 ? string.Format(" {0:d5}.MPLS", title.Playlist).Trim() : null,
                         FramerateNumerator = title.FrameRate.Num,
-                        FramerateDenominator = title.FrameRate.Den
+                        FramerateDenominator = title.FrameRate.Den,
+                        Type = title.Type
                     };
 
                 int currentTrack = 1;
index 32fddb36d1d448d373a0a1f32bac8598321bdd78..e60520fa75aaa4d1165b6ca99a572a5321f518b3 100644 (file)
@@ -11,10 +11,14 @@ namespace HandBrakeWPF.Services.Scan.Model
 {
     using System;
     using System.Collections.Generic;
+    using System.IO;
     using System.Linq;
 
     using HandBrake.ApplicationServices.Interop.Model;
 
+    using HandBrakeWPF.Model;
+    using HandBrakeWPF.Utilities;
+
     /// <summary>
     /// An object that represents a single Title of a DVD
     /// </summary>
@@ -123,6 +127,52 @@ namespace HandBrakeWPF.Services.Scan.Model
         /// </summary>
         public string SourceName { get; set; }
 
+        public string SourceDisplayName
+        {
+            get
+            {
+                switch (this.Type)
+                {
+                    case 0: // HB_DVD_TYPE
+                    case 1: // HB_BD_TYPE
+                    default:
+                        return string.Empty;
+                    case 2: // HB_STREAM_TYPE
+                    case 3: // HB_FF_STREAM_TYPE
+                        return Path.GetFileNameWithoutExtension(this.SourceName);
+                }
+            }
+        }
+
+        public string ItemDisplayText
+        {
+            get
+            {
+                return string.Format(
+                    "{0}{1} ({2:00}:{3:00}:{4:00}) {5}",
+                    this.TitleNumber,
+                    this.Playlist,
+                    this.Duration.Hours,
+                    this.Duration.Minutes,
+                    this.Duration.Seconds,
+                    this.SourceDisplayName);
+            }
+        }
+
+        public string ItemDisplayTextClosed
+        {
+            get
+            {
+                return string.Format(
+                    "{0}{1} ({2:00}:{3:00}:{4:00})",
+                    this.TitleNumber,
+                    this.Playlist,
+                    this.Duration.Hours,
+                    this.Duration.Minutes,
+                    this.Duration.Seconds);
+            }
+        }
+
         #endregion
 
         /// <summary>
index f4fffe924b06520376260817d125611146325178..d8e7a27fa5f2d2f8185129258f5f7d36ecfde6fb 100644 (file)
                 <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="0,5,0,0">\r
                     <Label FontWeight="Bold" Content="{x:Static Properties:ResourcesUI.MainView_Title}" />\r
                     <ComboBox Name="Titles"\r
-                                  MinWidth="100"\r
-                                  Margin="17,0,0,0"\r
-                                  ItemsSource="{Binding ScannedSource.Titles}"\r
-                                  ToolTip="{x:Static Properties:ResourcesTooltips.MainView_Title}"\r
-                                  SelectedItem="{Binding Path=SelectedTitle}" />\r
+                             Width="160"\r
+                             Margin="17,0,0,0"\r
+                             ItemsSource="{Binding ScannedSource.Titles}"\r
+                             ToolTip="{x:Static Properties:ResourcesTooltips.MainView_Title}"\r
+                             SelectedItem="{Binding Path=SelectedTitle}" >\r
+\r
+                        <ComboBox.Style>\r
+                            <Style TargetType="{x:Type ComboBox}">\r
+                                <Style.Triggers>\r
+                                    <DataTrigger Binding="{Binding Path=IsDropDownOpen, ElementName=Titles}" Value="True">\r
+                                        <Setter Property="DisplayMemberPath" Value="ItemDisplayText" />\r
+                                    </DataTrigger>\r
+                                    <DataTrigger Binding="{Binding Path=IsDropDownOpen, ElementName=Titles}" Value="False">\r
+                                        <Setter Property="DisplayMemberPath" Value="ItemDisplayTextClosed" />\r
+                                    </DataTrigger>\r
+                                </Style.Triggers>\r
+                            </Style>\r
+                        </ComboBox.Style>\r
+                    </ComboBox>\r
                     <Label Margin="8,0,0,0" FontWeight="Bold" Content="{x:Static Properties:ResourcesUI.MainView_Angle}" />\r
 \r
                     <ComboBox Name="Angles"\r