Support Visual Designers via DesignTime Instances (#37)

* Add Design.DataContext instances
* UI and logic adjustments
* Improved naming
* Use d:DesignTime instances on WPF
* Add more material design cards
* ValidatesOnNotifyDataErrors=True
* Use UWP 18362
* Mention AvaloniaRider
This commit is contained in:
Artyom V. Gorchakov 2020-09-02 02:17:30 +03:00 коммит произвёл GitHub
Родитель 3779fd026f
Коммит 22ae9fc029
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
30 изменённых файлов: 533 добавлений и 221 удалений

Просмотреть файл

@ -69,3 +69,4 @@ To compile the <a href="https://docs.microsoft.com/en-us/xamarin/xamarin-forms/"
- <a href="https://reactiveui.net/docs/handbook/events/">ReactiveUI.Events</a> turning regular events into observables
- <a href="https://github.com/Fody/Costura">Costura.Fody</a> which embeds references as resources
- <a href="https://www.jetbrains.com/rider/">JetBrains Rider</a> and <a href="https://visualstudio.microsoft.com/">Microsoft Visual Studio</a> IDEs
- <a href="https://github.com/fornever/avaloniarider">AvaloniaRider</a> plugin for visual designer support

Просмотреть файл

@ -20,13 +20,15 @@ namespace Camelotia.Presentation.Avalonia
// Configure ReactiveUI suspension management.
var suspension = new AutoSuspendHelper(ApplicationLifetime);
RxApp.SuspensionHost.CreateNewAppState = () => new MainState();
RxApp.SuspensionHost.SetupDefaultSuspendResume(new AkavacheSuspensionDriver<MainState>("CamelotiaV2"));
RxApp.SuspensionHost.SetupDefaultSuspendResume(new NewtonsoftJsonSuspensionDriver("appstate.json"));
suspension.OnFrameworkInitializationCompleted();
base.OnFrameworkInitializationCompleted();
// Configure app dependencies.
var window = new MainView();
var styles = new AvaloniaStyleManager(window);
Akavache.BlobCache.ApplicationName = "CamelotiaV2";
window.SwitchThemeButton.Click += (sender, args) => styles.UseNextTheme();
window.DataContext = new MainViewModel(
RxApp.SuspensionHost.GetAppState<MainState>(),
@ -50,7 +52,6 @@ namespace Camelotia.Presentation.Avalonia
);
window.Show();
base.OnFrameworkInitializationCompleted();
}
}
}

Просмотреть файл

@ -1,12 +1,11 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance interfaces:IAuthViewModel, IsDesignTimeCreatable=True}"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:views="clr-namespace:Camelotia.Presentation.Avalonia.Views"
x:Class="Camelotia.Presentation.Avalonia.Views.AuthView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d">
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation">
<Design.DataContext>
<designTime:DesignTimeAuthViewModel />
</Design.DataContext>
<Carousel Name="AuthTabs">
<Carousel.PageTransition>
<PageSlide Duration="0.25" Orientation="Vertical" />

Просмотреть файл

@ -1,11 +1,12 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance interfaces:ICreateFolderViewModel, IsDesignTimeCreatable=False}"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="Camelotia.Presentation.Avalonia.Views.CreateFolderView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d" Background="{DynamicResource ThemeCardBrush}">
x:Class="Camelotia.Presentation.Avalonia.Views.CreateFolderView"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
Background="{DynamicResource ThemeCardBrush}"
Padding="20">
<Design.DataContext>
<designTime:DesignTimeCreateFolderViewModel />
</Design.DataContext>
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="300">
@ -18,16 +19,15 @@
Margin="0 5" />
<StackPanel IsVisible="{Binding HasErrorMessage}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap" />
</StackPanel>
Margin="0 0 0 5">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap"
Margin="10" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 5">
<TextBlock Text="Creating new folder at:" Margin="0 0 5 0" />
<TextBlock Text="{Binding Path}" />
<TextBlock Text="{Binding Path}" Opacity="0.5" />
</StackPanel>
<TextBlock Text="Please, enter new folder name:" Margin="0 5" />
<TextBox Watermark="Folder name..." Text="{Binding Name, Mode=TwoWay}" />

Просмотреть файл

@ -1,11 +1,12 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance interfaces:IDirectAuthViewModel, IsDesignTimeCreatable=True}"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="Camelotia.Presentation.Avalonia.Views.DirectAuthView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d" Background="{DynamicResource ThemeCardBrush}">
x:Class="Camelotia.Presentation.Avalonia.Views.DirectAuthView"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
Background="{DynamicResource ThemeCardBrush}"
Padding="20">
<Design.DataContext>
<designTime:DesignTimeDirectAuthViewModel />
</Design.DataContext>
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="300">
@ -18,12 +19,11 @@
Margin="0 5" />
<StackPanel IsVisible="{Binding HasErrorMessage}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap" />
</StackPanel>
Margin="0 0 0 5">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap"
Margin="10" />
</StackPanel>
<TextBlock Text="Please, enter your user name:" Margin="0 5" />
<TextBox Watermark="User name..." Text="{Binding Username, Mode=TwoWay}" />

Просмотреть файл

@ -1,14 +1,11 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance interfaces:IFileViewModel, IsDesignTimeCreatable=True}"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:models="clr-namespace:Camelotia.Services.Models;assembly=Camelotia.Services"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:Camelotia.Presentation.Avalonia.Views"
x:Class="Camelotia.Presentation.Avalonia.Views.FileView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Background="Transparent"
mc:Ignorable="d">
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
x:Class="Camelotia.Presentation.Avalonia.Views.FileView"
Background="Transparent">
<Design.DataContext>
<designTime:DesignTimeFileViewModel />
</Design.DataContext>
<UserControl.ContextMenu>
<ContextMenu>
<MenuItem Header="Open" Command="{Binding Provider.Open}" />

Просмотреть файл

@ -1,15 +1,16 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance interfaces:IHostAuthViewModel, IsDesignTimeCreatable=True}"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="Camelotia.Presentation.Avalonia.Views.HostAuthView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d" Background="{DynamicResource ThemeCardBrush}">
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
x:Class="Camelotia.Presentation.Avalonia.Views.HostAuthView"
Background="{DynamicResource ThemeCardBrush}"
Padding="20">
<Design.DataContext>
<designTime:DesignTimeHostAuthViewModel />
</Design.DataContext>
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="300">
<TextBlock Text="Password Auth"
<TextBlock Text="Remote Host Auth"
Classes="Heading"
Margin="0 10" />
<ProgressBar HorizontalAlignment="Stretch"
@ -18,12 +19,11 @@
Margin="0 5" />
<StackPanel IsVisible="{Binding HasErrorMessage}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap" />
</StackPanel>
Margin="0 0 0 5">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap"
Margin="10" />
</StackPanel>
<TextBlock Text="Please, enter host address with port:" Margin="0 5" />
<Grid>

Просмотреть файл

@ -1,14 +1,15 @@
<Window xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance interfaces:IMainViewModel, IsDesignTimeCreatable=True}"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:views="clr-namespace:Camelotia.Presentation.Avalonia.Views"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="Camelotia.Presentation.Avalonia.Views.MainView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d" FontFamily="Ubuntu"
MinHeight="590" MinWidth="850"
Height="590" Width="850">
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
x:Class="Camelotia.Presentation.Avalonia.Views.MainView"
MinHeight="590" MinWidth="850"
Height="590" Width="850"
FontFamily="Ubuntu">
<Design.DataContext>
<designTime:DesignTimeMainViewModel />
</Design.DataContext>
<Window.Styles>
<!-- The first StyleInclude here will be replaced at runtime,
see Services/AvaloniaStyleManager.cs for more info. Other

Просмотреть файл

@ -1,11 +1,11 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance interfaces:IOAuthViewModel, IsDesignTimeCreatable=True}"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="Camelotia.Presentation.Avalonia.Views.OAuthView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d" Background="{DynamicResource ThemeCardBrush}">
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
x:Class="Camelotia.Presentation.Avalonia.Views.OAuthView"
Background="{DynamicResource ThemeCardBrush}">
<Design.DataContext>
<designTime:DesignTimeOAuthViewModel />
</Design.DataContext>
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="300">

Просмотреть файл

@ -1,13 +1,12 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance interfaces:IProviderViewModel, IsDesignTimeCreatable=True}"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:models="clr-namespace:Camelotia.Services.Models;assembly=Camelotia.Services"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:Camelotia.Presentation.Avalonia.Views"
x:Class="Camelotia.Presentation.Avalonia.Views.ProviderView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d">
xmlns:views="clr-namespace:Camelotia.Presentation.Avalonia.Views"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
x:Class="Camelotia.Presentation.Avalonia.Views.ProviderView">
<Design.DataContext>
<designTime:DesignTimeProviderViewModel />
</Design.DataContext>
<Grid>
<Grid>
<Grid.RowDefinitions>

Просмотреть файл

@ -1,11 +1,12 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DataContext="{d:DesignInstance interfaces:IRenameFileViewModel, IsDesignTimeCreatable=False}"
xmlns:interfaces="clr-namespace:Camelotia.Presentation.Interfaces;assembly=Camelotia.Presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
x:Class="Camelotia.Presentation.Avalonia.Views.RenameFileView"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
mc:Ignorable="d" Background="{DynamicResource ThemeCardBrush}">
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
x:Class="Camelotia.Presentation.Avalonia.Views.RenameFileView"
Background="{DynamicResource ThemeCardBrush}"
Padding="20">
<Design.DataContext>
<designTime:DesignTimeRenameFileViewModel />
</Design.DataContext>
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="300">
@ -18,16 +19,15 @@
Margin="0 5" />
<StackPanel IsVisible="{Binding HasErrorMessage}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap" />
</StackPanel>
Margin="0 0 0 5">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap"
Margin="10" />
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 5">
<TextBlock Text="Renaming file with name:" Margin="0 0 5 0" />
<TextBlock Text="{Binding OldName}" />
<TextBlock Text="{Binding OldName}" Opacity="0.5" />
</StackPanel>
<TextBlock Text="Please, enter new file name:" Margin="0 5" />
<TextBox Text="{Binding NewName, Mode=TwoWay}" Watermark="File name..." />

Просмотреть файл

@ -12,7 +12,7 @@
<DefaultLanguage>en-us</DefaultLanguage>
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.18362.0</TargetPlatformVersion>
<TargetPlatformMinVersion>10.0.16299.0</TargetPlatformMinVersion>
<TargetPlatformMinVersion>10.0.18362.0</TargetPlatformMinVersion>
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>

Просмотреть файл

@ -5,8 +5,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:Camelotia.Presentation.Wpf.Views"
d:DesignHeight="450"
d:DesignWidth="800"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeAuthViewModel, IsDesignTimeCreatable=True}"
mc:Ignorable="d">
<TabControl x:Name="AuthTabs">
<TabItem>

Просмотреть файл

@ -5,51 +5,53 @@
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DesignHeight="450"
d:DesignWidth="800"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeCreateFolderViewModel, IsDesignTimeCreatable=True}"
mc:Ignorable="d">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="300">
<TextBlock Text="Create Folder"
Foreground="#002171"
FontSize="16"
Margin="0 10" />
<ProgressBar HorizontalAlignment="Stretch"
IsIndeterminate="{Binding IsLoading}"
Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibility}}"
Margin="0 5" />
<StackPanel Visibility="{Binding HasErrorMessage, Converter={StaticResource BooleanToVisibility}}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap" />
<materialDesign:Card Width="300" VerticalAlignment="Center">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Margin="20">
<TextBlock Text="Create Folder"
Foreground="#002171"
FontSize="16"
Margin="0 10" />
<ProgressBar HorizontalAlignment="Stretch"
IsIndeterminate="{Binding IsLoading}"
Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibility}}"
Margin="0 5" />
<StackPanel Visibility="{Binding HasErrorMessage, Converter={StaticResource BooleanToVisibility}}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 5">
<TextBlock Text="Creating new folder at:" Margin="0 0 5 0" />
<TextBlock Text="{Binding Path}" Foreground="#002171" />
</StackPanel>
<TextBlock Text="Please, enter new folder name:" Margin="0 5" />
<TextBox Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
materialDesign:HintAssist.Hint="Folder name" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
Content="Create folder"
HorizontalAlignment="Stretch"
Command="{Binding Create}"
Margin="0 10 10 10" />
<Button Grid.Column="1"
Content="Close"
HorizontalAlignment="Stretch"
Command="{Binding Close}"
Margin="0 10" />
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 5">
<TextBlock Text="Creating new folder at:" Margin="0 0 5 0" />
<TextBlock Text="{Binding Path}" Foreground="#002171" />
</StackPanel>
<TextBlock Text="Please, enter new folder name:" Margin="0 5" />
<TextBox Text="{Binding Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
materialDesign:HintAssist.Hint="Folder name" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
Content="Create folder"
HorizontalAlignment="Stretch"
Command="{Binding Create}"
Margin="0 10 10 10" />
<Button Grid.Column="1"
Content="Close"
HorizontalAlignment="Stretch"
Command="{Binding Close}"
Margin="0 10" />
</Grid>
</StackPanel>
</materialDesign:Card>
</UserControl>

Просмотреть файл

@ -5,7 +5,8 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
d:DesignHeight="300"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeDirectAuthViewModel, IsDesignTimeCreatable=True}"
d:DesignWidth="300"
mc:Ignorable="d">
<materialDesign:Card Width="300" VerticalAlignment="Center">
@ -25,10 +26,10 @@
TextWrapping="Wrap" />
</StackPanel>
</StackPanel>
<TextBox Text="{Binding Username, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
<TextBox Text="{Binding Username, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
materialDesign:HintAssist.Hint="User name"
Margin="0 15 0 10" />
<TextBox Text="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
<TextBox Text="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
materialDesign:HintAssist.Hint="Password"
Margin="0 5 0 15" />
<Button Content="Login"

Просмотреть файл

@ -5,8 +5,11 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
d:DesignHeight="450"
d:DesignWidth="800"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeFileViewModel, IsDesignTimeCreatable=True}"
d:Background="White"
d:DesignHeight="42"
d:DesignWidth="500"
mc:Ignorable="d">
<Grid Margin="6">
<Grid.ColumnDefinitions>
@ -39,6 +42,7 @@
<TextBlock Grid.Column="1"
Text="{Binding Name}"
TextWrapping="Wrap"
VerticalAlignment="Center"
FontSize="14" />
<TextBlock Grid.Column="2"
Text="Directory"

Просмотреть файл

@ -5,9 +5,9 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
d:DesignHeight="300"
d:DesignWidth="300"
mc:Ignorable="d" >
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeHostAuthViewModel, IsDesignTimeCreatable=True}"
mc:Ignorable="d">
<materialDesign:Card Width="300" VerticalAlignment="Center">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Stretch"
@ -32,15 +32,15 @@
</Grid.ColumnDefinitions>
<TextBox Grid.Column="0"
materialDesign:HintAssist.Hint="Host address"
Text="{Binding Address, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
Text="{Binding Address, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
<TextBox Grid.Column="1" Margin="5 0 0 0"
materialDesign:HintAssist.Hint="Port"
Text="{Binding Port, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
Text="{Binding Port, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}" />
</Grid>
<TextBox Text="{Binding Username, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
<TextBox Text="{Binding Username, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
materialDesign:HintAssist.Hint="User name"
Margin="0 10" />
<TextBox Text="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
<TextBox Text="{Binding Password, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
materialDesign:HintAssist.Hint="Password"
Margin="0 5 0 15" />
<Button Content="Login"

Просмотреть файл

@ -7,6 +7,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespace:Camelotia.Presentation.Wpf.Views"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeMainViewModel, IsDesignTimeCreatable=True}"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextElement.FontWeight="Regular"
TextElement.FontSize="13"

Просмотреть файл

@ -3,33 +3,36 @@
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"
d:DesignHeight="450"
d:DesignWidth="800"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeOAuthViewModel, IsDesignTimeCreatable=True}"
mc:Ignorable="d">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="300">
<TextBlock Text="OAuth"
Foreground="#002171"
FontSize="16"
Margin="0 10" />
<ProgressBar HorizontalAlignment="Stretch"
IsIndeterminate="{Binding IsBusy}"
Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibility}}"
Margin="0 5" />
<StackPanel Visibility="{Binding HasErrorMessage, Converter={StaticResource BooleanToVisibility}}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
TextWrapping="Wrap"
Foreground="#990000" />
<materialDesign:Card Width="300" VerticalAlignment="Center">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Margin="20">
<TextBlock Text="OAuth"
Foreground="#002171"
FontSize="16"
Margin="0 10" />
<ProgressBar HorizontalAlignment="Stretch"
IsIndeterminate="{Binding IsBusy}"
Visibility="{Binding IsBusy, Converter={StaticResource BooleanToVisibility}}"
Margin="0 5" />
<StackPanel Visibility="{Binding HasErrorMessage, Converter={StaticResource BooleanToVisibility}}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
TextWrapping="Wrap"
Foreground="#990000" />
</StackPanel>
</StackPanel>
<Button Content="Login"
HorizontalAlignment="Stretch"
Command="{Binding Login}"
Margin="0 10" />
</StackPanel>
<Button Content="Login"
HorizontalAlignment="Stretch"
Command="{Binding Login}"
Margin="0 10" />
</StackPanel>
</materialDesign:Card>
</UserControl>

Просмотреть файл

@ -6,8 +6,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:views="clr-namespace:Camelotia.Presentation.Wpf.Views"
d:DesignHeight="200"
d:DesignWidth="450"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeProviderViewModel, IsDesignTimeCreatable=True}"
d:Background="White"
d:DesignWidth="500"
mc:Ignorable="d">
<Grid>
<Grid.RowDefinitions>

Просмотреть файл

@ -5,51 +5,53 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
d:DesignHeight="450"
d:DesignWidth="800"
xmlns:designTime="clr-namespace:Camelotia.Presentation.DesignTime;assembly=Camelotia.Presentation"
d:DataContext="{d:DesignInstance Type=designTime:DesignTimeRenameFileViewModel, IsDesignTimeCreatable=True}"
mc:Ignorable="d">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Center"
Width="300">
<TextBlock Text="Rename File"
Foreground="#002171"
FontSize="16"
Margin="0 10" />
<ProgressBar HorizontalAlignment="Stretch"
IsIndeterminate="{Binding IsLoading}"
Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibility}}"
Margin="0 5" />
<StackPanel Visibility="{Binding HasErrorMessage, Converter={StaticResource BooleanToVisibility}}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap" />
<materialDesign:Card Width="300" VerticalAlignment="Center">
<StackPanel VerticalAlignment="Center"
HorizontalAlignment="Stretch"
Margin="20">
<TextBlock Text="Rename File"
Foreground="#002171"
FontSize="16"
Margin="0 10" />
<ProgressBar HorizontalAlignment="Stretch"
IsIndeterminate="{Binding IsLoading}"
Visibility="{Binding IsLoading, Converter={StaticResource BooleanToVisibility}}"
Margin="0 5" />
<StackPanel Visibility="{Binding HasErrorMessage, Converter={StaticResource BooleanToVisibility}}"
Background="#ffeeee"
Margin="0 5">
<StackPanel Margin="10">
<TextBlock Text="{Binding ErrorMessage}"
Foreground="#990000"
TextWrapping="Wrap" />
</StackPanel>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 5">
<TextBlock Text="Renaming file with name:" Margin="0 0 5 0" />
<TextBlock Text="{Binding OldName}" Foreground="#002171" />
</StackPanel>
<TextBlock Text="Please, enter new file name:" Margin="0 5" />
<TextBox Text="{Binding NewName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
materialDesign:HintAssist.Hint="Folder name" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
Content="Rename file"
HorizontalAlignment="Stretch"
Command="{Binding Rename}"
Margin="0 10 10 10" />
<Button Grid.Column="1"
Content="Close"
HorizontalAlignment="Stretch"
Command="{Binding Close}"
Margin="0 10" />
</Grid>
</StackPanel>
<StackPanel Orientation="Horizontal" Margin="0 5">
<TextBlock Text="Renaming file with name:" Margin="0 0 5 0" />
<TextBlock Text="{Binding OldName}" Foreground="#002171" />
</StackPanel>
<TextBlock Text="Please, enter new file name:" Margin="0 5" />
<TextBox Text="{Binding NewName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
materialDesign:HintAssist.Hint="Folder name" />
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
<Button Grid.Column="0"
Content="Rename file"
HorizontalAlignment="Stretch"
Command="{Binding Rename}"
Margin="0 10 10 10" />
<Button Grid.Column="1"
Content="Close"
HorizontalAlignment="Stretch"
Command="{Binding Close}"
Margin="0 10" />
</Grid>
</StackPanel>
</materialDesign:Card>
</UserControl>

Просмотреть файл

@ -0,0 +1,24 @@
using Camelotia.Presentation.Interfaces;
using ReactiveUI;
namespace Camelotia.Presentation.DesignTime
{
public class DesignTimeAuthViewModel : ReactiveObject, IAuthViewModel
{
public IDirectAuthViewModel DirectAuth { get; } = new DesignTimeDirectAuthViewModel();
public IHostAuthViewModel HostAuth { get; } = new DesignTimeHostAuthViewModel();
public IOAuthViewModel OAuth { get; } = new DesignTimeOAuthViewModel();
public bool SupportsDirectAuth { get; }
public bool SupportsHostAuth { get; }
public bool SupportsOAuth { get; }
public bool IsAuthenticated { get; } = true;
public bool IsAnonymous { get; }
}
}

Просмотреть файл

@ -0,0 +1,30 @@
using System.Windows.Input;
using Camelotia.Presentation.Interfaces;
using ReactiveUI.Validation.Extensions;
using ReactiveUI.Validation.Helpers;
namespace Camelotia.Presentation.DesignTime
{
public class DesignTimeCreateFolderViewModel : ReactiveValidationObject<DesignTimeCreateFolderViewModel>, ICreateFolderViewModel
{
public DesignTimeCreateFolderViewModel() => this.ValidationRule(x => x.Name, name => false, "Validation error.");
public bool IsLoading { get; }
public bool IsVisible { get; set; } = false;
public string Name { get; set; }
public string Path { get; } = "/home/path";
public bool HasErrorMessage { get; } = true;
public string ErrorMessage { get; } = "Error message example.";
public ICommand Create { get; }
public ICommand Close { get; }
public ICommand Open { get; }
}
}

Просмотреть файл

@ -0,0 +1,24 @@
using System.Windows.Input;
using Camelotia.Presentation.Interfaces;
using ReactiveUI.Validation.Extensions;
using ReactiveUI.Validation.Helpers;
namespace Camelotia.Presentation.DesignTime
{
public class DesignTimeDirectAuthViewModel : ReactiveValidationObject<DesignTimeDirectAuthViewModel>, IDirectAuthViewModel
{
public DesignTimeDirectAuthViewModel() => this.ValidationRule(x => x.Username, name => false, "Validation error.");
public string Username { get; set; } = "Joseph";
public string Password { get; set; }
public ICommand Login { get; }
public bool HasErrorMessage { get; } = true;
public string ErrorMessage { get; } = "Error message example.";
public bool IsBusy { get; }
}
}

Просмотреть файл

@ -0,0 +1,28 @@
using System;
using System.Globalization;
using Camelotia.Presentation.Interfaces;
using ReactiveUI;
namespace Camelotia.Presentation.DesignTime
{
public class DesignTimeFileViewModel : ReactiveObject, IFileViewModel
{
public DesignTimeFileViewModel() : this(null) { }
public DesignTimeFileViewModel(DesignTimeProviderViewModel provider) => Provider = provider;
public string Name { get; } = "Awesome file.";
public IProviderViewModel Provider { get; }
public string Modified { get; } = DateTime.Now.ToString(CultureInfo.InvariantCulture);
public bool IsFolder { get; } = false;
public bool IsFile { get; } = true;
public string Path { get; } = "/home/path/file";
public string Size { get; } = "42 KB";
}
}

Просмотреть файл

@ -0,0 +1,28 @@
using System.Windows.Input;
using Camelotia.Presentation.Interfaces;
using ReactiveUI.Validation.Extensions;
using ReactiveUI.Validation.Helpers;
namespace Camelotia.Presentation.DesignTime
{
public class DesignTimeHostAuthViewModel : ReactiveValidationObject<DesignTimeHostAuthViewModel>, IHostAuthViewModel
{
public DesignTimeHostAuthViewModel() => this.ValidationRule(x => x.Username, name => false, "Validation error.");
public string Username { get; set; } = "Jotaro";
public string Password { get; set; } = "Qwerty";
public ICommand Login { get; }
public bool HasErrorMessage { get; } = true;
public string ErrorMessage { get; } = "Error message example.";
public bool IsBusy { get; }
public string Address { get; set; } = "127.0.0.1";
public string Port { get; set; } = "5001";
}
}

Просмотреть файл

@ -0,0 +1,43 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Windows.Input;
using Camelotia.Presentation.Interfaces;
using Camelotia.Services.Models;
using ReactiveUI;
namespace Camelotia.Presentation.DesignTime
{
public class DesignTimeMainViewModel : ReactiveObject, IMainViewModel
{
public ReadOnlyObservableCollection<IProviderViewModel> Providers { get; } =
new ReadOnlyObservableCollection<IProviderViewModel>(
new ObservableCollection<IProviderViewModel>(
new List<IProviderViewModel>
{
new DesignTimeProviderViewModel(),
new DesignTimeProviderViewModel()
}));
public IProviderViewModel SelectedProvider { get; set; } = new DesignTimeProviderViewModel();
public IEnumerable<ProviderType> SupportedTypes { get; } = new[] {ProviderType.Ftp, ProviderType.Sftp};
public ProviderType SelectedSupportedType { get; set; } = ProviderType.Sftp;
public bool WelcomeScreenCollapsed { get; } = true;
public bool WelcomeScreenVisible { get; }
public ICommand Unselect { get; }
public ICommand Refresh { get; }
public ICommand Remove { get; }
public ICommand Add { get; }
public bool IsLoading { get; }
public bool IsReady { get; }
}
}

Просмотреть файл

@ -0,0 +1,17 @@
using System.Windows.Input;
using Camelotia.Presentation.Interfaces;
using ReactiveUI;
namespace Camelotia.Presentation.DesignTime
{
public class DesignTimeOAuthViewModel : ReactiveObject, IOAuthViewModel
{
public ICommand Login { get; }
public bool HasErrorMessage { get; } = true;
public string ErrorMessage { get; } = "Error message example.";
public bool IsBusy { get; }
}
}

Просмотреть файл

@ -0,0 +1,74 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Input;
using Camelotia.Presentation.Interfaces;
using ReactiveUI;
namespace Camelotia.Presentation.DesignTime
{
public class DesignTimeProviderViewModel : ReactiveObject, IProviderViewModel
{
public DesignTimeProviderViewModel()
{
Files = new[]
{
new DesignTimeFileViewModel(this),
new DesignTimeFileViewModel(this)
};
SelectedFile = Files.FirstOrDefault();
}
public Guid Id { get; } = Guid.NewGuid();
public IAuthViewModel Auth { get; } = new DesignTimeAuthViewModel();
public IRenameFileViewModel Rename { get; } = new DesignTimeRenameFileViewModel();
public ICreateFolderViewModel Folder { get; } = new DesignTimeCreateFolderViewModel();
public IFileViewModel SelectedFile { get; set; }
public IEnumerable<IFileViewModel> Files { get; }
public ICommand DownloadSelectedFile { get; }
public ICommand UploadToCurrentPath { get; }
public ICommand DeleteSelectedFile { get; }
public ICommand UnselectFile { get; }
public ICommand Refresh { get; }
public ICommand Logout { get; }
public ICommand Back { get; }
public ICommand Open { get; }
public bool IsCurrentPathEmpty { get; }
public bool IsLoading { get; }
public bool IsReady { get; } = true;
public bool HasErrorMessage { get; }
public bool CanLogout { get; }
public bool CanInteract { get; }
public int RefreshingIn { get; } = 30;
public string CurrentPath { get; } = "/home/files";
public string Description { get; } = "Mock file system.";
public DateTime Created { get; } = DateTime.Now;
public string Name { get; } = "Awesome mock";
public string Size { get; } = "42MB";
}
}

Просмотреть файл

@ -0,0 +1,30 @@
using System.Windows.Input;
using Camelotia.Presentation.Interfaces;
using ReactiveUI.Validation.Extensions;
using ReactiveUI.Validation.Helpers;
namespace Camelotia.Presentation.DesignTime
{
public class DesignTimeRenameFileViewModel : ReactiveValidationObject<DesignTimeRenameFileViewModel>, IRenameFileViewModel
{
public DesignTimeRenameFileViewModel() => this.ValidationRule(x => x.NewName, name => false, "Validation error.");
public bool IsLoading { get; }
public bool IsVisible { get; set; } = false;
public string OldName { get; } = "file";
public string NewName { get; set; }
public bool HasErrorMessage { get; } = true;
public string ErrorMessage { get; } = "Error message example.";
public ICommand Rename { get; }
public ICommand Close { get; }
public ICommand Open { get; }
}
}