public CreateNewInstanceViewModel( NewInstanceType instanceType, AppPlayerModel appPlayerModel = null, string cloneFromVm = null, string oem = "", string abi = null, bool isAndroidDownloaded = true) { this.InstanceType = instanceType; this.SetAppPlayerModel(appPlayerModel); this.OEM = oem; this.IsAndroidDownloaded = isAndroidDownloaded; string oldValue = string.Empty; this.CpuCorePerformanceWidth = 320; this.CpuCoreCustomVisibility = false; this.PerformanceRamComboWidth = 320; this.CustomRamTextBoxVisibility = false; if (cloneFromVm != null) { this.OEM = InstalledOem.GetOemFromVmnameWithSuffix(cloneFromVm); oldValue = this.OEM.Equals("bgp", StringComparison.InvariantCultureIgnoreCase) ? "" : "_" + this.OEM; if (!string.IsNullOrEmpty(oldValue)) { cloneFromVm = cloneFromVm.Replace(oldValue, ""); } } if (string.IsNullOrEmpty(this.OEM)) { this.OEM = "bgp"; } if (this.InstanceType == NewInstanceType.Clone && !RegistryManager.RegistryManagers[this.OEM].Guest.ContainsKey(cloneFromVm)) { cloneFromVm = "Android"; } this.InitCPUInfo(); this.InitRAMInfo(); this.BuildCPUCombinationList(); this.BuildRAMCombinationList(); this.BuildResolutionsList(); this.BuildInstanceCountList(); this.BuildCloneFromInstanceList(); this.ResolutionType = this.ResolutionsList.First <ResolutionModel>((Func <ResolutionModel, bool>)(x => x.OrientationType == OrientationType.Landscape)); this.InstanceCount = 1; if (this.InstanceType == NewInstanceType.Clone) { this.CloneFromInstanceVmName = cloneFromVm + oldValue; } else { this.InitABISettings("Android", abi); } this.MaxResolutionWidth = Math.Max(this.MaxResolutionWidth, Screen.PrimaryScreen.Bounds.Width); this.MaxResolutionHeight = Math.Max(this.MaxResolutionHeight, Screen.PrimaryScreen.Bounds.Height); this.CloseWindowCommand = (ICommand) new RelayCommand(new System.Action(this.CloseCreateNewInstanceWindow), false); this.ABIHelpSupportCommand = (ICommand) new RelayCommand(new System.Action(this.ABIHelpSupport), false); this.CreateInstanceButtonClickCommand = (ICommand) new RelayCommand(new System.Action(this.CreateInstanceButtonClick), false); }
public void DownloadOem(AppPlayerModel appPlayerModel) { this.currentDownloadingOem = appPlayerModel; if (InstalledOem.InstalledCoexistingOemList.Contains(appPlayerModel.AppPlayerOem)) { using (BackgroundWorker backgroundWorker = new BackgroundWorker()) { backgroundWorker.DoWork += new DoWorkEventHandler(this.BGCreateNewInstance_DoWork); backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(this.BGCreateNewInstance_RunWorkerCompleted); backgroundWorker.RunWorkerAsync(); } } else { Publisher.PublishMessage(BrowserControlTags.oemDownloadStarted, this.ParentWindow.mVmName, (JObject)null); if (appPlayerModel.DownLoadOem((Downloader.DownloadExceptionEventHandler)(_1 => Publisher.PublishMessage(BrowserControlTags.oemDownloadFailed, this.ParentWindow.mVmName, new JObject() { ["MessageTitle"] = (JToken)LocaleStrings.GetLocalizedString("STRING_DOWNLOAD_FAILED", ""), ["MessageBody"] = (JToken)LocaleStrings.GetLocalizedString("STRING_ERROR_RECORDER_DOWNLOAD", ""), ["ActionType"] = (JToken)"failed" })), (Downloader.DownloadProgressChangedEventHandler)(size => { Decimal num = Decimal.Divide((Decimal)size, (Decimal)this.mSizeInBytes) * new Decimal(100); if (this.mLastPercentSend + 4 >= (int)num) { return; } Publisher.PublishMessage(BrowserControlTags.oemDownloadCurrentProgress, this.ParentWindow.mVmName, new JObject() { ["DownloadPercent"] = (JToken)num }); this.mLastPercentSend = (int)num; }), (Downloader.DownloadFileCompletedEventHandler)((_1, _2) => { Publisher.PublishMessage(BrowserControlTags.oemDownloadCompleted, this.ParentWindow.mVmName, (JObject)null); this.InstallOemOperation(); }), (Downloader.FilePayloadInfoReceivedHandler)(fileSize => this.mSizeInBytes = fileSize), (Downloader.UnsupportedResumeEventHandler)(_1 => Publisher.PublishMessage(BrowserControlTags.oemDownloadFailed, this.ParentWindow.mVmName, new JObject() { ["MessageTitle"] = (JToken)LocaleStrings.GetLocalizedString("STRING_DOWNLOAD_FAILED", ""), ["MessageBody"] = (JToken)LocaleStrings.GetLocalizedString("STRING_FAILED_DOWNLOAD_RETRY", ""), ["ActionType"] = (JToken)"retry" })), false)) { return; } Publisher.PublishMessage(BrowserControlTags.oemDownloadFailed, this.ParentWindow.mVmName, new JObject() { ["MessageTitle"] = (JToken)LocaleStrings.GetLocalizedString("STRING_DOWNLOAD_FAILED", ""), ["MessageBody"] = (JToken)LocaleStrings.GetLocalizedString("STRING_ERROR_RECORDER_DOWNLOAD", ""), ["ActionType"] = (JToken)"failed" }); } }
private void _bgGetUpdateDetails_RunWorkerCompleted( object sender, RunWorkerCompletedEventArgs e) { try { if (!(e.Result is JToken result)) { return; } this.OemUpdateList = new ObservableCollection <AppPlayerUpdateModel>(); IJEnumerable <JToken> source = result.First <JToken>().Children().Children <JToken>(); if (source != null && source.Any <JToken>()) { foreach (object obj in (IEnumerable <JToken>)source) { this.OemUpdateList.Add(JsonConvert.DeserializeObject <AppPlayerUpdateModel>(obj.ToString(), Utils.GetSerializerSettings())); } } foreach (AppPlayerModel coexistingOem in (Collection <AppPlayerModel>)InstalledOem.CoexistingOemList) { AppPlayerModel item = coexistingOem; AppPlayerUpdateModel playerUpdateModel = this.OemUpdateList.Where <AppPlayerUpdateModel>((Func <AppPlayerUpdateModel, bool>)(u => u.RequestedOem == item.AppPlayerOem)).FirstOrDefault <AppPlayerUpdateModel>(); if (playerUpdateModel != null) { playerUpdateModel.OemDisplayName = item.AppPlayerOemDisplayName; } } foreach (AppPlayerUpdateModel oemUpdate in (Collection <AppPlayerUpdateModel>) this.OemUpdateList) { AppPlayerUpdateModel item = oemUpdate; if (item.OemDisplayName != null && InstalledOem.InstalledCoexistingOemList.Contains(item.RequestedOem)) { SimpleIoc.Default.Unregister <EngineUpdateViewModel>(item.OemDisplayName); SimpleIoc.Default.Register <EngineUpdateViewModel>((Func <EngineUpdateViewModel>)(() => new EngineUpdateViewModel(item)), item.OemDisplayName); EngineUpdateViewModel instance = SimpleIoc.Default.GetInstance <EngineUpdateViewModel>(item.OemDisplayName); if (!this.EngineUpdateViewModelList.Contains(instance)) { this.EngineUpdateViewModelList.Add(instance); } } } this.RaisePropertyChanged("EngineUpdateViewModelList"); this.CheckUpdateGridVisibility = false; this.HyperLinkTextVisibility = true; } catch (Exception ex) { Logger.Error("Failed to get update details err: {0}", (object)ex.Message); } }
internal void InitProperties(string abi = "") { try { string vmIdFromVmName = Utils.GetVmIdFromVmName(this.VmName); string empty = string.Empty; this.Abi = string.IsNullOrEmpty(abi) ? Utils.GetValueInBootParams("abivalue", this.VmName, string.Empty, this.OEM) : abi; this.mAppPlayerModel = InstalledOem.GetAppPlayerModel(this.OEM, this.Abi); string suffix = this.mAppPlayerModel.Suffix; if (RegistryManager.RegistryManagers.ContainsKey(this.OEM) && ((IEnumerable <string>)RegistryManager.RegistryManagers[this.OEM].VmList).Contains <string>(this.VmName)) { if (string.IsNullOrEmpty(RegistryManager.RegistryManagers[this.OEM].Guest[this.VmName].DisplayName) && string.IsNullOrEmpty(this.InstanceDisplayName)) { if (string.Equals(this.VmName, "Android", StringComparison.InvariantCultureIgnoreCase)) { this.InstanceDisplayName = BlueStacks.Common.Strings.ProductDisplayName + " " + suffix; } else { this.InstanceDisplayName = BlueStacks.Common.Strings.ProductDisplayName + " " + vmIdFromVmName + " " + suffix; } RegistryManager.RegistryManagers[this.OEM].Guest[this.VmName].DisplayName = this.InstanceDisplayName.Trim(); } else if (!string.IsNullOrEmpty(this.InstanceDisplayName)) { RegistryManager.RegistryManagers[this.OEM].Guest[this.VmName].DisplayName = this.InstanceDisplayName + " " + suffix; } else { this.InstanceDisplayName = RegistryManager.RegistryManagers[this.OEM].Guest[this.VmName].DisplayName; } } else if (string.IsNullOrEmpty(this.InstanceDisplayName)) { if (string.Equals(this.VmName, "Android", StringComparison.InvariantCultureIgnoreCase)) { this.InstanceDisplayName = BlueStacks.Common.Strings.ProductDisplayName + " " + suffix; } else { this.InstanceDisplayName = BlueStacks.Common.Strings.ProductDisplayName + " " + vmIdFromVmName + " " + suffix; } } this.InstanceCheckBoxChecked = false; this.InitInstanceState(); } catch (Exception ex) { Logger.Error("Error in setting properties of instance" + ex?.ToString() + this.InstanceDisplayName + this.OEM + this.VmName + this.VmNameWithSuffix); } }
public void SetEngineName() { try { if (this.mAppPlayerModel == null) { this.mAppPlayerModel = InstalledOem.GetAppPlayerModel(this.OEM, this.Abi); } this.EngineName = this.mAppPlayerModel.AppPlayerOemDisplayName; } catch (Exception ex) { Logger.Error("Error in setting vmname" + ex?.ToString() + InstalledOem.CoexistingOemList.ToString()); } }
internal void SetOemData(AppPlayerModel oem = null) { this.OemList = InstalledOem.CoexistingOemList; AppPlayerModel appPlayerModel; if (oem == null) { ObservableCollection <AppPlayerModel> oemList = this.OemList; appPlayerModel = oemList != null?oemList.Where <AppPlayerModel>((Func <AppPlayerModel, bool>)(o => o.AppPlayerOem == "bgp")).FirstOrDefault <AppPlayerModel>() : (AppPlayerModel)null; } else { appPlayerModel = oem; } this.SelectedOem = appPlayerModel; }
private void OnCreateNewInstance(NewInstanceType instanceType) { Window window = (Window)null; if (this.View is Window view) { window = view.Owner; } this.CloseCurrentWindow(); string str = "bgp".Equals("bgp", StringComparison.InvariantCultureIgnoreCase) ? "" : "_bgp"; if (instanceType == NewInstanceType.Clone) { AppPlayerModel appPlayerModel = InstalledOem.GetAppPlayerModel("bgp", Utils.GetValueInBootParams("abivalue", "Android", string.Empty, "bgp")); Stats.SendMultiInstanceStatsAsync("clone_instance_clicked", "", "", "", 0, "", 0, "bgp", "", "", "", "", RegistryManager.Instance.CampaignMD5, true, ""); Messenger.Default.Send <InstanceCreationMessage>(new InstanceCreationMessage() { AppPlayerModel = appPlayerModel, InstanceType = instanceType, CloneFromVm = instanceType == NewInstanceType.Clone ? "Android" + str : (string)null }); } else { Stats.SendMultiInstanceStatsAsync("fresh_instance_clicked", "", "", "", 0, "", 0, "bgp", "", "", "", "", RegistryManager.Instance.CampaignMD5, true, ""); Messenger.Default.Send <ControlVisibilityMessage>(new ControlVisibilityMessage() { IsVisible = true }); SimpleIoc.Default.Unregister <NewEngineSelectorViewModel>(); SimpleIoc.Default.Register <NewEngineSelectorViewModel>(); NewEngineSelectorView engineSelectorView1 = new NewEngineSelectorView(); engineSelectorView1.Owner = window; engineSelectorView1.WindowStartupLocation = WindowStartupLocation.CenterOwner; NewEngineSelectorView engineSelectorView2 = engineSelectorView1; SimpleIoc.Default.GetInstance <NewEngineSelectorViewModel>().View = (IView)engineSelectorView2; SimpleIoc.Default.GetInstance <NewEngineSelectorViewModel>().SetOemData(InstalledOem.GetAppPlayerModel("bgp", Utils.GetValueInBootParams("abivalue", "Android", string.Empty, "bgp"))); if (InstalledOem.CoexistingOemList.Count < 2) { SimpleIoc.Default.GetInstance <NewEngineSelectorViewModel>().OemInstalledCheckABI(); } else { engineSelectorView2.ShowDialog(); } } }
public AboutSettingsControl(MainWindow window, SettingsWindow _) { this.ParentWindow = window; this.InitializeComponent(); this.Visibility = Visibility.Hidden; this.Loaded += new RoutedEventHandler(this.AboutSettingsControl_Loaded); AppPlayerModel appPlayerModel = InstalledOem.GetAppPlayerModel("bgp", Utils.GetValueInBootParams("abivalue", "Android", string.Empty, "bgp")); this.mVersionLabel.Content = (object)("v" + RegistryManager.Instance.Version); BlueStacksUIBinding.Bind(this.mSupportLabel, "STRING_SUPPORT"); this.mSupportLabel.ContentStringFormat = "{0} - "; BlueStacksUIBinding.Bind(this.mWebsiteLabel, "STRING_WEBSITE"); this.mWebsiteLabel.ContentStringFormat = "{0} - "; BlueStacksUIBinding.Bind(this.mSupportMailLabel, "STRING_SUPPORT_EMAIL"); this.mSupportMailLabel.ContentStringFormat = "{0} - "; if (Oem.Instance.IsProductBeta) { Label mVersionLabel = this.mVersionLabel; mVersionLabel.Content = (object)(mVersionLabel.Content?.ToString() + LocaleStrings.GetLocalizedString("STRING_BETA", "")); } if (appPlayerModel != null && appPlayerModel.AppPlayerOsArch != null) { Label mVersionLabel = this.mVersionLabel; mVersionLabel.Content = (object)(mVersionLabel.Content?.ToString() + ", " + appPlayerModel.AppPlayerOsArch); } else if (Oem.Instance.IsAndroid64Bit) { Label mVersionLabel = this.mVersionLabel; mVersionLabel.Content = (object)(mVersionLabel.Content?.ToString() + ", " + LocaleStrings.GetLocalizedString("STRING_64BIT_ANDROID", "")); } else { Label mVersionLabel = this.mVersionLabel; mVersionLabel.Content = (object)(mVersionLabel.Content?.ToString() + ", " + LocaleStrings.GetLocalizedString("STRING_32BIT_ANDROID", "")); } this.mTermsOfUseLink.NavigateUri = new Uri(WebHelper.GetUrlWithParams(string.Format((IFormatProvider)CultureInfo.InvariantCulture, "{0}/{1}", (object)WebHelper.GetServerHost(), (object)"help_articles"), (string)null, (string)null, (string)null) + "&article=" + "terms_of_use"); this.mDetailedChangeLogs.Inlines.Clear(); this.mDetailedChangeLogs.Inlines.Add(LocaleStrings.GetLocalizedString("STRING_LEARN_WHATS_NEW", "Learn What's New")); }
private void SetAppPlayerModel(AppPlayerModel appPlayerModel) { this.AppPlayerOemDisplayName = this.InstanceType == NewInstanceType.Fresh ? " - " + appPlayerModel?.AppPlayerOemDisplayName : string.Empty; this.IsAbiSetttingEnabled = !string.Equals(appPlayerModel.AppPlayerOem, "bgp64", StringComparison.InvariantCultureIgnoreCase); this.AbiSettingDisabledTooltip = string.Format((IFormatProvider)CultureInfo.InvariantCulture, LocaleStrings.GetLocalizedString("STRING_DISABLED_ABI_TOOLTIP", ""), (object)appPlayerModel?.AppPlayerOemDisplayName); }