Ejemplo n.º 1
0
 private System.Drawing.Rectangle GetRectangle(PointHolder start, PointHolder end)
 {
     return(new System.Drawing.Rectangle((int)Math.Min(start.X, end.X),
                                         (int)Math.Min(start.Y, end.Y),
                                         (int)Math.Abs(start.X - end.X),
                                         (int)Math.Abs(start.Y - end.Y)));
 }
Ejemplo n.º 2
0
        private void DisplayImage_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (!IsSelectingPoint)
            {
                foreach (var parkingArea in ParkingAreasCollection)
                {
                    if (GetRectangle(parkingArea.StartingPoint, parkingArea.EndingPoint).Contains((int)e.GetPosition(DisplayImage).X,
                                                                                                  (int)e.GetPosition(DisplayImage).Y))
                    {
                        HighlightParkingArea(parkingArea);
                        SelectedParkingArea = parkingArea;
                        return;
                    }
                }
                return;
            }

            if (PointSelected)
            {
                ParkingAreasCollection.Add(
                    new ParkingArea(
                        SelectedPointStart,
                        new PointHolder(
                            e.GetPosition(DisplayImage).X,
                            e.GetPosition(DisplayImage).Y)));
                IsSelectingPoint = false;
                DrawAreaOnBitmap(ParkingAreasCollection.Last());
            }
            else
            {
                PointSelected        = true;
                SelectedPointStart   = new PointHolder();
                SelectedPointStart.X = e.GetPosition(DisplayImage).X;
                SelectedPointStart.Y = e.GetPosition(DisplayImage).Y;
            }
        }
Ejemplo n.º 3
0
 public ParkingArea(PointHolder p1, PointHolder p2)
 {
     StartingPoint = p1;
     EndingPoint   = p2;
 }
Ejemplo n.º 4
0
 private void Button_Click_2(object sender, RoutedEventArgs e)
 {
     SelectedPointStart = new PointHolder();
     PointSelected      = false;
     IsSelectingPoint   = true;
 }