Exemplo n.º 1
0
        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);
        }
        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();
                }
            }
        }