Playing with Snackbar
This commit is contained in:
parent
ad14691479
commit
d39ffa2cb2
@ -132,6 +132,10 @@
|
|||||||
<Project>{07e2de31-80a0-43da-b307-1ca47cd930a1}</Project>
|
<Project>{07e2de31-80a0-43da-b307-1ca47cd930a1}</Project>
|
||||||
<Name>Katteker.UserInterface</Name>
|
<Name>Katteker.UserInterface</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\Katteker\Katteker.csproj">
|
||||||
|
<Project>{a45e1c59-ba9e-452c-a5e2-50de49d53e92}</Project>
|
||||||
|
<Name>Katteker</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Resource Include="nsis3-install.ico" />
|
<Resource Include="nsis3-install.ico" />
|
||||||
|
@ -31,8 +31,7 @@
|
|||||||
Margin="10,0"
|
Margin="10,0"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
DockPanel.Dock="Bottom"
|
DockPanel.Dock="Bottom"
|
||||||
IsActive="True"
|
MessageQueue="{Binding MessageQueue}" />
|
||||||
Message="Hello World" />
|
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<Button
|
<Button
|
||||||
Height="45"
|
Height="45"
|
||||||
|
@ -1,23 +1,47 @@
|
|||||||
using System.Threading.Tasks;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
using MaterialDesignThemes.Wpf;
|
||||||
using Prism.Commands;
|
using Prism.Commands;
|
||||||
using Prism.Mvvm;
|
using Prism.Mvvm;
|
||||||
|
|
||||||
namespace Example
|
namespace Example
|
||||||
{
|
{
|
||||||
[JetBrains.Annotations.UsedImplicitly]
|
[JetBrains.Annotations.UsedImplicitly]
|
||||||
public class MainWindowViewModel : BindableBase
|
public class MainWindowViewModel : BindableBase, IDisposable
|
||||||
{
|
{
|
||||||
public MainWindowViewModel()
|
public MainWindowViewModel()
|
||||||
{
|
{
|
||||||
UpdateCommand = new DelegateCommand<string>(async x => await UpdateAsync(x).ConfigureAwait(false));
|
UpdateCommand = new DelegateCommand<string>(async x => await UpdateAsync(x).ConfigureAwait(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task UpdateAsync(string startup) =>
|
private async Task UpdateAsync(string startup)
|
||||||
bool.TryParse(startup, out var isStartup)
|
{
|
||||||
? Katteker.UserInterface.CheckForUpdateAsync(isStartup)
|
var silent = !bool.Parse(startup);
|
||||||
: Task.FromResult(true);
|
try
|
||||||
|
{
|
||||||
|
var manager = Katteker.UpdateManager.Create();
|
||||||
|
var releases = await manager.CheckForUpdateAsync();
|
||||||
|
MessageQueue.Enqueue(releases.Any() ? "Update available" : "No Update available.", true);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
if (silent)
|
||||||
|
{
|
||||||
|
MessageQueue.Enqueue(e.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ICommand UpdateCommand { get; }
|
public ICommand UpdateCommand { get; }
|
||||||
|
|
||||||
|
public SnackbarMessageQueue MessageQueue { get; } = new SnackbarMessageQueue();
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
MessageQueue?.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user