コード例 #1
0
        private void Initialize()
        {
            // Load list
            ProfileList =
                new ObservableImmutableList <ClientProfileVm>(
                    ClientProfile.GetAllProfiles().Select(x => new ClientProfileVm(x)));

            if (MainWindowVm.Instance.SelectedWorkingProfile != null)
            {
                SelectedProfile = MainWindowVm.Instance.SelectedWorkingProfile;
            }
            else if (ProfileList == null || ProfileList.Count == 0)
            {
                SelectedProfile = new ClientProfileVm()
                {
                    Name             = "Default Profile",
                    IndexKey         = new byte[] { 0xB9, 0x9E, 0xB0, 0x02, 0x6F, 0x69, 0x81, 0x05, 0x63, 0x98, 0x9B, 0x28, 0x79, 0x18, 0x1A, 0x00 },
                    PackKey          = new byte[] { 0x22, 0xB8, 0xB4, 0x04, 0x64, 0xB2, 0x6E, 0x1F, 0xAE, 0xEA, 0x18, 0x00, 0xA6, 0xF6, 0xFB, 0x1C },
                    PackExtension    = ".epk",
                    IndexExtension   = ".eix",
                    WorkingDirectory = "WORKING_DIR",
                    UnpackDirectory  = "UNPACK_DIR"
                };

                ProfileList.Add(SelectedProfile);
            }
            else
            {
                SelectedProfile = ProfileList.FirstOrDefault(x => x.IsDefault) ?? ProfileList.First();
            }
        }
コード例 #2
0
        public void LoadGitGenerationSettings(IModuleData Data)
        {
            string filePath = DefaultPaths.ModuleGitGenSettingsFile(Data);

            if (Data != null && Data.ModuleSettings != null && File.Exists(Data.ModuleSettings.GitGenSettingsFile))
            {
                filePath = Data.ModuleSettings.GitGenSettingsFile;
            }

            if (File.Exists(filePath))
            {
                try
                {
                    Data.GitGenerationSettings = JsonConvert.DeserializeObject <GitGenerationSettings>(File.ReadAllText(filePath));
                    Log.Here().Important("Git generation settings file loaded.");
                }
                catch (Exception ex)
                {
                    Log.Here().Error("Error deserializing {0}: {1}", filePath, ex.ToString());
                }
            }

            bool settingsNeedSaving = false;

            if (Data.GitGenerationSettings == null)
            {
                Data.GitGenerationSettings = new GitGenerationSettings();
                settingsNeedSaving         = true;
            }

            //Rebuild from previous settings, in case a template name has changed, or new templates were added.
            List <TemplateGenerationData> previousSettings = null;

            if (Data.GitGenerationSettings.TemplateSettings != null)
            {
                previousSettings = Data.GitGenerationSettings.TemplateSettings.ToList();
            }

            ObservableImmutableList <TemplateGenerationData> templateSettings = new ObservableImmutableList <TemplateGenerationData>();

            foreach (var template in Data.Templates.Where(t => t.ID.ToLower() != "license"))
            {
                TemplateGenerationData tdata = new TemplateGenerationData()
                {
                    ID           = template.ID,
                    TemplateName = template.Name,
                    Enabled      = true,
                    TooltipText  = template.ToolTipText
                };

                if (previousSettings != null)
                {
                    var previousData = previousSettings.FirstOrDefault(s => s.ID == template.ID);
                    if (previousData != null)
                    {
                        tdata.Enabled      = previousData.Enabled;
                        settingsNeedSaving = true;
                    }
                }

                templateSettings.Add(tdata);
            }

            Data.GitGenerationSettings.SetTemplateSettings(templateSettings);

            if (settingsNeedSaving)
            {
                FileCommands.Save.SaveGitGenerationSettings(Data, DefaultPaths.ModuleGitGenSettingsFile(Data));
            }
        }