예제 #1
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, "");
            }
        }
예제 #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();
        }