Skip to content

Commit

Permalink
Adde ability to save the filters
Browse files Browse the repository at this point in the history
  • Loading branch information
MaciekRakowski committed Feb 11, 2013
1 parent c3526e5 commit 754d671
Show file tree
Hide file tree
Showing 7 changed files with 566 additions and 340 deletions.
11 changes: 6 additions & 5 deletions Snoop/DebugListenerTab/DebugListenerControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
xmlns:x="http:https://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http:https://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http:https://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid>
mc:Ignorable="d" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
Expand Down Expand Up @@ -41,8 +40,10 @@
<StackPanel Orientation="Horizontal" Margin="10,0,10,10" Grid.Row="1" Grid.ColumnSpan="2">
<Button Name="buttonClear" Width="75" Height="25" HorizontalAlignment="Left" Content="Clear Text" Click="buttonClear_Click"/>
<Button Name="buttonClearFilters" Margin="10,0,0,0" Width="75" Height="25" HorizontalAlignment="Left" Content="Clear Filters" Click="buttonClearFilters_Click"/>
<Button Name="buttonSetFilters" Margin="10,0,0,0" Width="75" Height="25" HorizontalAlignment="Left" Content="Set Filters" Click="buttonSetFilters_Click"/>

<Button Name="buttonSetFilters" Margin="10,0,0,0" Width="75" Height="25" HorizontalAlignment="Left" Content="Edit Filter" Click="buttonSetFilters_Click"/>
<TextBlock Name="textBlockStatus" Margin="10,0,0,0" Text="{Binding Path=FilterStatus}" />
<!--<TextBlock Margin="10,5,0,0" Text="Use Existing Filter: " />
<ComboBox Name="comboBoxExistingFilters" Width="115" Margin="10,0,0,0" />-->
</StackPanel>

</Grid>
Expand Down
14 changes: 9 additions & 5 deletions Snoop/DebugListenerTab/DebugListenerControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ namespace Snoop.DebugListenerTab
/// </summary>
public partial class DebugListenerControl : UserControl, IListener
{
private readonly FiltersViewModel filtersViewModel = new FiltersViewModel();
private readonly FiltersViewModel filtersViewModel;// = new FiltersViewModel();
private readonly SnoopDebugListener snoopDebugListener = new SnoopDebugListener();
public DebugListenerControl()
{
filtersViewModel = new FiltersViewModel(Properties.Settings.Default.SnoopDebugFilters);
this.DataContext = filtersViewModel;

InitializeComponent();

snoopDebugListener.RegisterListener(this);
}

private void checkBoxStartListening_Checked(object sender, RoutedEventArgs e)
{
Debug.Listeners.Add(snoopDebugListener);
//PresentationTraceSources.DataBindingSource.Switch.Level = SourceLevels.Verbose;
PresentationTraceSources.DataBindingSource.Listeners.Add(snoopDebugListener);
}

Expand All @@ -46,8 +48,6 @@ private void checkBoxStartListening_Unchecked(object sender, RoutedEventArgs e)

public void Write(string str)
{
//this.Dispatcher.InvokeActionSafe((
//this.Dispatcher.InvokeActionSafe(() => DoWrite(str));
if (!filtersViewModel.IsSet || filtersViewModel.FilterMatches(str))
{
this.Dispatcher.BeginInvoke(DispatcherPriority.Render, () => DoWrite(str));
Expand All @@ -64,13 +64,17 @@ private void DoWrite(string str)
private void buttonClear_Click(object sender, RoutedEventArgs e)
{
this.textBoxDebugContent.Clear();

}

private void buttonClearFilters_Click(object sender, RoutedEventArgs e)
{
var result = MessageBox.Show("Are you sure you want to clear your filters?", "Clear Filters Confirmation", MessageBoxButton.YesNo);
if (result == MessageBoxResult.Yes)
{
filtersViewModel.ClearFilters();
Properties.Settings.Default.SnoopDebugFilters = null;
}
}

private void buttonSetFilters_Click(object sender, RoutedEventArgs e)
Expand Down
50 changes: 11 additions & 39 deletions Snoop/DebugListenerTab/SetFiltersWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,12 @@
<Setter Property="Background" Value="#FFEAEAEA" />
</DataTrigger>
</Style.Triggers>
<!--<Style.Triggers>

<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter Property="Background" Value="Transparent"></Setter>
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter Property="Background" Value="#FFEAEAEA"></Setter>
</Trigger>
</Style.Triggers>-->
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10" Name="stackPanelFilter">
<StackPanel Orientation="Horizontal" Margin="0,5,0,5" Name="stackPanelFilter">
<ComboBox Width="100" Height="23" Name="comboBoxFilterTypes" SelectedIndex="{Binding Path=FilterType, Mode=TwoWay,Converter={x:Static converters:FilterTypeToIntConverter.Default}}">
<ComboBoxItem Content="Starts With" />
<ComboBoxItem Content="Ends With" />
Expand All @@ -73,42 +64,23 @@
Data="M19.831014,18.751491 L4.5959764,3.5164535" />
</Grid>
</Button>


<TextBlock Foreground="Black" Text="{Binding Path=GroupId}" Margin="5,3,0,0" />

</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!--<ItemsControl Name="itemsControlFilters" ItemsSource="{Binding Path=Filters}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="0,0,0,10">
<ComboBox Width="100" Name="comboBoxFilterTypes" SelectedIndex="0">
<ComboBoxItem Content="Starts With" />
<ComboBoxItem Content="Contains" />
<ComboBoxItem Content="Ends With" />
</ComboBox>
<TextBox Width="150" Margin="10,0,0,0" />
<Button Name="buttonRemoveFilter" Margin="10,0,0,0" Width="18" Height="18" Click="buttonRemoveFilter_Click">
<Grid>
<Path
Stretch="Fill"
Stroke="Black"
StrokeThickness="2"
Data="M18.33996,8.7972167 L1.8622991,25.274878" />
<Path
Stretch="Fill"
Stroke="Black"
StrokeThickness="2"
Data="M19.831014,18.751491 L4.5959764,3.5164535" />
</Grid>
</Button>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>-->


<Button Margin="0,10,0,0" Grid.Row="1" VerticalAlignment="Bottom" Name="buttonAddFilter" Click="buttonAddFilter_Click" Content="Add Another Filter" Width="110" Height="25" HorizontalAlignment="Left" />
<!--</StackPanel>-->
</Grid>
<Button Name="buttonSetFilter" Margin="10,0,0,0" Grid.Row="1" HorizontalAlignment="Left" Height="25" Width="110" Content="Set Filter" Click="buttonSetFilter_Click" />
<!--<StackPanel Orientation="Horizontal" Grid.Row="1">-->
<Button Name="buttonSetFilter" Margin="10,0,0,0" Grid.Row="1" HorizontalAlignment="Left" Height="25" Width="110" Content="Set Filter" Click="buttonSetFilter_Click" />
<!--<Button Name="buttonSaveFilter" Margin="10,0,0,0" Grid.Row="1" HorizontalAlignment="Left" Height="25" Width="110" Content="Save Filter" Click="buttonSaveFilter_Click" />-->
<!--</StackPanel>-->

</Grid>
</Window>
Loading

0 comments on commit 754d671

Please sign in to comment.