Skip to content
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
45 changes: 43 additions & 2 deletions samples/WpfDemoLib/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,38 +14,62 @@ public sealed class MainViewModel : ObservableObject {
public const string NotificationWarningIconResourceName =
"pack://application:,,,/WpfDemoLib;component/assets/images/icons8-notification-warning-32.png";

private string? _fileDialogResults;
private string? _secondWindowResult;

public MainViewModel(
ICommandFactory commandFactory,
ISecondViewService secondViewService,
IMessageBoxService messageBoxService,
ILocalizationService localizationService,
IProgressDialogFactory progressDialogFactory) {
IProgressDialogFactory progressDialogFactory,
IOpenFileDialogService openFileDialogService,
ISaveFileDialogService saveFileDialogService,
IOpenFolderDialogService openFolderDialogService) {
SecondViewService = secondViewService;

MessageBoxService = messageBoxService;
LocalizationService = localizationService;
ProgressDialogFactory = progressDialogFactory;

OpenFileDialogService = openFileDialogService;
SaveFileDialogService = saveFileDialogService;
OpenFolderDialogService = openFolderDialogService;

LoadViewCommand = commandFactory.CreateAsync(LoadAsync);
AcceptViewCommand = commandFactory.CreateAsync(AcceptAsync);

ShowSecondWindowCommand = commandFactory.CreateAsync(ShowSecondWindowAsync);
ShowDialogSecondWindowCommand = commandFactory.CreateAsync(ShowDialogSecondWindowAsync);

ShowDialogOpenFileCommand = commandFactory.Create(ShowDialogOpenFile);
ShowDialogSaveFileCommand = commandFactory.Create(ShowDialogSaveFile);
ShowDialogOpenFolderCommand = commandFactory.Create(ShowDialogOpenFolder);
}

public ISecondViewService SecondViewService { get; }

public IMessageBoxService MessageBoxService { get; }
public ILocalizationService LocalizationService { get; }
public IProgressDialogFactory ProgressDialogFactory { get; }
public IOpenFileDialogService OpenFileDialogService { get; }
public ISaveFileDialogService SaveFileDialogService { get; }
public IOpenFolderDialogService OpenFolderDialogService { get; }

public IAsyncRelayCommand LoadViewCommand { get; set; }
public IAsyncRelayCommand AcceptViewCommand { get; set; }
public IAsyncRelayCommand ShowSecondWindowCommand { get; set; }
public IAsyncRelayCommand ShowDialogSecondWindowCommand { get; set; }

public IRelayCommand ShowDialogOpenFileCommand { get; set; }
public IRelayCommand ShowDialogSaveFileCommand { get; set; }
public IRelayCommand ShowDialogOpenFolderCommand { get; set; }

public string? FileDialogResults {
get => _fileDialogResults;
set => this.RaiseAndSetIfChanged(ref _fileDialogResults, value);
}

public string? SecondWindowResult {
get => _secondWindowResult;
set => this.RaiseAndSetIfChanged(ref _secondWindowResult, value);
Expand Down Expand Up @@ -91,6 +115,23 @@ private async Task ShowDialogSecondWindowAsync() {
SecondWindowResult = SecondViewService.Result;
}
}

private void ShowDialogOpenFile() {
FileDialogResults = OpenFileDialogService.ShowDialog()
? OpenFileDialogService.File.Name
: null;
}

private void ShowDialogSaveFile() {
FileDialogResults =
SaveFileDialogService.ShowDialog(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "test.txt")
? SaveFileDialogService.File.Name
: null;
}

private void ShowDialogOpenFolder() {
FileDialogResults = OpenFolderDialogService.ShowDialog() ? OpenFolderDialogService.Folder.Name : null;
}

private async Task AsyncOperation(int maxValue, IProgress<int>? progress, CancellationToken cancellationToken) {
for(int i = 0; i < maxValue; i++) {
Expand Down
9 changes: 9 additions & 0 deletions samples/WpfUIDemoApp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ protected override void OnStartup(StartupEventArgs e) {

_kernel.UseWpfUIProgressDialog<MainViewModel>(
displayTitleFormat: localizationService.GetLocalizedString("ProgressDialog.Content"));

_kernel.UseWpfOpenFileDialog<MainViewModel>(
title: localizationService.GetLocalizedString("OpenFileDialog.Title"));

_kernel.UseWpfSaveFileDialog<MainViewModel>(
title: localizationService.GetLocalizedString("SaveFileDialog.Title"));

_kernel.UseWpfOpenFolderDialog<MainViewModel>(
title: localizationService.GetLocalizedString("OpenFolderDialog.Title"));

_kernel.Bind<ISecondViewService>().To<SecondViewService>();
_kernel.Bind<ISecondViewFactory>()
Expand Down
42 changes: 34 additions & 8 deletions samples/WpfUIDemoApp/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding SecondViewService}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding MessageBoxService}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding ProgressDialogFactory}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding OpenFileDialogService}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding SaveFileDialogService}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding OpenFolderDialogService}" />
</b:Interaction.Behaviors>

<b:Interaction.Triggers>
Expand All @@ -46,6 +49,7 @@

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
Expand Down Expand Up @@ -82,31 +86,53 @@
</ui:TitleBar.TrailingContent>
</ui:TitleBar>

<StackPanel
<DockPanel
Grid.Row="1"
Orientation="Horizontal">
LastChildFill="True">

<ui:Button
Margin="10"
Width="80"
Command="{Binding ShowSecondWindowCommand}"
Content="{me:LocalizationSource MainWindow.ButtonSecondWindowShow}" />

<ui:Button
Margin="10"
Width="80"
Command="{Binding ShowDialogSecondWindowCommand}"
Content="{me:LocalizationSource MainWindow.ButtonSecondWindowShowDialog}" />

<ui:TextBox
Margin="10"
Width="180"
IsReadOnly="True"
Text="{Binding SecondWindowResult}" />
</StackPanel>
</DockPanel>

<DockPanel
Grid.Row="2"
LastChildFill="True">

<ui:Button
Margin="10"
Command="{Binding ShowDialogOpenFileCommand}"
Content="{me:LocalizationSource MainWindow.ButtonDialogOpenFileCommand}" />

<ui:Button
Margin="10"
Command="{Binding ShowDialogSaveFileCommand}"
Content="{me:LocalizationSource MainWindow.ButtonDialogSaveFileCommand}" />

<ui:Button
Margin="10"
Command="{Binding ShowDialogOpenFolderCommand}"
Content="{me:LocalizationSource MainWindow.ButtonDialogOpenFolderCommand}" />

<ui:TextBox
Margin="10"
IsReadOnly="True"
Text="{Binding FileDialogResults}" />
</DockPanel>

<ui:NavigationView
Grid.Row="2"
Grid.Row="3"
x:Name="_navigationView"
Margin="10"
PaneTitle="{me:LocalizationSource MainWindow.Title}">
Expand All @@ -128,7 +154,7 @@
</ui:NavigationView>

<StackPanel
Grid.Row="3"
Grid.Row="4"
Orientation="Horizontal"
HorizontalAlignment="Right">

Expand Down
4 changes: 2 additions & 2 deletions samples/WpfUIDemoApp/Views/Pages/GridViewPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
<TextBlock
Margin="10"
FontWeight="Bold"
Text="{Binding Name,
StringFormat={StaticResource MainWindow.GroupGridColumn}}" />
Text="{Binding Name}">
</TextBlock>
</StackPanel>
</Expander.Header>
<ItemsPresenter />
Expand Down
8 changes: 8 additions & 0 deletions samples/WpfUIDemoApp/assets/localizations/language.en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
<system:String x:Key="MessageBox.Content">Hello world!</system:String>
<system:String x:Key="ProgressDialog.Content">Please wait [{0}/{1}]...</system:String>

<system:String x:Key="OpenFileDialog.Title">Choose file</system:String>
<system:String x:Key="SaveFileDialog.Title">Save file</system:String>
<system:String x:Key="OpenFolderDialog.Title">Choose folder</system:String>

<system:String x:Key="MainWindow.ButtonDialogOpenFileCommand">Choose file</system:String>
<system:String x:Key="MainWindow.ButtonDialogSaveFileCommand">Save file</system:String>
<system:String x:Key="MainWindow.ButtonDialogOpenFolderCommand">Choose folder</system:String>

<system:String x:Key="UIThemes.Dark">Dark</system:String>
<system:String x:Key="UIThemes.Light">Light</system:String>
</ResourceDictionary>
8 changes: 8 additions & 0 deletions samples/WpfUIDemoApp/assets/localizations/language.ru-RU.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,14 @@
<system:String x:Key="MessageBox.Content">Привет мир!</system:String>
<system:String x:Key="ProgressDialog.Content">Пожалуйста подождите [{0}/{1}]...</system:String>

<system:String x:Key="OpenFileDialog.Title">Выбрать файл</system:String>
<system:String x:Key="SaveFileDialog.Title">Сохранить файл</system:String>
<system:String x:Key="OpenFolderDialog.Title">Выбрать папку</system:String>

<system:String x:Key="MainWindow.ButtonDialogOpenFileCommand">Выбрать файл</system:String>
<system:String x:Key="MainWindow.ButtonDialogSaveFileCommand">Сохранить файл</system:String>
<system:String x:Key="MainWindow.ButtonDialogOpenFolderCommand">Выбрать папку</system:String>

<system:String x:Key="UIThemes.Dark">Темная</system:String>
<system:String x:Key="UIThemes.Light">Светлая</system:String>
</ResourceDictionary>
9 changes: 9 additions & 0 deletions samples/XpfDemoApp/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ protected override void OnStartup(StartupEventArgs e) {

_kernel.UseXtraProgressDialog<MainViewModel>(
displayTitleFormat: localizationService.GetLocalizedString("ProgressDialog.Content"));

_kernel.UseXtraOpenFileDialog<MainViewModel>(
title: localizationService.GetLocalizedString("OpenFileDialog.Title"));

_kernel.UseXtraSaveFileDialog<MainViewModel>(
title: localizationService.GetLocalizedString("SaveFileDialog.Title"));

_kernel.UseXtraOpenFolderDialog<MainViewModel>(
title: localizationService.GetLocalizedString("OpenFolderDialog.Title"));

_kernel.Bind<ISecondViewService>().To<SecondViewService>();
_kernel.Bind<ISecondViewFactory>()
Expand Down
52 changes: 39 additions & 13 deletions samples/XpfDemoApp/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

x:Name="_this"
mc:Ignorable="d"

Icon="{me:QualifiedImage assets/images/icons8-google-photos-144.png}"

WindowStartupLocation="CenterScreen"
Expand All @@ -35,6 +35,9 @@
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding MessageBoxService}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding ProgressDialogFactory}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding NotificationService}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding OpenFileDialogService}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding SaveFileDialogService}" />
<behaviors:WpfAttachServiceBehavior AttachableService="{Binding OpenFolderDialogService}" />
</b:Interaction.Behaviors>

<b:Interaction.Triggers>
Expand All @@ -47,42 +50,65 @@

<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel

<DockPanel
Grid.Row="0"
Orientation="Horizontal">
LastChildFill="True">

<dx:SimpleButton
Margin="10"
Width="80"
Command="{Binding ShowSecondWindowCommand}"
Content="{me:LocalizationSource MainWindow.ButtonSecondWindowShow}" />

<dx:SimpleButton
Margin="10"
Width="80"
Command="{Binding ShowDialogSecondWindowCommand}"
Content="{me:LocalizationSource MainWindow.ButtonSecondWindowShowDialog}" />

<dxe:TextEdit
Margin="10"
Width="180"
IsReadOnly="True"
Text="{Binding SecondWindowResult}" />
</StackPanel>
</DockPanel>

<StackPanel
<DockPanel
Grid.Row="1"
LastChildFill="True">

<dx:SimpleButton
Margin="10"
Command="{Binding ShowDialogOpenFileCommand}"
Content="{me:LocalizationSource MainWindow.ButtonDialogOpenFileCommand}" />

<dx:SimpleButton
Margin="10"
Command="{Binding ShowDialogSaveFileCommand}"
Content="{me:LocalizationSource MainWindow.ButtonDialogSaveFileCommand}" />

<dx:SimpleButton
Margin="10"
Command="{Binding ShowDialogOpenFolderCommand}"
Content="{me:LocalizationSource MainWindow.ButtonDialogOpenFolderCommand}" />

<dxe:TextEdit
Margin="10"
IsReadOnly="True"
Text="{Binding FileDialogResults}" />
</DockPanel>

<StackPanel
Grid.Row="2"
Margin="0 10"
VerticalAlignment="Top"
HorizontalAlignment="Right"
Orientation="Horizontal">

<dxe:ComboBoxEdit
x:Name="_themesComboBox"
SelectedIndex="0"
Expand All @@ -107,23 +133,23 @@
</StackPanel>

<dxe:TextEdit
Grid.Row="2"
Grid.Row="3"
Margin="10"
IsReadOnly="True"
EditMode="InplaceInactive"
TextWrapping="WrapWithOverflow"
Text="{me:LocalizationSource MainWindow.RandomText}" />

<StackPanel
Grid.Row="3"
Grid.Row="4"
Orientation="Horizontal"
HorizontalAlignment="Right">

<Image
Height="18"
Margin="10 0"
Source="{me:QualifiedImage /dosymep.WpfCore;component/assets/images/icons8-no-image-96.png}" />

<Image
Height="18"
Source="{me:QualifiedImage assets/images/icons8-google-photos-144.png}" />
Expand Down
8 changes: 8 additions & 0 deletions samples/XpfDemoApp/assets/localizations/language.en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
<system:String x:Key="MessageBox.Content">Hello world!</system:String>
<system:String x:Key="ProgressDialog.Content">Please wait [{0}/{1}]...</system:String>

<system:String x:Key="OpenFileDialog.Title">Choose file</system:String>
<system:String x:Key="SaveFileDialog.Title">Save file</system:String>
<system:String x:Key="OpenFolderDialog.Title">Choose folder</system:String>

<system:String x:Key="MainWindow.ButtonDialogOpenFileCommand">Choose file</system:String>
<system:String x:Key="MainWindow.ButtonDialogSaveFileCommand">Save file</system:String>
<system:String x:Key="MainWindow.ButtonDialogOpenFolderCommand">Choose folder</system:String>

<system:String x:Key="UIThemes.Dark">Dark</system:String>
<system:String x:Key="UIThemes.Light">Light</system:String>
</ResourceDictionary>
Loading
Loading