mirror of
https://github.com/egmont11/NetworkDiagram.git
synced 2026-07-24 07:09:43 +02:00
Inverting ifs, using switchcases etc. The things the IDE likes more.
This commit is contained in:
@@ -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; } = [];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user