forked from WELL-E/AutoUpdater
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
546 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,19 @@ | ||
using Microsoft.Maui; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific; | ||
using Application = Microsoft.Maui.Controls.Application; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Data; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using System.Windows; | ||
|
||
namespace AutoUpdate.MauiApp_Sample | ||
namespace AutoUpdate.MauiApp_Sample; | ||
|
||
public partial class App : Application | ||
{ | ||
public partial class App : Application | ||
{ | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
} | ||
public App() | ||
{ | ||
InitializeComponent(); | ||
|
||
protected override Window CreateWindow(IActivationState activationState) | ||
{ | ||
string args = @"eyJDbGllbnRUeXBlIjoxLCJBcHBOYW1lIjoiQXV0b1VwZGF0ZS5NYXVpQXBwLVNhbXBsZSIsIk1haW5BcHBOYW1lIjpudWxsLCJJbnN0YWxsUGF0aCI6IkQ6XFx1cGRhdGVfdGVzdCIsIkNsaWVudFZlcnNpb24iOiIxLjEuMSIsIkxhc3RWZXJzaW9uIjoiMS4xLjUiLCJVcGRhdGVMb2dVcmwiOiJodHRwczovL3d3dy5iYWlkdS5jb20vIiwiSXNVcGRhdGUiOmZhbHNlLCJVcGRhdGVVcmwiOiJodHRwOi8vMTI3LjAuMC4xOjUwMDEvdmVyc2lvbnMvMS8xLjEuMSIsIlZhbGlkYXRlVXJsIjpudWxsLCJNYWluVXBkYXRlVXJsIjpudWxsLCJNYWluVmFsaWRhdGVVcmwiOm51bGwsIlVwZGF0ZVZlcnNpb25zIjpbeyJQdWJUaW1lIjoxNjI2NzExNzYwLCJOYW1lIjpudWxsLCJNRDUiOiJmNjk4ZjkwMzJjMGQ1NDAxYmFjZDNiMGY1MzA5OTYxOCIsIlZlcnNpb24iOiIxLjEuMyIsIlVybCI6bnVsbCwiSXNVblppcCI6ZmFsc2V9LHsiUHViVGltZSI6MTYyNjcxMTgyMCwiTmFtZSI6bnVsbCwiTUQ1IjoiNmExMDQ2YTY2Y2VkZjUwOWJmYjJhNzcxYjJhN2E2NGUiLCJWZXJzaW9uIjoiMS4xLjQiLCJVcmwiOm51bGwsIklzVW5aaXAiOmZhbHNlfSx7IlB1YlRpbWUiOjE2MjY3MTE4ODAsIk5hbWUiOm51bGwsIk1ENSI6Ijc2ODljNDcyY2U3M2E0YjhmMWI3Yzc5MTczMTMzN2UxIiwiVmVyc2lvbiI6IjEuMS41IiwiVXJsIjpudWxsLCJJc1VuWmlwIjpmYWxzZX1dfQ=="; | ||
MainPage = new MainPage(); | ||
|
||
#if WINDOWS | ||
//var args = activationState.LaunchActivatedEventArgs.Arguments; | ||
MainPage = new MainPage(args); | ||
#endif | ||
return base.CreateWindow(activationState); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,99 @@ | ||
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="AutoUpdate.MauiApp_Sample.MainPage" | ||
Title="Update-APP" | ||
BackgroundColor="{DynamicResource SecondaryColor}"> | ||
|
||
<ScrollView> | ||
<Grid RowSpacing="25" RowDefinitions="Auto,Auto,Auto,Auto,Auto,Auto,Auto" | ||
Padding="{OnPlatform Android='30,60,30,30', Default='30'}"> | ||
|
||
<ProgressBar></ProgressBar> | ||
|
||
<Button | ||
Text="Test launch update." | ||
FontAttributes="Bold" | ||
Grid.Row="0" | ||
SemanticProperties.Hint="Click" | ||
HorizontalOptions="Center" Command="{Binding LaunchCommand}" /> | ||
<Grid RowSpacing="25" RowDefinitions="Auto,Auto,Auto,Auto,*" | ||
Padding="{OnPlatform iOS='30,60,30,30', Default='30'}"> | ||
<!--<Grid.RowDefinitions> | ||
<RowDefinition></RowDefinition> | ||
<RowDefinition></RowDefinition> | ||
</Grid.RowDefinitions>--> | ||
<!--<ProgressBar Height="30" Width="350" VerticalAlignment="Bottom" Minimum="{Binding ProgressMin}" Maximum="{Binding ProgressMax}" Value="{Binding ProgressVal}"></ProgressBar>--> | ||
<Grid Grid.Row="1" Margin="00,15,0,0"> | ||
<Grid.RowDefinitions> | ||
<RowDefinition></RowDefinition> | ||
<RowDefinition></RowDefinition> | ||
<RowDefinition></RowDefinition> | ||
<RowDefinition></RowDefinition> | ||
<RowDefinition></RowDefinition> | ||
<RowDefinition></RowDefinition> | ||
</Grid.RowDefinitions> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="50"></ColumnDefinition> | ||
<ColumnDefinition Width="*"></ColumnDefinition> | ||
</Grid.ColumnDefinitions> | ||
<Label Grid.Column="1" Text="Download statistics:" FontSize="14" Margin="5"> | ||
</Label> | ||
<Label x:Name="Tips1" /> | ||
|
||
<Label Grid.Row="1" Text="Download progress:" Grid.Column="1" Margin="5" FontSize="14" > | ||
</Label> | ||
<Label x:Name="Tips2" /> | ||
|
||
<Label | ||
Grid.Row="1" | ||
SemanticProperties.HeadingLevel="Level1" | ||
FontSize="32" | ||
Text="{Binding Tips1}" | ||
<Label Grid.Row="2" Grid.ColumnSpan="2" FontSize="14" Margin="5"> | ||
</Label> | ||
<Label x:Name="Tips3" /> | ||
|
||
<Label Grid.Row="3" x:Name="Tips4" Grid.Column="1" Margin="5"/> | ||
<Label Grid.Row="4" x:Name="Tips5" Grid.Column="1" Margin="5"/> | ||
<Label Grid.Row="5" x:Name="Tips6" Grid.Column="1" Margin="5"/> | ||
</Grid> | ||
|
||
|
||
<!--<Image Grid.Row="4" | ||
Source="bot.png" | ||
WidthRequest="250" | ||
HeightRequest="310" | ||
HorizontalOptions="Center" /> | ||
<Image Grid.Row="4" | ||
Source="GU.png" | ||
WidthRequest="250" | ||
HeightRequest="310" | ||
HorizontalOptions="Center" />--> | ||
|
||
|
||
<Label | ||
Grid.Row="2" | ||
Text="Hello, World!" | ||
Grid.Row="0" | ||
SemanticProperties.HeadingLevel="Level1" | ||
FontSize="32" | ||
Text="{Binding Tips2}" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Grid.Row="3" | ||
Text="Welcome to AutoUpdate MauiApp-Sample" | ||
Grid.Row="1" | ||
SemanticProperties.HeadingLevel="Level1" | ||
FontSize="32" | ||
Text="{Binding Tips3}" | ||
SemanticProperties.Description="Welcome to dot net Multi platform App U I" | ||
FontSize="18" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Grid.Row="4" | ||
Text="{Binding Tips4}" | ||
SemanticProperties.HeadingLevel="Level1" | ||
FontSize="32" | ||
Text="Check for Update Current Count: 0" | ||
Grid.Row="2" | ||
FontSize="18" | ||
FontAttributes="Bold" | ||
x:Name="CounterLabel" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Grid.Row="5" | ||
Text="{Binding Tips5}" | ||
SemanticProperties.HeadingLevel="Level1" | ||
FontSize="32" | ||
<Button | ||
Text="Click for Update!" | ||
FontAttributes="Bold" | ||
Grid.Row="3" | ||
SemanticProperties.Hint="" | ||
Clicked="OnCounterClicked" | ||
HorizontalOptions="Center" /> | ||
|
||
<Label | ||
Grid.Row="6" | ||
Text="{Binding Tips6}" | ||
SemanticProperties.HeadingLevel="Level1" | ||
FontSize="32" | ||
<Image Grid.Row="4" | ||
Source="dotnet_bot.png" | ||
SemanticProperties.Description="Cute dot net bot waving hi to you!" | ||
WidthRequest="250" | ||
HeightRequest="310" | ||
HorizontalOptions="Center" /> | ||
|
||
</Grid> | ||
</ScrollView> | ||
</ContentPage> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,111 @@ | ||
using AutoUpdate.MauiApp_Sample.ViewModels; | ||
using Microsoft.Maui.Controls; | ||
using Microsoft.Maui.Essentials; | ||
using GeneralUpdate.Common.Models; | ||
using GeneralUpdate.Core; | ||
using GeneralUpdate.Core.Strategys; | ||
using GeneralUpdate.Core.Update; | ||
using MvvmHelpers; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Text; | ||
using System.Windows; | ||
|
||
namespace AutoUpdate.MauiApp_Sample | ||
namespace AutoUpdate.MauiApp_Sample; | ||
|
||
public partial class MainPage : ContentPage | ||
{ | ||
public partial class MainPage : ContentPage | ||
int count = 0; | ||
|
||
public MainPage() | ||
{ | ||
InitializeComponent(); | ||
} | ||
|
||
private void OnCounterClicked(object sender, EventArgs e) | ||
{ | ||
count++; | ||
CounterLabel.Text = $"Check for Update Current Count: {count}"; | ||
|
||
SemanticScreenReader.Announce(CounterLabel.Text); | ||
|
||
var args = "eyJDbGllbnRUeXBlIjoxLCJBcHBOYW1lIjoiQXV0b1VwZGF0ZS5UZXN0IiwiTWFpbkFwcE5hbWUiOm51bGwsIkluc3RhbGxQYXRoIjoiRDpcXHVwZGF0ZV90ZXN0IiwiQ2xpZW50VmVyc2lvbiI6IjEuMS4xIiwiTGFzdFZlcnNpb24iOiIxLjEuNSIsIlVwZGF0ZUxvZ1VybCI6Imh0dHBzOi8vd3d3LmJhaWR1LmNvbS8iLCJJc1VwZGF0ZSI6ZmFsc2UsIlVwZGF0ZVVybCI6Imh0dHA6Ly8xMjcuMC4wLjE6NTAwMS92ZXJzaW9ucy8xLzEuMS4xIiwiVmFsaWRhdGVVcmwiOm51bGwsIk1haW5VcGRhdGVVcmwiOm51bGwsIk1haW5WYWxpZGF0ZVVybCI6bnVsbCwiVXBkYXRlVmVyc2lvbnMiOlt7IlB1YlRpbWUiOjE2MjY3MTE3NjAsIk5hbWUiOm51bGwsIk1ENSI6ImY2OThmOTAzMmMwZDU0MDFiYWNkM2IwZjUzMDk5NjE4IiwiVmVyc2lvbiI6IjEuMS4zIiwiVXJsIjpudWxsLCJJc1VuWmlwIjpmYWxzZX0seyJQdWJUaW1lIjoxNjI2NzExODIwLCJOYW1lIjpudWxsLCJNRDUiOiI2YTEwNDZhNjZjZWRmNTA5YmZiMmE3NzFiMmE3YTY0ZSIsIlZlcnNpb24iOiIxLjEuNCIsIlVybCI6bnVsbCwiSXNVblppcCI6ZmFsc2V9LHsiUHViVGltZSI6MTYyNjcxMTg4MCwiTmFtZSI6bnVsbCwiTUQ1IjoiNzY4OWM0NzJjZTczYTRiOGYxYjdjNzkxNzMxMzM3ZTEiLCJWZXJzaW9uIjoiMS4xLjUiLCJVcmwiOm51bGwsIklzVW5aaXAiOmZhbHNlfV19"; | ||
var bootStrap = new GeneralUpdateBootstrap(); | ||
bootStrap.MutiAllDownloadCompleted += OnMutiAllDownloadCompleted; | ||
bootStrap.MutiDownloadCompleted += OnMutiDownloadCompleted; | ||
bootStrap.MutiDownloadError += OnMutiDownloadError; | ||
bootStrap.MutiDownloadProgressChanged += OnMutiDownloadProgressChanged; | ||
bootStrap.MutiDownloadStatistics += OnMutiDownloadStatistics; | ||
bootStrap.Exception += OnException; | ||
bootStrap.Strategy<DefaultStrategy>(). | ||
Option(UpdateOption.DownloadTimeOut, 60). | ||
Option(UpdateOption.Format, "zip"). | ||
RemoteAddressBase64(args); | ||
bootStrap.LaunchAsync(); | ||
} | ||
|
||
|
||
private void OnMutiDownloadStatistics(object sender, GeneralUpdate.Core.Update.MutiDownloadStatisticsEventArgs e) | ||
{ | ||
Tips1.Text = $" { e.Speed } , { e.Remaining }"; | ||
} | ||
|
||
private void OnMutiDownloadProgressChanged(object sender, GeneralUpdate.Core.Update.MutiDownloadProgressChangedEventArgs e) | ||
{ | ||
switch (e.Type) | ||
{ | ||
case ProgressType.Check: | ||
if (!string.IsNullOrEmpty(e.Message)) | ||
{ | ||
Tips5.Text = e.Message; | ||
} | ||
break; | ||
case ProgressType.Donwload: | ||
//ProgressVal = e.BytesReceived; | ||
//if (ProgressMax != e.TotalBytesToReceive) | ||
//{ | ||
// ProgressMax = e.TotalBytesToReceive; | ||
//} | ||
Tips2.Text = $" { Math.Round(e.ProgressValue * 100, 2) }% , Receivedbyte:{ e.BytesReceived }M ,Totalbyte:{ e.TotalBytesToReceive }M"; | ||
break; | ||
case ProgressType.Updatefile: | ||
break; | ||
case ProgressType.Done: | ||
break; | ||
case ProgressType.Fail: | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
private void OnMutiDownloadCompleted(object sender, GeneralUpdate.Core.Update.MutiDownloadCompletedEventArgs e) | ||
{ | ||
public MainPage() { InitializeComponent(); } | ||
//Tips3 = $"{ e.Version.Name } download completed."; | ||
} | ||
|
||
public MainPage(string prameter) | ||
private void OnMutiAllDownloadCompleted(object sender, GeneralUpdate.Core.Update.MutiAllDownloadCompletedEventArgs e) | ||
{ | ||
if (e.IsAllDownloadCompleted) | ||
{ | ||
Tips4.Text = "AllDownloadCompleted"; | ||
} | ||
else | ||
{ | ||
InitializeComponent(); | ||
BindingContext = new MainViewModel(prameter); | ||
//wpf - DataContext | ||
//foreach (var version in e.FailedVersions) | ||
//{ | ||
// Debug.Write($"{ version.Item1.Name }"); | ||
//} | ||
} | ||
} | ||
|
||
private void OnMutiDownloadError(object sender, GeneralUpdate.Core.Update.MutiDownloadErrorEventArgs e) | ||
{ | ||
|
||
//Tips5 = $"{ e.Version.Name },{ e.Exception.Message }."; | ||
} | ||
|
||
private void OnException(object sender, GeneralUpdate.Core.Update.ExceptionEventArgs e) | ||
{ | ||
Tips6.Text = $"{ e.Exception.Message }"; | ||
} | ||
} | ||
|
Oops, something went wrong.