示例#1
0
        public Descart2D(Graphics g, Coor o, int minx, int miny, int maxx, int maxy)
        {
            this.G    = g;
            this.O    = o;
            this.MinX = minx;
            this.MinY = miny;
            this.MaxX = maxx;
            this.MaxY = maxy;

            Pen pen = new Pen(BackColor);

            g.DrawLine(pen, O.X, O.Y, 0, Math.Abs(MinY) + MaxY);
            pen = new Pen(Descart.Ruler);

            // Vẽ lưới
            for (int i = O.X; i < MaxX; i += Form1.PX)
            {
                g.DrawLine(pen, i, 0, i, Math.Abs(MinY) + MaxY);
            }
            for (int i = O.X; i > MinX; i -= Form1.PX)
            {
                g.DrawLine(pen, i, 0, i, Math.Abs(MinY) + MaxY);
            }
            for (int i = O.Y; i < MaxY; i += Form1.PX)
            {
                g.DrawLine(pen, 0, i, Math.Abs(MinX) + MaxX, i);
            }
            for (int i = O.Y; i > MinY; i -= Form1.PX)
            {
                g.DrawLine(pen, 0, i, Math.Abs(MinX) + MaxX, i);
            }
            pen = new Pen(Descart.Vec);

            g.DrawLine(pen, O.X, 0, O.X, Math.Abs(MinY) + MaxY);
            g.DrawLine(pen, 0, O.Y, Math.Abs(MinX) + MaxX, O.Y);
            SolidBrush brush = new SolidBrush(Descart.Vec);

            for (int i = 0; i < 6; i++)
            {
                g.FillRectangle(brush, O.X + i, i, 1, 1);
            }
            for (int i = 0; i < 6; i++)
            {
                g.FillRectangle(brush, O.X - i, i, 1, 1);
            }
            for (int i = 0; i < 6; i++)
            {
                g.FillRectangle(brush, Math.Abs(MinX) + MaxX - i, O.Y - i, 1, 1);
            }
            for (int i = 0; i < 6; i++)
            {
                g.FillRectangle(brush, Math.Abs(MinX) + MaxX - i, O.Y + i, 1, 1);
            }
        }
示例#2
0
 public void Hide(Graphics g, Coor O)
 {
     try
     {
         first.Hide(g, O);
         last.Hide(g, O);
         foreach (Point p in List)
         {
             p.Hide(g, O);
         }
     }
     catch (Exception) { }
 }
示例#3
0
 public void Show(Graphics g, Coor O)
 {
     if (!D3)
     {
         SolidBrush brush = new SolidBrush(Descart.Point);
         g.FillRectangle(brush, O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX - Form1.PX / 2, Form1.PX, Form1.PX);
     }
     else
     {
         SolidBrush brush = new SolidBrush(Descart.Point);
         g.FillRectangle(brush, O.X + X * Form1.PX - Form1.PX / 2 - Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX, O.Y - Y * Form1.PX - Form1.PX / 2 + Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX, Form1.PX, Form1.PX);
     }
 }
示例#4
0
 public void Show(Graphics g, Color c, Coor O, int size = 5)
 {
     if (!D3)
     {
         SolidBrush brush = new SolidBrush(c);
         g.FillRectangle(brush, O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX - Form1.PX / 2, size, size);
     }
     else
     {
         SolidBrush brush = new SolidBrush(c);
         g.FillRectangle(brush, O.X + X * Form1.PX - Form1.PX / 2 - Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX, O.Y - Y * Form1.PX - Form1.PX / 2 + Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX, size, size);
     }
 }
示例#5
0
 public static int Convert_D2P(int x, Coor O, int type)/*Chuyển đổi từ tọa độ Descart sang Pixel*/
 {
     if (type == -1)
     {
         return(x * Form1.PX + O.X);
     }
     else if (type == 0)
     {
         return(O.Y - x * Form1.PX);
     }
     else
     {
         return(0);
     }
 }
示例#6
0
 public static int Convert_P2D(int x, Coor O, int type) /*Chuyển đổi từ tọa độ Pixel sang Descart*/
 {
     if (type == -1)                                    //X
     {
         return(Convert.ToInt32(Math.Round(1.0 * (x - O.X) / Form1.PX)));
     }
     else if (type == 0)//Y
     {
         return(Convert.ToInt32(Math.Round(1.0 * (O.Y - x) / Form1.PX)));
     }
     else
     {
         return(0);
     }
 }
示例#7
0
 public void Hide(Graphics g, Coor O)
 {
     if (!D3)
     {
         SolidBrush brush = new SolidBrush(Descart.BackColor);
         g.FillRectangle(brush, O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX - Form1.PX / 2, Form1.PX / 2, Form1.PX / 2);
         g.FillRectangle(brush, O.X + X * Form1.PX + 1, O.Y - Y * Form1.PX - Form1.PX / 2, Form1.PX / 2, Form1.PX / 2);
         g.FillRectangle(brush, O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX + 1, Form1.PX / 2, Form1.PX / 2);
         g.FillRectangle(brush, O.X + X * Form1.PX + 1, O.Y - Y * Form1.PX + 1, Form1.PX / 2, Form1.PX / 2);
         g.DrawLine(new Pen(Descart.Ruler), O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX, O.X + X * Form1.PX + Form1.PX / 2, O.Y - Y * Form1.PX);
         g.DrawLine(new Pen(Descart.Ruler), O.X + X * Form1.PX, O.Y - Y * Form1.PX - Form1.PX / 2, O.X + X * Form1.PX, O.Y - Y * Form1.PX + Form1.PX / 2);
         if (X == 0)
         {
             g.DrawLine(new Pen(Descart.Vec), O.X + X * Form1.PX, O.Y - Y * Form1.PX - Form1.PX / 2, O.X + X * Form1.PX, O.Y - Y * Form1.PX + Form1.PX / 2);
         }
         if (Y == 0)
         {
             g.DrawLine(new Pen(Descart.Vec), O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX, O.X + X * Form1.PX + Form1.PX / 2, O.Y - Y * Form1.PX);
         }
     }
     else
     {
         SolidBrush brush = new SolidBrush(Descart.BackColor);
         g.FillRectangle(brush, O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX - Form1.PX / 2, Form1.PX / 2, Form1.PX / 2);
         g.FillRectangle(brush, O.X + X * Form1.PX + 1, O.Y - Y * Form1.PX - Form1.PX / 2, Form1.PX / 2, Form1.PX / 2);
         g.FillRectangle(brush, O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX + 1, Form1.PX / 2, Form1.PX / 2);
         g.FillRectangle(brush, O.X + X * Form1.PX + 1, O.Y - Y * Form1.PX + 1, Form1.PX / 2, Form1.PX / 2);
         g.DrawLine(new Pen(Descart.Ruler), O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX, O.X + X * Form1.PX + Form1.PX / 2, O.Y - Y * Form1.PX);
         g.DrawLine(new Pen(Descart.Ruler), O.X + X * Form1.PX, O.Y - Y * Form1.PX - Form1.PX / 2, O.X + X * Form1.PX, O.Y - Y * Form1.PX + Form1.PX / 2);
         if (X == 0 && Y > 0)
         {
             g.DrawLine(new Pen(Descart.Vec), O.X + X * Form1.PX, O.Y - Y * Form1.PX - Form1.PX / 2, O.X + X * Form1.PX, O.Y - Y * Form1.PX + Form1.PX / 2);
         }
         if (Y == 0 && X > 0)
         {
             g.DrawLine(new Pen(Descart.Vec), O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX, O.X + X * Form1.PX + Form1.PX / 2, O.Y - Y * Form1.PX);
         }
         if (Z == 0 && X > 0 && Y > 0)
         {
             g.DrawLine(new Pen(Descart.Vec), O.X + X * Form1.PX - Form1.PX / 2, O.Y - Y * Form1.PX + Form1.PX / 2, O.X + X * Form1.PX + Form1.PX / 2, O.Y - Y * Form1.PX - Form1.PX / 2);
         }
     }
 }
示例#8
0
 public void Show(Graphics g, Coor O, bool dut = false)
 {
     try
     {
         first.Show(g, O);
         last.Show(g, O);
         foreach (Point p in List)
         {
             if (dut)
             {
                 p.Show(g, Descart.Point, O, Form1.PX / 2);
             }
             else
             {
                 p.Show(g, O);
             }
         }
     }
     catch (Exception) { }
 }
示例#9
0
        public Label Show_Label(Coor O)
        {
            Label  lb    = new Label();
            Coor   temp  = Point.Convert_D2P(X, Y, O);
            string name1 = this.Name;

            if (name1.Equals(""))
            {
                name1 = Form1.GetPointName();
            }
            if (D3)
            {
                lb.Text = name1 + "(" + X + "," + Y + "," + Z + ")";
            }
            else
            {
                lb.Text = name1 + "(" + X + "," + Y + ")";
            }
            int x1, y1;

            if (D3)
            {
                if (X >= 0 && Y >= 0)
                {
                    x1 = temp.X + 10 - Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX;
                    y1 = temp.Y - 28 + Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX;
                }
                else if (X >= 0 && Y < 0)
                {
                    x1 = temp.X + 10 - Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX;
                    y1 = temp.Y + 28 + Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX;
                }
                else if (X < 0 && Y < 0)
                {
                    x1 = temp.X - 10 - Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX;
                    y1 = temp.Y + 28 + Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX;
                }
                else

                {
                    x1 = temp.X - 10 - Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX;
                    y1 = temp.Y - 28 + Convert.ToInt32(Math.Ceiling(Z * 0.5)) * Form1.PX;
                }
            }
            else
            {
                if (X >= 0 && Y >= 0)
                {
                    x1 = temp.X + 10;
                    y1 = temp.Y - 10;
                }
                else if (X >= 0 && Y < 0)
                {
                    x1 = temp.X + 10;
                    y1 = temp.Y + 10;
                }
                else if (X < 0 && Y < 0)
                {
                    x1 = temp.X - 10;
                    y1 = temp.Y + 10;
                }
                else

                {
                    x1 = temp.X - 10;
                    y1 = temp.Y - 10;
                }
            }
            lb.Location = new System.Drawing.Point(x1, y1);
            lb.Width    = Convert.ToInt32(lb.Font.Size) * lb.Text.Length - 10;
            return(lb);
        }
示例#10
0
 public static Coor Convert_D2P(int x, int y, Coor O)/*Chuyển đổi từ tọa độ Descart sang Pixel*/
 {
     return(new Coor(x * Form1.PX + O.X, O.Y - y * Form1.PX));
 }
示例#11
0
 public static Point Convert_P2D(int x, int y, Coor O)/*Chuyển đổi từ tọa độ Pixel sang Descart*/
 {
     return(new Point(Convert.ToInt32(Math.Round(1.0 * (x - O.X) / Form1.PX)), Convert.ToInt32(Math.Round(1.0 * (O.Y - y) / Form1.PX))));
 }