private void MenuOpen_Click(object sender, EventArgs e) { if (!Directory.Exists(Environment.CurrentDirectory + @"\Project\")) { Directory.CreateDirectory(Environment.CurrentDirectory + @"\Project\"); } var dialog = new OpenFileDialog() { InitialDirectory = Environment.CurrentDirectory + @"\Project\", Filter = "Engine Maps (*.mps) | *.mps", CheckFileExists = true, CheckPathExists = true, Multiselect = false, FilterIndex = 0 }; var result = dialog.ShowDialog(); if (result == DialogResult.OK) { var db = new Database(); Map = (Map)db.Open(dialog.FileName); ProjectPath = dialog.FileName; SafeFileName = dialog.SafeFileName; UpdateTitle(); UpdateSize(); } PictureMap.Invalidate(); }
private void RadioDirection_CheckedChanged(object sender, EventArgs e) { GroupAttributes.Enabled = false; ButtonClearDirection.Enabled = true; MenuCreateMap.Enabled = false; PictureMap.Invalidate(); }
public virtual void MouseEventDraw(System.Windows.Forms.MouseEventArgs e, bool move, Brick pbrk_NewBrick) { int x = fpcp_Map.GetMapIndexX(e.X); int y = fpcp_Map.GetMapIndexY(e.Y); if (Util.IsValidPoint(this.fpcp_Map, x, y)) { if (move) { switch (e.Button) { case MouseButtons.Left: this.MouseLeftMoveDraw(x, y, pbrk_NewBrick); fpcp_Map.Invalidate(); break; case MouseButtons.Right: this.MouseRightMoveDraw(x, y, pbrk_NewBrick); fpcp_Map.Invalidate(); break; case MouseButtons.None: this.MouseMoveDraw(x, y, pbrk_NewBrick); fpcp_Map.Invalidate(); break; } } else { switch (e.Button) { case MouseButtons.Left: this.MouseLeftDraw(x, y, pbrk_NewBrick); fpcp_Map.Invalidate(); break; case MouseButtons.Right: this.MouseRightDraw(x, y, pbrk_NewBrick); fpcp_Map.Invalidate(); break; } } } }
private void PictureMap_MouseDown(object sender, MouseEventArgs e) { var clicked_x = ((StartX * PicSize) + e.X) / TileSize; var clicked_y = ((StartY * PicSize) + e.Y) / TileSize; var clicked_tile = GetClickedAreaIndex(clicked_x, clicked_y); var x = (e.X / PicSize) + StartX; var y = (e.Y / PicSize) + StartY; if (RadioGround.Checked) { if (e.Button == MouseButtons.Left) { OpenParallaxImage(Map.Ground, clicked_tile); } else if (e.Button == MouseButtons.Right) { Map.Ground[clicked_tile].Bitmap = null; Map.Ground[clicked_tile].Name = "Empty"; } } else if (RadioFringe.Checked) { if (e.Button == MouseButtons.Left) { OpenParallaxImage(Map.Fringe, clicked_tile); } else if (e.Button == MouseButtons.Right) { Map.Fringe[clicked_tile].Bitmap = null; Map.Fringe[clicked_tile].Name = "Empty"; } } else if (RadioAttributes.Checked) { if (e.Button == MouseButtons.Left) { SelectAttribute(x, y); } else if (e.Button == MouseButtons.Right) { DiselectAttribute(x, y); } } if (RadioDirection.Checked) { if (e.Button == MouseButtons.Left) { SetDirection(x, y, e.X, e.Y); } } PictureMap.Invalidate(); }
private void ScrollGridOpacity_Scroll(object sender, ScrollEventArgs e) { var value = ScrollGridOpacity.Value; LabelGridOpacity.Text = "Grid Map: " + value; var white_brush = new SolidBrush(Color.FromArgb(value, Color.LightGray)); white_pen = new Pen(white_brush, 1); PictureMap.Invalidate(); }
private void ClearDirections() { for (var x = 0; x < Map.Property.Width; x++) { for (var y = 0; y < Map.Property.Height; y++) { ClearDirection(x, y); } } PictureMap.Invalidate(); }
private void ClearAttributes() { for (var x = 0; x < Map.Property.Width; x++) { for (var y = 0; y < Map.Property.Height; y++) { ClearAttribute(x, y); } } PictureMap.Invalidate(); }
private void ScrollParallaxOpacity_Scroll(object sender, ScrollEventArgs e) { var value = ScrollParallaxOpacity.Value; LabelParallaxOpacity.Text = "Grid Parallax: " + value; var coral_brush = new SolidBrush(Color.FromArgb(value, Color.Coral)); coral_pen = new Pen(coral_brush, 3); PictureMap.Invalidate(); }
public void UpdateSize() { var value_x = Map.Property.Width - MaxGridViewValueX; var value_y = Map.Property.Height - MaxGridViewValueY; if (value_x < 0) { value_x = 0; } if (value_y < 0) { value_y = 0; } if (StartX > value_x) { StartX = value_x; } if (StartY > value_y) { StartY = value_y; } ScrollStartX.Maximum = value_x; ScrollStartY.Maximum = value_y; ScrollStartX.Value = StartX; ScrollStartY.Value = StartY; LabelX.Text = "X: " + StartX; LabelY.Text = "Y: " + StartY; Map.UpdatSize(); PictureMap.Invalidate(); }
private void OpenParallaxImage(List <Parallax> list, int index) { var dialog = new OpenFileDialog() { InitialDirectory = Environment.CurrentDirectory, Filter = "Image Files (*.png) | *.png", CheckFileExists = true, CheckPathExists = true, Multiselect = false, FilterIndex = 0 }; var result = dialog.ShowDialog(); if (result == DialogResult.OK) { var bitmap = new Bitmap(dialog.FileName); list[index].Bitmap = bitmap; list[index].Name = dialog.SafeFileName; PictureMap.Invalidate(); } }
private void ButtonChangeColor(object sender, EventArgs e) { var dialog = new ColorDialog() { AllowFullOpen = true, AnyColor = true, FullOpen = true, SolidColorOnly = false }; SolidBrush brush; var result = dialog.ShowDialog(); if (result == DialogResult.OK) { brush = new SolidBrush(dialog.Color); ((Button)sender).BackColor = dialog.Color; } else { return; } var full_name = ((Button)sender).Name; var index = full_name.Substring(full_name.Length - 1, 1); var name = full_name.Replace(index, string.Empty); if (name == "ButtonBackColor") { switch (int.Parse(index)) { case 0: brushBackBlock = brush; break; case 1: brushBackAvoid = brush; break; case 2: brushBackTrap = brush; break; case 3: brushBackChat = brush; break; case 4: brushBackWarp = brush; break; } } else if (name == "ButtonForeColor") { switch (int.Parse(index)) { case 0: brushForeBlock = brush; break; case 1: brushForeAvoid = brush; break; case 2: brushForeTrap = brush; break; case 3: brushForeChat = brush; break; case 4: brushForeWarp = brush; break; } } PictureMap.Invalidate(); }
private void ScrollStartY_Scroll(object sender, ScrollEventArgs e) { StartY = ScrollStartY.Value; LabelY.Text = "Y: " + StartY; PictureMap.Invalidate(); }
private void PictureMap_MouseMove(object sender, MouseEventArgs e) { if (GroupAttributes.Enabled) { //var clicked_x = ((StartX * PicSize) + e.X) / TileSize; //var clicked_y = ((StartY * PicSize) + e.Y) / TileSize; //var clicked_tile = GetClickedAreaIndex(clicked_x, clicked_y); var x = (e.X / PicSize) + StartX; var y = (e.Y / PicSize) + StartY; if (RadioAttributes.Checked) { if (e.Button == MouseButtons.Left) { SelectAttribute(x, y); } else if (e.Button == MouseButtons.Right) { DiselectAttribute(x, y); } PictureMap.Invalidate(); } } if (GetAsyncKeyState(Keys.ShiftKey) < 0) { if (e.X > lastMouseX) { if (StartX < ScrollStartX.Maximum) { StartX++; } } else { if (StartX > 1) { StartX--; } } lastMouseX = e.X; ScrollStartX.Value = StartX; LabelX.Text = "X: " + StartX; PictureMap.Invalidate(); } if (GetAsyncKeyState(Keys.ControlKey) < 0) { if (e.Y > lastMouseY) { if (StartY < ScrollStartY.Maximum) { StartY++; } } else { if (StartY > 1) { StartY--; } } lastMouseY = e.Y; ScrollStartY.Value = StartY; LabelY.Text = "Y: " + StartY; PictureMap.Invalidate(); } }
private void MenuFringeView_Click(object sender, EventArgs e) { ViewFringe = MenuFringeView.Checked; PictureMap.Invalidate(); }
private void MenuParallaxId_Click(object sender, EventArgs e) { ViewParallaxId = MenuParallaxId.Checked; PictureMap.Invalidate(); }
private void MenuGroundView_Click(object sender, EventArgs e) { ViewGround = MenuGroundView.Checked; PictureMap.Invalidate(); }
private void MenuGridViewParallax_Click(object sender, EventArgs e) { viewGridParallax = MenuGridViewParallax.Checked; PictureMap.Invalidate(); }
private void MenuGridViewTile_Click(object sender, EventArgs e) { ViewGridTile = MenuGridViewTile.Checked; PictureMap.Invalidate(); }
private void CreateMapFromImage(string fileName, string safeFileName) { var bitmap = new Bitmap(fileName); var count_x = bitmap.Width / PicSize; var count_y = bitmap.Height / PicSize; var tile_count_x = bitmap.Width / TileSize; var tile_count_y = bitmap.Height / TileSize; if (count_x <= 0) { ShowInvalidImage(); return; } if (count_y <= 0) { ShowInvalidImage(); return; } if (bitmap.Width % PicSize > 0) { count_x++; } if (bitmap.Height % PicSize > 0) { count_y++; } if (bitmap.Width % TileSize > 0) { tile_count_x++; } if (bitmap.Height % TileSize > 0) { tile_count_y++; } if (Map.Property.Width != count_x) { Map.Property.Width = count_x; } if (Map.Property.Height != count_y) { Map.Property.Height = count_y; } UpdateSize(); var count = 0; Bitmap new_bitmap; CreateMapFolder(GetCompleteFolder(GetFolderName(safeFileName))); var new_bitmap_path = GetCompleteFolder(GetFolderName(safeFileName)); for (var x = 0; x < tile_count_x; x++) { for (var y = 0; y < tile_count_y; y++) { new_bitmap = CreateTileFromImage(ref bitmap, x, y); if (RadioGround.Checked) { Map.Ground[count].Name = $"{safeFileName}_ground_{count + 1}"; Map.Ground[count].Bitmap = new_bitmap; new_bitmap.Save(new_bitmap_path + $@"\{safeFileName}_ground_{count + 1}.png"); } else if (RadioFringe.Checked) { Map.Fringe[count].Name = $"{safeFileName}_fringe_{count + 1}"; Map.Fringe[count].Bitmap = new_bitmap; new_bitmap.Save(new_bitmap_path + $@"\{safeFileName}_fringe_{count + 1}.png"); } count++; } } PictureMap.Invalidate(); }
private void ScrollStartX_Scroll(object sender, ScrollEventArgs e) { StartX = ScrollStartX.Value; LabelX.Text = "X: " + StartX; PictureMap.Invalidate(); }