private void GetKeyLoggerData() { if (!File.Exists(LOG_PATH)) { print("No Logfile Found"); return; } logger = Serilizer.getDataFromFile(LOG_PATH, logger); foreach (ApplicationLog app in logger.applicationLog) { if (app.date == null || app.processName == null || app.windowName == null) { continue; } string[] rowData = new string[4]; string keyString = ""; foreach (string key in app.keyList) { keyString += key; } keyString = ReplaceKeyStrings(keyString); if (!aNameSource.Contains(app.processName)) { aNameSource.Add(app.processName); } if (!wNameSource.Contains(app.windowName)) { wNameSource.Add(app.windowName); } if (!dateSource.Contains(app.date.ToString())) { dateSource.Add(app.date.ToString()); } if (!textSource.Contains(keyString)) { textSource.Add(keyString); } rowData[0] = app.date.ToString(); rowData[1] = app.processName; rowData[2] = app.windowName; rowData[3] = keyString; keyLoggerDataView.Rows.Add(rowData); } searchBox.AutoCompleteCustomSource = textSource; }
public async void OnGameCompleted(object obj, EventArgs args) { _wasGameBeaten = true; Serilizer.ClearSaveGameCache(); string message = null; string levelUpMessage = null; int numberOfLevelups = 0; EventHandler onLevelUp = (object o, EventArgs e) => { numberOfLevelups++; }; // Sub our level up event just in case we did end level up. _expMgr.OnLevelUp += onLevelUp; _expMgr.PuzzleCompleted(_difficulty, (int)_secondsTicking); if (numberOfLevelups != 0) { levelUpMessage = Environment.NewLine + "You leveled up " + numberOfLevelups.ToString(); if (numberOfLevelups > 1) { levelUpMessage += " times"; } else { levelUpMessage += " time"; } } if (_gameInfo.AddIfHighScore(_difficulty, (int)_secondsTicking)) { message = "New Highscore"; } string finalMessage = "You win!"; if (message != null) { finalMessage = finalMessage + Environment.NewLine + message; } SaveApplicationData(); // Add to the total number of times the game was beaten. TimesPlayedData.OnGameBeaten(_difficulty); MessageDialog dlg = new MessageDialog(finalMessage, "Congragulations!"); await dlg.ShowAsync(); Frame.Navigate(typeof(MainPage)); }
public HighscoresPage() { this.InitializeComponent(); SodukoGameInfo sgi = new SodukoGameInfo(); sgi = Serilizer.GetPersistingSodukoGameInfo(); SetHighscores(sgi.Entries); // Set all of the time played data in the UI. TimesPlayedData.UpdateUI(TotalTimesPlayedTextBlock, EasyTimesPlayedTextBlock, NormalTimesPlayedTextBlock, HardTimesPlayedTextBlock); SetPageData(); }
private async void InitPuzzle() { _hasSaved = false; try { _puzzle = new SodukoPuzzle(9, PuzzleCanvas, HintMode.Adjacent); _puzzle.OnCompletedGame += OnGameCompleted; } catch (ArgumentException e) { // Do nothing... string failureMessage = e.Message; } _puzzle.ShowNumberSelector += OnObjectTapped; if (_sii.RestoreState) { if (Serilizer.IsStateSaved()) { LoadData(); } } else { _difficulty = _sii.DesiredDifficulty; if (!_puzzle.InitPuzzle(_difficulty)) { MessageDialog dlg = new MessageDialog("Couldn't init the puzzle!", "Failure"); await dlg.ShowAsync(); } } // The highscore is completely different and is always saved. _gameInfo = Serilizer.GetPersistingSodukoGameInfo(); _expMgr.LoadData(); DisplayHighScore(); SetDifficulty(_difficulty); ShowNumberSelector(); StartTimer(true); HintModeComboBox.SelectedItem = AdjacentComboBoxItem; }
private async void ForfeitButton_Click(object sender, RoutedEventArgs e) { // Show the puzzles answer and don't fire the OnPuzzleCompleted event. MessageDialog dlg = new MessageDialog("Are you certain?", "Continue"); bool solveThePuzzle = false; UICommandInvokedHandler okProc = (IUICommand command) => { solveThePuzzle = true; }; dlg.Commands.Add(new UICommand("Ok", okProc)); dlg.Commands.Add(new UICommand("No")); await dlg.ShowAsync(); if (solveThePuzzle) { _wasGameBeaten = true; Serilizer.ClearSaveGameCache(); _puzzle.SolvePuzzle(false); int tickCount = 0; // Wait five seconds and then navigate back. DispatcherTimer timer = new DispatcherTimer(); EventHandler <object> timerTick = (object senderTimer, object args) => { tickCount++; if (tickCount > 5) { Frame.Navigate(typeof(MainPage)); } }; timer.Interval = new TimeSpan(0, 0, 5); timer.Tick += timerTick; // Stop the main timer as we want to stop our game from updating. _dispatchTimer.Stop(); } }
public MainPage() { this.InitializeComponent(); _expMgr.LoadData(); Settings settings = new Settings(); Settings.Restore(); SetFontColor(); bool continueGameEnabled = Serilizer.IsStateSaved(); ContinueButton.Visibility = continueGameEnabled ? Visibility.Visible : Visibility.Collapsed; if (continueGameEnabled) { if (!SetContinueButtonText()) { // Something has gone terribly wrong. } } TimesPlayedData.LoadData(); TimesPlayedData.UpdateUI(TimesPlayedTextBlock); _expMgr.UpdateControls(LevelProgress, CurrentLevel, CurrentExp); }
private void SaveApplicationData() { _expMgr.SerilizeData(); // Save the persisting data. Serilizer.SavePersistingSodukoGameInfo(_gameInfo); }