Exemplo n.º 1
0
        public void RedrawPoint()
        {
            SolidBrush redBrush    = new SolidBrush(Color.Red);
            SolidBrush yellowBrush = new SolidBrush(Color.Yellow);
            Graphics   g           = XY_Point_Panel.CreateGraphics();


            for (int i = 0; i < XYgraph.Map.Length; i++)
            {
                if (XYgraph.Map[i] != -1)
                {
                    Point tmp = XYgraph.ConvertToPanel(i);

                    if (XYgraph.Map[i] == 1)
                    {
                        g.FillEllipse(redBrush, tmp.X - (XYgraph.pixel / 2), tmp.Y - (XYgraph.pixel / 2), XYgraph.pixel, XYgraph.pixel);
                    }
                    else
                    {
                        g.FillEllipse(yellowBrush, tmp.X - (XYgraph.pixel / 2), tmp.Y - (XYgraph.pixel) / 2, XYgraph.pixel, XYgraph.pixel);
                    }
                }
            }
            redBrush.Dispose();
            yellowBrush.Dispose();
        }
Exemplo n.º 2
0
 private void ResetBtn_Click(object sender, EventArgs e)
 {
     if (locked)
     {
         tlu.flag = true;
     }
     else
     {
         XY_Point_Panel.Refresh();
         tlu.Reset();
         XYgraph.Reset();
         Log.Clear();
     }
 }
Exemplo n.º 3
0
        private void XY_Point_Panel_MouseMove(object sender, MouseEventArgs e)
        {
            Point p = XY_Point_Panel.PointToClient(Cursor.Position);

            if (XYgraph.Map[XYgraph.ConvertToArray(p)] != -1)
            {
                if (XYgraph.last != p)
                {
                    Point tmp = XYgraph.ConvertToXY(p);
                    XY_Tip.SetToolTip(XY_Point_Panel, (tmp.X * 0.5) + "," + (tmp.Y * 0.5) + " value = " + XYgraph.Map[XYgraph.ConvertToArray(p)]);
                    XYgraph.last = p;
                }
            }
            else
            {
                XY_Tip.SetToolTip(XY_Panel, "");
            }
        }
Exemplo n.º 4
0
        private void XY_Point_Panel_MouseDown(object sender, MouseEventArgs e)
        {
            if (locked)
            {
                return;
            }
            Point      p = XY_Point_Panel.PointToClient(Cursor.Position);
            Graphics   g = XY_Point_Panel.CreateGraphics();
            SolidBrush brush;


            int value = -1;

            if (e.Button == MouseButtons.Left)
            {
                value = 1;
                brush = new SolidBrush(Color.Red);
            }
            else
            {
                value = 0;
                brush = new SolidBrush(Color.Yellow);
            }


            if (XYgraph.Map[XYgraph.ConvertToArray(p)] == value)
            {
                XY_Point_Panel.Refresh();
                XYgraph.Map[XYgraph.ConvertToArray(p)] = -1;
                RedrawPoint();
            }
            else
            {
                Point tmp = XYgraph.ConvertToPanel(p);
                //繪製的起點為左上角,因為要減到1/2的pixel
                g.FillEllipse(brush, tmp.X - XYgraph.pixel / 2, tmp.Y - XYgraph.pixel / 2, XYgraph.pixel, XYgraph.pixel);
                Console.WriteLine((tmp.X - XYgraph.pixel / 2) + " " + (tmp.Y - XYgraph.pixel / 2));
                XYgraph.Map[XYgraph.ConvertToArray(p)] = value;
            }

            brush.Dispose();
            g.Dispose();
        }
Exemplo n.º 5
0
        public void Notification(double a, double b, double t)
        {
            this.Invoke(new MethodInvoker(delegate()
            {
                try{
                    XY_Point_Panel.Refresh();
                    RedrawPoint();
                    //Color color = Color.FromArgb(0, 159, 247);
                    Pen pen    = new Pen(Color.White, 3f);
                    Graphics g = XY_Point_Panel.CreateGraphics();


                    double x1, x2, y1, y2;
                    if (!a.Equals(0))
                    {
                        y1 = XYgraph.h / 4 + 1;
                        y2 = -y1;
                        x1 = (t - b * y1) / a;
                        x2 = (t - b * y2) / a;
                    }
                    else
                    {
                        x1 = XYgraph.w / 4 + 1;
                        x2 = -x1;
                        y1 = (t - a * x1) / b;
                        y2 = (t - a * x2) / b;
                    }
                    g.DrawLine(pen, (float)(XYgraph.Center.X + x1 * XYgraph.pixel * 2),
                               (float)(XYgraph.Center.Y - y1 * XYgraph.pixel * 2),
                               (float)(XYgraph.Center.X + x2 * XYgraph.pixel * 2),
                               (float)(XYgraph.Center.Y - y2 * XYgraph.pixel * 2));

                    pen.Dispose();
                    g.Dispose();
                }
                catch
                {
                }
            }));
        }