コード例 #1
0
        private void 检索ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MyMapEditor.SelectedIndex == -1)
            {
                MessageBox.Show("请选择一个地图块!!");
                return;
            }
            List <int> list       = new List <int>(); list.Clear();
            int        ctrlfIndex = MyMapEditor.MapImage2Int(MyMapEditor.MapIMG_Block[MyMapEditor.SelectedIndex]);

            for (int i = 0; i < MapPanelEditor.PictureTotal; ++i)
            {
                if (MyMapEditor.MapIMG_Block[i] ==
                    MyMapEditor.ThemeBar[MyMapEditor.ThemeNum][ctrlfIndex])
                {
                    list.Add(i);
                }
            }

            new Form_Message(list, ctrlfIndex, MyMapEditor, (s, t) =>
            {
                var form = s as Form_Message;
                if (Form_Message.GlobalFlag == true)
                {
                    MyMapEditor.SelectedIndex = form.PassIndex;
                    new MapScrollBar(Map_VScrollBar, Map_HScrollBar, MyMapEditor)
                    .AutoDudge();
                    MapPanel.Refresh();
                    this.Focus();
                }
            }).Show();
        }
コード例 #2
0
ファイル: FileMap.cs プロジェクト: Peefy/DB2MapEditor
 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);
         }
     }
 }
コード例 #3
0
        private void Form_SmartEditor_Paint(object sender, PaintEventArgs e)
        {
            #region 画笔画刷定义
            Pen p = new Pen(Color.Black);
            #endregion
            #region 原始地图缩略图
            for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i)   //方块
            {
                int Temp = MapEditor.MapImage2Int(MapEditor.MapSmartE[i]);
                e.Graphics.FillRectangle(PaintHelper.BrushBlock[MapEditor.ThemeNum][Temp], new Rectangle(OPoint.X + i % (MapPanelEditor.RowNum) * MapPanelEditor.GridLenth,
                                                                                                         OPoint.Y + i / (MapPanelEditor.RowNum) * MapPanelEditor.GridLenth,
                                                                                                         MapPanelEditor.GridLenth, MapPanelEditor.GridLenth));
            }

            #endregion
            #region 用户自定义Map
            int Count_Temp = DesBrushRanc.Count;
            for (int i = 0; i <= Count_Temp - 1; ++i)
            {
                SolidBrush SBrush_Temp = new SolidBrush(DesBrushRanc[i].color);
                e.Graphics.FillRectangle(SBrush_Temp, new Rectangle(DesBrushRanc[i].point.X,
                                                                    DesBrushRanc[i].point.Y,
                                                                    MapPanelEditor.GridLenth, MapPanelEditor.GridLenth));
            }
            #endregion
            #region 网格线
            if (LinesEN == true)
            {
                for (int i = 0; i <= MapPanelEditor.RowNum; ++i)   //横线
                {
                    e.Graphics.DrawLine(p, OPoint.X, OPoint.Y + i * MapPanelEditor.GridLenth,
                                        OPoint.X + GridTotalLenth, OPoint.Y + i * MapPanelEditor.GridLenth);
                }
                for (int i = 0; i <= MapPanelEditor.RowNum; ++i)   //竖线
                {
                    e.Graphics.DrawLine(p, OPoint.X + i * MapPanelEditor.GridLenth, OPoint.Y,
                                        OPoint.X + i * MapPanelEditor.GridLenth, OPoint.Y + GridTotalLenth);
                }
            }
            #endregion
        }
コード例 #4
0
 private void btn_Grid2Draft_Click(object sender, EventArgs e)
 {
     this.UseWaitCursor = true;
     this.Cursor        = Cursors.WaitCursor;
     PaintHelper        = new BrushBlockHelper();
     DesBrushRanc.Clear();
     for (int i = 0; i < MapPanelEditor.PictureTotal; ++i)
     {
         PointBrush pb = new PointBrush();
         pb.clickindex = i;
         int mapid = MapEditor.MapImage2Int(MapEditor.MapIMG_Block[i]);
         pb.color = PaintHelper.BrushBlock[MapEditor.ThemeNum][mapid].Color;
         pb.point =
             new Point(OPoint.X + i % MapPanelEditor.RowNum * MapPanelEditor.GridLenth,
                       OPoint.Y + i / 40 * MapPanelEditor.GridLenth);
         DesBrushRanc.Add(pb);
     }
     this.Refresh();
     this.Cursor        = Cursors.Default;
     this.UseWaitCursor = false;
 }
コード例 #5
0
 public void Add(int index)
 {
     this.Index.Enqueue(index);
     this.Image.Add(MapEditor.MapIMG_Block[index]);
     this.ImageInThemeBarIndex.Add(MapEditor.MapImage2Int(MapEditor.MapIMG_Block[index]));
 }
コード例 #6
0
ファイル: Form_Grid.cs プロジェクト: Peefy/DB2MapEditor
        private void Form_Grid_Paint(object sender, PaintEventArgs e)
        {
            #region 画笔画刷定义
            //Graphics g = this.CreateGraphics();
            Pen p  = new Pen(Color.Black);
            Pen Wp = new Pen((LinesEN == true) ? Color.White : Color.Black, 3);
            Pen Sp = new Pen(MapEditor.MapCusorColor, 2);

            #endregion
            #region 地图信息
            if (isGameGrid == false)
            {
                for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i)   //方块
                {
                    int Temp = MapEditor.MapImage2Int(MapEditor.MapIMG_Block[i]);
                    e.Graphics.FillRectangle(PaintHelper.BrushBlock[MapEditor.ThemeNum][Temp], new Rectangle(OPoint.X + i % (MapPanelEditor.RowNum) * MapPanelEditor.GridLenth,
                                                                                                             OPoint.Y + i / (MapPanelEditor.RowNum) * MapPanelEditor.GridLenth,
                                                                                                             MapPanelEditor.GridLenth, MapPanelEditor.GridLenth));
                }
            }
            else
            {
                for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i)
                {
                    int Temp = MapEditor.MapImage2Int(MapEditor.MapIMG_Block[i]);
                    e.Graphics.DrawImage(PaintHelper.GameGridImageList[MapEditor.ThemeNum][Temp]
                                         , OPoint.X + i % (MapPanelEditor.RowNum) * 9, OPoint.Y + i / (MapPanelEditor.RowNum) * 9);
                }
            }
            #region 网格线
            if (LinesEN == true)
            {
                for (int i = 0; i <= MapPanelEditor.RowNum; ++i)   //横线
                {
                    e.Graphics.DrawLine(p, OPoint.X, OPoint.Y + i * MapPanelEditor.GridLenth,
                                        OPoint.X + GridTotalLenth, OPoint.Y + i * MapPanelEditor.GridLenth);
                }
                for (int i = 0; i <= MapPanelEditor.RowNum; ++i)   //竖线
                {
                    e.Graphics.DrawLine(p, OPoint.X + i * MapPanelEditor.GridLenth, OPoint.Y,
                                        OPoint.X + i * MapPanelEditor.GridLenth, OPoint.Y + GridTotalLenth);
                }
            }

            #endregion
            #endregion
            #region 框框
            if (isShowKuang == true)
            {
                WhiteLineLenthX = MapEditor.Size.Width / MapEditor.PictureSize * MapPanelEditor.GridLenth;
                WhiteLineLenthY = MapEditor.Size.Height / MapEditor.PictureSize * MapPanelEditor.GridLenth;
                int     Num_X = -MapEditor.MapLeft / MapEditor.PictureSize;
                int     Num_Y = -MapEditor.MapTop / MapEditor.PictureSize;
                Point[] POINT = new Point[4];
                POINT[0] = new Point(Num_X * MapPanelEditor.GridLenth + OPoint.X,
                                     Num_Y * MapPanelEditor.GridLenth + OPoint.Y);
                POINT[1] = new Point(Num_X * MapPanelEditor.GridLenth + OPoint.X + WhiteLineLenthX,
                                     Num_Y * MapPanelEditor.GridLenth + OPoint.Y);
                POINT[2] = new Point(Num_X * MapPanelEditor.GridLenth + OPoint.X,
                                     Num_Y * MapPanelEditor.GridLenth + OPoint.Y + WhiteLineLenthY);
                POINT[3] = new Point(Num_X * MapPanelEditor.GridLenth + OPoint.X + WhiteLineLenthX,
                                     Num_Y * MapPanelEditor.GridLenth + OPoint.Y + WhiteLineLenthY);
                e.Graphics.DrawLine(Wp, POINT[0], POINT[1]);
                e.Graphics.DrawLine(Wp, POINT[0], POINT[2]);
                e.Graphics.DrawLine(Wp, POINT[1], POINT[3]);
                e.Graphics.DrawLine(Wp, POINT[2], POINT[3]);
            }

            #endregion
            #region 显示选中光标
            if (MapEditor.SelectedIndex != -1)
            {
                int     xtemp  = (MapEditor.SelectedIndex) % 40;
                int     ytemp  = (MapEditor.SelectedIndex) / 40;
                Point[] POINT_ = new Point[4];
                POINT_[0] = new Point(xtemp * MapPanelEditor.GridLenth + OPoint.X,
                                      ytemp * MapPanelEditor.GridLenth + OPoint.Y);
                POINT_[1] = new Point(xtemp * MapPanelEditor.GridLenth + OPoint.X + MapPanelEditor.GridLenth,
                                      ytemp * MapPanelEditor.GridLenth + OPoint.Y);
                POINT_[2] = new Point(xtemp * MapPanelEditor.GridLenth + OPoint.X,
                                      ytemp * MapPanelEditor.GridLenth + OPoint.Y + MapPanelEditor.GridLenth);
                POINT_[3] = new Point(xtemp * MapPanelEditor.GridLenth + OPoint.X + MapPanelEditor.GridLenth,
                                      ytemp * MapPanelEditor.GridLenth + OPoint.Y + MapPanelEditor.GridLenth);
                e.Graphics.DrawLine(Sp, POINT_[0], POINT_[1]);
                e.Graphics.DrawLine(Sp, POINT_[0], POINT_[2]);
                e.Graphics.DrawLine(Sp, POINT_[1], POINT_[3]);
                e.Graphics.DrawLine(Sp, POINT_[2], POINT_[3]);
            }
            #endregion
        }
コード例 #7
0
ファイル: FileMap.cs プロジェクト: Peefy/DB2MapEditor
        /// <summary>
        /// 存入配置文件
        /// </summary>
        public static bool ClosingSaveAppInfo(MapPanelEditor mapEditor)
        {
            #region 存入配置文件
            try
            {
                if (Directory.Exists(ConfigPath) == false)
                {
                    Directory.CreateDirectory(ConfigPath);
                }
                FileStream   fs = new FileStream(ConfigPath + ConfigSaveFileName, FileMode.Create);
                BinaryWriter w  = new BinaryWriter(fs);
                #region 要存入的参数或者字符串

                w.Write(mapEditor.ThemeNum);
                for (int i = 0; i <= MapPanelEditor.PictureTotal - 1; ++i)
                {
                    w.Write(mapEditor.MapImage2Int(mapEditor.MapIMG_Block[i]));
                }

                w.Write(ToolStripOperation.IndexList.Count);
                for (int i = 0; i <= ToolStripOperation.IndexList.Count - 1; ++i)
                {
                    w.Write(ToolStripOperation.IndexList[i]);
                }

                string path = AppInfo.GetConfigPath() + "\\ComPlace";
                if (Directory.Exists(path) == false)
                {
                    Directory.CreateDirectory(path);
                }

                w.Write(ComposePlace.List.Count);
                for (int i = 0; i <= ComposePlace.List.Count - 1; ++i)
                {
                    ComposePlace.List[i].WriteToFile(w);
                }

                #endregion
                w.Flush();
                w.Close();
                fs.Close();
            }
            catch (Exception es)
            {
                throw (es);
            }
            #endregion
            #region 存入软件设置
            try
            {
                if (Directory.Exists(ConfigPath) == false)
                {
                    Directory.CreateDirectory(ConfigPath);
                }
                FileStream   fs = new FileStream(ConfigPath + OptionsSaveFileName, FileMode.Create);
                BinaryWriter w  = new BinaryWriter(fs);
                #region 要存入的参数或者字符串
                foreach (int id in QuickPlaceKey.KeyValueToMapId)
                {
                    w.Write(id);
                }

                w.Write(mapEditor.PictureSize);
                w.Write(mapEditor.MapCusorWidth);

                #endregion
                w.Flush();
                w.Close();
                fs.Close();
            }
            catch (Exception es)
            {
                throw (es);
            }
            #endregion
            return(true);
        }