Ejemplo n.º 1
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;
            }
        }
Ejemplo n.º 2
0
 public void RemoveFromZone(MapIDControl box, MapStatus location)
 {
     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);
         box.MouseDown -= ImportingBox_MouseDown;
     }
     else if (location == MapStatus.Existing)
     {
         UI.ExistingZone.Controls.Remove(box);
         ExistingMapPreviews.Remove(box);
         box.MouseDown -= ExistingBox_MouseDown;
     }
 }
Ejemplo n.º 3
0
        public void ImportImages(string[] imagepaths)
        {
            bool java   = (SelectedWorld is JavaWorld);
            var  import = new ImportWindow(java);

            import.InterpolationModeBox.SelectedIndex = Properties.Settings.Default.InterpIndex;
            import.ApplyAllCheck.Checked = Properties.Settings.Default.ApplyAllCheck;
            import.DitherChecked         = Properties.Settings.Default.Dither;
            import.StartImports(UI, imagepaths);
            Properties.Settings.Default.InterpIndex   = import.InterpolationModeBox.SelectedIndex;
            Properties.Settings.Default.ApplyAllCheck = import.ApplyAllCheck.Checked;
            Properties.Settings.Default.Dither        = import.DitherChecked;
            long id    = GetSafeID();
            var  tasks = new List <Task>();

            UI.OpenButton.Enabled = false;
            UI.SendButton.Enabled = false;
            foreach (var settings in import.OutputSettings)
            {
                var boxes = new List <MapIDControl>();
                for (int i = 0; i < settings.SplitH * settings.SplitW; i++)
                {
                    var box = new MapIDControl(id);
                    boxes.Add(box);
                    SendToZone(box, MapStatus.Importing);
                    id++;
                }
                var t = new Task <IEnumerable <Map> >(() =>
                {
                    if (java)
                    {
                        return(JavaMap.FromSettings(settings));
                    }
                    else
                    {
                        return(BedrockMap.FromSettings(settings));
                    }
                });
                t.Start();
                t.ContinueWith((prev) =>
                {
                    var results = prev.Result.ToArray();
                    for (int i = 0; i < settings.SplitH * settings.SplitW; i++)
                    {
                        boxes[i].SetBox(new MapPreviewBox(results[i]));
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
                tasks.Add(t);
            }
            var done = Task.WhenAll(tasks);

            done.ContinueWith((t) =>
            {
                UI.OpenButton.Enabled = true;
                UI.SendButton.Enabled = true;
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Ejemplo n.º 4
0
        // right-click maps to remove them
        private void ImportingBox_MouseDown(object sender, MouseEventArgs e)
        {
            MapIDControl box = sender as MapIDControl;

            if (e.Button == MouseButtons.Right)
            {
                ImportingMapPreviews.Remove(box);
                UI.ImportZone.Controls.Remove(box);
            }
        }
Ejemplo n.º 5
0
        private void NewWorldOpened()
        {
            ImportingMapPreviews.Clear();
            ExistingMapPreviews.Clear();

            UI.MapViewZone.Visible = true;
            UI.ImportZone.Controls.Clear();
            UI.ExistingZone.Controls.Clear();
            foreach (var map in SelectedWorld.WorldMaps.OrderBy(x => x.Key))
            {
                MapIDControl mapbox = new MapIDControl(map.Key, new MapPreviewBox(map.Value));
                SendToZone(mapbox, MapStatus.Existing);
            }
            UI.Text = "Image Map – " + SelectedWorld.Name;
        }
Ejemplo n.º 6
0
 private void SendToZone(MapIDControl box, MapStatus location)
 {
     if (location == MapStatus.Importing)
     {
         RemoveFromZone(box, MapStatus.Existing);
         UI.ImportZone.Controls.Add(box);
         ImportingMapPreviews.Add(box);
         box.MouseDown += ImportingBox_MouseDown;
     }
     else if (location == MapStatus.Existing)
     {
         RemoveFromZone(box, MapStatus.Importing);
         UI.ExistingZone.Controls.Add(box);
         ExistingMapPreviews.Add(box);
         box.MouseDown += ExistingBox_MouseDown;
     }
 }
Ejemplo n.º 7
0
        private void ExistingBox_MouseDown(object sender, MouseEventArgs e)
        {
            MapIDControl box = sender as MapIDControl;

            if (e.Button == MouseButtons.Right)
            {
                if (!box.Selected)
                {
                    foreach (var other in ExistingMapPreviews)
                    {
                        other.SetSelected(false);
                    }
                    box.SetSelected(true);
                }
                UI.ExistingContextMenu.Show(box, new Point(e.X, e.Y));
            }
            else
            {
                ClickSelect(box, MapStatus.Existing);
            }
        }
Ejemplo n.º 8
0
        public void ImportImages(string[] imagepaths)
        {
            var import = new ImportWindow();

            import.InterpolationModeBox.SelectedIndex = Properties.Settings.Default.InterpIndex;
            import.ApplyAllCheck.Checked = Properties.Settings.Default.ApplyAllCheck;
            import.StartImports(UI, imagepaths);
            Properties.Settings.Default.InterpIndex   = import.InterpolationModeBox.SelectedIndex;
            Properties.Settings.Default.ApplyAllCheck = import.ApplyAllCheck.Checked;
            var taken = ImportingMapPreviews.Concat(ExistingMapPreviews).Select(x => x.ID).ToList();

            taken.Add(-1);
            long id = taken.Max() + 1;

            foreach (var image in import.OutputImages)
            {
                MapIDControl mapbox = new MapIDControl(id, SelectedWorld is JavaWorld ? (Map) new JavaMap(image) : new BedrockMap(image));
                ImportingMapPreviews.Add(mapbox);
                UI.ImportZone.Controls.Add(mapbox);
                mapbox.MouseDown += ImportingBox_MouseDown;
                id++;
            }
        }
Ejemplo n.º 9
0
 public void SaveMap(MapIDControl map, string file)
 {
     map.Map.Image.GetImage().Save(file);
 }