Пример #1
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();
     }
 }
Пример #2
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();
        }
Пример #3
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
                {
                }
            }));
        }