Beispiel #1
0
        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);
            }
        }
Beispiel #2
0
        private void TimerPublicInfoRenew_Tick(object sender, EventArgs e)
        {
            try
            {
                if (SmartPaste.State == null)
                {
                    粘贴ToolStripMenuItem.Enabled = false;
                    快速放置栏.Items[(int)(ToolStripOperation.KindEnum.Paste) /
                                ToolStripOperation.AssistantConstant - ToolStripOperation.minenum].Enabled = false;
                }
                else
                {
                    粘贴ToolStripMenuItem.Enabled = true;
                    快速放置栏.Items[(int)(ToolStripOperation.KindEnum.Paste) /
                                ToolStripOperation.AssistantConstant - ToolStripOperation.minenum].Enabled = true;
                }

                重做ToolStripMenuItem.Enabled = !OnceOperation.ResumeStackIsNull();
                快速放置栏.Items[(int)(ToolStripOperation.KindEnum.Resume) /
                            ToolStripOperation.AssistantConstant - ToolStripOperation.minenum].Enabled = !OnceOperation.ResumeStackIsNull();


                撤销ToolStripMenuItem.Enabled = !OnceOperation.StackIsNull();
                快速放置栏.Items[(int)(ToolStripOperation.KindEnum.Undo) /
                            ToolStripOperation.AssistantConstant - ToolStripOperation.minenum].Enabled = !OnceOperation.StackIsNull();

                SmartPaste.ShowHoverPaste();
                MapPanel.Refresh();
            }
            catch
            {
            }
        }
Beispiel #3
0
 public void  制ToolStripMenuItem1_Click(object sender, EventArgs e)
 {
     if (MapListBoxInitClass.ItemDownId == -1)
     {
         return;
     }
     if (MapListBoxInitClass.ItemDownId < 256)
     {
         MyMapEditor.MapCathe =
             MyMapEditor.ThemeBar[MyMapEditor.ThemeNum][MapListBoxInitClass.ItemDownId];
         mapListBox.PasteBox.Image = MyMapEditor.MapCathe;
     }
     else
     {
         SmartPaste NowPaste = new SmartPaste(SmartPasteCopyKind.CtrlC, MyMapEditor);
         NowPaste.Items = ComposePlace.List[MapListBoxInitClass.ItemDownId - 256].Items;
         Size sizetemp = ComposePlace.List[MapListBoxInitClass.ItemDownId - 256].Size;
         NowPaste.Size                  = sizetemp;
         SmartPaste.State               = NowPaste;
         SmartPaste.IsPasteIng          = true;
         mapListBox.SmartPasteBox.Image =
             mapListBox.MapListBox.Items[MapListBoxInitClass.ComPlaceId].
             SubItems[MapListBoxInitClass.ItemDownId - 256].HeadImage;
         mapListBox.label_SmartPasteNum.Text = "智能粘贴:" + "有" + SmartPaste.State.Items.Index.Count +
                                               "个图片元素 " + sizetemp.Width.ToString() + "×" + sizetemp.Height.ToString() + " 复制";
     }
 }
Beispiel #4
0
        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);
        }
Beispiel #5
0
 private void 粘贴ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (SmartPaste.Paste(MyMapEditor) == false)
     {
         MessageBox.Show("智能粘贴不完全成功!\r\n" + "原因选择坐标不合适!");//+
     }
     if (SmartPaste.State == null)
     {
         mapListBox.SmartPasteBox.Image      = null;
         mapListBox.label_SmartPasteNum.Text = "智能粘贴:Null";
     }
     OnceOperation.ClearResume();
     MapPlaceCom();
 }
Beispiel #6
0
        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();
            }
        }
Beispiel #7
0
        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;
                }
            }
        }
Beispiel #8
0
 private void 剪切ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MyMapEditor.SelectedIndex == -1)
     {
         return;
     }
     if (MyMapEditor.ImagBlockCus == false)
     {
         MyMapEditor.MapCathe      = MyMapEditor.MapIMG_Block[MyMapEditor.SelectedIndex];
         mapListBox.PasteBox.Image = MyMapEditor.MapIMG_Block[MyMapEditor.SelectedIndex];
     }
     else
     {
         var NowPaste = new SmartPaste(SmartPasteCopyKind.CtrlX, MyMapEditor);
         mapListBox.SmartPasteBox.Image      = SmartPaste.PasteImage;
         mapListBox.label_SmartPasteNum.Text = SmartPaste.TextShowStr;
     }
     MapPanel.Refresh();
 }
Beispiel #9
0
 private void MapPlaceCom()
 {
     MapPanel.Refresh();
     SmartPaste.HoverPasteInit();
 }