Ejemplo n.º 1
0
        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);
                }
            }
        }
Ejemplo n.º 2
0
        public void KeyNumQuickPlace(Keys key)
        {
            if (mapEditor.SelectedIndex == -1)
            {
                return;
            }
            int KeyVal = 0;

            if (key == Keys.D0)
            {
                KeyVal = 10 - 1;
            }
            else
            {
                KeyVal = (int)(key - Keys.D0) - 1;
            }
            if (mapEditor.ImagBlockCus == false)
            {
                OnceOperation.RedoOneMap(mapEditor.SelectedIndex, mapEditor);
                mapEditor.MapIMG_Block[mapEditor.SelectedIndex] =
                    mapEditor.ThemeBar[mapEditor.ThemeNum][KeyValueToMapId[KeyVal]];
                OnceOperation.ClearResume();
            }
            else
            {
                //if (mapEditor.NowMap == AroundMap.MapNone)
                //   return;
                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;

                PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.RectanglePastePlace, mapEditor);

                for (int j = 0; j < ytemp; ++j)
                {
                    int index = 0;
                    for (int i = 0; i < xtemp; ++i)
                    {
                        index = i + Index_Temp + j * 40;
                        OperationTemp.Items.Add(index);
                        mapEditor.MapIMG_Block[index] = mapEditor.ThemeBar[mapEditor.ThemeNum][KeyValueToMapId[KeyVal]];
                    }
                }
                OnceOperation.Redo(OperationTemp);
                OnceOperation.ClearResume();
                mapEditor.DataInit();
            }
        }
Ejemplo n.º 3
0
        public bool Place()
        {
            PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.RectanglePastePlace, mapEditor);

            for (int j = 0; j < ytemp; ++j)
            {
                int index = 0;
                for (int i = 0; i < xtemp; ++i)
                {
                    index = i + Index_Temp + j * 40;
                    OperationTemp.Items.Add(index);
                    mapEditor.MapIMG_Block[index] = mapEditor.MapCathe;
                }
            }
            OnceOperation.Redo(OperationTemp);
            OnceOperation.ClearResume();

            mapEditor.DataInit();

            return(true);
        }
Ejemplo n.º 4
0
        private void MapPanel_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
            if (e.Modifiers.CompareTo(Keys.Shift) == 0 && e.KeyCode == Keys.C)
            {
                MyMapEditor.SelectedIndex = -1;
            }
            else if (e.Modifiers.CompareTo(Keys.Control) == 0)
            {
                switch (e.KeyCode)
                {
                case Keys.Z:
                    撤销ToolStripMenuItem_Click(null, null);
                    break;

                case Keys.V:
                    粘贴ToolStripMenuItem_Click(null, null);
                    break;

                case Keys.S:
                    FileMap.ClosingSaveAppInfo(MyMapEditor);
                    break;

                case Keys.X:
                    剪切ToolStripMenuItem_Click(null, null);
                    break;

                case Keys.Y:
                    重做ToolStripMenuItem_Click(null, null);
                    break;

                case Keys.F:
                    检索ToolStripMenuItem_Click(null, null);
                    break;

                case Keys.C:
                    制ToolStripMenuItem_Click(null, null);
                    break;

                case Keys.Space:
                    粘贴ToolStripMenuItem_Click(null, null);
                    break;
                }
                MapPlaceCom();
                MyMapEditor.ControlWheel = true;
            }
            else if (e.Modifiers.CompareTo(Keys.Alt) == 0)
            {
                switch (e.KeyCode)
                {
                case Keys.C:
                    SmartPaste.State = null;
                    mapListBox.label_SmartPasteNum.Text = "智能编辑:Null";
                    mapListBox.SmartPasteBox.Image      = null;
                    break;
                }
            }
            else if (e.KeyCode == Keys.Space)
            {
                if (MyMapEditor.ImagBlockCus == false)
                {
                    if (MyMapEditor.SelectedIndex == -1)
                    {
                        return;
                    }
                    MapEditorRedo();
                    MapPlaceCom();
                    MyMapEditor.MapIMG_Block[MyMapEditor.SelectedIndex] = MyMapEditor.MapCathe;
                }
                else
                {
                    if (new MapMorePictures(MyMapEditor).Place() == false)
                    {
                        return;
                    }
                    MapPlaceCom();
                }
            }
            else if (e.KeyCode == Keys.A)
            {
                if (MyMapEditor.ImagBlockCus == false)
                {
                    MyMapEditor.DataInit();
                }
                else
                {
                    if (new MapMorePictures(MyMapEditor).MoveOperation(AroundMap.MapLeft) == false)
                    {
                        return;
                    }
                    MapPlaceCom();
                }
            }
            else if (e.KeyCode == Keys.D)
            {
                if (MyMapEditor.ImagBlockCus == false)
                {
                    MyMapEditor.DataInit();
                }
                else
                {
                    if (new MapMorePictures(MyMapEditor).MoveOperation(AroundMap.MapRight) == false)
                    {
                        return;
                    }
                    MapPlaceCom();
                }
            }
            else if (e.KeyCode == Keys.W)
            {
                if (MyMapEditor.ImagBlockCus == false)
                {
                    MyMapEditor.DataInit();
                }
                else
                {
                    if (new MapMorePictures(MyMapEditor).MoveOperation(AroundMap.MapUp) == false)
                    {
                        return;
                    }
                    MapPlaceCom();
                }
            }
            else if (e.KeyCode == Keys.S)
            {
                if (MyMapEditor.ImagBlockCus == false)
                {
                    MyMapEditor.DataInit();
                }
                else
                {
                    if (new MapMorePictures(MyMapEditor).MoveOperation(AroundMap.MapDown) == false)
                    {
                        return;
                    }
                    MapPlaceCom();
                }
            }
            MapPanel.Focus();
            MapPanel.Refresh();
        }
Ejemplo n.º 5
0
        /// <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
        }