예제 #1
0
 private void MouseDown_Select(Point eLocation)
 {
     //Nếu nhấn phím CTRL, sẽ chọn đồng thời nhiều shape. Nếu hình đã chọn mà chọn lần 2, sẽ thành bỏ chọn
     if (IsCTRL_pressed)
     {
         DrawObj.ForEach((Action <MyShapes>)(shape =>
         {
             if (shape.Select(eLocation))
             {
                 shape.IsSelected = !shape.IsSelected;
             }
         }));
     }
     //Nếu không nhấn CTRL, chỉ có thể chọn duy nhất 1 hình rồi return
     else
     {
         SelectedShape = SelectShape(eLocation);
         FirstPoint    = eLocation;
         if (SelectedShape != null)
         {
             UpdateInfo();
             if (IsZooming)
             {
                 SelectedShape.SelectPoint(eLocation);
             }
             IsDrawRegion = false;
         }
         else    //Draw a rectangle region
         {
             IsDrawRegion   = true;
             SelectedRegion = new Rectangle(eLocation, new Size(0, 0));
         }
     }
     RePaint();
 }