add resharper and hover effect for modules; change navigation bar

This commit is contained in:
Rene Schwarz
2021-08-10 02:03:11 +02:00
parent cdb86331e5
commit 910383775b
64 changed files with 792 additions and 832 deletions

View File

@@ -16,37 +16,49 @@ namespace Server_Dashboard {
//List with all Modules inside
public ObservableCollection<ModuleData> Modules { get; set; }
//Creates Default Modules, remove before release and when implementing the actual data comming from the socket
//Creates Default Modules, remove before release and when implementing the actual data coming from the socket
public DashboardModuleViewModel(DataTable moduleData) {
Modules = new ObservableCollection<ModuleData>();
foreach (DataRow row in moduleData.Rows) {
if (row[0] != null) {
byte[] iconBytes = row[3] == DBNull.Value ? null : (byte[])row[3];
Modules.Add(new ModuleData(true) {
ModuleName = (string)row?[2],
Creator = (string)row?[0],
ModuleIcon = ConvertByteToBitmapImage(iconBytes),
CreationDate = (DateTime)row?[1],
ServerInformation = null
});
if (row[0] == null)
return;
byte[] iconBytes = row[3] == DBNull.Value ? null : (byte[])row[3];
DataTable serverData = DatabaseHandler.GetServerData((int)row[4]);
ServerInformation serverInformation = null;
if (serverData.Rows.Count != 0) {
DataRow serverRow = serverData.Rows[0];
serverInformation = new ServerInformation {
ServerName = (string)serverRow[4] ?? "",
PublicIpAddress = (string)serverRow[6] ?? "",
PrivateIpAddress = (string)serverRow[5] ?? "",
Uptime = (TimeSpan)serverRow[7],
OsUserName = (string)serverRow[3] ?? ""
};
}
Modules.Add(new ModuleData(false) {
ModuleName = (string)row[2] ?? "",
Creator = (string)row[0] ?? "",
ModuleIcon = ConvertByteToBitmapImage(iconBytes),
CreationDate = (DateTime)row[1],
ServerInformation = serverInformation
});
}
}
private BitmapImage ConvertByteToBitmapImage(byte[] icon) {
if (icon != null) {
try {
using MemoryStream ms = new MemoryStream(icon);
BitmapImage moduleIcon = new BitmapImage();
moduleIcon.BeginInit();
moduleIcon.StreamSource = ms;
moduleIcon.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
moduleIcon.CacheOption = BitmapCacheOption.OnLoad;
moduleIcon.EndInit();
moduleIcon.Freeze();
return moduleIcon;
} catch { }
}
private static BitmapImage ConvertByteToBitmapImage(byte[] icon) {
if (icon == null)
return null;
try {
using MemoryStream ms = new MemoryStream(icon);
BitmapImage moduleIcon = new BitmapImage();
moduleIcon.BeginInit();
moduleIcon.StreamSource = ms;
moduleIcon.CreateOptions = BitmapCreateOptions.PreservePixelFormat;
moduleIcon.CacheOption = BitmapCacheOption.OnLoad;
moduleIcon.EndInit();
moduleIcon.Freeze();
return moduleIcon;
} catch { }
return null;
}
}