Make comment blocks expandable & improve parsing
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Filtration.ObjectModel;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
|
||||
using System;
|
||||
|
||||
namespace Filtration.ViewModels
|
||||
{
|
||||
internal interface IItemFilterCommentBlockViewModel : IItemFilterBlockViewModelBase
|
||||
@@ -47,8 +48,22 @@ namespace Filtration.ViewModels
|
||||
ItemFilterCommentBlock.Comment = value;
|
||||
IsDirty = true;
|
||||
RaisePropertyChanged();
|
||||
RaisePropertyChanged("Header");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Header
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] commentLines = ItemFilterCommentBlock.Comment.Split(new[] { Environment.NewLine }, StringSplitOptions.None);
|
||||
if (commentLines[0].StartsWith(@"============") || commentLines[0].StartsWith(@"------------"))
|
||||
{
|
||||
commentLines[0] = commentLines[1];
|
||||
}
|
||||
return commentLines[0].TrimStart(' ');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -76,8 +76,19 @@
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column ="0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/>
|
||||
<Button Grid.Column="1" Command="{Binding ToggleSectionCommand}"
|
||||
|
||||
<Expander Grid.Column="1"
|
||||
Style="{StaticResource ExpanderRightAlignStyle}"
|
||||
x:Name="BlockExpander">
|
||||
|
||||
<Expander.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Label Grid.Column="0" VerticalAlignment="Center" MinWidth="150" Content="{Binding Header, Mode=OneWay}"></Label>
|
||||
<Button Grid.Column="1" Command="{Binding ToggleSectionCommand}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
VerticalAlignment="Center"
|
||||
@@ -86,9 +97,9 @@
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
ToolTip="Expand Section" Visibility="{Binding IsExpanded, Converter={StaticResource InverseBooleanVisibilityConverter}}">
|
||||
<Image Source="/Filtration;component/Resources/Icons/expand_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||
</Button>
|
||||
<Button Grid.Column="1" Command="{Binding ToggleSectionCommand}"
|
||||
<Image Source="/Filtration;component/Resources/Icons/expand_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||
</Button>
|
||||
<Button Grid.Column="1" Command="{Binding ToggleSectionCommand}"
|
||||
Width="25"
|
||||
Height="25"
|
||||
VerticalAlignment="Center"
|
||||
@@ -97,8 +108,18 @@
|
||||
Background="Transparent"
|
||||
BorderBrush="Transparent"
|
||||
ToolTip="Collapse Section" Visibility="{Binding IsExpanded, Converter={StaticResource BooleanVisibilityConverter}}">
|
||||
<Image Source="/Filtration;component/Resources/Icons/collapse_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||
</Button>
|
||||
<Image Source="/Filtration;component/Resources/Icons/collapse_icon.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||
</Button>
|
||||
</Grid>
|
||||
</Expander.Header>
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBox Grid.Column ="0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" VerticalAlignment="Center" TextWrapping="Wrap" MinWidth="150"/>
|
||||
</Grid>
|
||||
</Expander>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
|
||||
Reference in New Issue
Block a user