Polish header controls and fix information tab layout issues

This commit is contained in:
Meik
2026-03-05 11:04:53 +01:00
parent 03fc189639
commit c29ca72b2b
5 changed files with 304 additions and 216 deletions

View File

@@ -148,24 +148,50 @@ namespace C4IT_CustomerPanel.UserControls
RemoteHost = Environment.GetEnvironmentVariable("ClientName2");
#endif
TxtHostname.Text = RemoteHost;
if (string.IsNullOrEmpty(RemoteHost))
CanvasHostname.Visibility = Visibility.Collapsed;
CanvasHostname.Visibility = string.IsNullOrEmpty(RemoteHost)
? Visibility.Collapsed
: Visibility.Visible;
TxtUsername.Text = Environment.UserDomainName + "\\" + Environment.UserName;
TxtIpaddress.Text = InformationHelper.GetIp4Address(MainWindow.MainInstance.ConfigSettings.ShowIpInfoOnlyInCorporateNetwork);
DriveInfo[] dInfo = InformationHelper.GetDrives();
TxtLastreboot.Text = InformationHelper.GetLastReboot().ToString(CultureInfo.CurrentUICulture);
StPaDrives.Children.Clear();
StPaDrives2.Children.Clear();
int fixedDriveCount = 0;
foreach (DriveInfo drive in dInfo)
{
if (drive.DriveType == DriveType.Fixed)
fixedDriveCount++;
}
int cardsPerRow = fixedDriveCount <= 1 ? 1 : 2;
double availableDriveWidth = StPaDrives.Width > 0 ? StPaDrives.Width : 334;
double driveCardWidth = Math.Max(120, (availableDriveWidth / cardsPerRow) - 4);
int k = 0;
foreach (DriveInfo drive in dInfo)
{
if ((drive.DriveType == DriveType.Fixed))
{
Grid gri = new Grid { HorizontalAlignment = HorizontalAlignment.Center };
Label lb = new Label { HorizontalAlignment = HorizontalAlignment.Center };
Grid gri = new Grid
{
HorizontalAlignment = HorizontalAlignment.Stretch,
Width = driveCardWidth
};
Label lb = new Label
{
HorizontalAlignment = HorizontalAlignment.Stretch,
HorizontalContentAlignment = HorizontalAlignment.Center,
FontSize = 11,
Padding = new Thickness(2, 0, 2, 0)
};
StackPanel sp = new StackPanel
{
HorizontalAlignment = HorizontalAlignment.Center,
Margin = new Thickness(10, 0, 0, 0)
HorizontalAlignment = HorizontalAlignment.Left,
Margin = new Thickness((k % cardsPerRow) == 0 ? 0 : 8, 0, 0, 0),
Width = driveCardWidth
};
var pbg = new CustomProgressBar
{
@@ -174,10 +200,8 @@ namespace C4IT_CustomerPanel.UserControls
lb.Content = drive.Name + " - " + InformationHelper.FormatBytes(drive.TotalSize - drive.TotalFreeSpace, false) + " / " + InformationHelper.FormatBytes(drive.TotalSize, true);
lb.ToolTip = lb.Content;
lb.ClipToBounds = true;
sp.Width = StPaDrives.Width / dInfo.Length;
pbg.Width = sp.Width;
pbg.Width = driveCardWidth;
pbg.Height = 20;
sp.HorizontalAlignment = HorizontalAlignment.Center;
sp.Orientation = Orientation.Vertical;
gri.Children.Add(pbg);
pbg.ProgressValue = (int)((drive.TotalSize - drive.TotalFreeSpace) * 100 / drive.TotalSize);
@@ -194,11 +218,7 @@ namespace C4IT_CustomerPanel.UserControls
k++;
}
}
if (k <= 1)
{
// StPaDrives2.Height = 0;
// BtnRemoteSupport.Margin = new Thickness(0, -35, 0, 0);
}
StPaDrives2.Visibility = k > 2 ? Visibility.Visible : Visibility.Collapsed;
}
catch (Exception)
{