示例#1
0
        protected async void OnFirstLoadMats(object sender, EventArgs e)
        {
            form.SetLoadingState();
            InitialMats = await api.GetMaterialsSheet();

            UpdateMaterialsList();
            form.SetReadyState();
        }
示例#2
0
        private async Task <InventorySet> FigureOutInaraCorrection()
        {
            // Get current inventory as represented on Inara.cz
            api.ClearMaterialsCache();
            var inaraMats = await api.GetMaterialsSheet();

            // If everything matches, there are no corrections
            if (last.ExactlyEquals(inaraMats))
            {
                return(null);
            }

            // Look for new stuff on Inara
            var inaraChange = new HashSet <string>(inaraMats.Keys);

            inaraChange.ExceptWith(new HashSet <string>(last.Keys));

            // If Inara has new mats, cheat until we can get an update out
            if (inaraChange.Count > 0)
            {
                foreach (var mat in inaraMats.Keys)
                {
                    dm.EliteMatsLookup[mat.Replace(" ", "").ToLower()] = mat;
                    dm.MaterialTypeLookup[mat] = "Material";
                }
            }

            if (form.DoesUserWantInaraCorrection())
            {
                // Apply a correction to Picard's values
                return(inaraMats - last);
            }
            else
            {
                // Quit without saving
                Application.Exit();
                return(null);
            }
        }