Exemple #1
0
        private void importImageDialog_FileOk(object sender, CancelEventArgs e)
        {
            try
            {
                m_floorPlanImage = new Bitmap(Image.FromFile(importImageDialog.FileName));      // hopefully, they opened an image
                m_fpState        = fpState.NOSCALE;                                             // The state changes to reflecft our new image

                SetScale(10);                                                                   // Call set scale automatically - we can remove this
            }
            catch (Exception) { }
            DrawFloor();
        }
Exemple #2
0
 public void MoveRobot(Point loc, int facing)
 {
     m_status.position = new Position(loc.X, loc.Y, facing);
     if (m_status.path != null)
     {
         m_fpState = fpState.HAVEPATH;
     }
     else
     {
         m_fpState = fpState.SETDEST;
     }
     DrawFloor();
 }
Exemple #3
0
        private void SetDestination(object sender, MouseEventArgs e)
        {
            m_status.position = getPosition();

            PostMessage(m_status.endPoint.ToString());

            m_status.endPoint = PanelToFloorPlan(new Point(e.X, e.Y));

            m_status.path = m_pathfinder.getPath();

            m_fpState = fpState.HAVEPATH;

            DrawFloor();
        }
Exemple #4
0
 private void Click_Import(object sender, EventArgs e)
 {
     importImageDialog.InitialDirectory = ".\floorplan";
     importImageDialog.ShowDialog();
     try
     {
         m_floorPlanImage = new Bitmap(Image.FromFile(importImageDialog.FileName));
     }
     catch (Exception) { }
     //m_status = new Status(m_floorPlanImage, 3);
     m_fpState = fpState.IMAGE;
     SetScale(10);
     DrawFloor();
 }
Exemple #5
0
        private void Click_FloorPlan(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
            case MouseButtons.Left:
                switch (m_fpState)
                {
                case fpState.IMAGE:
                    m_pixelsperfootStart = e.Location;
                    m_fpState            = fpState.DRAWSCALE;
                    t_DrawScaleTimer     = new Timer(m_callback, null, 0, 100);
                    break;

                case fpState.DRAWSCALE:
                    m_pixelsperfootEnd = e.Location;
                    double scaleLength = Length(m_pixelsperfootStart.X - m_pixelsperfootEnd.X, m_pixelsperfootStart.Y - m_pixelsperfootEnd.Y);
                    SetScale(scaleLength);
                    break;

                case fpState.SETROBOT:
                    PlaceRobot(sender, e);
                    break;

                case fpState.SETDEST:
                case fpState.HAVEPATH:
                    if (m_status != null)
                    {
                        SetDestination(sender, e);
                    }
                    break;
                }
                break;

            case MouseButtons.Right:
                floorPlanContext.Show(System.Windows.Forms.Control.MousePosition);
                break;

            case MouseButtons.Middle:
                break;

            default:
                break;
            }
        }
Exemple #6
0
        private void SetScale(double scaleLength)
        {
            m_fpState = fpState.IMAGE;
            using (ScaleForm sf = new ScaleForm(scaleLength, scaleLength / m_pixelsperfoot, this))
            {
                sf.ShowDialog();
                m_pixelsperfoot = sf.m_scale;
                m_status        = new Status(m_floorPlanImage, m_pixelsperfoot);
                m_pathfinder    = new QGPathFinder(m_status, this);
                m_ratioX        = (double)(m_status.floorPlan.getXTileNum()) / (double)(floorPlanPanel.Width);
                m_ratioY        = (double)m_status.floorPlan.getYTileNum() / (double)floorPlanPanel.Height;
                m_fpState       = fpState.SETDEST;
            }
            if (t_DrawScaleTimer != null)
            {
                t_DrawScaleTimer.Dispose();
            }

            m_fpState = fpState.SETDEST;
            DrawFloor();
        }
Exemple #7
0
        public MainForm()
        {
            InitializeComponent();

            m_host = new CRobotHost(this);

            m_destImage = Image.FromFile("Images\\destImage.png");

            m_camera = new CWebcam(livePanel, null, false);
            m_camera.Initialize();
            m_camera.SetReady();

            m_center = new Point(floorPlanPanel.Width / 2, floorPlanPanel.Height / 2);

            m_fg = Graphics.FromHwnd(floorPlanPanel.Handle);

            m_pixelsperfoot = 2.0;

            m_callback = new TimerCallback(DrawScale);
            m_fpState  = fpState.NONE;

            t_DrawFloorDelegate = new DDrawFloor(DrawFloor);
        }
Exemple #8
0
        public MainForm()
        {
            InitializeComponent();

            m_host = new CRobotHost(this);

            m_destImage = Image.FromFile("Images\\destImage.png");

            m_camera = new CWebcam(livePanel, null, false);
            m_camera.Initialize();
            m_camera.SetReady();

            m_center = new Point(floorPlanPanel.Width / 2, floorPlanPanel.Height / 2);

            m_fg = Graphics.FromHwnd(floorPlanPanel.Handle);

            m_pixelsperfoot = 2.0;

            m_callback = new TimerCallback(DrawScale);
            m_fpState = fpState.NONE;

            t_DrawFloorDelegate = new DDrawFloor(DrawFloor);
        }
Exemple #9
0
        private void Click_SetDestination(object sender, EventArgs e)
        {
            m_fpState = fpState.SETDEST;

            DrawFloor();
        }
Exemple #10
0
        private void Click_PlaceRobot(object sender, EventArgs e)
        {
            m_fpState = fpState.SETROBOT;

                DrawFloor();
        }
Exemple #11
0
 private void Click_Import(object sender, EventArgs e)
 {
     importImageDialog.InitialDirectory = ".\floorplan";
     importImageDialog.ShowDialog();
     try
     {
         m_floorPlanImage = new Bitmap(Image.FromFile(importImageDialog.FileName));
     }
     catch (Exception) { }
     //m_status = new Status(m_floorPlanImage, 3);
     m_fpState = fpState.IMAGE;
     SetScale(10);
     DrawFloor();
 }
Exemple #12
0
        private void Click_FloorPlan(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
            case MouseButtons.Left:
                switch (m_fpState)
                {
                case fpState.IMAGE:
                    m_pixelsperfootStart = e.Location;
                    m_fpState = fpState.DRAWSCALE;
                    t_DrawScaleTimer = new Timer(m_callback, null, 0, 100);
                    break;

                case fpState.DRAWSCALE:
                    m_pixelsperfootEnd = e.Location;
                    double scaleLength = Length(m_pixelsperfootStart.X - m_pixelsperfootEnd.X, m_pixelsperfootStart.Y - m_pixelsperfootEnd.Y);
                    SetScale(scaleLength);
                    break;

                case fpState.SETROBOT:
                    PlaceRobot(sender, e);
                    break;

                case fpState.SETDEST:
                case fpState.HAVEPATH:
                    if (m_status != null)
                    {
                        SetDestination(sender, e);
                    }
                    break;

                }
                break;

            case MouseButtons.Right:
                floorPlanContext.Show(System.Windows.Forms.Control.MousePosition);
                break;

            case MouseButtons.Middle:
                break;

            default:
                break;
            }
        }
Exemple #13
0
 public void MoveRobot(Point loc, int facing)
 {
     m_status.position = new Position(loc.X, loc.Y, facing);
     if (m_status.path != null)
         m_fpState = fpState.HAVEPATH;
     else
         m_fpState = fpState.SETDEST;
     DrawFloor();
 }
Exemple #14
0
        private void Click_SetDestination(object sender, EventArgs e)
        {
            m_fpState = fpState.SETDEST;

            DrawFloor();
        }
Exemple #15
0
        private void SetScale(double scaleLength)
        {
            m_fpState = fpState.IMAGE;
            using (ScaleForm sf = new ScaleForm(scaleLength, scaleLength / m_pixelsperfoot, this))
            {
                sf.ShowDialog();
                m_pixelsperfoot = sf.m_scale;
                m_status = new Status(m_floorPlanImage, m_pixelsperfoot);
                m_pathfinder = new QGPathFinder(m_status, this);
                m_ratioX = (double)(m_status.floorPlan.getXTileNum()) / (double)(floorPlanPanel.Width);
                m_ratioY = (double)m_status.floorPlan.getYTileNum() / (double)floorPlanPanel.Height;
                m_fpState = fpState.SETDEST;
            }
            if (t_DrawScaleTimer != null)
            {
                t_DrawScaleTimer.Dispose();
            }

            m_fpState = fpState.SETDEST;
            DrawFloor();
        }
Exemple #16
0
        private void importImageDialog_FileOk(object sender, CancelEventArgs e)
        {
            try
            {
                m_floorPlanImage = new Bitmap(Image.FromFile(importImageDialog.FileName));      // hopefully, they opened an image
                m_fpState = fpState.NOSCALE;                                                    // The state changes to reflecft our new image

                SetScale(10);                                                                   // Call set scale automatically - we can remove this
            }
            catch (Exception) { }
            DrawFloor();
        }
Exemple #17
0
 /// <summary>
 /// Result of clicking the "Place Robot" menu option
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Click_PlaceRobot(object sender, EventArgs e)
 {
     if (m_fpState == fpState.SETDEST || m_fpState == fpState.HAVEPATH || m_fpState == fpState.SETROBOT)
     {
         m_fpState = fpState.SETROBOT;
         DrawFloor();
     }
 }
Exemple #18
0
        /// <summary>
        /// Result of clicking the FloorPlanPanel - does different things depending on fpState and the button clicked
        /// </summary>
        /// <param name="e">mouse position</param>
        private void Click_FloorPlan(object sender, MouseEventArgs e)
        {
            switch (e.Button)
            {
                case MouseButtons.Left:                                         // If we're dealing with a normal click
                    switch (m_fpState)
                    {
                        case fpState.NOSCALE:                                     // We've loaded the image, so this is to set the scale
                            m_scaleStart = e.Location;                          // Set the starting point then go into DrawScale mode
                            m_fpState = fpState.DRAWSCALE;
                            t_DrawTimer = new Timer(m_callback, null, 0, 100);
                            break;

                        case fpState.DRAWSCALE:                                 // We're currently drawing the scale, so this is the endpoint
                            m_scaleEnd = e.Location;                            // Set the endpoint and then call SetScale method
                            double scaleLength = Length(m_scaleStart.X - m_scaleEnd.X, m_scaleStart.Y - m_scaleEnd.Y);
                            if (t_DrawTimer != null)
                            {
                                t_DrawTimer.Dispose();                                     // If there's a drawscale timer running, kill it
                            }
                            SetScale(scaleLength);
                            break;

                        case fpState.SETROBOT:                                  // We're setting the rotob's position
                            PlaceRobot(sender, e);
                            new FacingForm(this).Show();
                            //m_fpState = fpState.SETFACING;
                            //t_DrawTimer = new Timer(m_callback, null, 0, 100);
                            break;
                        case fpState.SETFACING:                                 // Once we plae the robot, we need to set its current facing direction
                            m_fpState = fpState.SETDEST;
                            Point panelPosition = (FloorPlanToPanel(m_host.Status.Position.location));
                            Point mousePosition = e.Location;
                            m_host.Status.Position.facing = SlopeToFacing(panelPosition, mousePosition);

                            if (t_DrawTimer != null)
                            {
                                t_DrawTimer.Dispose();                                     // If there's a drawscale timer running, kill it
                            }
                            DrawFloor();
                            break;

                        case fpState.SETDEST:                                   // If we have a destination or path
                        case fpState.HAVEPATH:                                  // Then we're just setting new destinations
                            if (m_host.Status != null)
                            {
                                SetDestination(sender, e);
                            }
                            break;
                    }
                    break;

                case MouseButtons.Right:                                        // If it's a right-click, show the context menu
                    floorPlanContext.Show(System.Windows.Forms.Control.MousePosition);
                    break;

                case MouseButtons.Middle:
                    break;

                default:
                    break;
            }
        }
Exemple #19
0
 /// <summary>
 /// Move's the robot's position
 /// </summary>
 /// <param name="loc">Location on the floorplanpanel</param>
 /// <param name="facing"></param>
 public void PlaceRobot(Point loc, int facing)
 {
     if (m_host.Status != null)
     {
         m_host.Status.Position = new Position(PanelToFloorPlan(loc), facing);
         if (m_host.Status.Path != null)
             m_fpState = fpState.HAVEPATH;
         else
             m_fpState = fpState.SETDEST;
         DrawFloor();
     }
 }
Exemple #20
0
 public void DrawScale()
 {
     m_fpState = fpState.NOSCALE;
     DrawFloor();
 }
Exemple #21
0
 /// <summary>
 /// Set's the robot's destination
 /// </summary>
 private void SetDestination(object sender, MouseEventArgs e)
 {
     m_host.SetDestination(PanelToFloorPlan(new Point(e.X, e.Y)));       // Set the endpoint in the Host's status
     m_fpState = fpState.HAVEPATH;                                       // Update the state
     DrawFloor();                                                        // Draw the floor
 }
Exemple #22
0
        private void SetDestination(object sender, MouseEventArgs e)
        {
            m_status.position = getPosition();

            PostMessage(m_status.endPoint.ToString());

            m_status.endPoint = PanelToFloorPlan(new Point(e.X, e.Y));

            m_status.path = m_pathfinder.getPath();

            m_fpState = fpState.HAVEPATH;

            DrawFloor();
        }
Exemple #23
0
        private Timer t_DrawTimer; // A timer for drawing the line when setting scale

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Constructor
        /// </summary>
        public MainForm()
        {
            InitializeComponent();

            m_host = new See3PO.Host(this);                                     // Create a Host

            m_center = new Point(floorPlanPanel.Width / 2, floorPlanPanel.Height / 2); //find the center of the image

            m_fg = Graphics.FromHwnd(floorPlanPanel.Handle);                    // create a graphics object to draw on the floorplanpanel

            m_scale = 2.0;                                                      // default ppf

            m_callback = new TimerCallback(DrawScale);                          // I have no idea why we do this, but
            t_DrawFloorDelegate = new DDrawFloor(DrawFloor);                    //it's necessary for the drawscale thread

            m_fpState = fpState.START;                                           // Set the fpState to none, since nothing has been done
            Click_ConnectMenuItem(this, null);
        }
Exemple #24
0
 private void Click_SetDestination(object sender, EventArgs e)
 {
     if (m_fpState == fpState.SETDEST || m_fpState == fpState.HAVEPATH || m_fpState == fpState.SETROBOT)
     {
         m_fpState = fpState.SETDEST;
         DrawFloor();
     }
 }
Exemple #25
0
        private void Click_PlaceRobot(object sender, EventArgs e)
        {
            m_fpState = fpState.SETROBOT;

            DrawFloor();
        }