merged from work
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@ -1,14 +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/">
|
||||
<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/"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019">
|
||||
<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" />
|
||||
<ui:ThemeResources />
|
||||
<ui:XamlControlsResources />
|
||||
<!-- Other merged dictionaries here -->
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
|
@ -1,5 +1,6 @@
|
||||
using Prism.Ioc;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ExampleCore
|
||||
{
|
||||
@ -8,6 +9,12 @@ namespace ExampleCore
|
||||
/// </summary>
|
||||
public partial class App
|
||||
{
|
||||
public App()
|
||||
{
|
||||
System.Windows.Forms.Application.SetHighDpiMode(HighDpiMode.SystemAware);
|
||||
System.Windows.Forms.Application.EnableVisualStyles();
|
||||
System.Windows.Forms.Application.SetCompatibleTextRenderingDefault(false);
|
||||
}
|
||||
protected override void RegisterTypes(IContainerRegistry containerRegistry)
|
||||
{
|
||||
//nothing
|
||||
|
@ -1,12 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<TargetFramework>net5.0-windows10.0.18362.0</TargetFramework>
|
||||
<UseWPF>true</UseWPF>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<ApplicationIcon>nsis3-install.ico</ApplicationIcon>
|
||||
<Version>1.1.5</Version>
|
||||
<Version>1.3.14</Version>
|
||||
<Nullable>enable</Nullable>
|
||||
<LangVersion>latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@ -14,17 +16,15 @@
|
||||
</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" />
|
||||
<PackageReference Include="Emoji.Wpf" Version="0.3.0" />
|
||||
<PackageReference Include="ModernWpfUI" Version="0.9.3" />
|
||||
<PackageReference Include="Prism.Core" Version="8.0.0.1909" />
|
||||
<PackageReference Include="Prism.DryIoc" Version="8.0.0.1909" />
|
||||
<PackageReference Include="Prism.Wpf" Version="8.0.0.1909" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Katteker\Katteker.csproj" />
|
||||
<ProjectReference Include="..\src\Katteker\Katteker.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
1
ExampleCore/Katteker.config
Normal file
1
ExampleCore/Katteker.config
Normal file
@ -0,0 +1 @@
|
||||
{"Publish":"\\\\srv-lsimctrl01\\e$\\Squirrel\\TT","Changelog":null,"Channel":" Dev"}
|
@ -1,105 +1,62 @@
|
||||
<Window x:Class="ExampleCore.MainWindow"
|
||||
<Window
|
||||
x:Class="ExampleCore.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:emoji="clr-namespace:Emoji.Wpf;assembly=Emoji.Wpf"
|
||||
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"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
xmlns:ui="http://schemas.modernwpf.com/2019"
|
||||
Title="{x:Static local:MainWindowViewModel.WindowTitle}"
|
||||
Width="800"
|
||||
Height="450"
|
||||
Height="500"
|
||||
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"
|
||||
ui:WindowHelper.UseModernWindowStyle="True"
|
||||
TextOptions.TextFormattingMode="Display"
|
||||
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>
|
||||
<Window.Resources>
|
||||
<system:Boolean x:Key="True">True</system:Boolean>
|
||||
<system:Boolean x:Key="False">False</system:Boolean>
|
||||
</Window.Resources>
|
||||
|
||||
<b:Interaction.Triggers>
|
||||
<b:EventTrigger EventName="ContentRendered">
|
||||
<b:InvokeCommandAction Command="{Binding UpdateCommand}" CommandParameter="{StaticResource True}" />
|
||||
</b:EventTrigger>
|
||||
</b:Interaction.Triggers>
|
||||
<ScrollViewer>
|
||||
<StackPanel>
|
||||
<StackPanel.Resources>
|
||||
<Style BasedOn="{StaticResource {x:Type Button}}" TargetType="Button">
|
||||
<Setter Property="Height" Value="45" />
|
||||
<Setter Property="Margin" Value="10" />
|
||||
<Setter Property="FontSize" Value="24" />
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<Button
|
||||
Command="{Binding UpdateCommand}"
|
||||
CommandParameter="{StaticResource False}"
|
||||
Content="Update" />
|
||||
<Button Command="{Binding OpenFolderDialogCommand}" Content="Open Folder Dialog" />
|
||||
<Button Command="{Binding OpenFileDialogCommand}" Content="Open File Dialog" />
|
||||
<emoji:TextBlock
|
||||
Margin="20"
|
||||
HorizontalAlignment="Center"
|
||||
FontSize="60"
|
||||
Text="😂" />
|
||||
<GroupBox Margin="10" Header="Command line parameters">
|
||||
<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>
|
||||
Background="WhiteSmoke"
|
||||
FontFamily="Consolas"
|
||||
Text="{Binding CommandLineParameters}"
|
||||
TextWrapping="Wrap" />
|
||||
</GroupBox>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</Window>
|
@ -1,102 +1,86 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
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
|
||||
public class MainWindowViewModel : BindableBase
|
||||
{
|
||||
private bool _showRestartAppDialog;
|
||||
private readonly UpdateManager _updateManager;
|
||||
public static string WindowTitle { get; } = "Example Core " + Assembly.GetExecutingAssembly().GetName().Version?.ToString(3);
|
||||
|
||||
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);
|
||||
UpdateCommand = new DelegateCommand<bool?>(async x => await UpdateAsync(x.GetValueOrDefault()).ConfigureAwait(false));
|
||||
OpenFolderDialogCommand = new DelegateCommand(OpenFolder);
|
||||
OpenFileDialogCommand = new DelegateCommand(OpenFile);
|
||||
}
|
||||
|
||||
private void OpenFileCommand()
|
||||
private static void OpenFile()
|
||||
{
|
||||
var openFile = new FolderBrowserDialog();
|
||||
using var openFile = new OpenFileDialog();
|
||||
if (openFile.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
MessageBox.Show(openFile.SelectedPath, "Example Core");
|
||||
MessageBox.Show(openFile.FileName, WindowTitle);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void RestartApp(object obj)
|
||||
private static void OpenFolder()
|
||||
{
|
||||
if (obj is bool restart && restart)
|
||||
using var folderBrowser = new FolderBrowserDialog();
|
||||
if (folderBrowser.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
_updateManager.RestartApp();
|
||||
MessageBox.Show(folderBrowser.SelectedPath, WindowTitle);
|
||||
}
|
||||
|
||||
ShowRestartAppDialog = false;
|
||||
}
|
||||
|
||||
private async Task UpdateAsync(string startup)
|
||||
private async Task UpdateAsync(bool startup)
|
||||
{
|
||||
if (_updateManager == null) return;
|
||||
var silent = bool.Parse(startup);
|
||||
try
|
||||
{
|
||||
var releases = (await _updateManager.CheckForUpdateAsync().ConfigureAwait(false)).ToList();
|
||||
if (releases.Any())
|
||||
var updates = await _updateManager.CheckForUpdatesAsync().ConfigureAwait(false);
|
||||
if (updates.Any())
|
||||
{
|
||||
MessageQueue.Enqueue("Update available", "Update now", ActionHandler);
|
||||
var dialogResult = MessageBox.Show("Update available, update now?", WindowTitle,
|
||||
MessageBoxButtons.YesNo,
|
||||
MessageBoxIcon.Information);
|
||||
if (dialogResult == DialogResult.Yes && await _updateManager.UpdateAppAsync().ConfigureAwait(false))
|
||||
{
|
||||
dialogResult = MessageBox.Show("The update is ready to install. Do you want to install it now?",
|
||||
WindowTitle,
|
||||
MessageBoxButtons.YesNo, MessageBoxIcon.Question);
|
||||
if (dialogResult == DialogResult.Yes) System.Windows.Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
else if (!silent)
|
||||
else if (!startup)
|
||||
{
|
||||
MessageQueue.Enqueue("No Update available.", true);
|
||||
MessageBox.Show("No Update available.", WindowTitle, MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
if (silent)
|
||||
if (startup)
|
||||
{
|
||||
MessageQueue.Enqueue(e.Message);
|
||||
MessageBox.Show(e.Message, WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async void ActionHandler()
|
||||
{
|
||||
if (await _updateManager.UpdateAppAsync().ConfigureAwait(false))
|
||||
{
|
||||
ShowRestartAppDialog = true;
|
||||
}
|
||||
}
|
||||
|
||||
public ICommand UpdateCommand { get; }
|
||||
|
||||
public SnackbarMessageQueue MessageQueue { get; } = new SnackbarMessageQueue();
|
||||
public ICommand OpenFolderDialogCommand { get; }
|
||||
|
||||
public bool ShowRestartAppDialog
|
||||
{
|
||||
get => _showRestartAppDialog;
|
||||
set => SetProperty(ref _showRestartAppDialog, value);
|
||||
}
|
||||
public ICommand OpenFileDialogCommand { get; }
|
||||
|
||||
public ICommand RestartAppDialogCommand { get; }
|
||||
|
||||
public ICommand OpenFileDialogCommand
|
||||
{
|
||||
get;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
MessageQueue?.Dispose();
|
||||
}
|
||||
public string CommandLineParameters => Environment.CommandLine;
|
||||
}
|
||||
}
|
@ -7,10 +7,13 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
||||
<PublishProtocol>FileSystem</PublishProtocol>
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Any CPU</Platform>
|
||||
<TargetFramework>netcoreapp3.0</TargetFramework>
|
||||
<PublishDir>bin\Release\netcoreapp3.0\publish\</PublishDir>
|
||||
<TargetFramework>net5.0-windows10.0.18362.0</TargetFramework>
|
||||
<PublishDir>..\publish\</PublishDir>
|
||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||
<SelfContained>true</SelfContained>
|
||||
<_IsPortable>false</_IsPortable>
|
||||
<PublishSingleFile>True</PublishSingleFile>
|
||||
<PublishReadyToRun>True</PublishReadyToRun>
|
||||
<PublishTrimmed>False</PublishTrimmed>
|
||||
</PropertyGroup>
|
||||
</Project>
|
8
ExampleCore/Properties/launchSettings.json
Normal file
8
ExampleCore/Properties/launchSettings.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"profiles": {
|
||||
"ExampleCore": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "Dangerous Mouse"
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user