Какая-то смотрелка, чего там происходит в девайсине

This commit is contained in:
ftc
2024-02-25 18:03:27 +03:00
parent e8f2b39554
commit 6d944c1a44
20 changed files with 3109 additions and 0 deletions
+88
View File
@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Windows.Media;
namespace charger_gui
{
class MainWindowViewModel : INotifyPropertyChanged
{
private List<string> ports;
public List<string> Ports
{
get
{
if (ports == null)
{
FillPorts();
}
return ports;
}
}
public float iAcc;
public string IAcc
{
get
{
return string.Format("{0,8:0.0000}", iAcc);
}
}
public float uAcc;
public string UAcc
{
get
{
return string.Format("{0,8:0.0000}", uAcc);
}
}
public float iLamp;
public string ILamp
{
get
{
return string.Format("{0,8:0.0000}", iLamp);
}
}
public float uLamp;
public string ULamp
{
get
{
return string.Format("{0,8:0.0000}", uLamp);
}
}
public bool isConnected;
private Brush connectedBrush = new SolidColorBrush(Color.FromRgb(0, 255, 0));
private Brush notConnectedBrush = new SolidColorBrush(Color.FromRgb(255, 0, 0));
public Brush ConnectionStatus
{
get
{
if (isConnected) return connectedBrush;
else return notConnectedBrush;
}
}
private void FillPorts()
{
ports = new List<string>(SerialPort.GetPortNames());
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler == null) return;
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}