/// <summary> /// Gets the ram. /// </summary> public RamModel GetRam() { var ramInfo = GetRamInfo(); var ramModel = new RamModel(); return((RamModel)ramModel.InjectFrom(ramInfo)); }
private void BuildRAMCombinationList() { this.RamList = new ObservableCollection <RamModel>(); foreach (PerformanceSetting performanceSetting in Enum.GetValues(typeof(PerformanceSetting))) { RamModel ramModel = new RamModel(); if (performanceSetting != PerformanceSetting.Custom) { string str1 = ""; switch (performanceSetting) { case PerformanceSetting.High: bool flag = false; if ((double)this.mSystemRAM >= 7782.4 && this.mUserCPUCores >= 8) { flag = true; } str1 = LocaleStrings.GetLocalizedString("STRING_HIGH", ""); ramModel.RAM = Math.Min(this.CurrentMaxRAM, flag ? 4096 : 3072); ramModel.RAMInGB = Math.Min(Convert.ToInt32(this.CurrentMaxRAM / 1024), flag ? 4 : 3); break; case PerformanceSetting.Medium: str1 = LocaleStrings.GetLocalizedString("STRING_MEDIUM", ""); ramModel.RAM = Math.Min(this.CurrentMaxRAM, 2048); ramModel.RAMInGB = Math.Min(Convert.ToInt32(this.CurrentMaxRAM / 1024), 2); break; case PerformanceSetting.Low: str1 = LocaleStrings.GetLocalizedString("STRING_LOW", ""); ramModel.RAM = Math.Min(this.CurrentMaxRAM, 1024); ramModel.RAMInGB = Math.Min(Convert.ToInt32(this.CurrentMaxRAM / 1024), 1); break; } string str2 = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0} {1}", (object)ramModel.RAMInGB, (object)LocaleStrings.GetLocalizedString("STRING_MEMORY_GB", "")); ramModel.RamDisplayText = string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0} {1}", (object)str1, (object)string.Format((IFormatProvider)CultureInfo.InvariantCulture, LocaleStrings.GetLocalizedString("STRING_BRACKETS_0", ""), (object)str2)); } else { ramModel.RamDisplayText = LocaleStrings.GetLocalizedString("STRING_CUSTOM_MB", ""); ramModel.RAM = 1024; ramModel.RAMInGB = 1; } ramModel.PerformanceSettingType = performanceSetting; this.RamList.Add(ramModel); } }
private void PreloadDataFromCloneInstance(string vmName) { this.Dpi = Utils.GetDpiFromBootParameters(RegistryManager.RegistryManagers[this.OEM].Guest[vmName].BootParameters); if (this.Is64BitABIValuesValid()) { this.Is64BitABIValid = true; } string valueInBootParams = Utils.GetValueInBootParams("abivalue", vmName, string.Empty, this.OEM); if (!string.IsNullOrEmpty(valueInBootParams)) { if (this.Is64BitABIValuesValid()) { switch (valueInBootParams) { case "7": this.AbiValue = ABISetting.Auto64; break; case "15": this.AbiValue = ABISetting.ARM64; break; default: this.AbiValue = ABISetting.Custom; break; } } else { switch (valueInBootParams) { case "15": this.AbiValue = ABISetting.Auto; break; case "4": this.AbiValue = ABISetting.ARM; break; default: this.AbiValue = ABISetting.Custom; break; } } } else if (this.Is64BitABIValuesValid()) { Utils.UpdateValueInBootParams("abivalue", ABISetting.Auto64.GetDescription(), vmName, true, this.OEM); } else { Utils.UpdateValueInBootParams("abivalue", ABISetting.Auto.GetDescription(), vmName, true, this.OEM); } if (this.AbiValue == ABISetting.Custom) { this.IsCustomABI = true; } int currentCpucount = RegistryManager.RegistryManagers[this.OEM].CurrentEngine == "raw" ? 1 : RegistryManager.RegistryManagers[this.OEM].Guest[vmName].VCPUs; CpuModel cpuModel = this.CPUList.FirstOrDefault <CpuModel>((Func <CpuModel, bool>)(x => x.CoreCount == currentCpucount)); if (cpuModel == null) { cpuModel = this.CPUList.First <CpuModel>((Func <CpuModel, bool>)(x => x.PerformanceSettingType == PerformanceSetting.Custom)); cpuModel.CoreCount = currentCpucount; this.CoreCount = currentCpucount; } this.SelectedCPU = cpuModel; RamModel ramModel = this.RamList.FirstOrDefault <RamModel>((Func <RamModel, bool>)(x => x.RAM == RegistryManager.RegistryManagers[this.OEM].Guest[vmName].Memory)); if (ramModel == null) { ramModel = this.RamList.First <RamModel>((Func <RamModel, bool>)(x => x.PerformanceSettingType == PerformanceSetting.Custom)); ramModel.RAM = RegistryManager.RegistryManagers[this.OEM].Guest[vmName].Memory; } this.SelectedRAM = ramModel; ResolutionModel resolutionModel = this.ResolutionsList.FirstOrDefault <ResolutionModel>((Func <ResolutionModel, bool>)(x => x.AvailableResolutionsDict.Keys.Contains <string>(string.Format("{0} x {1}", (object)RegistryManager.RegistryManagers[this.OEM].Guest[vmName].GuestWidth, (object)RegistryManager.RegistryManagers[this.OEM].Guest[vmName].GuestHeight)))) ?? this.ResolutionsList.First <ResolutionModel>((Func <ResolutionModel, bool>)(x => x.OrientationType == OrientationType.Custom)); resolutionModel.CombinedResolution = string.Format("{0} x {1}", (object)RegistryManager.RegistryManagers[this.OEM].Guest[vmName].GuestWidth, (object)RegistryManager.RegistryManagers[this.OEM].Guest[vmName].GuestHeight); this.ResolutionType = resolutionModel; }