Exemplo n.º 1
0
        private void myPanel1_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.X - OPoint.X >= GridTotalLenth || e.Y - OPoint.Y >= GridTotalLenth)
            {
                return;
            }
            if (e.X - OPoint.X < 0 || e.Y - OPoint.Y < 0)
            {
                return;
            }
            int xnum   = e.X - (e.X - OPoint.X) % MapPanelEditor.GridLenth;
            int ynum   = e.Y - (e.Y - OPoint.Y) % MapPanelEditor.GridLenth;
            int xindex = (xnum - OPoint.X) / MapPanelEditor.GridLenth + 1;
            int yindex = (ynum - OPoint.Y) / MapPanelEditor.GridLenth + 1;

            X坐标.Text = "X坐标: " + xindex.ToString();
            Y坐标.Text = "Y坐标: " + yindex.ToString();
            if (LeftClickMoveEN == false && RightClickMoveEN == false)
            {
                return;
            }
            if (LeftClickMoveEN == true)
            {
                int        index       = (xnum - OPoint.X) / MapPanelEditor.GridLenth + (ynum - OPoint.Y) / MapPanelEditor.GridLenth * 40;
                Point      Point_Temp  = new Point(xnum, ynum);
                PointBrush PointB_Temp = new PointBrush(Point_Temp, SelectedColor, index);
                int        CountTemp   = DesBrushRanc.Count;
                for (int i = 0; i <= DesBrushRanc.Count - 1; i++)
                {
                    if (DesBrushRanc[i].point == PointB_Temp.point)
                    {
                        DesBrushRanc.RemoveAt(i);
                        break;
                    }
                }
                DesBrushRanc.Add(PointB_Temp);
            }
            if (RightClickMoveEN == true)
            {
                int        index       = (xnum - OPoint.X) / MapPanelEditor.GridLenth + (ynum - OPoint.Y) / MapPanelEditor.GridLenth * 40;
                Point      Point_Temp  = new Point(xnum, ynum);
                PointBrush PointB_Temp = new PointBrush(Point_Temp, SelectedColor, index);
                int        CountTemp   = DesBrushRanc.Count;
                for (int i = 0; i <= DesBrushRanc.Count - 1; i++)
                {
                    if (DesBrushRanc[i].point == PointB_Temp.point)
                    {
                        DesBrushRanc.RemoveAt(i);
                        break;
                    }
                }
            }
            myPanel1.Refresh();
        }
Exemplo n.º 2
0
 private void myPanel1_MouseDown(object sender, MouseEventArgs e)
 {
     if (e.X - OPoint.X >= GridTotalLenth || e.Y - OPoint.Y >= GridTotalLenth)
     {
         return;
     }
     if (e.X - OPoint.X < 0 || e.Y - OPoint.Y < 0)
     {
         return;
     }
     if (e.Button == MouseButtons.Left)
     {
         int        xnum        = e.X - (e.X - OPoint.X) % MapPanelEditor.GridLenth;
         int        ynum        = e.Y - (e.Y - OPoint.Y) % MapPanelEditor.GridLenth;
         int        index       = (xnum - OPoint.X) / MapPanelEditor.GridLenth + (ynum - OPoint.Y) / MapPanelEditor.GridLenth * MapPanelEditor.RowNum;
         Point      Point_Temp  = new Point(xnum, ynum);
         PointBrush PointB_Temp = new PointBrush(Point_Temp, SelectedColor, index);
         int        CountTemp   = DesBrushRanc.Count;
         for (int i = 0; i <= DesBrushRanc.Count - 1; i++)
         {
             if (DesBrushRanc[i].point == PointB_Temp.point)
             {
                 DesBrushRanc.RemoveAt(i);
                 break;
             }
         }
         DesBrushRanc.Add(PointB_Temp);
         LeftClickMoveEN = true;
     }
     else if (e.Button == MouseButtons.Right)
     {
         int        xnum        = e.X - (e.X - OPoint.X) % MapPanelEditor.GridLenth;
         int        ynum        = e.Y - (e.Y - OPoint.Y) % MapPanelEditor.GridLenth;
         int        index       = (xnum - OPoint.X) / MapPanelEditor.GridLenth + (ynum - OPoint.Y) / MapPanelEditor.GridLenth * 40;
         Point      Point_Temp  = new Point(xnum, ynum);
         PointBrush PointB_Temp = new PointBrush(Point_Temp, Color.Black, index);
         int        CountTemp   = DesBrushRanc.Count;
         for (int i = 0; i <= DesBrushRanc.Count - 1; i++)
         {
             if (DesBrushRanc[i].point == PointB_Temp.point)
             {
                 DesBrushRanc.RemoveAt(i);
                 break;
             }
         }
         RightClickMoveEN = true;
     }
     myPanel1.Refresh();
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
        private void 载入草稿_Click(object sender, EventArgs e)
        {
            if (载入草稿Dialog.ShowDialog() == DialogResult.OK)
            {
                string resultFile = 载入草稿Dialog.FileName;
                if (File.Exists(resultFile))
                {
                    try
                    {
                        FileStream   fs = new FileStream(resultFile, FileMode.Open);
                        BinaryReader r  = new BinaryReader(fs);

                        DesBrushRanc.Clear();

                        int CountTemp = r.ReadInt32();

                        for (int i = 0; i <= CountTemp - 1; i++)
                        {
                            int   x_temp, y_temp;
                            Color color_temp;
                            x_temp     = r.ReadInt32();
                            y_temp     = r.ReadInt32();
                            color_temp = ColorTranslator.FromHtml(r.ReadString());
                            Point      point_temp      = new Point(x_temp, y_temp);
                            PointBrush pointbrush_temp = new PointBrush(point_temp, color_temp, i);
                            DesBrushRanc.Add(pointbrush_temp);
                        }

                        r.Close();
                        fs.Close();
                        this.Refresh();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }