自动更新
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using GeekDesk.Control.Windows;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using GlobalHotKey;
|
||||
using HandyControl.Data;
|
||||
using Microsoft.Win32;
|
||||
using System;
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace GeekDesk.Control.UserControls.PannelCard
|
||||
{
|
||||
string path = (string)obj;
|
||||
|
||||
string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Jpeg);
|
||||
//string base64 = ImageUtil.FileImageToBase64(path, ImageFormat.Jpeg);
|
||||
|
||||
IconInfo iconInfo = new IconInfo
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
|
||||
using GalaSoft.MvvmLight.Command;
|
||||
using GeekDesk.Control.UserControls;
|
||||
using GeekDesk.Control.UserControls.Config;
|
||||
using GeekDesk.ViewModel;
|
||||
|
||||
@@ -4,13 +4,41 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:GeekDesk.Control.Windows"
|
||||
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||
mc:Ignorable="d"
|
||||
Title="UpdateWindow" Height="450" Width="800"
|
||||
Title="UpdateWindow" Height="300" Width="450"
|
||||
WindowStyle="None"
|
||||
AllowsTransparency="True"
|
||||
Background="Transparent" ShowInTaskbar="False">
|
||||
<Border Background="White">
|
||||
|
||||
<Border Background="AliceBlue" MouseDown="DragMove">
|
||||
<StackPanel HorizontalAlignment="Center">
|
||||
<hc:Card BorderThickness="0" Effect="{DynamicResource EffectShadow2}" Margin="20,20,20,0">
|
||||
<!--Card 的内容部分-->
|
||||
<Border CornerRadius="4,4,0,0" Height="160">
|
||||
<StackPanel>
|
||||
<TextBlock Margin="10" x:Name="MsgTitle" TextWrapping="Wrap" FontSize="16" HorizontalAlignment="Left" Style="{DynamicResource TextBlockLargeBold}" Text="测试"/>
|
||||
<TextBlock Margin="15" x:Name="Msg" TextWrapping="Wrap" VerticalAlignment="Center" Text=""/>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
<!--Card 的尾部部分-->
|
||||
<hc:Card.Footer>
|
||||
<StackPanel Margin="10" Width="420">
|
||||
<!--Card 的一级内容-->
|
||||
<TextBlock TextWrapping="NoWrap" x:Name="Title" Style="{DynamicResource TextBlockLargeBold}" TextTrimming="CharacterEllipsis"
|
||||
Text=""
|
||||
HorizontalAlignment="Left"/>
|
||||
<!--Card 的二级内容-->
|
||||
<TextBlock TextWrapping="NoWrap" x:Name="SubTitle" Style="{DynamicResource TextBlockDefault}" TextTrimming="CharacterEllipsis"
|
||||
Margin="0,6,0,0"
|
||||
HorizontalAlignment="Left"/>
|
||||
</StackPanel>
|
||||
</hc:Card.Footer>
|
||||
</hc:Card>
|
||||
<hc:UniformSpacingPanel Spacing="100" HorizontalAlignment="Center" Margin="0,10,0,0">
|
||||
<Button Content="暂不更新" Click="Close_Click" />
|
||||
<Button Content="前往更新" Click="Confirm_Click" Background="#5BC0DE" Foreground="White" RenderTransformOrigin="0.696,0.45"/>
|
||||
</hc:UniformSpacingPanel>
|
||||
</StackPanel>
|
||||
|
||||
</Border>
|
||||
</Window>
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
using System;
|
||||
using GeekDesk.Constant;
|
||||
using GeekDesk.Util;
|
||||
using GeekDesk.ViewModel;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
@@ -19,9 +25,83 @@ namespace GeekDesk.Control.Windows
|
||||
/// </summary>
|
||||
public partial class UpdateWindow : Window
|
||||
{
|
||||
public UpdateWindow()
|
||||
private static AppConfig appConfig = MainWindow.appData.AppConfig;
|
||||
private static string githubUrl = "";
|
||||
private static string giteeUrl = "";
|
||||
private UpdateWindow(JObject jo)
|
||||
{
|
||||
InitializeComponent();
|
||||
try
|
||||
{
|
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen;
|
||||
InitializeComponent();
|
||||
DataHandle(jo);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 移动窗口
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void DragMove(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.LeftButton == MouseButtonState.Pressed)
|
||||
{
|
||||
DragMove();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void DataHandle(JObject jo)
|
||||
{
|
||||
Title.Text = StringUtil.IsEmpty(jo["title"]) ? "" : jo["title"].ToString();
|
||||
SubTitle.Text = StringUtil.IsEmpty(jo["subTitle"]) ? "" : jo["subTitle"].ToString();
|
||||
MsgTitle.Text = StringUtil.IsEmpty(jo["msgTitle"]) ? "" : jo["msgTitle"].ToString();
|
||||
JArray ja = JArray.Parse(StringUtil.IsEmpty(jo["msg"]) ? "[]" : jo["msg"].ToString());
|
||||
githubUrl = StringUtil.IsEmpty(jo["githubUrl"]) ? ConfigurationManager.AppSettings["GitHubUrl"] : jo["githubUrl"].ToString();
|
||||
giteeUrl = StringUtil.IsEmpty(jo["giteeUrl"]) ? ConfigurationManager.AppSettings["GiteeUrl"] : jo["giteeUrl"].ToString();
|
||||
string msg = "";
|
||||
for (int i=0; i<ja.Count; i++)
|
||||
{
|
||||
msg += "•" + ja[i].ToString() + "\n";
|
||||
}
|
||||
Msg.Text = msg;
|
||||
}
|
||||
|
||||
private void Close_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private void Confirm_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
string packageUrl;
|
||||
switch (appConfig.UpdateType)
|
||||
{
|
||||
case UpdateType.GitHub:
|
||||
packageUrl = githubUrl;
|
||||
break;
|
||||
default:
|
||||
packageUrl = giteeUrl;
|
||||
break;
|
||||
}
|
||||
Process.Start(packageUrl);
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private static System.Windows.Window window = null;
|
||||
public static void Show(JObject jo)
|
||||
{
|
||||
if (window == null || !window.Activate())
|
||||
{
|
||||
window = new UpdateWindow(jo);
|
||||
}
|
||||
window.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user