-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Filters: Extract ReleaseFilterPanel.
- Loading branch information
Showing
5 changed files
with
129 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<UserControl x:Class="Happy_Reader.View.ReleaseFilterPanel" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:local="clr-namespace:Happy_Reader.View" | ||
mc:Ignorable="d" | ||
d:DesignHeight="450" d:DesignWidth="800"> | ||
<Grid x:Name="MainGrid"> | ||
|
||
</Grid> | ||
</UserControl> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
using Happy_Reader.Model.VnFilters; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Controls.Primitives; | ||
using System.Windows.Data; | ||
namespace Happy_Reader.View | ||
{ | ||
public partial class ReleaseFilterPanel : UserControl | ||
{ | ||
private readonly ReleaseMonthFilter _releaseMonth = new(); | ||
public IFilter ViewModel { get; set; } | ||
|
||
public ReleaseFilterPanel() | ||
{ | ||
InitializeComponent(); | ||
//MainGrid.DataContext = _releaseMonth; | ||
var grid = MainGrid; | ||
var relativeCheckBox = new CheckBox() { Content = "Relative", DataContext = _releaseMonth }; | ||
relativeCheckBox.SetBinding(ToggleButton.IsCheckedProperty, new Binding(nameof(ReleaseMonthFilter.Relative)) { NotifyOnSourceUpdated = true }); | ||
relativeCheckBox.Checked += UpdateReleaseMonthFilter; | ||
relativeCheckBox.Unchecked += UpdateReleaseMonthFilter; | ||
relativeCheckBox.SourceUpdated += UpdateReleaseMonthFilter; | ||
var yearTextBox = new LabeledTextBox { Label = "Year", DataContext = _releaseMonth }; | ||
yearTextBox.SetBinding(LabeledTextBox.TextProperty, | ||
new Binding(nameof(ReleaseMonthFilter.Year)) { NotifyOnSourceUpdated = true }); | ||
yearTextBox.SourceUpdated += UpdateReleaseMonthFilter; | ||
var monthTextBox = new LabeledTextBox { Label = "Month", DataContext = _releaseMonth }; | ||
monthTextBox.SetBinding(LabeledTextBox.TextProperty, | ||
new Binding(nameof(ReleaseMonthFilter.Month)) { NotifyOnSourceUpdated = true }); | ||
monthTextBox.SourceUpdated += UpdateReleaseMonthFilter; | ||
grid.ColumnDefinitions.Add(new ColumnDefinition()); | ||
grid.ColumnDefinitions.Add(new ColumnDefinition()); | ||
grid.ColumnDefinitions.Add(new ColumnDefinition()); | ||
grid.Children.Add(relativeCheckBox); | ||
Grid.SetColumn(relativeCheckBox, 0); | ||
grid.Children.Add(yearTextBox); | ||
Grid.SetColumn(yearTextBox, 1); | ||
grid.Children.Add(monthTextBox); | ||
Grid.SetColumn(monthTextBox, 2); | ||
} | ||
|
||
private void UpdateReleaseMonthFilter(object sender, RoutedEventArgs e) | ||
{ | ||
if (ViewModel == null) return; | ||
ViewModel.Value = _releaseMonth; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters