private async Task OnUpdaterEvent(UpdatingState ea) { switch (ea.UpdateSate) { case UpdateSate.InitializingUpdater: await this.UIThreadAsync(() => { CheckUpdatesButton.IsEnabled = false; }); break; case UpdateSate.DownloadingUpdate: await this.UIThreadAsync(() => { _TataruModel.TataruViewModel.UserStartedUpdateTextVisibility = false; _TataruModel.TataruViewModel.DownloadingUpdateVisibility = true; }); break; case UpdateSate.ReadyToRestart: await this.UIThreadAsync(() => { _TataruModel.TataruViewModel.UserStartedUpdateTextVisibility = false; _TataruModel.TataruViewModel.RestartReadyVisibility = true; _TataruModel.TataruViewModel.DownloadingUpdateVisibility = false; TaskBarIcon.ShowBalloonTip((string)this.Resources["NotifyUpdateTitle"], (string)this.Resources["NotifyUpdateText"], Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info); }); break; case UpdateSate.UpdatingFinished: await this.UIThreadAsync(() => { _TataruModel.TataruViewModel.UserStartedUpdateTextVisibility = false; if (!_TataruModel.TataruViewModel.RestartReadyVisibility && !_TataruModel.TataruViewModel.DownloadingUpdateVisibility && _TataruModel.TataruViewModel.UpdateCheckByUser ) { UserStartedUpdateText.Text = (string)this.Resources["NoUpdatesFound"]; _TataruModel.TataruViewModel.UserStartedUpdateTextVisibility = true; } _TataruModel.TataruViewModel.UpdateCheckByUser = false; OnUserStartedUpdateEnd(); }); break; } }
public GameplayManager(IMeshManager manager) { meshManager = manager; state = new UpdatingState(this); isStability = true; InverseGravity = false; haveEmptyCells = true; text = GameObject.Find("Score").GetComponent <Text>(); score = 0; newScore = Resources.Load <Object>("Prefabs/points"); }
sealed public override void SetValue(object value) { if (_updatingState != UpdatingState.None) return; MvxBindingTrace.Trace(MvxTraceLevel.Diagnostic,"Receiving setValue to " + (value ?? "").ToString()); try { _updatingState = UpdatingState.UpdatingTarget; var safeValue = MakeValueSafeForTarget(value); _targetPropertyInfo.SetValue(_target, safeValue, null); } finally { _updatingState = UpdatingState.None; } }
sealed protected override void FireValueChanged(object newValue) { if (_updatingState != UpdatingState.None) { return; } MvxBindingTrace.Trace(MvxTraceLevel.Diagnostic, "Firing changed to " + (newValue ?? "").ToString()); try { _updatingState = UpdatingState.UpdatingSource; base.FireValueChanged(newValue); } finally { _updatingState = UpdatingState.None; } }
sealed public override void SetValue(object value) { if (_updatingState != UpdatingState.None) { return; } MvxBindingTrace.Trace(MvxTraceLevel.Diagnostic, "Receiving setValue to " + (value ?? "").ToString()); try { _updatingState = UpdatingState.UpdatingTarget; var safeValue = MakeValueSafeForTarget(value); _targetPropertyInfo.SetValue(_target, safeValue, null); } finally { _updatingState = UpdatingState.None; } }
private static async Task Update(string url) { var fileName = url.Split('/').LastOrDefault() ?? "tmp.zip"; var filePath = Path.Combine("temp", fileName); try { Console.WriteLine("Creating temp file directory"); if(Directory.Exists("temp")) Directory.Delete("temp", true); Directory.CreateDirectory("temp"); } catch(Exception e) { throw new Exception("Error creating/clearing the download directory.", e); } _state = UpdatingState.Downloading; try { using(var wc = new WebClient()) { var lockThis = new object(); Console.WriteLine("Downloading latest version... 0%"); wc.DownloadProgressChanged += (sender, e) => { lock(lockThis) { Console.CursorLeft = 0; Console.CursorTop = 1; Console.WriteLine("Downloading latest version... {0}/{1}KB ({2}%)", e.BytesReceived / (1024), e.TotalBytesToReceive / (1024), e.ProgressPercentage); } }; await wc.DownloadFileTaskAsync(url, filePath); } } catch(Exception e) { throw new Exception("Error download the file.", e); } _state = UpdatingState.Extracting; try { File.Move(filePath, filePath.Replace("rar", "zip")); Console.WriteLine("Extracting files..."); ZipFile.ExtractToDirectory(filePath, "temp"); const string newPath = "temp\\Hearthstone Deck Tracker\\"; CopyFiles("temp", newPath); } catch(Exception e) { throw new Exception("Error extracting the downloaded file.", e); } _state = UpdatingState.Starting; try { Process.Start("Hearthstone Deck Tracker.exe"); } catch(Exception e) { throw new Exception("Error restarting HDT.", e); } }
/// <summary> /// 다운로드/압축풀기 /// </summary> /// <param name="url"></param> /// <returns></returns> private static async Task Update(string url) { // 임시폴더 생성 var fileName = url.Split('/').LastOrDefault() ?? "tmp.zip"; var filePath = Path.Combine(tempFolder, fileName); try { Console.WriteLine($"{tempFolder} 폴더 생성"); if (Directory.Exists(tempFolder)) { Directory.Delete(tempFolder, true); } Directory.CreateDirectory(tempFolder); } catch (Exception ex) { throw new Exception($"{tempFolder} 삭제/생성 실패!", ex); } // 다운로드 _state = UpdatingState.Downloading; try { using (var wc = new WebClient()) { var lockThis = new object(); var done = false; wc.DownloadProgressChanged += (sender, e) => { lock (lockThis) { if (!done) { Console.CursorLeft = 0; Console.CursorTop = 2; Console.WriteLine($"최신버전 다운로드... {e.BytesReceived / (1024)}/{e.TotalBytesToReceive / (1024)}KB ({e.ProgressPercentage}%)"); } if (e.ProgressPercentage == 100) { done = true; } } }; wc.DownloadFileCompleted += Wc_DownloadFileCompleted; await wc.DownloadFileTaskAsync(url, filePath); var local = File.GetLastWriteTime(filePath); } } catch (Exception e) { throw new Exception("다운로드 실패!", e); } // 압축 풀기 _state = UpdatingState.Extracting; try { Console.WriteLine("압축 푸는 중..."); ZipFile.ExtractToDirectory(filePath, tempFolder); CopyFiles(tempFolder, newPath); } catch (Exception e) { throw new Exception("압축 풀기 실패!", e); } _state = UpdatingState.Starting; // 대상 타스크 실행 try { Process.Start($"{newPath}{procName}.exe"); } catch (Exception e) { throw new Exception($"{procName} 실행 실패!", e); } }
sealed protected override void FireValueChanged(object newValue) { if (_updatingState != UpdatingState.None) return; MvxBindingTrace.Trace(MvxTraceLevel.Diagnostic, "Firing changed to " + (newValue ?? "").ToString()); try { _updatingState = UpdatingState.UpdatingSource; base.FireValueChanged(newValue); } finally { _updatingState = UpdatingState.None; } }
private static async Task Update(string url) { var fileName = url.Split('/').LastOrDefault() ?? "tmp.zip"; var filePath = Path.Combine("temp", fileName); try { Console.WriteLine("Creating temp file directory"); if(Directory.Exists("temp")) Directory.Delete("temp", true); Directory.CreateDirectory("temp"); } catch(Exception e) { throw new Exception("Error creating/clearing the download directory.", e); } _state = UpdatingState.Downloading; try { using(var wc = new WebClient()) { var lockThis = new object(); Console.WriteLine("Downloading latest version... 0%"); wc.DownloadProgressChanged += (sender, e) => { lock(lockThis) { Console.CursorLeft = 0; Console.CursorTop = 1; Console.WriteLine("Downloading latest version... {0}/{1}KB ({2}%)", e.BytesReceived / (1024), e.TotalBytesToReceive / (1024), e.ProgressPercentage); } }; await wc.DownloadFileTaskAsync(url, filePath); } } catch(Exception e) { throw new Exception("Error download the file.", e); } _state = UpdatingState.Extracting; try { File.Move(filePath, filePath.Replace("rar", "zip")); Console.WriteLine("Extracting files..."); ZipFile.ExtractToDirectory(filePath, "temp"); const string newPath = "temp\\Hearthstone Deck Tracker\\"; CopyFiles("temp", newPath); } catch(Exception e) { throw new Exception("Error extracting the downloaded file.", e); } _state = UpdatingState.Starting; try { Process.Start("Hearthstone Deck Tracker.exe"); } catch(Exception e) { throw new Exception("Error restarting HDT.", e); } }