More Prism stuff

This commit is contained in:
Holger Boerchers 2018-07-31 20:58:55 +02:00
parent 9c23948f38
commit 947db44090
9 changed files with 55 additions and 34 deletions

View File

@ -98,7 +98,8 @@ namespace KattekerCreator.Helper
if (textWriter == null) textWriter = Console.Out;
LoopProperties(pi =>
{
var displayName = GetDisplayName(pi) ?? pi.Name;
var displayName = GetDisplayName(pi);
if (displayName == null) return;
var value = pi.GetValue(_parsedObject);
textWriter.Write(displayName.PadRight(20, ' '));
if (value == null)

View File

@ -3,7 +3,7 @@ using System.Linq;
namespace KattekerCreator
{
public class PathFragments
public struct PathFragments
{
private readonly string[] _fragments;
@ -19,7 +19,5 @@ namespace KattekerCreator
public override int GetHashCode() => (_fragments != null ? _fragments.GetHashCode() : 0);
public override string ToString() => string.Join(Path.DirectorySeparatorChar.ToString(), _fragments.Take(_fragments.Length - 1));
protected bool Equals(PathFragments other) => Equals(_fragments, other._fragments);
}
}

View File

@ -10,7 +10,7 @@ namespace Example
protected override void InitializeShell()
{
(Shell as Window)?.Show();
Application.Current.MainWindow?.Show();
}
}
}

View File

@ -57,16 +57,11 @@
<HintPath>..\packages\Prism.Wpf.6.3.0\lib\net45\Prism.Wpf.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\Prism.Wpf.6.3.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
@ -94,6 +89,7 @@
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="MainWindowViewModel.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
@ -128,10 +124,6 @@
<Project>{07e2de31-80a0-43da-b307-1ca47cd930a1}</Project>
<Name>Katteker.UserInterface</Name>
</ProjectReference>
<ProjectReference Include="..\Katteker\Katteker.csproj">
<Project>{a45e1c59-ba9e-452c-a5e2-50de49d53e92}</Project>
<Name>Katteker</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="nsis3-install.ico" />

View File

@ -3,22 +3,41 @@
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:Example"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/"
Title="MainWindow"
Width="800"
Height="450"
d:DataContext="{d:DesignInstance local:MainWindowViewModel}"
prism:ViewModelLocator.AutoWireViewModel="True"
Background="#E20074"
ContentRendered="MainWindow_OnContentRendered"
mc:Ignorable="d">
<i:Interaction.Triggers>
<i:EventTrigger EventName="ContentRendered">
<i:InvokeCommandAction Command="{Binding UpdateCommand}" CommandParameter="True" />
</i:EventTrigger>
</i:Interaction.Triggers>
<StackPanel>
<Button Margin="10" FontSize="24" Content="Update" Click="ButtonBase_OnClick"></Button>
<TextBlock Margin="20" Text=":-)" FontSize="60" HorizontalAlignment="Center" RenderTransformOrigin="0.5,0.5" >
<Button
Margin="10"
Command="{Binding UpdateCommand}"
CommandParameter="False"
Content="Update"
FontSize="24" />
<TextBlock
Margin="20"
HorizontalAlignment="Center"
FontSize="60"
RenderTransformOrigin="0.5,0.5"
Text=":-)">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="90"/>
<TranslateTransform/>
<ScaleTransform />
<SkewTransform />
<RotateTransform Angle="90" />
<TranslateTransform />
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>

View File

@ -18,15 +18,5 @@ namespace Example
a.ManifestModule.GetPEKind(out var peKind, out var machine);
Title = $"{version} | {peKind} | {machine}";
}
private async void MainWindow_OnContentRendered(object sender, EventArgs e)
{
await Katteker.UserInterface.CheckForUpdateAsync(true).ConfigureAwait(false);
}
private async void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
await Katteker.UserInterface.CheckForUpdateAsync().ConfigureAwait(false);
}
}
}

View File

@ -0,0 +1,22 @@
using System.Threading.Tasks;
using System.Windows.Input;
using Prism.Commands;
using Prism.Mvvm;
namespace Example
{
public class MainWindowViewModel : BindableBase
{
public MainWindowViewModel()
{
UpdateCommand = new DelegateCommand<string>(async x => await UpdateAsync(x).ConfigureAwait(false));
}
private Task UpdateAsync(string startup) =>
bool.TryParse(startup, out var isStartup)
? Katteker.UserInterface.CheckForUpdateAsync(isStartup)
: Task.FromResult(true);
public ICommand UpdateCommand { get; }
}
}

View File

@ -49,5 +49,5 @@ using System.Windows;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.2")]
[assembly: AssemblyFileVersion("1.1.2")]
[assembly: AssemblyVersion("1.1.5")]
[assembly: AssemblyFileVersion("1.1.5")]

View File

@ -34,7 +34,6 @@
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Runtime.Serialization" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>