private async Task RunAnimationsAsync() { try { await Task.Delay(500); // so others can see what was put down before the animations start. int x; var loopTo = _totalSteps - 1; for (x = 1; x <= loopTo; x++) { await Task.Delay((int)_internval); foreach (var thisTrick in _trickList !) { thisTrick.CurrentX += thisTrick.DiffX; thisTrick.CurrenyY += thisTrick.DiffY; GameBoard !.SetLocation(thisTrick.Index, thisTrick.CurrentX, thisTrick.CurrenyY); } } foreach (var thisCard in _tempArea !.CardList) { thisCard.Visible = false; } foreach (var thisTrick in _trickList !) { GameBoard !.SetLocation(thisTrick.Index, thisTrick.StartX, thisTrick.StartY); } } catch (Exception ex) { UIPlatform.ShowError(ex.Message); //hopefully okay. return; } }
async Task <bool> IPrepareSong.PrepareSongAsync(Action changePropertyMethod, IBaseSong currentSong, int resumeAt) { _mP3.StopPlay(); string paths = currentSong.FullPath; if (IsMp3(paths) == false) { string OldPath = currentSong.FullPath; paths = ConvertToMp3(currentSong.FullPath); await RenameFileAsync(OldPath, paths); } if (FileExists(paths) == false) { if (ShowErrors == true) { UIPlatform.ShowError($"Cannot find the path {paths} when trying to play a song. Maybe the hard drive is having problems or you have been disconnected from the network"); return(false); } } changePropertyMethod.Invoke(); _mP3.Path = paths; if (resumeAt == 0) { await _mP3.PlayAsync(); } else { await _mP3.PlayAsync(resumeAt); } return(true); }
protected async Task DisplayRootViewForAsync() { try { OurContainer!.RegisterType<TViewModel>(true); OurContainer!.RegisterType<TView>(true); //i think that the shell stuff needs to be singleton. //if i am wrong, rethink. object item = cons!.Resolve<TViewModel>()!; TView view = cons!.Resolve<TView>(); view.DataContext = item; await ShowWindowAsync(view, item); } catch (Exception ex) { if (TestData!.ShowErrorMessageBoxes == false) { CommonBasicStandardLibraries.BasicDataSettingsAndProcesses.VBCompat.Stop(); //so i can see the stacktrace, etc. } if (ex.InnerException != null) { UIPlatform.ShowError(ex.InnerException.Message); return; } //if we need the stack trace, rethink. UIPlatform.ShowError(ex.Message); //at least i get hints. } }
private async void ThisPlayer_Progress(string timeElapsed, string totalTime) { try { int els = Player !.TimeElapsed(); els += 3; if (els < ResumeSecs && ResumeSecs > 5 && els <= 5) { _attempts++; if (_attempts > 10) { UIPlatform.ShowError("Somehow; its failing to autoresume no matter what. Already tried 10 times. Therefore; its being closed out"); return; } await Player.PlayAsync(VideoLength, ResumeSecs); } VideoPosition = Player.TimeElapsed(); ProgressText = $"{timeElapsed}/{totalTime}"; } catch (Exception ex) { UIPlatform.ShowError(ex.Message); //for now, if there is an error on reloading, will be forced to show error and close out to see what the problem could be. } }
protected override async Task BeforePlayerInitAsync() { try { await base.BeforePlayerInitAsync(); //needs this for sure. _secs = await ResumeAtAsync(); if (_secs == 0 && SelectedItem.Opening.HasValue == true) { _secs = SelectedItem.Opening !.Value; } VideoPath = SelectedItem.Path; SelectedItem.LastWatched = DateTime.Now; if (SelectedItem.ResumeAt.HasValue == false) { await _loader.UpdateMovieAsync(SelectedItem); } else { await _loader.AddToHistoryAsync(SelectedItem); } } catch (Exception ex) { UIPlatform.ShowError(ex.Message); } }
protected override async Task AfterPlayerInitAsync() { try { if (SelectedItem.Opening.HasValue == false) { Button3Text = "Movie Started"; VideoLength = 0; } else if (SelectedItem.Closing.HasValue == false) { Button3Text = "Movie Ended"; VideoLength = 0; } else { VideoLength = SelectedItem.Closing !.Value; } ResumeSecs = _secs; VideoPosition = _secs; await ShowVideoLoadedAsync(); } catch (Exception ex) { UIPlatform.ShowError(ex.Message); } }
protected override async Task AfterPlayerInitAsync() { try { if (_hasIntro) { var(StartTime, HowLong) = GetSkipData(); SkipSceneClass ThisSkip = new SkipSceneClass() { StartTime = StartTime, HowLong = HowLong }; var ThisList = new CustomBasicList <SkipSceneClass> { ThisSkip }; Player.AddScenesToSkip(ThisList); } var tvLength = Player.Length(); await CalculateDurationAsync(tvLength); } catch (Exception ex) { UIPlatform.ShowError(ex.Message); } }
//private bool _startedUp; //private int _lastResumeAt; async Task IPlaylistSongProgressPlayer.StartUpAsync() { //_startedUp = true; if (_playlistId == null) { throw new BasicBlankException("There was no playlist id. Therefore, can't even start up. Rethink"); } var progress = _data.GetSinglePlayListProgress(_playlistId.Value); var tempsongs = _data.GetPlayListSongs(_playlistId.Value); int resumeat = 0; await _data.PerformAdvancedMusicProcessAsync(async (cons, trans) => { if (progress == null) { progress = Resolve <IPlayListProgress>(); progress.PlayList = _playlistId.Value; progress.ResumeAt = 0; progress.SongNumber = 1; UpTo = 1; resumeat = 0; await _data.AddNewPlayListProgressAsync(progress, cons, trans); } else { resumeat = progress.ResumeAt; UpTo = progress.SongNumber; } _songs = new CustomBasicList <IBaseSong>(); foreach (IPlayListSong thisTemp in tempsongs) { if (thisTemp.Song == null) { UIPlatform.ShowError("The Song From PlayList Song Was Nothing. Rethink"); break; } thisTemp.Song.SongNumber = thisTemp.SongNumber; _songs.Add(thisTemp.Song); } trans.Commit(); }); SongsLeft = _songs.Count - UpTo; //maybe no need for minus 1 (?) try { _currentSong = _songs[UpTo - 1]; } catch (Exception ex) { UIPlatform.ShowError(ex.Message); return; } //_lastResumeAt = resumeat; UpdateProgress.Invoke(); //i think that this should to this too (?) await _currentSong.PlayNewSongAsync(resumeat); //hopefully this simple (?) }
public static async Task SendGameOverAsync(this IAggregatorContainer aggregator) { try { await aggregator.Aggregator.PublishAsync(new GameOverEventModel()); //problem seems to be whoever handles the game over in this case. } catch (Exception ex) { UIPlatform.ShowError(ex.Message); } }
protected async Task ShowVideoLoadedAsync() { if (VideoLength == 0) { VideoLength = Player.Length(); } if (VideoLength == -1) { UIPlatform.ShowError("Movie Length can't be -1"); return; } FullScreen = true; await Player.PlayAsync(VideoLength, VideoPosition); }
Task IHandleAsync<SocketErrorEventModel>.HandleAsync(SocketErrorEventModel message) { if (message.Category == EnumSocketCategory.Client) { MessageBox.Show($"Client Socket Error. The message was {message.Message}"); } else if (message.Category == EnumSocketCategory.Server) { MessageBox.Show($"Server Socket Error. The message was {message.Message}"); } else { UIPlatform.ShowError("No Category Found For Socket Error"); } return Task.CompletedTask; }
private async Task RunAnimations() { try { double totalXDistance; double totalYDistance; double eachx = 0; double eachy = 0; int x; int upTox = 0; int upToy = 0; await Task.Run(() => { totalXDistance = _destinationX - _startX; totalYDistance = _destinationY - _startY; eachx = totalXDistance / _totalSteps; eachy = totalYDistance / _totalSteps; upTox = _startX; upToy = _startY; }); var loopTo = _totalSteps - 1; for (x = 1; x <= loopTo; x++) { await Task.Delay((int)_interval); upTox += (int)eachx; upToy += (int)eachy; GameBoard !.SetLocation(_image !, upTox, upToy); } await Task.Delay((int)_interval); GameBoard !.SetLocation(_image !, _destinationX, _destinationY); if (CanClearAtEnd == false) { GameBoard.Clear(); } } catch (Exception ex) { UIPlatform.ShowError(ex.Message); //well see how well this works (?) return; } }
protected override async Task BeforePlayerInitAsync() { try { await base.BeforePlayerInitAsync(); int secs = _logic.GetSeconds(SelectedItem); ResumeSecs = secs; VideoPosition = ResumeSecs; VideoPath = SelectedItem.FullPath(); _hasIntro = SelectedItem.BeginAt > 0; //taking a chance by showing that if begin at is greater than 0 then show it has intro. //not sure if it will cause problems but its a chance i have to take. //good news is if i run into more problems can do a mock where it pretends it chose the episode for testing. //_hasIntro = SelectedItem.AlreadySkippedOpening == false && SelectedItem.BeginAt > 0; await _logic.AddToHistoryAsync(SelectedItem); } catch (Exception ex) { UIPlatform.ShowError(ex.Message); } }
protected override async Task ActivateAsync() { if (BasicData.MultiPlayer == true) { UIPlatform.ShowError("Needs to rethink multiplayer."); return; } await base.ActivateAsync(); if (TestMode != EnumTestCategory.None && BasicData.GamePackageMode == EnumGamePackageMode.Production) { throw new BasicBlankException("Cannot have a test mode for screens because its in production"); } if (TestMode != EnumTestCategory.None) { //needs to do the opening screen part. IScreen screen; switch (TestMode) { case EnumTestCategory.FirstOption: FirstScreen = MainContainer.Resolve <FirstOptionViewModel>(); screen = FirstScreen; break; case EnumTestCategory.CardsPlayer: CardsScreen = MainContainer.Resolve <CardsPlayerViewModel>(); screen = CardsScreen; break; case EnumTestCategory.Advanced: AdvancedScreen = MainContainer.Resolve <AdvancedOptionsViewModel>(); screen = AdvancedScreen; break; default: throw new BasicBlankException("Rethink"); } await LoadScreenAsync(screen); } }
public async Task DoAnimateAsync(ISelectableObject thisImage) { thisImage.IsSelected = false; GameBoard !.Clear(); GameBoard.AddChild(thisImage); try { GameBoard.SetLocation(thisImage, LocationFrom.X, LocationFrom.Y); } catch (Exception ex) { UIPlatform.ShowError(ex.Message); return; } _startX = (int)LocationFrom.X; // myLocation.X _startY = (int)LocationFrom.Y; // myLocation.Y _destinationX = (int)LocationTo.X; _destinationY = (int)LocationTo.Y; var temps = LongestTravelTime / _interval; _totalSteps = (int)temps; _image = thisImage; await RunAnimations(); }
private void MP3_ErrorRaised(string message) { UIPlatform.ShowError(message); }
private void ThisPlayer_ErrorRaised(string message) { UIPlatform.ShowError(message); }
public Task ProcessErrorAsync(string errorMessage) //done. { UIPlatform.ShowError(errorMessage); return(Task.CompletedTask); }
public async Task ProcessMessageAsync(SentMessage thisMessage) { try { switch (thisMessage.Status.ToLower()) { case "ready": ms.IReadyNM thisReady = _thisContainer.Resolve <ms.IReadyNM>(); await thisReady.ProcessReadyAsync(thisMessage.Body); break; case "loadgame": ms.ILoadGameNM thisLoad = _thisContainer.Resolve <ms.ILoadGameNM>(); await thisLoad.LoadGameAsync(thisMessage.Body); break; case "savedgame": UIPlatform.ShowError("savedgame is obsolete. Try to use loadgame now"); break; case "reshuffledcards": ms.IReshuffledCardsNM thisReshuffle = _thisContainer.Resolve <ms.IReshuffledCardsNM>(); await thisReshuffle.ReshuffledCardsReceived(thisMessage.Body); break; case "newgame": ms.INewGameNM thisGame = _thisContainer.Resolve <ms.INewGameNM>(); await thisGame.NewGameReceivedAsync(thisMessage.Body); break; case "restoregame": ms.IRestoreNM thisRestore = _thisContainer.Resolve <ms.IRestoreNM>(); await thisRestore.RestoreMessageAsync(thisMessage.Body); break; case "endturn": ms.IEndTurnNM thisEnd = _thisContainer.Resolve <ms.IEndTurnNM>(); await thisEnd.EndTurnReceivedAsync(thisMessage.Body); break; case "drawcard": ms.IDrawCardNM thisDrawCard = _thisContainer.Resolve <ms.IDrawCardNM>(); await thisDrawCard.DrawCardReceivedAsync(thisMessage.Body); break; case "chosepiece": ms.IChoosePieceNM thisPiece = _thisContainer.Resolve <ms.IChoosePieceNM>(); await thisPiece.ChoosePieceReceivedAsync(thisMessage.Body); break; case "pickup": ms.IPickUpNM thisPick = _thisContainer.Resolve <ms.IPickUpNM>(); await thisPick.PickUpReceivedAsync(thisMessage.Body); break; case "discard": ms.IDiscardNM thisDicard = _thisContainer.Resolve <ms.IDiscardNM>(); await thisDicard.DiscardReceivedAsync(thisMessage.Body); break; case "move": ms.IMoveNM thisMove = _thisContainer.Resolve <ms.IMoveNM>(); await thisMove.MoveReceivedAsync(thisMessage.Body); break; case "rolled": ms.IRolledNM thisRoll = _thisContainer.Resolve <ms.IRolledNM>(); await thisRoll.RollReceivedAsync(thisMessage.Body); break; case "processhold": ms.IProcessHoldNM thisHold = _thisContainer.Resolve <ms.IProcessHoldNM>(); await thisHold.ProcessHoldReceivedAsync(int.Parse(thisMessage.Body)); //if you send something not int, will get casting errors. break; case "selectdice": ms.ISelectDiceNM thisDice = _thisContainer.Resolve <ms.ISelectDiceNM>(); await thisDice.SelectDiceReceivedAsync(int.Parse(thisMessage.Body)); break; case "drew": UIPlatform.ShowError("drew is obsolete. Try drawdomino"); break; case "drawdomino": ms.IDrewDominoNM thisDomino = _thisContainer.Resolve <ms.IDrewDominoNM>(); await thisDomino.DrewDominoReceivedAsync(int.Parse(thisMessage.Body)); break; case "playdomino": ms.IPlayDominoNM playDomino = _thisContainer.Resolve <ms.IPlayDominoNM>(); await playDomino.PlayDominoMessageAsync(int.Parse(thisMessage.Body)); break; case "trickplay": ms.ITrickNM thisTrick = _thisContainer.Resolve <ms.ITrickNM>(); await thisTrick.TrickPlayReceivedAsync(int.Parse(thisMessage.Body)); break; default: ms.IMiscDataNM thisMisc = _thisContainer.Resolve <ms.IMiscDataNM>(); await thisMisc.MiscDataReceived(thisMessage.Status, thisMessage.Body); break; } } catch (Exception ex) { if (_thisTest.ShowErrorMessageBoxes == true) { UIPlatform.ShowError(ex.Message); //which will close out but at least you get a messagebox. } else { CommonBasicStandardLibraries.BasicDataSettingsAndProcesses.VBCompat.Stop(); //Execute.OnUIThread(() => //{ // throw new BasicBlankException("Error", ex); //}); } } }
Task IHandleAsync <DisconnectEventModel> .HandleAsync(DisconnectEventModel message) { UIPlatform.ShowError("Disconnected"); return(Task.CompletedTask); }