Exemplo n.º 1
0
        private void CreateMap(BTMap newMap, bool Select)
        {
            PictureBox pb = new PictureBox();

            pb.Size        = new Size(ItemSize, ItemSize);
            pb.Image       = newMap.Image;
            pb.SizeMode    = PictureBoxSizeMode.Zoom;
            pb.BorderStyle = BorderStyle.None;
            pb.MouseDown  += Pb_MouseDown;

            ListedMap newListedMap = new ListedMap
            {
                Map    = newMap,
                Aspect = pb
            };

            maps.Add(newListedMap);

            if (currentMap != null)
            {
                currentMap.Aspect.BorderStyle = BorderStyle.None;
            }

            if (Select)
            {
                currentMap     = newListedMap;
                pb.BorderStyle = BorderStyle.FixedSingle;
            }

            viewPanel.Controls.Add(pb);
        }
Exemplo n.º 2
0
 private void BtnDuplicateMap_Click(object sender, EventArgs e)
 {
     if (activeMap != null)
     {
         SelectElement(null);
         activeMap = mapList.AddMap(CaptureMapAspect(), elements);
         UpdateToolbarAndDropStatus();
     }
 }
Exemplo n.º 3
0
        private void MapList_MapSelected(object sender, MapSelectedEventArgs e)
        {
            activeMap = e.SelectedMap;
            SelectElement(null);

            foreach (var elem in elements)
            {
                this.Controls.Remove(elem);
                elem.Dispose();
            }

            elements.Clear();

            if (activeMap == null)
            {
                return;
            }

            foreach (var elem in activeMap.Elements)
            {
                var set = PluginInstance.PluginRequestCharSet(elem.CharSetId, null, null).FirstOrDefault();

                if (set == null)
                {
                    continue;
                }

                var newLemen = new MapElement();
                newLemen.PixelScale = pixelScale;
                newLemen.Set        = set.Clone();
                newLemen.CellX      = elem.CharX;
                newLemen.CellY      = elem.CharY;
                newLemen.SetScale   = elem.Scale;
                newLemen.Click     += ElementOnDrag_Click;
                newLemen.Drag      += ElementOnDrag_Drag;
                newLemen.ExtraByte  = elem.ExtraData;

                this.Controls.Add(newLemen);
                newLemen.BringToFront();
                PlaceElement(newLemen);
                elements.Add(newLemen);
            }
        }
Exemplo n.º 4
0
        private void BtnNewMap_Click(object sender, EventArgs e)
        {
            if (activeMap != null)
            {
                foreach (var elem in elements)
                {
                    this.Controls.Remove(elem);
                    elem.Dispose();
                }
                elements.Clear();
                activeMap = null;
                this.Refresh();
            }

            var aspect = CaptureMapAspect();

            activeMap = mapList.AddMap(aspect, elements);
            UpdateToolbarAndDropStatus();
        }
Exemplo n.º 5
0
        public BTMap AddMap(Bitmap Image, IEnumerable <MapElement> Elements)
        {
            BTMap newMap = new BTMap
            {
                Id       = Guid.NewGuid(),
                Image    = Image,
                Elements = Elements.Select(e => new BTMapElement
                {
                    CharSetId = e.Set.Id,
                    CharX     = e.CellX,
                    CharY     = e.CellY,
                    Scale     = e.SetScale
                }).ToArray()
            };

            CreateMap(newMap, true);

            return(newMap);
        }
Exemplo n.º 6
0
        private void BtnDeleteMap_Click(object sender, EventArgs e)
        {
            if (activeMap != null)
            {
                if (MessageBox.Show("Delete map", "Warning!! Action cannot be undo, are you sure you want to completely delete the map?", MessageBoxButtons.YesNo) != DialogResult.Yes)
                {
                    return;
                }

                mapList.DeleteMap();
                foreach (var elem in elements)
                {
                    this.Controls.Remove(elem);
                    elem.Dispose();
                }
                elements.Clear();
                activeMap = null;
                SelectElement(null);
                UpdateToolbarAndDropStatus();
            }
        }