public void reportSearchProgress(string file, bool isSearchFile) { if(!this.evermoreModel.SearchPage.Dispatcher.CheckAccess()) { this.evermoreModel.SearchPage.Dispatcher.BeginInvoke( new Action<string, bool> (reportSearchProgress), new object[] { file, isSearchFile }); return; } if (isSearchFile) { this.evermoreModel.IsFileFound = true; this.evermoreModel.SearchPage.FoundFilesComboBox.Items.Add(file); this.evermoreModel.FileFoundCount += 1; // DO not riase toast if more than 10 files have already been found - UI hang issue if (this.evermoreModel.FileFoundCount <= 10) { ToastWindow toast = new ToastWindow(this, "[" + this.evermoreModel.FileFoundCount + "] " + "New file found!\n" + file); toast.RaiseToast(); Debug.WriteLine("[Success] Received file : " + file); } } else { this.evermoreModel.SearchProgressLabelContent = "Looking in " + file; Debug.WriteLine("[Reporting] Processing dir : " + file); } }
private void updateUI() { try { this.fileInfo = new FileInfo(this.filePath); if (this.lastUpdateTime != this.fileInfo.LastWriteTime) { this.fileSize = fileInfo.Length; this.lastUpdateTime = this.fileInfo.LastWriteTime; this.LastUpdatedLabel.Content = "Last updated at " + String.Format("{0}", DateTime.Now); Debug.WriteLine("File Changed : " + fileInfo.Length); //Display Toast ToastWindow toast; if (this.firstTime) { toast = new ToastWindow(this.parentWindow, "Relax gentlemen, we are watching your file."); this.firstTime = false; } else { toast = new ToastWindow(this.parentWindow, "File haz been updated!\nNew Size - " + fileInfo.Length + " bytes."); } toast.RaiseToast(); } else { //Debug.WriteLine("File size same : " + fileInfo.Length); } TimeSpan diff = DateTime.Now - this.lastUpdateTime; if (diff.Minutes < 1 && diff.Seconds < 60) { this.MinutesAgoLabel.Content = diff.Seconds + " seconds ago"; } else { this.MinutesAgoLabel.Content = diff.Minutes + " minutes ago"; } } catch (Exception ex) { if (!this.errorDetected) { this.EndWatch(); this.errorDetected = true; ((MainWindow)this.parentWindow).HandleError(ex); } } }