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); }
private void BtnDuplicateMap_Click(object sender, EventArgs e) { if (activeMap != null) { SelectElement(null); activeMap = mapList.AddMap(CaptureMapAspect(), elements); UpdateToolbarAndDropStatus(); } }
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); } }
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(); }
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); }
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(); } }