Ejemplo n.º 1
0
        private void OnShowHddLoadsCallback(object state)
        {
            if (string.IsNullOrEmpty(this.currentSelectedHdd))
            {
                return;
            }

            var  hddLoad = string.Empty;
            bool allHdds = false;

            allHdds = this.currentSelectedHdd == WsapmTools.GetCommonDiaplayNameAllDrives();

            try
            {
                if (allHdds)
                {
                    hddLoad = WsapmConvert.ConvertByteToKB(this.hddLoad.GetCurrentHddLoadTotalAllHdds()).ToString("0.00") + " KB/s";
                }
                else
                {
                    hddLoad = WsapmConvert.ConvertByteToKB(this.hddLoad.GetCurrentHddLoadInBytesPerSecond(this.currentSelectedHdd)).ToString("0.00") + " KB/s";
                }
            }
            catch (Exception)
            {
            }

            Dispatcher.Invoke((Action)(() =>
            {
                this.labelCurrentHddLoad.Content = hddLoad;
            }));
        }
Ejemplo n.º 2
0
        void timer_Tick(object sender, EventArgs e)
        {
            try
            {
                switch (this.checkType)
                {
                case LoadCheckType.Cpu:
                    this.textBlockLoad.Text += this.cpuLoad.GetAverageCpuLoad(numberOfProbes, breakBetweenProbes).ToString("0.00") + " %" + Environment.NewLine;
                    break;

                case LoadCheckType.NetworkTotal:
                    this.textBlockLoad.Text += (WsapmConvert.ConvertByteToKB(this.networkLoad.GetAverageNetworkLoadTotalInBytesPerSecond(numberOfProbes, breakBetweenProbes))).ToString("0.00") + " KB/s" + Environment.NewLine;
                    break;

                case LoadCheckType.NetworkReceived:
                    this.textBlockLoad.Text += (WsapmConvert.ConvertByteToKB(this.networkLoad.GetCurrentNetworkLoadReceivedInBytesPerSecond(numberOfProbes, breakBetweenProbes))).ToString("0.00") + " KB/s" + Environment.NewLine;
                    break;

                case LoadCheckType.NetworkSent:
                    this.textBlockLoad.Text += (WsapmConvert.ConvertByteToKB(this.networkLoad.GetCurrentNetworkLoadSentInBytesPerSecond(numberOfProbes, breakBetweenProbes))).ToString("0.00") + " KB/s" + Environment.NewLine;
                    break;

                default:
                    break;
                }
            }
            catch (Exception ex)
            {
                if (this.timer != null)
                {
                    this.timer.Stop();
                    this.timer.Tick -= timer_Tick;
                }

                MessageBox.Show(String.Format(Wsapm.Resources.Wsapm.LoadWindow_ReadValueError, Environment.NewLine, ex.Message), Wsapm.Resources.Wsapm.General_MessageBoxErrorTitle, MessageBoxButton.OK, MessageBoxImage.Error);
                this.Dispatcher.Invoke((Action)(() => this.Close()));
            }

            this.scrollViewer.ScrollToEnd();
            CommandManager.InvalidateRequerySuggested();
        }
Ejemplo n.º 3
0
        private void OnShowNetworkLoadsCallback(object state)
        {
            if (string.IsNullOrEmpty(this.currentSelectedNic))
            {
                return;
            }

            var  loadTotal    = string.Empty;
            var  loadSent     = string.Empty;
            var  loadReceived = string.Empty;
            bool allNics      = false;

            allNics = this.currentSelectedNic == WsapmTools.GetCommonDiaplayNameAllNetworkInterfaces();

            try
            {
                if (allNics)
                {
                    loadTotal    = WsapmConvert.ConvertByteToKBit(this.networkLoad.GetCurrentNetworkLoadTotalAllNics()).ToString("0.00") + " KBit/s";
                    loadSent     = WsapmConvert.ConvertByteToKBit(this.networkLoad.GetCurrentNetworkLoadUploadAllNics()).ToString("0.00") + " KBit/s";
                    loadReceived = WsapmConvert.ConvertByteToKBit(this.networkLoad.GetCurrentNetworkLoadDownloadAllNics()).ToString("0.00") + " KBit/s";
                }
                else
                {
                    loadTotal    = WsapmConvert.ConvertByteToKBit(this.networkLoad.GetCurrentNetworkLoadTotal(this.currentSelectedNic)).ToString("0.00") + " KBit/s";
                    loadSent     = WsapmConvert.ConvertByteToKBit(this.networkLoad.GetCurrentNetworkLoadUpload(this.currentSelectedNic)).ToString("0.00") + " KBit/s";
                    loadReceived = WsapmConvert.ConvertByteToKBit(this.networkLoad.GetCurrentNetworkLoadDownload(this.currentSelectedNic)).ToString("0.00") + " KBit/s";
                }
            }
            catch (Exception)
            {
            }

            Dispatcher.Invoke((Action)(() =>
            {
                this.labelCurrentNetworkLoadReceived.Content = loadReceived;
                this.labelCurrentNetworkLoadSent.Content = loadSent;
                this.labelCurrentNetworkLoadTotal.Content = loadTotal;
            }));
        }