public static void ClickEvent(MouseEventArgs e, MapPanelEditor mapEditor, MyPanel.MyPanel control) { MapPanelMouse.NowUpTime = MapPanelMouse.CurrentTimeMillis; if (e.Button == MouseButtons.Right && MapPanelMouse.IsMouseHold() == false) { Point nowClick = new Point(e.X, e.Y); if (mapEditor.ImagBlockCus == true) { Point old = new Point(mapEditor.ImLineXOld, mapEditor.ImLineYOld); Point now = new Point(mapEditor.ImLineXNow, mapEditor.ImLineYNow); Rectangle rec = mapEditor.GetExpandRectangleFromDiagonalPoints(old, now); if (mapEditor.RectangleContainsPoint(rec, nowClick) == true) { control.MouseRightDownMenu.Show(control, nowClick); } else { mapEditor.DataInit(); } } else { control.MouseRightDownMenu.Show(control, nowClick); } } }
public static void DownEvent(MouseEventArgs e, MapPanelEditor mapEditor, MyPanel.MyPanel MapPanel) { MapPanelMouse.NowDownTime = MapPanelMouse.CurrentTimeMillis; MapPanel.Focus(); MapPanelMouse.RecordDownPoint(e, mapEditor); MapPanelShow showTemp = new MapPanelShow(mapEditor); int MapTotalSizeX = showTemp.MapTotalSizeX; int MapTotalSizeY = showTemp.MapTotalSizeY; if (e.X >= MapTotalSizeX || e.Y >= MapTotalSizeY) { return; } if (e.X < 0 || e.Y < 0) { return; } if (e.Button == MouseButtons.Right) { MapDragPlace.IsEnter = false; MapDragPlace.IsOver = false; MoveXOld = e.X; MoveYOld = e.Y; mapEditor.MapDragEN = true; mapEditor.SelectedIndex = MapPanelMouse.DownSelectIndex(e, mapEditor); } else if (e.Button == MouseButtons.Left) { SmartPaste.HoverPasteInit(); mapEditor.SelectedIndex = MapPanelMouse.DownSelectIndex(e, mapEditor); MapPanelMouse.ImLineFisrtDown(e, mapEditor); mapEditor.Imaginary = true; mapEditor.ImagBlockCus = false; } else if (e.Button == MouseButtons.Middle) { mapEditor.ImagBlockCus = false; MoveXOld = e.X; MoveYOld = e.Y; mapEditor.Magnify = true; mapEditor.SelectedIndex = MapPanelMouse.DownSelectIndex(e, mapEditor); MapPanel.Refresh(); } }
public static void UpEvent(MouseEventArgs e, MapPanelEditor mapEditor, MyPanel.MyPanel MapPanel) { MapPanelMouse.NowUpTime = MapPanelMouse.CurrentTimeMillis; mapEditor.MapDragEN = false; mapEditor.Magnify = false; mapEditor.Imaginary = false; SmartPaste.HoverPasteInit(); if (e.Button == MouseButtons.Left) { int MapTotalSizeX = mapEditor.PictureSize * MapPanelEditor.RowNum + mapEditor.MapLeft; int MapTotalSizeY = mapEditor.PictureSize * MapPanelEditor.RowNum + mapEditor.MapTop; if (MapPanelMouse.IsMouseHold() == true) { mapEditor.ImagBlockCus = true; } } }
/// <summary> /// 地图编辑器初始化 /// </summary> /// <returns>无返回值</returns> public void Init() { #region MapEditorInit MyMapEditor = new MapPanelEditor(); MyMapEditor.OnPanelRefresh += () => { MapPanel?.Refresh(); }; #endregion #region MapPanelInit MapPanel.MouseRightDownMenu = MapPanelMenu; MapPanel.Paint += (sender, e) => { new MapPanelShow(MyMapEditor) .DrawMapPicture(e.Graphics) .DrawSelectedIndex(e.Graphics) .DrawImagenaryAndBlock(e.Graphics) .DrawOver(e.Graphics) .DrawPasteHover(e.Graphics); }; MapPanel.DragDrop += (sender, e) => { MapPanelMouse.DragDropEvent(e, MyMapEditor, MapPanel); MapPanel.Refresh(); }; MapPanel.DragEnter += (sender, e) => { MapPanelMouse.DragEnterEvent(e, MyMapEditor, MapPanel); MapPanel.Refresh(); }; MapPanel.DragLeave += (sender, e) => { MapPanelMouse.DragLeaveEvent(e, MyMapEditor, MapPanel); MapPanel.Refresh(); }; MapPanel.MouseDown += (sender, e) => { MapPanelMouse.DownEvent(e, MyMapEditor, MapPanel); MapPanel.Refresh(); }; MapPanel.MouseUp += (sender, e) => { MapPanelMouse.UpEvent(e, MyMapEditor, MapPanel); this.Cursor = Cursors.Default; MapPanel.Refresh(); }; MapPanel.MouseClick += (sender, e) => { MapPanelMouse.ClickEvent(e, MyMapEditor, MapPanel); MapPanel.Refresh(); }; MapPanel.MouseMove += (sender, e) => { MapPanelMouse.MoveEvent(e, MyMapEditor, MapPanel, Map_VScrollBar, Map_HScrollBar); }; MapPanel.MouseWheel += (sender, e) => { if (MyMapEditor.ControlWheel == true) { this.Cursor = Cursors.Cross; MyMapEditor.DataInit(); MyMapEditor.PictureSize = MapPanelMouse.WheelChangePicSize(e, MyMapEditor); new MapScrollBar(Map_VScrollBar, Map_HScrollBar, MyMapEditor) .ChangeInfo().AutoDudge(); MapPanel.Refresh(); } }; MapPanel.MouseDoubleClick += (sender, e) => { int MapTotalSizeX = MyMapEditor.PictureSize * MapPanelEditor.RowNum + MyMapEditor.MapLeft; int MapTotalSizeY = MyMapEditor.PictureSize * MapPanelEditor.RowNum + MyMapEditor.MapTop; if (e.X >= MapTotalSizeX || e.Y >= MapTotalSizeY) { return; } if (e.X < 0 || e.Y < 0) { return; } if (e.Button == MouseButtons.Left) { if (MyMapEditor.SelectedIndex == -1) { return; } MapEditorRedo(); MyMapEditor.MapIMG_Block[MyMapEditor.SelectedIndex] = MyMapEditor.MapCathe; MapPlaceCom(); } }; MapPanel.KeyUp += delegate { MyMapEditor.ControlWheel = false; this.Cursor = Cursors.Default; }; #endregion #region MapFileInit // try { FileMap.LoadSaveAppInfo(MyMapEditor); MapPanel.Refresh(); } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } #endregion #region MapListBoxInit mapListBox = new Form_MapListBoxShow(this); #endregion #region ScollBarInit new MapScrollBar(Map_VScrollBar, Map_HScrollBar, MyMapEditor) .ChangeInfo(); #endregion #region ToolStripMenuInit MapThemeChange.ListoolStripInfo.Add(遗迹主题ToolStripMenuItem); MapThemeChange.ListoolStripInfo.Add(海岸主题ToolStripMenuItem); MapThemeChange.ListoolStripInfo.Add(山地主题ToolStripMenuItem); MapThemeChange.ListoolStripInfo.Add(城堡主题ToolStripMenuItem); MapThemeChange.ListoolStripInfo.Add(城市主题ToolStripMenuItem); MapThemeChange.ListoolStripInfo.Add(未来城主题ToolStripMenuItem); MapThemeChange.ListoolStripInfo.Add(太空主题ToolStripMenuItem); MapThemeChange.ListoolStripInfo.Add(异次元主题ToolStripMenuItem); MapThemeChange.ListoolStripInfo.Add(博士基地主题ToolStripMenuItem); for (int i = 0; i < MapThemeChange.ListoolStripInfo.Count; ++i) { MapThemeChange.ListoolStripInfo[i].Tag = i; } ChangeToolStripInfo(); ChangeToolMenuItemInfo(); TimerPublicInfoRenew.Start(); #endregion }