/// <summary> /// 마우스 업 이벤트 /// DrawObject 의 추가, 선택, 이동, 사이즈 변경 등 후에 마우스 클릭을 놓으면 이벤트가 마무리 된다. /// </summary> private void DrawBox_MouseUp(object sender, MouseEventArgs e) { //마우스 왼쪽 버튼이 클릭된 상태였고, DrawObjectType 이 선택하기가 아닐 때, if (e.Button == MouseButtons.Left && !(MainController.Instance.DrawObjectType == DrawObjectType.Select)) { //DrawBox 의 상태를 아무것도 지정하지 않는다. MainController.Instance.SelectMode = SelectMode.None; //새롭게 추가되어 그려진 DrawObject 를 최종 상태로 설정한다. MainController.Instance.GraphicModel.GrapList[0].Normalize(); //Pencil 변수를 null 로 초기화 한다. this.mNewPencil = null; MainController.Instance.Notify(ObserverAction.Select); } else { ////DrawBox 의 상태가 영역으로 선택하기 일 때 if (MainController.Instance.SelectMode == SelectMode.NetSelection) { ControlPaint.DrawReversibleFrame(this.RectangleToScreen(RectangleObject.GetNormalizedRectangle(this.mStartPoint, this.mLastPoint)), Color.Black, FrameStyle.Dashed); //모든 DrawObject 의 선택을 해제한다. this.UnSelectAll(); //마우스의 처음과 마지막 위치 만큼의 Rectangle 을 생성한다. Rectangle rec = RectangleObject.GetNormalizedRectangle(this.mStartPoint, this.mLastPoint); //rec 의 영역에 DrawObject 가 포함된다면 선택된걸로 설정한다. foreach (DrawObject o in MainController.Instance.GraphicModel.GrapList) { if (o.IntersectsWith(rec)) { o.Selected = true; } } //DrawBox 의 상태를 아무것도 지정하지 않는다. MainController.Instance.SelectMode = SelectMode.None; } //DrawObjec 의 사이즈 변경 변수가 Null 이 아니라면 변경된 된 크기만큼 최종적으로 설정해준다. if (this.mResizedObject != null) { this.mResizedObject.Normalize(); this.mResizedObject = null; } //DrawBox 의 Paint 이벤트를 호출한다. this.Invalidate(false); } //마우스 캡쳐를 해제한다. this.Capture = false; }
/// <summary> /// 그리기 도구에 선택된 DrawObject 의 종류에 따라 새로운 DrawObject 객체를 생성해서 반환한다. /// </summary> /// <param name="aType">그리기 도구에서 선택된 도구의 종류</param> /// <param name="aLocation">DrawObject가 그려질 위치</param> /// <returns></returns> private DrawObject AddNewDrawObject(DrawObjectType aType, Point aLocation) { switch (aType) { case DrawObjectType.Rectangle: return(new RectangleObject(aLocation.X, aLocation.Y, 1, 1)); case DrawObjectType.Ellipse: return(new EllipseObject(aLocation.X, aLocation.Y, 1, 1)); case DrawObjectType.Line: return(new LineObject(aLocation.X, aLocation.Y, aLocation.X + 1, aLocation.Y + 1)); case DrawObjectType.Pencil: this.mLastX = aLocation.X; this.mLastY = aLocation.Y; return(this.mNewPencil = new PencilObejct(aLocation.X, aLocation.Y, aLocation.X + 1, aLocation.Y + 1)); } return(new RectangleObject(aLocation.X, aLocation.Y, 1, 1)); }