creewick / uWidgets

Standalone .NET application with a variety of customizable widgets
Other
190 stars 8 forks source link

Colors change, monitor widget expansion etc #23

Open ragedogg opened 3 months ago

ragedogg commented 3 months ago

Hi, Do you plan to create font, background etc color for manual change? This would be great :)

and another suggestion... for the Monitor widget, option to add graph, temp and GPU to monitor :)

i know. a lot of suggestions :)

WhatDamon commented 3 months ago

GPU and temperature readings can probably be implemented with LibreHardwareMonitorLib, and graphics can be implemented with Avalonia's own components I'll see if I can accomplish some of what you're asking.

WhatDamon commented 3 months ago
using LibreHardwareMonitor.Hardware;

class Program
{
    static void Main(string[] args)
    {
        Computer computer = new Computer();
        computer.IsCpuEnabled = true;
        computer.IsGpuEnabled = true;
        computer.Open();
        while (true)
        {
            computer.Accept(new UpdateVisitor());
            foreach (IHardware hardware in computer.Hardware)
            {
                if (hardware.HardwareType == HardwareType.Cpu)
                {
                    Console.WriteLine("CPU Temperature:");
                    foreach (ISensor sensor in hardware.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Temperature)
                        {
                            Console.WriteLine("\t{0}: {1}°C", sensor.Name, sensor.Value);
                        }
                    }
                }
                else if (hardware.HardwareType == HardwareType.GpuNvidia || hardware.HardwareType == HardwareType.GpuAmd || hardware.HardwareType == HardwareType.GpuIntel)
                {
                    Console.WriteLine("GPU Temperature:");
                    foreach (ISensor sensor in hardware.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Temperature)
                        {
                            Console.WriteLine("\t{0}: {1}°C", sensor.Name, sensor.Value);
                        }
                    }
                }
            }
            Thread.Sleep(1000);
        }
    }
}

class UpdateVisitor : IVisitor
{
    public void VisitComputer(IComputer computer)
    {
        computer.Traverse(this);
    }
    public void VisitHardware(IHardware hardware)
    {
        hardware.Update();
        foreach (IHardware subHardware in hardware.SubHardware)
            subHardware.Accept(this);
    }
    public void VisitSensor(ISensor sensor) { }
    public void VisitParameter(IParameter parameter) { }
}

It successfully reads out the temperature information, but has a hard time getting the average value.

GPU usage reading has not been successful yet.

There are also multiple GPUs and multiple temperature sensors to consider later, even if some devices don't have temperature sensors.

Other things such as color changes and graphics, I am not familiar with some of the logic of this project and may need to be implemented by other contributors or project owners

creewick commented 3 months ago

Hi! You provided a lot of useful suggestions Let's discuss it one by one:

Do you think this will meet your needs? I surely can add customisations for each individual widget, but it would take more time and I really not sure how to show it in the UI.

creewick commented 3 months ago

As for the Monitor widget: