예제 #1
0
        // With pre-defined dependancy
        public MonitorTabViewModel(LatencyMonitorConfig configuration)
        {
            this.Model         = new MonitorTabModel();
            this.Configuration = configuration;

            MonitorObserver = new Observer <MonitorServiceNotify>(
                (data) => { NotifyObservers(data); });

            this.startLatencyMonitorCommand = new StartLatencyMonitorCommand(this.Model.Addresses, this);

            this.AddNewAddressCommand = new RelayCommand((obj) => {
                AddNewAddress(txtb_newAddress);
            });

            this.AddNewAddressFromFileCommand = new RelayCommand((obj) =>
            {
                OpenFileDialog ofd = new OpenFileDialog();

                bool?result = ofd.ShowDialog();

                if (result == true)
                {
                    AddMultipleNewAddresses(AddressParser.Parse(ofd.FileName));
                }
            });


            Init();
        }
예제 #2
0
            public void Execute(object latencyMonitorConfig)
            {
                if (IsChecked)
                {
                    IsChecked = false;
                    Monitor.Abort(); // TODO: change it to stop the thread using a boolean or somethin.

                    this.ViewModel.BtnStartBackgroundColor = new LinearGradientBrush(Color.FromRgb(25, 200, 33), Color.FromRgb(0, 233, 88), 1);
                    this.ViewModel.BtnStartContent         = "Start!";
                }
                else
                {
                    IsChecked = true;

                    LatencyMonitorConfig configuration = this.ViewModel.Configuration;
                    this.monitorService = new MonitorService(configuration);
                    this.monitorService.Subscribe(this.ViewModel.MonitorObserver);

                    Monitor = new Thread(() => { monitorService.StartMonitor(this.Addresses); });
                    Monitor.Start();

                    this.ViewModel.BtnStartBackgroundColor = new SolidColorBrush(Color.FromRgb(200, 25, 25));
                    this.ViewModel.BtnStartContent         = "Stop!";
                }
            }
        private void InitViewModels()
        {
            LatencyMonitorConfig monitorConfigModel = new LatencyMonitorConfig();

            SettingsModel settings = new SettingsModel(monitorConfigModel, alertConfig, logConfig);

            #region Log Tab
            // Log tab
            logViewModel = new LogViewModel();
            #endregion

            #region Settings Tab
            // Settings tab
            monitorConfigViewModel = new MonitorConfigViewModel(settings);
            #endregion

            #region Monitor Tab
            // Monitor tab
            monitorTabViewModel = new MonitorTabViewModel(settings.monitorConfig); // notice the same 'settings' object as before in order to synchronize them.
            #endregion

            #region About Tab
            // About tab
            this.aboutViewModel = new AboutViewModel();
            #endregion

            #region Experimental Tab
            // Experimental tab
            //ExperimentalViewModel experimentalViewModel = new ExperimentalViewModel();
            #endregion
        }
예제 #4
0
 public MonitorService(LatencyMonitorConfig configuration)
 {
     latencyMonitor = new LatencyMonitor(configuration);
 }
예제 #5
0
 public SettingsModel(LatencyMonitorConfig configuration, AlertConfigModel alertConfigModel, LogConfigModel logConfigModel)
 {
     this.monitorConfig    = configuration;
     this.alertConfigModel = alertConfigModel;
     this.logConfigModel   = logConfigModel;
 }