merged from work

This commit is contained in:
2019-12-20 20:02:14 +01:00
parent 202608651b
commit 11e3a02511
505 changed files with 65307 additions and 823 deletions

1065
ExampleCore/Annotations.cs Normal file

File diff suppressed because it is too large Load Diff

15
ExampleCore/App.xaml Normal file
View File

@ -0,0 +1,15 @@
<dryioc:PrismApplication x:Class="ExampleCore.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dryioc="http://prismlibrary.com/">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</dryioc:PrismApplication>

18
ExampleCore/App.xaml.cs Normal file
View File

@ -0,0 +1,18 @@
using Prism.Ioc;
using System.Windows;
namespace ExampleCore
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App
{
protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
//nothing
}
protected override Window CreateShell() => Container.Resolve<MainWindow>();
}
}

View File

@ -0,0 +1,52 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<ApplicationIcon>nsis3-install.ico</ApplicationIcon>
<Version>1.1.5</Version>
</PropertyGroup>
<ItemGroup>
<None Remove="nsis3-install.ico" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommonServiceLocator" Version="2.0.5" />
<PackageReference Include="DryIoc.dll" Version="4.0.7" />
<PackageReference Include="MaterialDesignColors" Version="1.2.1" />
<PackageReference Include="MaterialDesignThemes" Version="3.0.0" />
<PackageReference Include="Prism.Core" Version="7.2.0.1233-pre" />
<PackageReference Include="Prism.DryIoc" Version="7.2.0.1233-pre" />
<PackageReference Include="Prism.Wpf" Version="7.2.0.1233-pre" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Katteker\Katteker.csproj" />
</ItemGroup>
<ItemGroup>
<Resource Include="nsis3-install.ico" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<None Update="changelog.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>

105
ExampleCore/MainWindow.xaml Normal file
View File

@ -0,0 +1,105 @@
<Window x:Class="ExampleCore.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:local="clr-namespace:ExampleCore"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
xmlns:prism="http://prismlibrary.com/"
Title="MainWindow"
Width="800"
Height="450"
d:DataContext="{d:DesignInstance local:MainWindowViewModel}"
prism:ViewModelLocator.AutoWireViewModel="True"
Background="{DynamicResource MaterialDesignPaper}"
FontFamily="{DynamicResource MaterialDesignFont}"
TextElement.FontSize="13"
TextElement.FontWeight="Regular"
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
TextOptions.TextFormattingMode="Ideal"
TextOptions.TextRenderingMode="Auto"
mc:Ignorable="d">
<i:Interaction.Triggers>
<i:EventTrigger EventName="ContentRendered">
<i:InvokeCommandAction Command="{Binding UpdateCommand}" CommandParameter="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<md:DialogHost IsOpen="{Binding ShowRestartAppDialog}">
<md:DialogHost.DialogContent>
<Grid Margin="10">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<TextBlock
Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="2"
Text="The update was installed successful. Do you want to restart?" />
<Button
Grid.Row="1"
Grid.Column="0"
Command="{Binding RestartAppDialogCommand}"
IsCancel="False"
Style="{StaticResource MaterialDesignFlatButton}">
<Button.CommandParameter>
<system:Boolean xmlns:system="clr-namespace:System;assembly=mscorlib">
True
</system:Boolean>
</Button.CommandParameter>
YES
</Button>
<Button
Grid.Row="1"
Grid.Column="1"
Command="{Binding RestartAppDialogCommand}"
IsCancel="True"
Style="{StaticResource MaterialDesignFlatButton}">
<Button.CommandParameter>
<system:Boolean xmlns:system="clr-namespace:System;assembly=mscorlib">
False
</system:Boolean>
</Button.CommandParameter>
NO
</Button>
</Grid>
</md:DialogHost.DialogContent>
<DockPanel>
<md:Snackbar
Margin="10,0"
HorizontalAlignment="Stretch"
DockPanel.Dock="Bottom"
MessageQueue="{Binding MessageQueue}" />
<StackPanel>
<Button
Height="45"
Margin="10"
Command="{Binding UpdateCommand}"
CommandParameter="False"
Content="Update"
FontSize="24" />
<Button Content="Open File Dialog" Command="{Binding OpenFileDialogCommand}" />
<TextBlock
Margin="20"
HorizontalAlignment="Center"
FontSize="60"
RenderTransformOrigin="0.5,0.5"
Text=":-)">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="90" />
<TranslateTransform />
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
</StackPanel>
</DockPanel>
</md:DialogHost>
</Window>

View File

@ -0,0 +1,13 @@
namespace ExampleCore
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow
{
public MainWindow()
{
InitializeComponent();
}
}
}

View File

@ -0,0 +1,102 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;
using Katteker;
using MaterialDesignThemes.Wpf;
using Prism.Commands;
using Prism.Mvvm;
namespace ExampleCore
{
[JetBrains.Annotations.UsedImplicitly]
public class MainWindowViewModel : BindableBase, IDisposable
{
private bool _showRestartAppDialog;
private readonly UpdateManager _updateManager;
public MainWindowViewModel()
{
UpdateManager.TryCreate(out _updateManager);
UpdateCommand = new DelegateCommand<string>(async x => await UpdateAsync(x).ConfigureAwait(false));
RestartAppDialogCommand = new DelegateCommand<object>(RestartApp);
OpenFileDialogCommand = new DelegateCommand(OpenFileCommand);
}
private void OpenFileCommand()
{
var openFile = new FolderBrowserDialog();
if (openFile.ShowDialog() == DialogResult.OK)
{
MessageBox.Show(openFile.SelectedPath, "Example Core");
}
}
private void RestartApp(object obj)
{
if (obj is bool restart && restart)
{
_updateManager.RestartApp();
}
ShowRestartAppDialog = false;
}
private async Task UpdateAsync(string startup)
{
if (_updateManager == null) return;
var silent = bool.Parse(startup);
try
{
var releases = (await _updateManager.CheckForUpdateAsync().ConfigureAwait(false)).ToList();
if (releases.Any())
{
MessageQueue.Enqueue("Update available", "Update now", ActionHandler);
}
else if (!silent)
{
MessageQueue.Enqueue("No Update available.", true);
}
}
catch (Exception e)
{
if (silent)
{
MessageQueue.Enqueue(e.Message);
}
}
}
private async void ActionHandler()
{
if (await _updateManager.UpdateAppAsync().ConfigureAwait(false))
{
ShowRestartAppDialog = true;
}
}
public ICommand UpdateCommand { get; }
public SnackbarMessageQueue MessageQueue { get; } = new SnackbarMessageQueue();
public bool ShowRestartAppDialog
{
get => _showRestartAppDialog;
set => SetProperty(ref _showRestartAppDialog, value);
}
public ICommand RestartAppDialogCommand { get; }
public ICommand OpenFileDialogCommand
{
get;
}
public void Dispose()
{
MessageQueue?.Dispose();
}
}
}

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishProtocol>FileSystem</PublishProtocol>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<TargetFramework>netcoreapp3.0</TargetFramework>
<PublishDir>bin\Release\netcoreapp3.0\publish\</PublishDir>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>true</SelfContained>
<_IsPortable>false</_IsPortable>
</PropertyGroup>
</Project>

5
ExampleCore/changelog.md Normal file
View File

@ -0,0 +1,5 @@
# Changelog
## 1.0.0
- Hello World

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB