private void BtnFindNode_Click(object sender, EventArgs e) { try { CheckTxtBox(TxtInputData.Text); int data = Int32.Parse(TxtInputData.Text); RefreshListbox(); string nodeLocated = aNode.Find(data).Data.ToString(); int index = ListBoxOutput.FindString($"[{nodeLocated}"); TxtInputData.Text = null; TxtInputData.Focus(); ListBoxOutput.SetSelected(index, true); MessageBox.Show($"Found Data Node [{nodeLocated}]", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (FormatException ex) { MessageBox.Show($"{ex.Message.ToString()}", "Prøv igen", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtInputData.SelectAll(); TxtInputData.Focus(); } catch (NullReferenceException) { MessageBox.Show($"Node med nr. {TxtInputData.Text} findes ikke", "Prøv igen", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtInputData.SelectAll(); TxtInputData.Focus(); } }
public void Output(string output, bool consoleOnly = false) { if (consoleOnly) { System.Diagnostics.Debug.WriteLine(output); return; } if (ListBoxOutput.Dispatcher.CheckAccess()) { System.Diagnostics.Debug.WriteLine(output); // stop using memory for old debug lines. if (ListBoxOutput.Items.Count > 500) { ListBoxOutput.Items.RemoveAt(0); } ListBoxOutput.Items.Add(output); ListBoxOutput.ScrollIntoView(ListBoxOutput.Items[ListBoxOutput.Items.Count - 1]); if (output.StartsWith("Error") && Height == NormalHeight) { Height = DebugHeight; } } else { ListBoxOutput.Dispatcher.BeginInvoke(new Action(() => Output(output))); } }
public void Output(string output, bool consoleOnly = false, string translatedText = "") { if (consoleOnly) { System.Diagnostics.Debug.WriteLine(output); return; } if (ListBoxOutput.Dispatcher.CheckAccess()) { if (translatedText != String.Empty) { lblTranslatedText.Content = translatedText; RecordingIcon.Visibility = Visibility.Hidden; PassedResults.Visibility = Visibility.Visible; //1 filter alle waardeloze woorden var cleanWords = IntelActService.VeryNoice(translatedText); IA_keywords.Content = String.Join(", ", cleanWords.ToArray()); //2 Determine the keywords var action = IntelActService.DetermineKeyWords(cleanWords); if (action == null) { throw new Exception("no matching action"); } IA_action.Content = action.Name; IA_entity.Content = action.Entity; IA_search.Content = action.Value; //3 Match ActionStuff with an actual Redirect var redirect = IntelActService.MatchActionStuffToRedirect(action); if (redirect == null) { throw new Exception("no matching redirect"); } IA_url.Content = redirect.Url; } System.Diagnostics.Debug.WriteLine(output); // stop using memory for old debug lines. if (ListBoxOutput.Items.Count > 500) { ListBoxOutput.Items.RemoveAt(0); } ListBoxOutput.Items.Add(output); ListBoxOutput.ScrollIntoView(ListBoxOutput.Items[ListBoxOutput.Items.Count - 1]); if (output.StartsWith("Error") && Height == NormalHeight) { Height = DebugHeight; } } else { ListBoxOutput.Dispatcher.BeginInvoke(new Action(() => Output(output))); } }
private void TimerOnTick(object sender, EventArgs eventArgs) { Task.Run(() => { _index = -1; _currentRequest = Context.GetNextRequest(); //List is cleared. if (_currentRequest == null) { Dispatcher.Invoke(() => { _timer.Stop(); _diskSchedulingViewModel.IsStopButtonEnabled = false; _diskSchedulingViewModel.IsStartButtonEnabled = true; _diskSchedulingViewModel.IsAddRequestsManuallyCommand = true; _diskSchedulingViewModel.IsAddRandomCommandEnabled = true; }); return; } //To enable updatting data to the OxyPlot plot UI the plot must be invalidated. _diskSchedulingViewModel.PlotModel.InvalidatePlot(false); //Display current for (var i = 0; i < _requestList.Count; i++) { if (_requestList[i] == _currentRequest.Current) { _index = i; } } for (var i = 0; i < _requests.Count; i++) { if (_requests[i].Current != _currentRequest.Current) { continue; } //xx = _requests.Count; _requests.RemoveAt(i); break; } _diskSchedulingViewModel.PlotSeries.Add(new DataPoint(_index, _count)); _count--; Dispatcher.Invoke(delegate { _diskSchedulingViewModel.CurrectRunningProceses.Add("Current request: " + _currentRequest.Current + " Strategy: " + _currentStrategy); ListBoxOutput.ScrollIntoView(ListBoxOutput.Items[ListBoxOutput.Items.Count - 1]); }); _diskSchedulingViewModel.PlotModel.InvalidatePlot(true); //Display current }); }
//Start the timer. public void StartCommand() { _diskSchedulingViewModel.CurrectRunningProceses.Clear(); //CreateRequestList(); GetFromUi(); _count = _requests.Count; Context.Requests = _requests; Context.CurrentRequest = _requests[0]; _diskSchedulingViewModel.PlotSeries.Clear(); //Add first element. _currentRequest = _requests[0]; for (var i = 0; i < _requestList.Count; i++) { if (_requestList[i] == _currentRequest.Current && _requestList[i] != -1) { _index = i; } } for (var i = 0; i < _requests.Count; i++) { if (_requests[i].Current == _currentRequest.Current) { _requests.RemoveAt(i); break; } } _diskSchedulingViewModel.PlotSeries.Add(new DataPoint(_index, _count)); _count--; Dispatcher.Invoke(delegate { _diskSchedulingViewModel.CurrectRunningProceses.Add("Current request: " + _currentRequest.Current + " Strategy: " + _currentStrategy); ListBoxOutput.ScrollIntoView(ListBoxOutput.Items[ListBoxOutput.Items.Count - 1]); }); //Start timer. _timer.Start(); }
private void BtnFindNode_Click(object sender, EventArgs e) { try { CheckTxtBox(TxtEmail.Text, TxtEmail); string email = TxtEmail.Text; RefreshListbox(); TxtEmail.Focus(); string nodeLocated = aNode.Find(email).Data.Email.ToString(); int index = ListBoxOutput.FindString($"{nodeLocated}"); ListBoxOutput.SetSelected(index, true); MessageBox.Show($"Bruger med email: [{nodeLocated}] er blevet fundet!", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (FormatException ex) { MessageBox.Show($"{ex.Message.ToString()}", "Indtastnings fejl", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch (NullReferenceException) { MessageBox.Show($"Brugeren med email: {TxtEmail.Text} findes ikke", "Prøv igen", MessageBoxButtons.OK, MessageBoxIcon.Warning); TxtEmail.SelectAll(); TxtEmail.Focus(); } }