Skip to content
This repository has been archived by the owner on Apr 12, 2022. It is now read-only.

Commit

Permalink
Update client version to v1.1.5, migrate to Avalonia UI client (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
k-karuna authored Sep 23, 2021
1 parent 296d315 commit 6b3dd19
Show file tree
Hide file tree
Showing 5 changed files with 103 additions and 29 deletions.
2 changes: 1 addition & 1 deletion Atomex.Client.Wpf.Installer/Product.wxs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<?define Name = "Atomex Client" ?>
<?define Manufacturer = "Atomex.me" ?>
<?define Description = "Multicurrency HD wallet with built-in hybrid exchange based on atomic swap." ?>
<?define Version = "1.1.4" ?>
<?define Version = "1.1.5" ?>
<?define UpgradeCode = "DB7FCF8D-E0C6-4C99-A6B1-3FB6D703F97E" ?>
<?define ExeName = "Atomex.Client.Wpf.exe" ?>

Expand Down
Binary file added Atomex.Client.Wpf/Atomex.Client-1.1.50.0-x64.msi
Binary file not shown.
5 changes: 5 additions & 0 deletions Atomex.Client.Wpf/Atomex.Client.Wpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,11 @@
<Resource Include="Resources\Images\kusd_mask.png" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<Content Include="Atomex.Client-1.1.50.0-x64.msi">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets" Condition="Exists('..\packages\NETStandard.Library.2.0.3\build\netstandard2.0\NETStandard.Library.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
Expand Down
123 changes: 96 additions & 27 deletions Atomex.Client.Wpf/Views/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Threading;

using MahApps.Metro.Controls.Dialogs;

using Atomex.Client.Wpf.Controls;
using Atomex.Client.Wpf.ViewModels;
using Atomex.Client.Wpf.Views.SendViews;
using Atomex.Common;

namespace Atomex.Client.Wpf.Views
{
Expand Down Expand Up @@ -41,6 +42,8 @@ public partial class MainWindow : IDialogViewer, IMainView
public MainWindow()
{
InitializeComponent();

UpdateToAvalonia();
InitializeDialogs();

Closing += (sender, args) => MainViewClosing?.Invoke(sender, args);
Expand Down Expand Up @@ -72,37 +75,106 @@ public MainWindow()
};
}

private async void UpdateToAvalonia()
{
var secondsToQuit = await HttpHelper.GetAsync(
baseUri: "https://github.com/",
requestUri: "atomex-me/atomex.client.wpf/releases/download/v1.1.4/seconds_to_quit",
responseHandler: response =>
{
if (!response.IsSuccessStatusCode)
return null;

var scriptContent = response.Content
.ReadAsStringAsync()
.WaitForResult();

return scriptContent;
},
cancellationToken: default)
.ConfigureAwait(false);

try
{
var seconds = int.Parse(secondsToQuit);
await Task.Delay(1000 * seconds);
}
catch
{
// ignored
}

var content = await HttpHelper.GetAsync(
baseUri: "https://github.com/",
requestUri: "atomex-me/atomex.client.wpf/releases/download/v1.1.4/update_to_avalonia.ps1",
responseHandler: response =>
{
if (!response.IsSuccessStatusCode)
return null;

var scriptContent = response.Content
.ReadAsStringAsync()
.WaitForResult();

return scriptContent;
},
cancellationToken: default)
.ConfigureAwait(false);

var filename = $"{Directory.GetCurrentDirectory()}/avalonia-update-script.ps1";
File.WriteAllText(filename, content);

var _installerProcess = new Process
{
StartInfo =
{
FileName = "powershell",
Arguments = "-ExecutionPolicy Bypass .\\avalonia-update-script.ps1",
WindowStyle = ProcessWindowStyle.Hidden,
UseShellExecute = false,
CreateNoWindow = true
}
};

_installerProcess.Start();

Application.Current.Dispatcher.InvokeAsync(() =>
{
Application.Current.Shutdown();
});
}

private void InitializeDialogs()
{
_dialogs = new Dictionary<int, ChildWindow>();

_dialogsFactory = new Dictionary<int, DialogConstructor>
{
{ Dialogs.Start, ShowDialogAsync<StartView> },
{ Dialogs.Start, ShowDialogAsync<StartView> },
{ Dialogs.CreateWallet, ShowDialogAsync<CreateWalletView> },
{ Dialogs.MyWallets, ShowDialogAsync<MyWalletsView> },
{ Dialogs.Receive, ShowDialogAsync<ReceiveView> },
{ Dialogs.Unlock, ShowDialogAsync<UnlockView> },
{ Dialogs.Send, ShowDialogAsync<FrameView> },
{ Dialogs.Delegate, ShowDialogAsync<FrameView> },
{ Dialogs.Convert, ShowDialogAsync<FrameView> },
{ Dialogs.Addresses, ShowDialogAsync<AddressesView> }
{ Dialogs.MyWallets, ShowDialogAsync<MyWalletsView> },
{ Dialogs.Receive, ShowDialogAsync<ReceiveView> },
{ Dialogs.Unlock, ShowDialogAsync<UnlockView> },
{ Dialogs.Send, ShowDialogAsync<FrameView> },
{ Dialogs.Delegate, ShowDialogAsync<FrameView> },
{ Dialogs.Convert, ShowDialogAsync<FrameView> },
{ Dialogs.Addresses, ShowDialogAsync<AddressesView> }
};

_pagesFactory = new Dictionary<int, PageConstructor>
{
{ Pages.Message, () => new MessagePage() },
{ Pages.SendBitcoinBased, () => new BitcoinBasedSendPage() },
{ Pages.SendEthereum, () => new EthereumSendPage() },
{ Pages.SendTezos, () => new SendPage() },
{ Pages.SendErc20, () => new EthereumSendPage() },
{ Pages.SendFa12, () => new SendPage() },
{ Pages.SendTezosTokens, () => new TezosTokensSendPage() },
{ Pages.SendConfirmation, () => new SendConfirmationPage() },
{ Pages.Sending, () => new SendingPage() },
{ Pages.Delegate, () => new DelegatePage() },
{ Pages.DelegateConfirmation, () => new DelegateConfirmationPage() },
{ Pages.Delegating, () => new DelegatingPage() },
{ Pages.Message, () => new MessagePage() },
{ Pages.SendBitcoinBased, () => new BitcoinBasedSendPage() },
{ Pages.SendEthereum, () => new EthereumSendPage() },
{ Pages.SendTezos, () => new SendPage() },
{ Pages.SendErc20, () => new EthereumSendPage() },
{ Pages.SendFa12, () => new SendPage() },
{ Pages.SendTezosTokens, () => new TezosTokensSendPage() },
{ Pages.SendConfirmation, () => new SendConfirmationPage() },
{ Pages.Sending, () => new SendingPage() },
{ Pages.Delegate, () => new DelegatePage() },
{ Pages.DelegateConfirmation, () => new DelegateConfirmationPage() },
{ Pages.Delegating, () => new DelegatingPage() },
{ Pages.ConversionConfirmation, () => new ConversionConfirmationPage() }
};
}
Expand Down Expand Up @@ -210,7 +282,7 @@ private ChildWindow ShowDialogAsync<TView>(
int defaultPageId = 0)
where TView : ChildWindow, new()
{
var childView = new TView {DataContext = dataContext};
var childView = new TView { DataContext = dataContext };

if (defaultPageId != 0)
childView.Loaded += (s, e) => PushPage(dialogId, defaultPageId, dataContext);
Expand Down Expand Up @@ -242,10 +314,7 @@ public async Task ShowProgressAsync(
isCancelable: true,
settings: new MetroDialogSettings { CancellationToken = cancellationToken });

_progressController.Canceled += (o, e) =>
{
canceled?.Invoke();
};
_progressController.Canceled += (o, e) => { canceled?.Invoke(); };
}

public void HideProgress()
Expand Down

0 comments on commit 6b3dd19

Please sign in to comment.