Пример #1
0
        private void AddIndicatorWindow(VitalIndicator indicator, Vital monitoringVital)
        {
            var borderedIndicator = new BorderedVitalIndicator(indicator, this.indicatorWidth, this.indicatorHeight);
            var indicatorWindow   = new IndicatorWindow(borderedIndicator, monitoringVital, (indicator.Width - 70.0), indicator.Height);

            indicatorWindows.Add(indicatorWindow);
        }
Пример #2
0
        public void ListenToCPUUsage(VitalIndicator indicator)
        {
            var    text = (string)indicator.label.Content;
            Action task = () => {
                var    usage     = GetCPUUsage();
                var    usageText = text + usage + "%";
                Action updateUI  = () => { indicator.UpdateIndicator(usageText, usage); };
                indicator.Dispatcher.Invoke(updateUI);
            };

            InvokeEverySeconds(task, 2);
        }
Пример #3
0
        public void ListenToGPULoad(VitalIndicator indicator)
        {
            var    text = (string)indicator.label.Content;
            Action task = () => {
                var    usage     = gpuReport.load;
                var    usageText = text + usage + "%";
                Action updateUI  = () => { indicator.UpdateIndicator(usageText, usage); };
                indicator.Dispatcher.Invoke(updateUI);
            };

            task();
            InvokeEverySeconds(task, 2);
        }
Пример #4
0
        private void AddNewIndicator(Vital monitoringVital)
        {
            VitalIndicator indicator;

            switch (monitoringVital)
            {
            case Vital.CPUUsage:
                indicator = new VitalIndicator($"{VitalMonitor.GetCPUName()} Load ", this.indicatorWidth, this.indicatorHeight);
                monitor.ListenToCPUUsage(indicator);
                break;

            case Vital.RAMUsage:
                indicator = new VitalIndicator("RAM Load ", this.indicatorWidth, this.indicatorHeight);
                monitor.ListenToRAMUsage(indicator);
                break;

            case Vital.GPUUsage:
                indicator = new VitalIndicator($"{VitalMonitor.GetGPUName()} Load ", this.indicatorWidth, this.indicatorHeight);
                monitor.ListenToGPULoad(indicator);
                break;

            case Vital.GPUMemoryUsage:
                indicator = new VitalIndicator($"{VitalMonitor.GetGPUName()} Memory ", this.indicatorWidth, this.indicatorHeight);
                monitor.ListenToGPUMemoryLoad(indicator);
                break;

            case Vital.GPUFanRPM:
                indicator = new VitalIndicator($"{VitalMonitor.GetGPUName()} Fan ", this.indicatorWidth, this.indicatorHeight);
                monitor.ListenToGPUFanSpeed(indicator);
                break;

            case Vital.GPUTemp:
                indicator = new VitalIndicator($"{VitalMonitor.GetGPUName()} Temp ", this.indicatorWidth, this.indicatorHeight);
                monitor.ListenToGPUTemp(indicator);
                break;

            case Vital.HarddriveSpace:
                var drives = DriveInfo.GetDrives();
                for (int i = 0; i < drives.Count(); i++)
                {
                    var drive          = drives[i];
                    var driveIndicator = new VitalIndicator($"{drive.Name} ", this.indicatorWidth, this.indicatorHeight);
                    monitor.ListenToDrive(driveIndicator, drive);
                    AddIndicatorWindow(driveIndicator, monitoringVital);
                }
                return;

            default: return;
            }
            AddIndicatorWindow(indicator, monitoringVital);
        }
Пример #5
0
        public void ListenToGPUFanSpeed(VitalIndicator indicator)
        {
            var    text = (string)indicator.label.Content;
            Action task = () => {
                var    usage        = gpuReport.fanSpeed;
                var    usagePercent = (((double)gpuReport.fanSpeed / 4000.0) * 100.0);
                var    usageText    = text + usage + " RPM";
                Action updateUI     = () => { indicator.UpdateIndicator(usageText, usagePercent); };
                indicator.Dispatcher.Invoke(updateUI);
            };

            task();
            InvokeEverySeconds(task, 2);
        }
Пример #6
0
        public void ListenToGPUTemp(VitalIndicator indicator)
        {
            var    text = (string)indicator.label.Content;
            Action task = () => {
                var    tempf       = gpuReport.tempFahrenheit;
                var    tempPercent = ((tempf / 200.0) * 100);
                var    usageText   = text + tempf + "F";
                Action updateUI    = () => { indicator.UpdateIndicator(usageText, tempPercent); };
                indicator.Dispatcher.Invoke(updateUI);
            };

            task();
            InvokeEverySeconds(task, 2);
        }
Пример #7
0
        public void ListenToDrive(VitalIndicator indicator, DriveInfo drive)
        {
            var driveLabel = drive.Name;

            driveLabel = driveLabel.Replace(@":\", "") + " :    ";
            var    percentUsed = Math.Abs((((100 * drive.AvailableFreeSpace / drive.TotalSize)) - 100));
            Action task        = () => {
                var    usedText = driveLabel + percentUsed + "%";
                Action updateUI = () => { indicator.UpdateIndicator(usedText, percentUsed); };
                indicator.Dispatcher.Invoke(updateUI);
            };

            task();
            InvokeEverySeconds(task, 120);
        }
        public BorderedVitalIndicator(VitalIndicator indicator, double width, double height)
        {
            this.indicator = indicator;
            var indicatorRoot = new Grid();

            indicatorRoot.Width  = width;
            indicatorRoot.Height = (height * 1.5);
            indicatorRoot.HorizontalAlignment = HorizontalAlignment.Center;
            indicatorRoot.VerticalAlignment   = VerticalAlignment.Top;
            this.Width                        = (indicator.Width - 70.0);
            this.Height                       = indicator.Height;
            this.VerticalAlignment            = VerticalAlignment.Top;
            this.HorizontalAlignment          = HorizontalAlignment.Center;
            this.BorderBrush                  = new SolidColorBrush(Color.FromArgb((byte)255, (byte)50, (byte)50, (byte)50));
            this.BorderThickness              = new Thickness(2);
            this.Child                        = indicatorRoot;
            indicator.label.FontSize          = 15.0;
            indicator.label.VerticalAlignment = VerticalAlignment.Bottom;
            indicator.label.Margin            = new Thickness(0, 0, 0, 15);
            indicatorRoot.Children.Add(indicator);
        }