Esempio n. 1
0
        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)));
            }
        }
Esempio n. 2
0
        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)));
            }
        }
Esempio n. 3
0
        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
            });
        }
Esempio n. 4
0
        //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();
        }