コード例 #1
0
ファイル: ViewController.cs プロジェクト: hyunjay/image-map
        private Task ImportFromSettings(long id, Edition edition, MapCreationSettings settings)
        {
            var number = settings.NumberOfMaps;
            var boxes  = new MapIDControl[number];

            for (int i = 0; i < number; i++)
            {
                var box = new MapIDControl(id + i);
                boxes[i]       = box;
                box.MouseDown += Box_MouseDown;
            }
            SendToZone(boxes, MapStatus.Importing);
            Task <IEnumerable <Map> > t;

            if (edition == Edition.Java)
            {
                t = new Task <IEnumerable <Map> >(() =>
                {
                    return(JavaMap.FromSettings(settings));
                });
            }
            else
            {
                t = new Task <IEnumerable <Map> >(() =>
                {
                    return(BedrockMap.FromSettings(settings));
                });
            }
            t.ContinueWith((prev) =>
            {
                settings.Dispose();
                if (t.IsFaulted)
                {
                    MessageBox.Show($"Failed to create some maps for this reason: {ExceptionMessage(t.Exception)}", "Map load error!");
                    RemoveFromZone(boxes, MapStatus.Importing);
                }
                var results = prev.Result.ToArray();
                for (int i = 0; i < number; i++)
                {
                    boxes[i].SetBox(new MapPreviewBox(results[i]));
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
            return(t);
        }
コード例 #2
0
 public override IEnumerable <Map> MapsFromSettings(MapCreationSettings settings, IProgress <MapCreationProgress> progress)
 {
     // bedrock maps are fast enough that reporting progress is not needed
     return(BedrockMap.FromSettings(settings));
 }