Skip to content

Commit

Permalink
add tooltip to LastModified column (to see exact timestamp)
Browse files Browse the repository at this point in the history
  • Loading branch information
unitycoder committed Jan 15, 2025
1 parent ecc66e9 commit 54dab25
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
18 changes: 18 additions & 0 deletions UnityLauncherPro/Converters/LastModifiedConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,23 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu
return DateTime.ParseExact((string)value, MainWindow.currentDateFormat, culture);
}

}

// just for tooltip
[ValueConversion(typeof(DateTime), typeof(String))]
public class LastModifiedConverterTooltip : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null) return null;
DateTime date = (DateTime)value;
return date.ToString(MainWindow.currentDateFormat);
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return DateTime.ParseExact((string)value, MainWindow.currentDateFormat, culture);
}

}
}
20 changes: 19 additions & 1 deletion UnityLauncherPro/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
Title="UnityLauncherPro" Height="650" Width="880" WindowStartupLocation="CenterScreen" Background="{DynamicResource ThemeDarkestBackground}" MinWidth="780" MinHeight="650" AllowsTransparency="True" WindowStyle="None" Margin="0" KeyDown="OnWindowKeyDown" Closing="Window_Closing" SizeChanged="Window_SizeChanged" Icon="Images/icon.ico" SourceInitialized="Window_SourceInitialized" MouseDown="Window_MouseDown">
<Window.Resources>
<converters:LastModifiedConverter x:Key="lastModifiedConverter"/>
<converters:LastModifiedConverterTooltip x:Key="LastModifiedConverterTooltip"/>
<converters:ReleaseDateConverter x:Key="releaseDateConverter"/>
</Window.Resources>

Expand Down Expand Up @@ -142,13 +143,30 @@
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>
<!--<DataGridTextColumn CellStyle="{StaticResource NoFocusCellStyle}" Binding="{Binding Modified, StringFormat=\{0:dd/MM/yyyy HH:mm:ss\}}" ClipboardContentBinding="{x:Null}" Header="Modified" IsReadOnly="True" Width="120"/>-->
<DataGridTextColumn Header="Modified" Binding="{Binding Modified, Converter={StaticResource lastModifiedConverter}}" CellStyle="{StaticResource NoFocusCellStyle}" ClipboardContentBinding="{x:Null}" IsReadOnly="True" Width="120">
<DataGridTextColumn Header="Modified"
Binding="{Binding Modified, Converter={StaticResource lastModifiedConverter}}"
ClipboardContentBinding="{x:Null}"
IsReadOnly="True"
Width="120">
<DataGridTextColumn.HeaderTemplate>
<DataTemplate>
<TextBlock Text="Modified" IsHitTestVisible="False" />
</DataTemplate>
</DataGridTextColumn.HeaderTemplate>
<DataGridTextColumn.CellStyle>
<Style TargetType="DataGridCell">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="ToolTip">
<Setter.Value>
<ToolTip>
<TextBlock Text="{Binding Modified, Converter={StaticResource LastModifiedConverterTooltip}}" />
</ToolTip>
</Setter.Value>
</Setter>
</Style>
</DataGridTextColumn.CellStyle>
</DataGridTextColumn>

<DataGridTextColumn Header="Arguments" Binding="{Binding Arguments}" CellStyle="{StaticResource NoFocusCellStyle}" ClipboardContentBinding="{x:Null}" IsReadOnly="False" Width="100">
<DataGridTextColumn.HeaderTemplate>
<DataTemplate>
Expand Down

0 comments on commit 54dab25

Please sign in to comment.