private void SetupComputerSection() { //OS Name string osName = ComputerManager.GetOSName().Replace("Microsoft", "").Trim(); OperatingSystemTextBlock.Text = osName; if (osName.Equals("Unknown")) { OperatingSystemTextBlock.Foreground = new SolidColorBrush(Colors.Red); } else { OperatingSystemTextBlock.Foreground = new SolidColorBrush(Colors.Blue); OperatingSystemImage.Visibility = Visibility.Visible; try { if (osName.Contains("7")) { OperatingSystemImage.Source = new BitmapImage(new Uri(@"Resources\windows10.png", UriKind.Relative)); } else if (osName.Contains("8.1")) { OperatingSystemImage.Source = new BitmapImage(new Uri(@"Resources\windows8.1.png", UriKind.Relative)); } else if (osName.Contains("8")) { OperatingSystemImage.Source = new BitmapImage(new Uri(@"Resources\Windows8.png", UriKind.Relative)); } else if (osName.Contains("10")) { OperatingSystemImage.Source = new BitmapImage(new Uri(@"Resources\windows10.png", UriKind.Relative)); } else { OperatingSystemImage.Visibility = Visibility.Hidden; EventLogger.WriteLog("SYSTEM OS VERSION ERROR", osName); } } catch (Exception ex) { EventLogger.WriteLog("SYSTEM OS VERSION ERROR", ex.ToString()); OperatingSystemImage.Visibility = Visibility.Hidden; } //OS Version string OSVersion = ComputerManager.GetOSVersion(); BuildVersionTextBlock.Text = OSVersion; if (OSVersion.Equals("Unknown")) { BuildVersionTextBlock.Foreground = new SolidColorBrush(Colors.Red); } else { BuildVersionTextBlock.Foreground = new SolidColorBrush(Colors.Blue); } //Machine Name try { string computerName = Environment.MachineName; string currentUser = Environment.UserName; ComputerNameTextBlock.Foreground = new SolidColorBrush(Colors.Blue); ComputerIDTextBlock.Foreground = new SolidColorBrush(Colors.Black); ComputerNameTextBlock.Text = computerName; string macAddr = MacAddress.GetFirstMacAddress(); var PCID = UserConfig.PCID.Equals("default") ? $"{computerName}-{currentUser}-{macAddr}" : UserConfig.PCID; ComputerIDTextBlock.Text = $"PC ID: {PCID}"; PCIDTextBox.Text = PCID; PCIDContextMenu.Text = $"PC ID: {PCID}"; } catch (Exception ex) { EventLogger.WriteLog("SYSTEM MACHINE NAME ERROR", ex.ToString(), UserConfig.LogPath); ComputerNameTextBlock.Foreground = new SolidColorBrush(Colors.Red); ComputerNameTextBlock.Text = "Unknown"; ComputerIDTextBlock.Foreground = new SolidColorBrush(Colors.Gray); ComputerIDTextBlock.Text = "Unknown ID"; } //User Name try { string userName = Environment.UserName; CurrentUserTextBlock.Foreground = new SolidColorBrush(Colors.Blue); CurrentUserTextBlock.Text = userName; } catch (Exception ex) { EventLogger.WriteLog("SYSTEM USERNAME ERROR", ex.ToString(), UserConfig.LogPath); CurrentUserTextBlock.Foreground = new SolidColorBrush(Colors.Red); CurrentUserTextBlock.Text = "Unknown"; } } }