예제 #1
0
 public void RemoveFromZone(IEnumerable <MapIDControl> boxes, MapStatus location)
 {
     foreach (var box in boxes)
     {
         box.SetSelected(false);
         box.SetConflict(false);
         if (box == LastImportSelected)
         {
             LastImportSelected = null;
         }
         if (box == LastExistingSelected)
         {
             LastExistingSelected = null;
         }
         if (location == MapStatus.Importing)
         {
             UI.ImportZone.Controls.Remove(box);
             ImportingMapPreviews.Remove(box);
         }
         else if (location == MapStatus.Existing)
         {
             UI.ExistingZone.Controls.Remove(box);
             ExistingMapPreviews.Remove(box);
         }
     }
 }
예제 #2
0
        private void ClickSelect(MapIDControl box, MapStatus area)
        {
            MapIDControl current = area == MapStatus.Importing ? LastImportSelected : LastExistingSelected;
            var          list    = area == MapStatus.Importing ? ImportingMapPreviews : ExistingMapPreviews;

            box.ToggleSelected();
            if (Control.ModifierKeys == Keys.Shift && current != null)
            {
                bool state = current.Selected;
                int  first = list.IndexOf(current);
                int  last  = list.IndexOf(box);
                for (int i = Math.Min(first, last); i < Math.Max(first, last); i++)
                {
                    list[i].SetSelected(state);
                }
            }
            if (area == MapStatus.Importing)
            {
                LastImportSelected = box;
            }
            else
            {
                LastExistingSelected = box;
            }
        }
예제 #3
0
        public MapIDControl NewMapIDControl(long id, Map map)
        {
            MapIDControl box = new MapIDControl(id, map);

            box.MouseDown += Box_MouseDown;
            return(box);
        }
예제 #4
0
 private MapStatus?WhereIsBox(MapIDControl box)
 {
     if (ImportingMapPreviews.Contains(box))
     {
         return(MapStatus.Importing);
     }
     if (ExistingMapPreviews.Contains(box))
     {
         return(MapStatus.Existing);
     }
     return(null);
 }
예제 #5
0
        private void ClickSelect(MapIDControl box)
        {
            var controls = Controls.OfType <MapIDControl>().ToList();
            var current  = LastSelected;

            box.ToggleSelected();
            if (Control.ModifierKeys == Keys.Shift && current != null)
            {
                bool state = current.IsSelected;
                int  first = controls.IndexOf(current);
                int  last  = controls.IndexOf(box);
                for (int i = Math.Min(first, last); i < Math.Max(first, last); i++)
                {
                    controls[i].SetSelected(state);
                }
            }
            LastSelected = box;
        }
예제 #6
0
        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);
        }
예제 #7
0
        private void NewWorldOpened()
        {
            ImportingMapPreviews.Clear();
            ExistingMapPreviews.Clear();

            UI.MapViewZone.Visible = true;
            UI.ImportZone.Controls.Clear();
            UI.ImportZone.Controls.Add(UI.ClickOpenLabel);
            UI.ClickOpenLabel.Visible = true;
            UI.ExistingZone.Controls.Clear();
            UI.ProcessingMapsDone();
            foreach (var map in SelectedWorld.WorldMaps.OrderBy(x => x.Key))
            {
                MapIDControl mapbox = new MapIDControl(map.Key, new MapPreviewBox(map.Value));
                mapbox.MouseDown += Box_MouseDown;
                SendToZone(mapbox, MapStatus.Existing);
            }
            UI.Text = "Image Map – " + SelectedWorld.Name;
        }
예제 #8
0
 public void RemoveFromZone(MapIDControl box, MapStatus location)
 {
     RemoveFromZone(new MapIDControl[] { box }, location);
 }
예제 #9
0
 private void SendToZone(MapIDControl box, MapStatus location)
 {
     SendToZone(new MapIDControl[] { box }, location);
 }
예제 #10
0
 public void SaveMap(MapIDControl map, string file)
 {
     map.Map.Image.Save(file);
 }