Example #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);
            }
        }
Example #2
0
 private void 重做ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     OnceOperation.Resume(MyMapEditor);
     new MapScrollBar(Map_VScrollBar, Map_HScrollBar, MyMapEditor)
     .AutoDudge();
     MapPlaceCom();
 }
Example #3
0
        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);
                    }
                }
            }
        }
Example #4
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
            {
            }
        }
Example #5
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);
        }
Example #6
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();
            }
        }
Example #7
0
        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);
        }
Example #8
0
 private void MapAllClrRedo()
 {
     for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i)
     {
         MyMapEditor.MapAllClrImgList.Add(MyMapEditor.MapIMG_Block[i]);
     }
     OnceOperation.ClearResume();
     MapPlaceCom();
     MyMapEditor.ALLClrUndoFlag = true;
 }
Example #9
0
 private void MapEditorRedo()
 {
     try
     {
         OnceOperation.ClearResume();
         OnceOperation.RedoOneMap(MyMapEditor.SelectedIndex, MyMapEditor);
     }
     catch { }
     MapPlaceCom();
 }
Example #10
0
        private void MapEditorUndo()
        {
            if (OnceOperation.Undo(MyMapEditor) == false)
            {
                return;
            }

            MyMapEditor.DataInit();
            new MapScrollBar(Map_VScrollBar, Map_HScrollBar, MyMapEditor)
            .AutoDudge();
            MapPlaceCom();
        }
Example #11
0
 private void 全部变为花地ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("是否全部变为空地", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
     {
         OnceOperation.RedoAllMap(MyMapEditor);
         for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i)
         {
             MyMapEditor.MapIMG_Block[i] = MyMapEditor.ThemeBar[MyMapEditor.ThemeNum][(int)MapIdDefine.花地Start + 2];
         }
         OnceOperation.ClearResume();
         MapPlaceCom();
     }
 }
Example #12
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();
 }
Example #13
0
 void FormSmartEditorShow()
 {
     if (formSmart.ShowDialog() == DialogResult.OK)
     {
         PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.PastePlace, MyMapEditor);
         int            CountTemp     = formSmart.DesBrushRanc.Count;
         for (int i = 0; i <= CountTemp - 1; ++i)
         {
             int IndexTemp = formSmart.DesBrushRanc[i].clickindex;
             OperationTemp.Items.Add(IndexTemp);
             if (formSmart.DesBrushRanc[i].color == SmartEditor.ColorBlock[0].BackColor)
             {
                 SmartEditor NowSE = new SmartEditor(MyMapEditor);
                 NowSE.Start(MapStructureKind.Water, formSmart.DesBrushRanc, i);
             }
             if (formSmart.DesBrushRanc[i].color == SmartEditor.ColorBlock[1].BackColor)
             {
                 SmartEditor NowSE = new SmartEditor(MyMapEditor);
                 NowSE.Start(MapStructureKind.Magma, formSmart.DesBrushRanc, i);
             }
             if (formSmart.DesBrushRanc[i].color == SmartEditor.ColorBlock[2].BackColor)
             {
                 SmartEditor NowSE = new SmartEditor(MyMapEditor);
                 NowSE.Start(MapStructureKind.Ice, formSmart.DesBrushRanc, i);
             }
             if (formSmart.DesBrushRanc[i].color == SmartEditor.ColorBlock[3].BackColor)
             {
                 SmartEditor NowSE = new SmartEditor(MyMapEditor);
                 //NowSE.Start(MapStructureKind.Universe, Form_Temp, i);
             }
             if (formSmart.DesBrushRanc[i].color == SmartEditor.ColorBlock[4].BackColor)
             {
                 SmartEditor NowSE = new SmartEditor(MyMapEditor);
                 NowSE.Start(MapStructureKind.MountainTop, formSmart.DesBrushRanc, i);
             }
         }
         OnceOperation.Redo(OperationTemp);
         MapPlaceCom();
         formSmart.Close();
     }
 }
Example #14
0
        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);
        }
Example #15
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);
        }
Example #16
0
 public void MapListBox_ClickSubItem(object sender, CCWin.SkinControl.ChatListClickEventArgs e, MouseEventArgs es)
 {
     if (es.Button == MouseButtons.Left)
     {
         if (e.SelectSubItem.ID < 256)
         {
             if (MyMapEditor.SelectedIndex == -1)
             {
                 return;
             }
             MapEditorRedo();
             MyMapEditor.MapIMG_Block[MyMapEditor.SelectedIndex] =
                 MyMapEditor.ThemeBar[MyMapEditor.ThemeNum][Convert.ToInt32(e.SelectSubItem.ID)];
             MapPlaceCom();
         }
         else
         {
             if (MyMapEditor.SelectedIndex == -1)
             {
                 return;
             }
             PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.PastePlace, MyMapEditor);
             try
             {
                 int minIndex = ComposePlace.List[(int)e.SelectSubItem.ID - 256].MinIndex;
                 if (minIndex == -1)
                 {
                     return;
                 }
                 int num      = MapPanelEditor.RowNum;
                 int width    = ComposePlace.List[(int)e.SelectSubItem.ID - 256].Size.Width;
                 int height   = ComposePlace.List[(int)e.SelectSubItem.ID - 256].Size.Height;
                 int iterator = 0;
                 foreach (int IndexTemp in ComposePlace.List[(int)e.SelectSubItem.ID - 256].Items.Index)
                 {
                     int Index = MyMapEditor.SelectedIndex + IndexTemp - minIndex;
                     int x = Index % num; int y = Index / num;
                     if ((x + width) > num || (y + height) > num)
                     {
                         continue;
                     }
                     OperationTemp.Items.Add(Index);
                     MyMapEditor.MapIMG_Block[Index] = ComposePlace.List[(int)e.SelectSubItem.ID - 256].Items.Image[iterator++];
                 }
             }
             catch
             {
             }
             finally
             {
                 OnceOperation.Redo(OperationTemp);
             }
             OnceOperation.ClearResume();
             MapPlaceCom();
         }
     }
     else
     {
         MapListBoxInitClass.ItemDownId = (int)e.SelectSubItem.ID;
     }
 }
Example #17
0
        private void 智能连接ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <PointBrush> DesBrushRanc = new List <PointBrush>();

            int WaterMin = (int)MapIdDefine.水面Start;
            int WaterMax = (int)MapIdDefine.水面End;
            int MagmaMin = (int)MapIdDefine.岩浆Start;
            int MagmaMax = (int)MapIdDefine.岩浆End;

            SmartEditor.ColorBlock.Clear();
            for (int i = 0; i < 6; ++i)
            {
                SmartEditor.ColorBlock.Add(new PictureBox());
            }
            SmartEditor.ColorBlock[0].BackColor = Color.Blue;
            SmartEditor.ColorBlock[1].BackColor = Color.Red;
            SmartEditor.ColorBlock[2].BackColor = Color.LightBlue;
            SmartEditor.ColorBlock[3].BackColor = Color.Gray;
            SmartEditor.ColorBlock[4].BackColor = Color.Yellow;
            SmartEditor.ColorBlock[5].BackColor = Color.LightCyan;

            for (int i = 0; i < MapPanelEditor.PictureTotal; ++i)
            {
                int index = MyMapEditor.MapImage2Int(MyMapEditor.MapIMG_Block[i]);
                if (MyPublicFuntion.MathFunctionDefine.IsInRange(index, WaterMin, WaterMax) == true)
                {
                    int xnum = i / 40 + 1; int ynum = i % 40 + 1;
                    DesBrushRanc.Add(new PointBrush(new Point(xnum, ynum), SmartEditor.ColorBlock[0].BackColor, i));
                }
                else if (MyPublicFuntion.MathFunctionDefine.IsInRange(index, MagmaMin, MagmaMax) == true)
                {
                    int xnum = i / 40 + 1; int ynum = i % 40 + 1;
                    DesBrushRanc.Add(new PointBrush(new Point(xnum, ynum), SmartEditor.ColorBlock[1].BackColor, i));
                }
            }
            PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.PastePlace, MyMapEditor);
            int            CountTemp     = DesBrushRanc.Count;

            for (int i = 0; i <= CountTemp - 1; ++i)
            {
                int IndexTemp = DesBrushRanc[i].clickindex;
                OperationTemp.Items.Add(IndexTemp);
                if (DesBrushRanc[i].color == SmartEditor.ColorBlock[0].BackColor)
                {
                    SmartEditor NowSE = new SmartEditor(MyMapEditor);
                    NowSE.Start(MapStructureKind.Water, DesBrushRanc, i);
                }
                if (DesBrushRanc[i].color == SmartEditor.ColorBlock[1].BackColor)
                {
                    SmartEditor NowSE = new SmartEditor(MyMapEditor);
                    NowSE.Start(MapStructureKind.Magma, DesBrushRanc, i);
                }
                if (DesBrushRanc[i].color == SmartEditor.ColorBlock[2].BackColor)
                {
                    SmartEditor NowSE = new SmartEditor(MyMapEditor);
                    NowSE.Start(MapStructureKind.Ice, DesBrushRanc, i);
                }
                if (DesBrushRanc[i].color == SmartEditor.ColorBlock[3].BackColor)
                {
                    SmartEditor NowSE = new SmartEditor(MyMapEditor);
                    //NowSE.Start(MapStructureKind.Universe, Form_Temp, i);
                }
                if (DesBrushRanc[i].color == SmartEditor.ColorBlock[4].BackColor)
                {
                    SmartEditor NowSE = new SmartEditor(MyMapEditor);
                    NowSE.Start(MapStructureKind.MountainTop, DesBrushRanc, i);
                }
            }
            OnceOperation.Redo(OperationTemp);
            MapPlaceCom();
        }
Example #18
0
        public bool MoveOperation(AroundMap map)
        {
            Image[]        ImageCache    = new Image[xtemp * ytemp];
            PlaceOperation OperationTemp = new PlaceOperation(PlaceOperation.Kind.LeftMove, mapEditor);

            switch (map)
            {
            case AroundMap.MapLeft:
                for (int j = 0; j < ytemp; ++j)
                {
                    ImageCache[j] = mapEditor.MapIMG_Block[0 + Index_Temp + j * 40 - 1];
                    for (int i = 0; i < xtemp; ++i)
                    {
                        int index = i + Index_Temp + j * 40 - 1;
                        OperationTemp.Items.Add(index);
                        mapEditor.MapIMG_Block[i + Index_Temp + j * 40 - 1] = mapEditor.MapIMG_Block[i + Index_Temp + j * 40];
                    }
                    OperationTemp.Items.Add(xtemp - 1 + Index_Temp + j * 40);
                    mapEditor.MapIMG_Block[xtemp - 1 + Index_Temp + j * 40] = ImageCache[j];
                }
                break;

            case AroundMap.MapRight:
                for (int j = 0; j < ytemp; ++j)
                {
                    ImageCache[j] = mapEditor.MapIMG_Block[xtemp - 1 + Index_Temp + j * 40 + 1];
                    for (int i = xtemp - 1; i >= 0; --i)
                    {
                        OperationTemp.Items.Add(i + Index_Temp + j * 40 + 1);
                        mapEditor.MapIMG_Block[i + Index_Temp + j * 40 + 1] = mapEditor.MapIMG_Block[i + Index_Temp + j * 40];
                    }
                    OperationTemp.Items.Add(0 + Index_Temp + j * 40);
                    mapEditor.MapIMG_Block[0 + Index_Temp + j * 40] = ImageCache[j];
                }
                break;

            case AroundMap.MapUp:
                for (int i = 0; i < xtemp; ++i)
                {
                    ImageCache[i] = mapEditor.MapIMG_Block[i + Index_Temp - 1 * 40];
                    for (int j = 0; j < ytemp; ++j)
                    {
                        OperationTemp.Items.Add(i + Index_Temp + j * 40 - 40);
                        mapEditor.MapIMG_Block[i + Index_Temp + j * 40 - 40] = mapEditor.MapIMG_Block[i + Index_Temp + j * 40];
                    }
                    OperationTemp.Items.Add(i + Index_Temp + (ytemp - 1) * 40);
                    mapEditor.MapIMG_Block[i + Index_Temp + (ytemp - 1) * 40] = ImageCache[i];
                }
                break;

            case AroundMap.MapDown:
                for (int i = 0; i < xtemp; ++i)
                {
                    ImageCache[i] = mapEditor.MapIMG_Block[i + Index_Temp + (ytemp) * 40];
                    for (int j = ytemp - 1; j >= 0; --j)
                    {
                        OperationTemp.Items.Add(i + Index_Temp + j * 40 + 40);
                        mapEditor.MapIMG_Block[i + Index_Temp + j * 40 + 40] = mapEditor.MapIMG_Block[i + Index_Temp + j * 40];
                    }
                    OperationTemp.Items.Add(i + Index_Temp + 0 * 40);
                    mapEditor.MapIMG_Block[i + Index_Temp + 0 * 40] = ImageCache[i];
                }
                break;

            default:
                return(false);
            }

            OnceOperation.Redo(OperationTemp);
            OnceOperation.ClearResume();

            mapEditor.DataInit();

            return(true);
        }