| @@ -5,7 +5,7 @@ | |||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | |||
| xmlns:local="clr-namespace:Installer" | |||
| mc:Ignorable="d" | |||
| Title="Installer" Height="200" Window.SizeToContent="Width"> | |||
| Title="Installer" Window.SizeToContent="WidthAndHeight"> | |||
| <Grid> | |||
| <Grid.ColumnDefinitions> | |||
| <ColumnDefinition Width="40" /> | |||
| @@ -37,16 +37,18 @@ | |||
| <Button Grid.Row="3" Grid.Column="6" Name="GetRouteBtn" Content="Browse..." Command="{Binding ClickBrowseCommand}" Visibility="{Binding RouteBoxVis}" /> | |||
| <Button Grid.Row="3" Grid.Column="7" Name="SetBtm" Content="Confirm" Command="{Binding ClickConfirmCommand}" Visibility="{Binding RouteBoxVis}"/> | |||
| <Button Grid.Row="3" Grid.Column="2" Grid.ColumnSpan="2" Name="UpdateBtn" Content="{Binding UpdateBtnCont}" Command="{Binding ClickUpdateCommand}" Visibility="{Binding MenuVis}" /> | |||
| <TextBlock Grid.Row="4" Grid.Column="2" Text="{Binding UpdateInfo}" Visibility="{Binding MenuVis}" /> | |||
| <Button Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="2" Name="MoveBtn" Content="Move" Command="{Binding ClickMoveCommand}" Visibility="{Binding MenuVis}" /> | |||
| <Button Grid.Row="7" Grid.Column="2" Grid.ColumnSpan="2" Name="UninstBtn" Content="UnInstall" Command="{Binding ClickUninstCommand}" Visibility="{Binding MenuVis}" /> | |||
| <Button Grid.Row="6" Grid.Column="2" Grid.ColumnSpan="2" Name="UninstBtn" Content="UnInstall" Command="{Binding ClickUninstCommand}" Visibility="{Binding MenuVis}" /> | |||
| <Button Grid.Row="7" Grid.Column="2" Grid.ColumnSpan="2" Name="MenuBackBtn" Content="回到登陆界面" Command="{Binding ClickBackCommand}" Visibility="{Binding MenuVis}" /> | |||
| <TextBlock Grid.Row="3" Grid.Column="4" Text="Processing" Grid.ColumnSpan="2" Visibility="{Binding ProgressVis}"/> | |||
| <ProgressBar Grid.Row="5" Grid.Column="2" Grid.ColumnSpan="6" Minimum="0" Maximum="100" Name="Progress" Visibility="{Binding ProgressVis}" IsIndeterminate="True"/> | |||
| <TextBlock Grid.Row="4" Grid.Column="2" Grid.ColumnSpan="4" Text="操作完成!你可以继续操作或退出" Visibility="{Binding CompleteVis}"/> | |||
| <Button Grid.Row="6" Grid.Column="2" Name="BackBtn" Content="返回" Command="{Binding ClickBackCommand}" Visibility="{Binding CompleteVis}"/> | |||
| <TextBlock Grid.Row="4" Grid.Column="1" Grid.ColumnSpan="4" Text="操作完成!你可以继续操作或退出" Visibility="{Binding CompleteVis}"/> | |||
| <Button Grid.Row="6" Grid.Column="1" Name="BackBtn" Content="返回" Command="{Binding ClickBackCommand}" Visibility="{Binding CompleteVis}" Click="BackBtn_Click"/> | |||
| <Button Grid.Row="6" Grid.Column="4" Grid.ColumnSpan="2" Name="ExitBtn" Content="退出" Command="{Binding ClickExitCommand}" Visibility="{Binding CompleteVis}"/> | |||
| <TextBlock Grid.Row="3" Grid.Column="1" Text="账号:" Visibility="{Binding LoginVis}" /> | |||
| @@ -64,7 +66,7 @@ | |||
| <Button Grid.Row="7" Grid.Column="1" Name="Replay" Content="打开回放" Command="{Binding ClickReplayCommand}" Visibility="{Binding WebVis}" /> | |||
| <Button Grid.Row="3" Grid.Column="3" Grid.ColumnSpan="2" Content="申请对战" Command="{Binding ClickRequestCommand}" Visibility="{Binding WebVis}" /> | |||
| <TextBox Grid.Row="4" Grid.Column="3" Grid.ColumnSpan="2" Text="{Binding Enemy}" Visibility="{Binding WebVis}" /> | |||
| <Button Grid.Row="6" Grid.Column="3" Grid.ColumnSpan="2" Content="退出登录" Command="{Binding ClickLogoutCommand}" Visibility="{Binding WebVis}" /> | |||
| <Button Grid.Row="6" Grid.Column="3" Grid.ColumnSpan="2" Content="退出登录" Command="{Binding ClickBackCommand}" Visibility="{Binding WebVis}" /> | |||
| </Grid> | |||
| </Window> | |||
| @@ -39,5 +39,10 @@ namespace Installer | |||
| this.DataContext = new SettingsViewModel(); | |||
| } | |||
| private void BackBtn_Click(object sender, RoutedEventArgs e) | |||
| { | |||
| } | |||
| } | |||
| } | |||
| @@ -41,6 +41,14 @@ namespace starter.viewmodel.settings | |||
| private HttpClient client = new HttpClient(); | |||
| private WebConnect.Web web = new WebConnect.Web(); | |||
| public SettingsModel() | |||
| { | |||
| Route = Data.FilePath; | |||
| Username = ""; | |||
| Password = ""; | |||
| updates = ""; | |||
| } | |||
| /// <summary> | |||
| /// save settings | |||
| /// </summary> | |||
| @@ -52,6 +60,7 @@ namespace starter.viewmodel.settings | |||
| // ask if abort install, with warning sign, defalut no; | |||
| if (repeatOption == MessageBoxResult.No) | |||
| { | |||
| Route = Data.FilePath; | |||
| return false; // 回到选择地址界面 | |||
| } | |||
| else | |||
| @@ -69,7 +78,11 @@ namespace starter.viewmodel.settings | |||
| } | |||
| public int move() | |||
| { | |||
| return Tencent_cos_download.MoveProgram(Route); | |||
| int state = Tencent_cos_download.MoveProgram(Route); | |||
| if (state != 0) | |||
| Route = Data.FilePath; | |||
| return state; | |||
| } | |||
| ///<summary> | |||
| ///check for update | |||
| @@ -100,7 +113,7 @@ namespace starter.viewmodel.settings | |||
| { | |||
| if (updateInfo.changedFileCount != 0 || updateInfo.newFileCount != 0) | |||
| { | |||
| Updates = "发现新版本" + updateInfo.status; | |||
| Updates = "发现新版本"; | |||
| } | |||
| return Status.menu; | |||
| } | |||
| @@ -137,14 +150,7 @@ namespace starter.viewmodel.settings | |||
| /// </summary> | |||
| public string Route | |||
| { | |||
| get | |||
| { | |||
| return Data.FilePath; | |||
| } | |||
| set | |||
| { | |||
| Data.FilePath = value; | |||
| } | |||
| get; set; | |||
| } | |||
| public string Username | |||
| @@ -310,6 +316,14 @@ namespace Downloader | |||
| { | |||
| dict.Add("installpath", newPath); | |||
| } | |||
| if (dict == null || !dict.ContainsKey("download")) | |||
| { | |||
| dict?.Add("download", "true"); | |||
| } | |||
| else | |||
| { | |||
| dict["download"] = "true"; | |||
| } | |||
| } | |||
| using FileStream fs2 = new FileStream(path, FileMode.Open, FileAccess.ReadWrite); | |||
| using StreamWriter sw = new StreamWriter(fs2); | |||
| @@ -87,7 +87,10 @@ namespace starter.viewmodel.settings | |||
| this.RaisePropertyChanged("MenuVis"); | |||
| this.RaisePropertyChanged("RouteBoxVis"); | |||
| this.RaisePropertyChanged("ProgressVis"); | |||
| //TODO: Thread will be taken by process working and window will not refresh. | |||
| this.RaisePropertyChanged("CompleteVis"); | |||
| this.RaisePropertyChanged("WindowWidth"); | |||
| this.RaisePropertyChanged("WebVis"); | |||
| } | |||
| } | |||
| public string Intro | |||
| @@ -277,15 +280,17 @@ namespace starter.viewmodel.settings | |||
| if (Status == SettingsModel.Status.newUser) | |||
| { | |||
| Status = SettingsModel.Status.working; | |||
| this.RaisePropertyChanged("ProgressVis"); | |||
| if (obj.install()) | |||
| { | |||
| Status = SettingsModel.Status.menu; | |||
| Status = SettingsModel.Status.successful; | |||
| } | |||
| } | |||
| else if (Status == SettingsModel.Status.move) | |||
| { | |||
| Status = SettingsModel.Status.working; | |||
| this.RaisePropertyChanged("ProgressVis"); | |||
| switch (obj.move()) | |||
| { | |||
| case -1: | |||
| @@ -295,6 +300,7 @@ namespace starter.viewmodel.settings | |||
| Status = SettingsModel.Status.error; | |||
| break; | |||
| } | |||
| Status = SettingsModel.Status.successful; | |||
| } | |||
| })); | |||
| } | |||
| @@ -313,11 +319,13 @@ namespace starter.viewmodel.settings | |||
| if (obj.UpdatePlanned) | |||
| { | |||
| Status = SettingsModel.Status.working; | |||
| this.RaisePropertyChanged("ProgressVis"); | |||
| if (obj.Update()) | |||
| { | |||
| Status = SettingsModel.Status.successful; | |||
| this.RaisePropertyChanged("UpdateButtonCont"); | |||
| this.RaisePropertyChanged("UpdateBtnCont"); | |||
| this.RaisePropertyChanged("UpdateInfo"); | |||
| } | |||
| else | |||
| @@ -326,8 +334,10 @@ namespace starter.viewmodel.settings | |||
| else | |||
| { | |||
| Status = SettingsModel.Status.working; | |||
| this.RaisePropertyChanged("ProgressVis"); | |||
| Status = obj.checkUpdate(); | |||
| this.RaisePropertyChanged("UpdateButtonCont"); | |||
| this.RaisePropertyChanged("UpdateBtnCont"); | |||
| this.RaisePropertyChanged("UpdateInfo"); | |||
| } | |||
| })); | |||
| } | |||
| @@ -359,6 +369,7 @@ namespace starter.viewmodel.settings | |||
| clickUninstCommand = new BaseCommand(new Action<object>(o => | |||
| { | |||
| Status = SettingsModel.Status.working; | |||
| this.RaisePropertyChanged("ProgressVis"); | |||
| switch (obj.Uninst()) | |||
| { | |||
| case -1: | |||
| @@ -405,7 +416,21 @@ namespace starter.viewmodel.settings | |||
| { | |||
| clickLaunchCommand = new BaseCommand(new Action<object>(o => | |||
| { | |||
| if (!obj.Launch()) | |||
| if (obj.UpdatePlanned) | |||
| { | |||
| Status = SettingsModel.Status.working; | |||
| this.RaisePropertyChanged("ProgressVis"); | |||
| if (obj.Update()) | |||
| { | |||
| this.RaisePropertyChanged("UpdateBtnCont"); | |||
| this.RaisePropertyChanged("LaunchBtnCont"); | |||
| Status = SettingsModel.Status.login; | |||
| this.RaisePropertyChanged("UpdateInfo"); | |||
| } | |||
| else | |||
| Status = SettingsModel.Status.error; | |||
| } | |||
| else if (!obj.Launch()) | |||
| { | |||
| Status = SettingsModel.Status.menu; | |||
| } | |||
| @@ -429,19 +454,19 @@ namespace starter.viewmodel.settings | |||
| return clickEditCommand; | |||
| } | |||
| } | |||
| private BaseCommand clickLogoutCommand; | |||
| public BaseCommand ClickLogoutCommand | |||
| private BaseCommand clickBackCommand; | |||
| public BaseCommand ClickBackCommand | |||
| { | |||
| get | |||
| { | |||
| if (clickLogoutCommand == null) | |||
| if (clickBackCommand == null) | |||
| { | |||
| clickLogoutCommand = new BaseCommand(new Action<object>(o => | |||
| clickBackCommand = new BaseCommand(new Action<object>(o => | |||
| { | |||
| Status = SettingsModel.Status.login; | |||
| })); | |||
| } | |||
| return clickLogoutCommand; | |||
| return clickBackCommand; | |||
| } | |||
| } | |||
| } | |||