예제 #1
0
        /// <summary>
        /// Parses the manifest for the latest version info
        /// </summary>
        /// <returns>Latest release version</returns>
        private static string ParseVersionFromManifest(string manifestFilePath)
        {
            var manifest = AsbManifest.FromJsonFile(manifestFilePath);

            if (manifest.modules.TryGetValue("ARK Smart Breeding", out var app))
            {
                return(app.version);
            }

            throw new FormatException("version of main app not found in manifest");
        }
예제 #2
0
        public UpdateModules()
        {
            InitializeComponent();
            Loc.ControlText(BtOk, "OK");
            Loc.ControlText(BtCancel, "Cancel");

            var manifestFilePath = FileService.GetPath(FileService.ManifestFileName);

            if (!File.Exists(manifestFilePath))
            {
                return;
            }

            _asbManifest = AsbManifest.FromJsonFile(manifestFilePath);
            if (_asbManifest?.modules == null)
            {
                return;
            }

            // Display installed and available modules
            var moduleGroups = _asbManifest.modules.Where(kv => kv.Value.Category != "main").Select(kv => kv.Value)
                               .GroupBy(m => m.Category);

            _checkboxesUpdateModule = new List <CheckBox>();
            _checkboxesSelectModule = new List <CheckBox>();

            FlpModules.FlowDirection = FlowDirection.TopDown;
            FlpModules.WrapContents  = false;

            foreach (var g in moduleGroups)
            {
                var header = new Label {
                    Text = g.Key, Margin = new Padding(5, 20, 0, 5), AutoSize = true
                };
                header.Font = new Font(header.Font.FontFamily, header.Font.Size * 2);
                FlpModules.Controls.Add(header);
                var group        = g.OrderBy(m => !m.LocallyAvailable).ThenBy(m => m.Name).ToArray();
                var onlyOneEntry = group.Length == 1;
                foreach (var m in group)
                {
                    var moduleDisplay = CreateModuleControl(m, onlyOneEntry);
                    FlpModules.Controls.Add(moduleDisplay);
                }
            }

            InitiallySelectedSpeciesImageCollectionId = _checkboxesSelectModule.Where(cb => cb.Checked).Select(cb => cb.Tag as AsbModule)
                                                        .FirstOrDefault(m => (m?.LocallyAvailable ?? false) && m?.Category == "Species Images")?.Id;
        }