public static bool LoadMapInfo(string path, MapPanelEditor mapEditor) { if (File.Exists(path)) { try { FileStream fs = new FileStream(path, FileMode.Open); BinaryReader r = new BinaryReader(fs); OnceOperation.RedoAllMap(mapEditor); for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i) { mapEditor.MapIMG_Block[i] = mapEditor.Int2MapImage(r.ReadInt32()); } OnceOperation.ClearResume(); SmartPaste.HoverPasteInit(); r.Close(); fs.Close(); } catch { return(false); } return(true); } else { return(false); } }
public void MapLoad(MapPanelEditor mapEditor, OpenFileDialog openFileDialog) { openFileDialog.FilterIndex = 1; openFileDialog.Filter = new FileMap.FileOperator().MapSaveFilter; openFileDialog.RestoreDirectory = true; if (openFileDialog.ShowDialog() == DialogResult.OK) { string resultFile = openFileDialog.FileName; if (File.Exists(resultFile)) { try { FileStream fs = new FileStream(resultFile, FileMode.Open); BinaryReader r = new BinaryReader(fs); OnceOperation.RedoAllMap(mapEditor); for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i) { mapEditor.MapIMG_Block[i] = mapEditor.Int2MapImage(r.ReadInt32()); } OnceOperation.ClearResume(); r.Close(); fs.Close(); } catch (Exception ex) { throw (ex); //MessageBox.Show(ex.Message); } } } }
public static int WheelChangePicSize(MouseEventArgs e, MapPanelEditor mapEditor) { int PicSize_Temp = mapEditor.PictureSize; PicSize_Temp += (int)(e.Delta * 0.1); return(MyPublicFuntion.MathFunctionDefine.Range(PicSize_Temp, MinPicSize, MaxPicSize)); }
public SmartPaste(SmartPasteCopyKind kind, MapPanelEditor mapedi) { MapEditor = mapedi; this.Items = new MapBlockContent(MapEditor); CopyMapThemeNum = MapEditor.ThemeNum; Size = new Size(); CopyKind = kind; int ImagOldLeft = MapEditor.MapLeft; int ImagOldTop = MapEditor.MapTop; int ImagBlockCusx1 = MapEditor.ImagBlockCusx1; int ImagBlockCusy1 = MapEditor.ImagBlockCusy1; int ImagBlockCusx2 = MapEditor.ImagBlockCusx2; int ImagBlockCusy2 = MapEditor.ImagBlockCusy2; int Index_Temp = (ImagBlockCusx1 - ImagOldLeft) / MapEditor.PictureSize + (ImagBlockCusy1 - ImagOldTop) / MapEditor.PictureSize * 40; int xtemp = (ImagBlockCusx2 - ImagBlockCusx1) / MapEditor.PictureSize; int ytemp = (ImagBlockCusy2 - ImagBlockCusy1) / MapEditor.PictureSize; this.Size = new Size(xtemp, ytemp); for (int j = 0; j < ytemp; ++j) { int index = 0; for (int i = 0; i < xtemp; ++i) { index = i + Index_Temp + j * 40; this.Items.Add(index); SmartPaste.State = this; } } SmartPaste.IsPasteIng = true; }
public void MapSave(MapPanelEditor mapEditor, SaveFileDialog saveFileDialog) { saveFileDialog.FilterIndex = 1; saveFileDialog.Filter = new FileOperator().MapSaveFilter; saveFileDialog.RestoreDirectory = true; if (saveFileDialog.ShowDialog() == DialogResult.OK) { System.IO.FileStream fst = (System.IO.FileStream)saveFileDialog.OpenFile(); //输出文件 fst.Close(); var savePath = saveFileDialog.FileName.ToString(); //获得文件路径 try { FileStream fs = new FileStream(savePath, FileMode.Create); BinaryWriter w = new BinaryWriter(fs); for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i) { w.Write(mapEditor.MapImage2Int(mapEditor.MapIMG_Block[i])); } w.Flush(); w.Close(); fs.Close(); MessageBox.Show("保存地图方案成功!"); } catch (Exception ex) { throw (ex); } } }
public static void ImLineFisrtDown(MouseEventArgs e, MapPanelEditor mapEditor) { mapEditor.ImLineXOld = e.X; mapEditor.ImLineYOld = e.Y; mapEditor.ImLineXNow = e.X; mapEditor.ImLineYNow = e.Y; }
public MapBlockContent(MapPanelEditor mapedi) { MapEditor = mapedi; Index = new Queue <int>(); Image = new List <Image>(); ImageInThemeBarIndex = new List <int>(); }
public static int DownSelectIndex(MouseEventArgs e, MapPanelEditor mapEditor) { mapEditor.MapClickXnum = e.X - (e.X - mapEditor.MapLeft) % mapEditor.PictureSize; mapEditor.MapClickYnum = e.Y - (e.Y - mapEditor.MapTop) % mapEditor.PictureSize; return((mapEditor.MapClickXnum - mapEditor.MapLeft) / mapEditor.PictureSize + (mapEditor.MapClickYnum - mapEditor.MapTop) / mapEditor.PictureSize * 40); }
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 Form_Draft(MapPanelEditor mapedi) { InitializeComponent(); SendMessage((IntPtr)this.Handle, WM_SETREDRAW, FALSE, 0); MapEditor = mapedi; this.Refresh(); }
public SmartPaste(MapPanelEditor mapedi) { MapEditor = mapedi; this.Items = new MapBlockContent(MapEditor); CopyMapThemeNum = MapEditor.ThemeNum; Size = new Size(); CopyKind = SmartPasteCopyKind.NoneCopy; }
public static bool Paste(MapPanelEditor mapEditor) { MapEditor = mapEditor; bool IsSuccessPaste = true; if (MapEditor.SelectedIndex == -1) { return(false); } PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.PastePlace, MapEditor); try { if (SmartPaste.State == null) { return(true); } int num = MapPanelEditor.RowNum; int width = SmartPaste.State.Size.Width; int height = SmartPaste.State.Size.Height; if (SmartPaste.IsPasteIng == true) { int minIndex = SmartPaste.State.MinIndex; if (minIndex == -1) { return(false); } int iterator = 0; foreach (int IndexTemp in SmartPaste.State.Items.Index) { if (SmartPaste.State.CopyKind == SmartPasteCopyKind.CtrlX) { OperationTemp.Items.Add(IndexTemp); MapEditor.MapIMG_Block[IndexTemp] = MapEditor.ThemeBar[MapEditor.ThemeNum][(int)MapIdDefine.空地]; } int Index = MapEditor.SelectedIndex + IndexTemp - minIndex; int x = Index % num; int y = Index / num; //if ((x + width) > num || (y + height) > num) // continue; OperationTemp.Items.Add(Index); MapEditor.MapIMG_Block[Index] = MapEditor.ImgAutoImg(SmartPaste.State.Items.Image[iterator++], SmartPaste.State.CopyMapThemeNum); } } } catch { IsSuccessPaste = false; } finally { OnceOperation.Redo(OperationTemp); } if (SmartPaste.State.CopyKind == SmartPasteCopyKind.CtrlX) { SmartPaste.State = null; } return((IsSuccessPaste == false) ? false : true); }
public Form_Message(List <int> list, int id, MapPanelEditor mapedi) { InitializeComponent(); MapEditor = mapedi; IndexInfoList = list; CtrlfMapId = id; nmUD_CtrlfMapId.Value = CtrlfMapId; CtrlFInfoShow(); }
public static void RedoAllMap(MapPanelEditor MapEditor) { PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.AllMap, MapEditor); for (int index = 0; index <= MapPanelEditor.PictureTotal - 1; ++index) { OperationTemp.Items.Add(index); } OnceOperation.Redo(OperationTemp); }
public Form_Message(List <int> list, int id, MapPanelEditor mapedi, EventHandler updateHandler) { InitializeComponent(); MapEditor = mapedi; IndexInfoList = list; CtrlfMapId = id; nmUD_CtrlfMapId.Value = CtrlfMapId; UpdateDataGridView += updateHandler; CtrlFInfoShow(); }
public static void DragDropEvent(DragEventArgs e, MapPanelEditor mapEditor, MyPanel.MyPanel MapPanel) { if (IsFileEnter == false) { return; } string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); FileMap.LoadMapInfo(path, mapEditor); MapPanel.Refresh(); }
public static void RedoOneMap(int index, MapPanelEditor MapEditor) { if (index == -1) { return; } PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.SinglePlace, MapEditor); OperationTemp.Items.Add(index); Redo(OperationTemp); }
public Form_SmartEditor(MapPanelEditor mapedi) { InitializeComponent(); SendMessage((IntPtr)this.Handle, WM_SETREDRAW, FALSE, 0); this.StartPosition = FormStartPosition.CenterScreen; MapEditor = mapedi; myPanel1.Paint += Form_SmartEditor_Paint; myPanel1.MouseMove += Form_SmartEditor_MouseMove; myPanel1.MouseDown += Form_SmartEditor_MouseDown; myPanel1.MouseUp += Form_SmartEditor_MouseUp; }
public Form_Option(MapPanelEditor mapEdi) { InitializeComponent(); this.WindowState = FormWindowState.Maximized; this.ControlBox = false; this.ShowIcon = false; this.ShowInTaskbar = false; this.ShowDrawIcon = false; mapEditor = mapEdi; this.nmudSetPictrueSize.Value = mapEditor.PictureSize; this.umudSetCusorWidth.Value = mapEditor.MapCusorWidth; }
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 MapListBoxInitClass Init(ChatListBox MapListBox, MapPanelEditor mapEditor) { MapListBox.Items.Clear(); foreach (string str in this.MapListBoxItemStr) { MapListBox.Items.Add(new ChatListItem(str)); } foreach (ChatListItem item in MapListBox.Items) { item.SubItems.Clear(); } InitMapListJudgeTheme(MapListBox, mapEditor); RenewComposePlace(MapListBox, mapEditor); return(this); }
public MapMorePictures(MapPanelEditor mapedi) { mapEditor = mapedi; ImagOldLeft = mapEditor.MapLeft; ImagOldTop = mapEditor.MapTop; ImagBlockCusx1 = mapEditor.ImagBlockCusx1; ImagBlockCusy1 = mapEditor.ImagBlockCusy1; ImagBlockCusx2 = mapEditor.ImagBlockCusx2; ImagBlockCusy2 = mapEditor.ImagBlockCusy2; Index_Temp = (ImagBlockCusx1 - ImagOldLeft) / mapEditor.PictureSize + (ImagBlockCusy1 - ImagOldTop) / mapEditor.PictureSize * 40; xtemp = (ImagBlockCusx2 - ImagBlockCusx1) / mapEditor.PictureSize; ytemp = (ImagBlockCusy2 - ImagBlockCusy1) / mapEditor.PictureSize; }
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; } } }
public Form_MapIdHexShow(MapPanelEditor mapedi) { InitializeComponent(); MapEditor = mapedi; this.StartPosition = FormStartPosition.CenterScreen; this.FormBorderStyle = FormBorderStyle.FixedSingle; this.MaximizeBox = false; //this.MinimizeBox = false; this.DoubleBuffered = true; //this.ControlBox = false; //this.ShowIcon = false; //this.ShowInTaskbar = false; //this.ShowDrawIcon = false; this.KeyPreview = true; //this.TopMost = true; }
public static void DragEnterEvent(DragEventArgs e, MapPanelEditor mapEditor, MyPanel.MyPanel MapPanel) { MapPanel.Focus(); string path = ((System.Array)e.Data.GetData(DataFormats.FileDrop)).GetValue(0).ToString(); if (MyPublicFuntion.StringOperation.GetFileexc(path) == MyPublicFuntion.StringOperation.GetFileexc(new FileMap.FileOperator().MapLoadFilter)) { e.Effect = DragDropEffects.All; IsFileEnter = true; } else { IsFileEnter = false; e.Effect = DragDropEffects.None; } MapPanel.Refresh(); }
public static bool Undo(MapPanelEditor MapEditor) { if (OnceOperation.StackIsNull() == true) { return(false); } PlaceOperation OperationTemp = Stack.Pop(); PlaceOperation ResumeOpTemp = new PlaceOperation(PlaceOperation.Kind.SinglePlace, MapEditor); ResumeStack.Push(ResumeOpTemp); //ResumeStack.Push(ResumeOpTemp); //ResumeStack.Pop(); switch (OperationTemp.OpKind) { case PlaceOperation.Kind.SinglePlace: case PlaceOperation.Kind.RectanglePastePlace: case PlaceOperation.Kind.AllMap: case PlaceOperation.Kind.LeftMove: case PlaceOperation.Kind.RightMove: case PlaceOperation.Kind.UpMove: case PlaceOperation.Kind.DownMove: case PlaceOperation.Kind.PastePlace: int iterator = 0; foreach (int IndexTemp in OperationTemp.Items.Index) { MapEditor.SelectedIndex = IndexTemp; ResumeOpTemp.Items.Add(MapEditor.SelectedIndex); MapEditor.MapIMG_Block[MapEditor.SelectedIndex] = MapEditor.Int2MapImage(OperationTemp.Items.ImageInThemeBarIndex[iterator++]); if (OperationTemp.Items.Image.Count == iterator) { return(true); } } break; } ResumeStack.Push(ResumeOpTemp); //ResumeStack.Push(ResumeOpTemp); return(true); }
public ComposePlace(MapPanelEditor MapEditor) { mapEditor = MapEditor; this.Items = new MapBlockContent(MapEditor); int ImagOldLeft = MapEditor.MapLeft; int ImagOldTop = MapEditor.MapTop; int ImagBlockCusx1 = MapEditor.ImagBlockCusx1; int ImagBlockCusy1 = MapEditor.ImagBlockCusy1; int ImagBlockCusx2 = MapEditor.ImagBlockCusx2; int ImagBlockCusy2 = MapEditor.ImagBlockCusy2; int Index_Temp = (ImagBlockCusx1 - ImagOldLeft) / MapEditor.PictureSize + (ImagBlockCusy1 - ImagOldTop) / MapEditor.PictureSize * 40; int xtemp = (ImagBlockCusx2 - ImagBlockCusx1) / MapEditor.PictureSize; int ytemp = (ImagBlockCusy2 - ImagBlockCusy1) / MapEditor.PictureSize; int picSize = 10; Image AddNewImg = new Bitmap(picSize * xtemp, picSize * ytemp); Graphics g = Graphics.FromImage(AddNewImg); for (int j = 0; j < ytemp; ++j) { int index = 0; for (int i = 0; i < xtemp; ++i) { index = i + Index_Temp + j * 40; this.Items.Add(index); Rectangle r = new Rectangle(i * picSize, j * picSize, picSize, picSize); g.DrawImage(MapEditor.MapIMG_Block[index], r); } } this.ShowImg = AddNewImg; this.Size = new Size(xtemp, ytemp); }
public void RenewComposePlace(ChatListBox MapListBox, MapPanelEditor mapEditor) { #region 常用放置 ADDacc = ComPlaceId; MapListBox.Items[ADDacc].SubItems.Clear(); MapAddNumber = ComposePlace.List.Count; MapListBoxItemAdd(ADDacc, MapAddNumber, MapListBox); foreach (ComposePlace com in ComposePlace.List) { com.RenewShowImgAndItemImage(); } for (int i = 0; i < MapAddNumber; ++i) { MapListBoxComposePlaceItemMessegeRenew(ComposePlace.List[i].ShowImg, ADDacc, i, i, "组合", ComposePlace.List[i].Size, MapListBox); } ++ADDacc; #endregion }
public MapPanelShow(MapPanelEditor mapeditor) { mapEditor = mapeditor; lenth = mapEditor.PictureSize; }
private PlaceOperation(MapPanelEditor mapEditor) { MapEditor = mapEditor; }