private void Menu_SavePNG_Click(object sender, EventArgs e) { var pb = WinFormsUtil.GetUnderlyingControl <PictureBox>(sender); if (pb?.Image == null) { WinFormsUtil.Alert(MessageStrings.MsgNoPictureLoaded); return; } CM_Picture.Close(ToolStripDropDownCloseReason.CloseCalled); const string name = "map"; using var sfd = new SaveFileDialog { Filter = "png file (*.png)|*.png|All files (*.*)|*.*", FileName = $"{name}.png", }; if (sfd.ShowDialog() != DialogResult.OK) { return; } if (!Menu_SavePNGTerrain.Checked) { PB_Map.Image.Save(sfd.FileName, ImageFormat.Png); } else if (!Menu_SavePNGItems.Checked) { PB_Map.BackgroundImage.Save(sfd.FileName, ImageFormat.Png); } else { var img = (Bitmap)PB_Map.BackgroundImage.Clone(); using var gfx = Graphics.FromImage(img); gfx.DrawImage(PB_Map.Image, new Point(0, 0)); img.Save(sfd.FileName, ImageFormat.Png); } }
private void Menu_SavePNG_Click(object sender, EventArgs e) { var pb = WinFormsUtil.GetUnderlyingControl <PictureBox>(sender); if (pb?.Image == null) { WinFormsUtil.Alert("No picture loaded."); return; } string name; if (pb == PB_Player) { name = SAV.Players[PlayerIndex].Personal.Name; } else if (pb == PB_Villager) { name = L_ExternalName.Text; } else { name = "photo"; } var bmp = pb.Image; using var sfd = new SaveFileDialog { Filter = "png file (*.png)|*.png|All files (*.*)|*.*", FileName = $"{name}.png", }; if (sfd.ShowDialog() != DialogResult.OK) { return; } bmp.Save(sfd.FileName, ImageFormat.Png); }
private void ClickClone(object sender, EventArgs e) { var pb = WinFormsUtil.GetUnderlyingControl <PictureBox>(sender); if (pb == null) { return; } var index = SlotPictureBoxes.IndexOf(pb); var item = GetItem(index); for (int i = 0; i < SlotPictureBoxes.Count; i++) { if (i == index) { continue; } var dest = GetItem(i); dest.CopyFrom(item); SlotPictureBoxes[i].BackgroundImage = Sprites.GetImage(item, L_ItemName.Font); } System.Media.SystemSounds.Asterisk.Play(); }