Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added font weight changing when message has been seen #175

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 21 additions & 4 deletions src/Papercut.Core/Domain/Message/MessageEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public class MessageEntry : INotifyPropertyChanged, IEquatable<MessageEntry>, IF

bool _isSelected;

public MessageEntry(FileInfo fileInfo)
bool _hasBeenSeen;

public MessageEntry(FileInfo fileInfo)
{
this._info = fileInfo;

Expand Down Expand Up @@ -83,11 +85,26 @@ public bool IsSelected
set
{
this._isSelected = value;
this.OnPropertyChanged(nameof(this.IsSelected));
}

if (value)
{
this.HasBeenSeen = true;
}
this.OnPropertyChanged(nameof(this.IsSelected));
}
}

public bool Equals(MessageEntry other)
public bool HasBeenSeen
{
get => this._hasBeenSeen;
set
{
this._hasBeenSeen = value;
this.OnPropertyChanged(nameof(this.HasBeenSeen));
}
}

public bool Equals(MessageEntry other)
{
return Equals(this._info, other._info);
}
Expand Down
101 changes: 58 additions & 43 deletions src/Papercut.UI/Views/MessageListView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,55 +11,70 @@
mc:Ignorable="d"
d:DesignHeight="400" d:DesignWidth="200"
IsEnabled="{Binding Path=IsLoading,Converter={StaticResource InverseBooleanConverter}}">
<i:Interaction.Behaviors>
<Behaviors:InteractivityBlurOnDisabled BlurRadius="3" />
</i:Interaction.Behaviors>
<ListBox Name="MessagesList" Width="Auto" Height="Auto" SelectionMode="Extended" VirtualizingStackPanel.IsVirtualizing="false"
<i:Interaction.Behaviors>
<Behaviors:InteractivityBlurOnDisabled BlurRadius="3" />
</i:Interaction.Behaviors>
<ListBox Name="MessagesList" Width="Auto" Height="Auto" SelectionMode="Extended" VirtualizingStackPanel.IsVirtualizing="false"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Padding="0" Margin="2"
cal:Message.Attach="[Event KeyDown] = [Action MessageListKeyDown($eventArgs)]"
ItemsSource="{Binding MessagesSorted}">
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Open Containing Folder..." IsEnabled="{Binding Path=HasSelectedMessage}"
<ListBox.ContextMenu>
<ContextMenu>
<MenuItem Header="Open Containing Folder..." IsEnabled="{Binding Path=HasSelectedMessage}"
cal:Message.Attach="OpenMessageFolder" />
</ContextMenu>
</ListBox.ContextMenu>
<i:Interaction.Behaviors>
<Behaviors:DragDropIFile />
</i:Interaction.Behaviors>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid ToolTip="{Binding File}" Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition
</ContextMenu>
</ListBox.ContextMenu>
<i:Interaction.Behaviors>
<Behaviors:DragDropIFile />
</i:Interaction.Behaviors>
<ListBox.ItemTemplate>
<DataTemplate>
<Grid ToolTip="{Binding File}" Margin="2">
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="{Binding Path=ViewportWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ScrollViewer}}" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding Subject}" FontWeight="Bold"
TextTrimming="CharacterEllipsis"
Visibility="{Binding Subject, Converter={StaticResource CollapsedIfFalse}}" FontSize="14"/>
<Grid Grid.Column="0" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding Path=ViewportWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ScrollViewer}}" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding DisplayText}"
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding Subject}"
TextTrimming="CharacterEllipsis"
Visibility="{Binding Subject, Converter={StaticResource CollapsedIfFalse}}" FontSize="14">

<TextBlock.Style>
<Style TargetType="TextBlock">
<Style.Triggers>
<DataTrigger Binding="{Binding HasBeenSeen}" Value="True">
<Setter Property="FontWeight" Value="Normal"/>
</DataTrigger>
<DataTrigger Binding="{Binding HasBeenSeen}" Value="False">
<Setter Property="FontWeight" Value="Bold"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>

</TextBlock>
<Grid Grid.Column="0" Grid.Row="1">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="{Binding Path=ViewportWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ScrollViewer}}" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<TextBlock Grid.Column="0" Grid.Row="0" Text="{Binding DisplayText}"
TextTrimming="CharacterEllipsis" />
</Grid>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>
</Grid>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
</Style>
</ListBox.ItemContainerStyle>
</ListBox>

</UserControl>