Исправление кнопок в просмотрщике
This commit is contained in:
@@ -27,7 +27,7 @@
|
|||||||
<Button
|
<Button
|
||||||
Width="25"
|
Width="25"
|
||||||
Margin="0,0,3,0"
|
Margin="0,0,3,0"
|
||||||
Click="FirstButton_OnClick"
|
Command="{Binding FirstPageCommand}"
|
||||||
Content="<<"
|
Content="<<"
|
||||||
DockPanel.Dock="Left"
|
DockPanel.Dock="Left"
|
||||||
IsEnabled="{Binding HasPrevious}" />
|
IsEnabled="{Binding HasPrevious}" />
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<Button
|
<Button
|
||||||
Width="25"
|
Width="25"
|
||||||
Margin="0,0,3,0"
|
Margin="0,0,3,0"
|
||||||
Click="PreviousButton_OnClick"
|
Command="{Binding PreviousPageCommand}"
|
||||||
Content="<"
|
Content="<"
|
||||||
DockPanel.Dock="Left"
|
DockPanel.Dock="Left"
|
||||||
IsEnabled="{Binding HasPrevious}" />
|
IsEnabled="{Binding HasPrevious}" />
|
||||||
@@ -43,7 +43,7 @@
|
|||||||
<Button
|
<Button
|
||||||
Width="25"
|
Width="25"
|
||||||
Margin="3,0,0,0"
|
Margin="3,0,0,0"
|
||||||
Click="LastButton_OnClick"
|
Command="{Binding LastPageCommand}"
|
||||||
Content=">>"
|
Content=">>"
|
||||||
DockPanel.Dock="Right"
|
DockPanel.Dock="Right"
|
||||||
IsEnabled="{Binding HasNext}" />
|
IsEnabled="{Binding HasNext}" />
|
||||||
@@ -51,7 +51,7 @@
|
|||||||
<Button
|
<Button
|
||||||
Width="25"
|
Width="25"
|
||||||
Margin="3,0,0,0"
|
Margin="3,0,0,0"
|
||||||
Click="NextButton_OnClick"
|
Command="{Binding NextPageCommand}"
|
||||||
Content=">"
|
Content=">"
|
||||||
DockPanel.Dock="Right"
|
DockPanel.Dock="Right"
|
||||||
IsEnabled="{Binding HasNext}" />
|
IsEnabled="{Binding HasNext}" />
|
||||||
|
|||||||
@@ -8,16 +8,6 @@ namespace Pf2eDataScrapper.WPF.EntityViewer.Component;
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
internal partial class EntityListControl : System.Windows.Controls.UserControl
|
internal partial class EntityListControl : System.Windows.Controls.UserControl
|
||||||
{
|
{
|
||||||
public EntityListViewModel? ViewModel
|
|
||||||
{
|
|
||||||
get => _viewModel;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_viewModel = value;
|
|
||||||
DataContext = ViewModel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private EntityListViewModel? _viewModel;
|
private EntityListViewModel? _viewModel;
|
||||||
|
|
||||||
public EntityListControl()
|
public EntityListControl()
|
||||||
@@ -29,22 +19,22 @@ internal partial class EntityListControl : System.Windows.Controls.UserControl
|
|||||||
|
|
||||||
private void FirstButton_OnClick(object sender, RoutedEventArgs e)
|
private void FirstButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel?.FirstPage();
|
// DataContext?.FirstPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PreviousButton_OnClick(object sender, RoutedEventArgs e)
|
private void PreviousButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel?.PreviousPage();
|
//ViewModel?.PreviousPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NextButton_OnClick(object sender, RoutedEventArgs e)
|
private void NextButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel?.NextPage();
|
//ViewModel?.NextPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void LastButton_OnClick(object sender, RoutedEventArgs e)
|
private void LastButton_OnClick(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
ViewModel?.LastPage();
|
//ViewModel?.LastPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TextBox_PreviewTextInput(
|
private void TextBox_PreviewTextInput(
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ internal class StructureRow : INotifyPropertyChanged
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string ButtonIcon =>
|
public string ButtonIcon =>
|
||||||
HasButton && !((StructureFieldComplex)Field).Collapsed
|
HasButton && !((StructureFieldComplex)Field).Collapsed
|
||||||
? IconChar.PlusSquare.ToChar()
|
? IconChar.MinusSquare.ToChar()
|
||||||
: IconChar.MinusSquare.ToChar();
|
: IconChar.PlusSquare.ToChar();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Глубина отображения поля.
|
/// Глубина отображения поля.
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ using System.Collections.Generic;
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using AngleSharp.Browser;
|
|
||||||
using LinqToDB.DataProvider.Access;
|
using LinqToDB.DataProvider.Access;
|
||||||
using Pf2eDataScrapper.WPF.EntityViewer.Stores;
|
using Pf2eDataScrapper.WPF.EntityViewer.Stores;
|
||||||
using Pf2eModel;
|
using Pf2eModel;
|
||||||
@@ -129,13 +128,41 @@ internal class EntityListViewModel : ViewModelBase
|
|||||||
|
|
||||||
#region "Методы кнопок"
|
#region "Методы кнопок"
|
||||||
|
|
||||||
public void FirstPage() => Page = 1;
|
private PageNavigationCommand? _firstPageCommand;
|
||||||
|
public PageNavigationCommand FirstPageCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _firstPageCommand ??= new PageNavigationCommand(() => { Page = 1; });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void PreviousPage() => Page--;
|
private PageNavigationCommand? _previousPageCommand;
|
||||||
|
public PageNavigationCommand PreviousPageCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _previousPageCommand ??= new PageNavigationCommand(() => { Page--; });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void NextPage() => Page++;
|
private PageNavigationCommand? _nextPageCommand;
|
||||||
|
public PageNavigationCommand NextPageCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _nextPageCommand ??= new PageNavigationCommand(() => { Page++; });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void LastPage() => Page = PageCount;
|
private PageNavigationCommand? _lastPageCommand;
|
||||||
|
public PageNavigationCommand LastPageCommand
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _lastPageCommand ??= new PageNavigationCommand(() => { Page = PageCount; });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool HasPrevious => Page != 1;
|
public bool HasPrevious => Page != 1;
|
||||||
|
|
||||||
@@ -167,3 +194,20 @@ internal class EntityListViewModel : ViewModelBase
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class PageNavigationCommand(Action action) : System.Windows.Input.ICommand
|
||||||
|
{
|
||||||
|
public Action Action { get; } = action;
|
||||||
|
|
||||||
|
public event EventHandler? CanExecuteChanged;
|
||||||
|
|
||||||
|
public bool CanExecute(object? parameter)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Execute(object? parameter)
|
||||||
|
{
|
||||||
|
Action.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user