async Task ExecuteLoadResultsCommand() { if (IsBusy) { return; } IsBusy = true; try { ResultsList.Clear(); var items = await App.ResultDB.GetResultsByAssessmentSession(App.AssessmentSession.SessionId); foreach (var item in items) { ResultsList.Add(item); } } catch (Exception ex) { Debug.WriteLine(ex); } finally { IsBusy = false; } }
private async void BrowseForImages() { StatusText = "Running..."; FileOpenPicker openPicker = new FileOpenPicker(); openPicker.CommitButtonText = "Open"; openPicker.FileTypeFilter.Add(".jpg"); openPicker.FileTypeFilter.Add(".jpe"); openPicker.FileTypeFilter.Add(".bmp"); openPicker.FileTypeFilter.Add(".png"); openPicker.FileTypeFilter.Add(".gif"); openPicker.ViewMode = PickerViewMode.Thumbnail; openPicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary; IReadOnlyList <StorageFile> files = await openPicker.PickMultipleFilesAsync(); if (files.Count > 0) { ResultsList.Clear(); } foreach (StorageFile file in files) { try { var result = await ProcessImage(file); ResultsList.Add(result); } catch (Exception ex) { Debug.WriteLine(ex); } } StatusText = "Ready"; }
public void Compute() { ResultsList.Clear(); AstronomicalObject origin = StationSelector.SelectedStation; AstronomicalObject[] stations = Environment.Stations.Where(s => s.Star.KnownObjectProximities.ContainsKey(origin.Star) && s.Star.KnownObjectProximities[origin.Star] < MaxDistanceFromOrigin).ToArray(); ThreadPool.QueueUserWorkItem(ComputeWorker, new ComputeArgs() { stations = stations, cargo = Cargo, budget = Budget, maxJumps = MaxJumpsPerTravel, origin = origin, maxDistPerJump = MaxDistancePerjump, }); }
private void RemoveItems(IList <object> selectedItems) { if (selectedItems?.Count == ResultsList.Count) { ResultsList.Clear(); } else { List <int> indicesToRemove = selectedItems .Select(x => ResultsList.IndexOf(x as OcrResultDisplay)) .OrderByDescending(x => x) .ToList(); foreach (int i in indicesToRemove) { ResultsList.RemoveAt(i); } } }
private void OpenFile_OnClick(object sender, RoutedEventArgs e) { OpenFileDialog dialog = new OpenFileDialog(); dialog.Multiselect = false; dialog.Filter = "mp4 files (*.mp4)|*.mp4|avi files (*.avi)|*.avi|all files (*.*)|*.*"; Button_Click(this, new AccessKeyPressedEventArgs()); var dialogResult = dialog.ShowDialog(); if (dialogResult != null && dialogResult.Value) { // if photo file if (dialog.FileName.EndsWith(".jpg")) { Bitmap bitmap = new Bitmap(dialog.FileName); //SplashScreenImage.Source = new BitmapImage(new Uri(dialog.FileName, UriKind.RelativeOrAbsolute)); } else { FileName = System.IO.Path.GetFileName(dialog.FileName); SourceMediaElement.Source = new Uri(dialog.FileName, UriKind.RelativeOrAbsolute); // SplashScreenImage.Visibility = Visibility.Collapsed; VideoTimeTextBlock.Visibility = Visibility.Visible; ResultsList.Clear(); SourceMediaElement.Play(); if (SourceMediaElement.NaturalDuration.HasTimeSpan) { VideoDuration = SourceMediaElement.NaturalDuration.TimeSpan.TotalSeconds; } _videoTimer.Start(); _processTimer.Start(); } } }
/// <summary> /// 把查询出的差异转换成UI呈现对象 /// </summary> public void ConvertToCompareResult() { ResultsList.Clear(); RepairedNum = 0; UIShow = ""; foreach (var re in _service.DifTableList) { if (re.ErrorType == 1) { //丢失的列 foreach (var col in re.LostCol) { var tmp = new UICompareResult { ObjectName = re.SourceInfo.name, ObjectType = re.SourceInfo.type, ErrorItem = col.Name, ErrorItemType = "col", ErrorType = DicError[2] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } //冗余的列 foreach (var col in re.MoreCol) { var tmp = new UICompareResult { ObjectName = re.SourceInfo.name, ObjectType = re.SourceInfo.type, ErrorItem = col.Name, ErrorItemType = "col", ErrorType = DicError[3] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } } if (re.ErrorType == 2) { var tmp = new UICompareResult { ObjectName = re.SourceInfo.name, ObjectType = re.SourceInfo.type, ErrorItem = re.SourceInfo.name, ErrorItemType = re.SourceInfo.type, ErrorType = DicError[re.ErrorType] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } if (re.ErrorType == 3) { var tmp = new UICompareResult { ObjectName = re.TargetInfo.name, ObjectType = re.TargetInfo.type, ErrorItem = re.TargetInfo.name, ErrorItemType = re.TargetInfo.type, ErrorType = DicError[re.ErrorType] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } } if (new AppInfo().NeedCompareIndex) { foreach (var re in _service.DifIndexList) { //如果是丢失 对象信息从源对象取 if (re.ErrorType == 2) { var tmp = new UICompareResult { ObjectName = re.SourceInfo.name, ObjectType = re.SourceInfo.type, ErrorItem = re.SourceInfo.name, ErrorItemType = re.SourceInfo.type, ErrorType = DicError[re.ErrorType] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } //如果是冗余 对象信息从源对象取 if (re.ErrorType == 3) { var tmp = new UICompareResult { ObjectName = re.TargetInfo.name, ObjectType = re.TargetInfo.type, ErrorItem = re.TargetInfo.name, ErrorItemType = re.TargetInfo.type, ErrorType = DicError[re.ErrorType] }; ResultsList.Add(tmp); UIShow = UIShow + tmp; } } } UIThread.Invoke(() => { NeedRepairNum = ResultsList.Count; NotifyOfPropertyChange(() => CanRepairDB); }); }
void SearchButtonClick(object sender, EventArgs e) { string filePath = path; string[] Line = { "1", "2" }; int startIndex; StreamReader sr = new StreamReader(filePath); int results = 0; int LineInSession = 0; string CurSession = ""; if (!More) { RowsDone = 0; GlobalResults = 0; } SearchOption = 1; int resultIndex = 0; bool lineDone = false; if (More) { while (results < RowsDone) { sr.ReadLine(); results++; } results = 0; } if (More && !sr.EndOfStream || !More) { ResultsList.Clear(); ListPanel.Dispose(); this.ListPanel = new System.Windows.Forms.Panel(); this.ListPanel.AutoScroll = true; this.ListPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.ListPanel.Location = new System.Drawing.Point(264, 36); this.ListPanel.Name = "ListPanel"; this.ListPanel.Size = new System.Drawing.Size(328, 669); this.ListPanel.TabIndex = 2; this.Controls.Add(this.ListPanel); } while (!sr.EndOfStream && results <= results_limit) { Line = sr.ReadLine().Split('|'); /* * [0] id [6] msg time * [1] conn [7] sender id * [2] session [8] sender name * [3] ses start [9] receiver id * [4] ses end [10] receiver name * [5] contact [11] msg */ if (CurSession != Line[2] && Line.Length == 12) { CurSession = Line[2]; LineInSession = 1; } else if (Line.Length == 12) { LineInSession++; } while (!lineDone && Line.Length == 12) { startIndex = Line[11].IndexOf(SearchBox.Text, resultIndex, StringComparison.OrdinalIgnoreCase); if (SearchBox.Text != "" && startIndex >= 0) { //resultEntry=CutLongString(Line[10],SearchBox.Text,resultIndex); ResultsList.Add(new Message_Entry(Line[0], Line[6], Line[1], Line[2], Line[5], Line[7], Line[8], Line[9], Line[10], Line[11], SearchBox.Text, startIndex, LineInSession)); resultIndex = startIndex + 1; results++; GlobalResults++; } else { lineDone = true; } } lineDone = false; resultIndex = 0; RowsDone++; ResultsCount.Text = results.ToString() + "(" + GlobalResults + ")"; } PrintResults(); sr.Close(); More = false; }
void RegExpSearchButtonClick(object sender, EventArgs e) { //SearchResults res1 = new SearchResults(ResultsBrowser); int results = 0; int LineInSession = 0; string CurSession = ""; if (!More) { RowsDone = 0; GlobalResults = 0; } SearchOption = 2; string filePath = path; Regex regex; if (RegExpSearchBox.Text == "" || RegExpSearchBox.Text == "*" || RegExpSearchBox.Text == ".*" || RegExpSearchBox.Text == ".*$") { MessageBox.Show("Be more specific!"); } else { regex = new Regex(RegExpSearchBox.Text); StreamReader sr = new StreamReader(filePath); if (More) { while (results < RowsDone) { sr.ReadLine(); results++; } results = 0; } if (More && !sr.EndOfStream || !More) { ResultsList.Clear(); ListPanel.Dispose(); this.ListPanel = new System.Windows.Forms.Panel(); this.ListPanel.AutoScroll = true; this.ListPanel.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; this.ListPanel.Location = new System.Drawing.Point(264, 36); this.ListPanel.Name = "ListPanel"; this.ListPanel.Size = new System.Drawing.Size(328, 669); this.ListPanel.TabIndex = 2; this.Controls.Add(this.ListPanel); } while (!sr.EndOfStream && results <= results_limit) { string[] Line = sr.ReadLine().Split('|'); if (CurSession != Line[2] && Line.Length == 12) { CurSession = Line[2]; LineInSession = 1; } else if (Line.Length == 12) { LineInSession++; } Match m = regex.Match(Line[11]); while (m.Success) { ResultsList.Add(new Message_Entry(Line[0], Line[6], Line[1], Line[2], Line[5], Line[7], Line[8], Line[9], Line[10], Line[11], m.Value, m.Index, LineInSession)); m = m.NextMatch(); results++; GlobalResults++; } RowsDone++; ResultsCount.Text = results.ToString() + "(" + GlobalResults + ")"; } PrintResults(); sr.Close(); More = false; } }
private void ClearData() { Items.Clear(); }