コード例 #1
0
        private void View_screen_paint(object sender, PaintEventArgs e)
        {
            if (Sight.Checked)
            {
                Graphics g = e.Graphics;

                Pen redPen = new Pen(Color.FromArgb(128, 255, 0, 0), 2);

                Type         pboxType   = ViewScreen.GetType();
                PropertyInfo irProperty = pboxType.GetProperty("ImageRectangle", BindingFlags.GetProperty | BindingFlags.NonPublic | BindingFlags.Instance);
                Rectangle    rectangle  = (Rectangle)irProperty.GetValue(ViewScreen, null);

                int H     = rectangle.Height - 1;
                int W     = rectangle.Width - 1;
                int X     = rectangle.Left;
                int Y     = rectangle.Top;
                int Small = W / 4;
                int Large = W / 2;
                g.DrawLine(redPen, 0 + X, 0 + Y, W + X, H + Y);
                g.DrawLine(redPen, 0 + X, H + Y, W + X, 0 + Y);
                g.DrawLine(redPen, W / 2 + X, H + Y, W / 2 + X, 0 + Y);
                g.DrawLine(redPen, 0 + X, H / 2 + Y, W + X, H / 2 + Y);
                g.DrawEllipse(redPen, W / 2 - Small / 2 + X, H / 2 - Small / 2 + Y, Small, Small);
                g.DrawEllipse(redPen, W / 2 - Large / 2 + X, H / 2 - Large / 2 + Y, Large, Large);

                redPen.Dispose();
            }
        }
コード例 #2
0
        private void DragMove(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left && MainStatus.Destination != null)
            {
                PropertyInfo pInfo = ViewScreen.GetType().GetProperty("ImageRectangle",
                                                                      System.Reflection.BindingFlags.Public |
                                                                      System.Reflection.BindingFlags.NonPublic |
                                                                      System.Reflection.BindingFlags.Instance);

                Rectangle rectangle = (Rectangle)pInfo.GetValue(ViewScreen, null);
                MouseMag = Convert.ToDouble(MagFactor.Text) / rectangle.Width;  // microscope magnification inches per pixel

                double dMouseX = e.X - DragMouseStartX;
                double dMouseY = e.Y - DragMouseStartY;

                double NewX = DragAxisStartX - MouseMag * dMouseX;
                double NewY = DragAxisStartY + MouseMag * dMouseY;

                WriteLineHandleException(String.Format("MoveExp0={0} 0.2", NewX * XResolution));
                WriteLineHandleException(String.Format("MoveExp1={0} 0.2", NewY * YResolution));
            }
        }