Inverting ifs, using switchcases etc. The things the IDE likes more.

This commit is contained in:
Matěj Kubíček
2026-03-28 21:22:31 +01:00
parent 9e88ce1cee
commit e46f38d153
4 changed files with 243 additions and 227 deletions
+41 -35
View File
@@ -1,4 +1,3 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text.Json.Serialization;
@@ -13,58 +12,65 @@ namespace NetworkDiagram.Models
public class DeviceTemplate
{
public string Name { get; set; } = string.Empty;
public string Name { get; init; } = string.Empty;
public string IconPath { get; set; } = string.Empty;
}
public class PlacedDevice : INotifyPropertyChanged
{
private string _name = string.Empty;
private List<string> _ipAddresses = new List<string>();
private string _annotation = string.Empty;
private double _x;
private double _y;
public string Name
{
get => _name;
set { _name = value; OnPropertyChanged(); }
}
public string Name
{
get;
set
{
field = value;
OnPropertyChanged();
}
} = string.Empty;
public string TemplateName { get; set; } = string.Empty;
[JsonIgnore]
public string IconPath { get; set; } = string.Empty;
public double X
{
get => _x;
set { _x = value; OnPropertyChanged(); OnPropertyChanged(nameof(CenterX)); }
public double X
{
get;
set
{
field = value;
OnPropertyChanged();
OnPropertyChanged(nameof(CenterX));
}
}
public double Y
{
get => _y;
set { _y = value; OnPropertyChanged(); OnPropertyChanged(nameof(CenterY)); }
public double Y
{
get;
set
{
field = value;
OnPropertyChanged();
OnPropertyChanged(nameof(CenterY));
}
}
public List<string> IpAddresses
{
get => _ipAddresses;
set { _ipAddresses = value; OnPropertyChanged(); }
}
public List<string> IpAddresses
{
get;
set
{
field = value;
OnPropertyChanged();
}
} = [];
public string Annotation
{
get => _annotation;
set { _annotation = value; OnPropertyChanged(); }
}
public double CenterX => X + 50;
public double CenterY => Y + 40;
public event PropertyChangedEventHandler? PropertyChanged;
protected void OnPropertyChanged([CallerMemberName] string? name = null)
private void OnPropertyChanged([CallerMemberName] string? name = null)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
}
@@ -79,7 +85,7 @@ namespace NetworkDiagram.Models
public class Diagram
{
public List<PlacedDevice> Devices { get; set; } = new List<PlacedDevice>();
public List<Connection> Connections { get; set; } = new List<Connection>();
public List<PlacedDevice> Devices { get; set; } = [];
public List<Connection> Connections { get; set; } = [];
}
}