Exemple #1
0
        private void TryImport(OpenedFile[] files)
        {
            // Whether at least one file was successfully imported
            var successfulImport = false;
            // Whether at least one .evol file failed to be imported
            var failedImport = false;

            foreach (OpenedFile file in files)
            {
                var extension = file.Extension.ToLower();
                if (extension.Equals(".evol"))
                {
                    var encoded = file.ToUTF8String();
                    try {
                        var simulationData = SimulationSerializer.ParseSimulationData(encoded, file.Name);
                        // SimulationSerializer.SaveSimulation(simulationData);
                    } catch {
                        failedImport = true;
                        Debug.LogError(string.Format("Failed to parse .evol file contents: {0}", encoded));
                        continue;
                    }
                    SimulationSerializer.SaveSimulationFile(file.Name, encoded, false);
                    successfulImport = true;
                }
            }
            RefreshCache();
            try {
                viewController.Refresh();
            } catch {
                DelayExtensions.Delay(this, 0.2f, delegate() { viewController.Refresh(); });
            }
            if (successfulImport)
            {
                importIndicator.FadeInOut();
            }
            if (failedImport)
            {
                failedImportIndicator.FadeInOut(1.8f);
            }
        }