/// <summary> /// Lorsqu'un bouton souris est relâché /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainSurface_MouseUp(object sender, MouseEventArgs e) { if (_MouseDown) { //Mode de dessin if (EditorHelper.Instance.CurrentStageState >= Enums.StagePanelState.HotSpots && EditorHelper.Instance.CurrentDrawingTool != Enums.DrawingTools.Pointer) { if (e.Button == System.Windows.Forms.MouseButtons.Right) { //On "fixe" le vecteur courant UpdateAreaLocation(EditorHelper.Instance.SelectedHotSpot); EditorHelper.Instance.SelectedHotSpot = null; EditorHelper.Instance.SelectedHotSpotPoint = -1; if (EditorHelper.Instance.HotSpotEditionMode) { this.HotSpotEditionCompleted(this, new EventArgs()); } EditorHelper.Instance.HotSpotEditionMode = false; MainSurface.Refresh(); _MouseDown = false; } //Mode édition if (EditorHelper.Instance.HotSpotEditionMode) { _MouseDown = false; } //Mode création else if (EditorHelper.Instance.SelectedHotSpot != null) { Point mousePosition = _Service.GetDragStageCoords(this.PointToClient(Cursor.Position)); _Service.CreateNewPointToTheCurrentSelectedHotSpot(mousePosition, EditorHelper.Instance.SelectedHotSpot.Points.Length); MainSurface.Refresh(); } } else { if (_MouseMove) { RefreshStage(); } _MouseDown = false; _MouseMove = false; ReloadItemChosen(); } } }
/// <summary> /// Lorsque la souris se déplace /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainSurface_MouseMove(object sender, MouseEventArgs e) { //Status Bar this.MouseChangePosition(_Service.GetDragStageCoords(new Point(e.X, e.Y)), new EventArgs()); #region Dessins pour add ou suppression de vecteurs if (EditorHelper.Instance.CurrentStageState >= Enums.StagePanelState.HotSpots && EditorHelper.Instance.CurrentDrawingTool != Enums.DrawingTools.Pointer) { //Mode édition if (EditorHelper.Instance.HotSpotEditionMode) { Point mousePosition = _Service.GetDragStageCoords(this.PointToClient(Cursor.Position)); if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { if (_Service.IsOnTheSelectedPolygon(mousePosition, false)) { ChangeCursor(AddVectorCursor); } else { ChangeCursor(DrawingCursor); } } else if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt) { if (_Service.GetVectorPoint(mousePosition) != -1) { ChangeCursor(RemoveVectorCursor); } else { ChangeCursor(DrawingCursor); } } else { ChangeCursor(DrawingCursor); } } } #endregion #region Drap & Drop if (_MouseDown) { //Modes dessin if (EditorHelper.Instance.CurrentStageState >= Enums.StagePanelState.HotSpots && EditorHelper.Instance.CurrentDrawingTool != Enums.DrawingTools.Pointer) { //Mode édition if (EditorHelper.Instance.HotSpotEditionMode && EditorHelper.Instance.SelectedHotSpotPoint > -1) { //Mode mouvement édition Point mousePosition = _Service.GetDragStageCoords(this.PointToClient(Cursor.Position)); _Service.MoveVectorPoint(mousePosition, EditorHelper.Instance.SelectedHotSpotPoint); MainSurface.Refresh(); } else if (EditorHelper.Instance.SelectedHotSpot != null) { MainSurface.Refresh(); } } //Modes image else { _Service.MoveObjectDragDrop(e.Location); _MouseMove = true; RefreshSelection(); } } #endregion }
/// <summary> /// Rafraichi la sélection /// </summary> public void RefreshSelection() { MainSurface.Refresh(); }
/// <summary> /// Lorsqu'un bouton souris est pressé /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void MainSurface_MouseDown(object sender, MouseEventArgs e) { //Mode de dessin if (EditorHelper.Instance.CurrentStageState >= Enums.StagePanelState.HotSpots && EditorHelper.Instance.CurrentDrawingTool != Enums.DrawingTools.Pointer) { Point mousePosition = _Service.GetDragStageCoords(this.PointToClient(Cursor.Position)); //Mode édition if (EditorHelper.Instance.SelectedHotSpot != null && EditorHelper.Instance.HotSpotEditionMode) { if ((Control.ModifierKeys & Keys.Control) == Keys.Control) { if (!_Service.IsOnTheSelectedPolygon(mousePosition, true)) { _Service.CreateNewPointToTheCurrentSelectedHotSpot(mousePosition, EditorHelper.Instance.SelectedHotSpot.Points.Length); } MainSurface.Refresh(); } else if ((Control.ModifierKeys & Keys.Alt) == Keys.Alt) { if (_Service.RemovePointOfTheCurrentSelectedHotSpot(mousePosition)) { MainSurface.Refresh(); } } else { EditorHelper.Instance.SelectedHotSpotPoint = _Service.GetVectorPoint(mousePosition); _MouseDown = true; } } //Mode création else if (EditorHelper.Instance.SelectedHotSpot == null) { DeselectStageObjects(); switch (EditorHelper.Instance.CurrentStageState) { case Enums.StagePanelState.HotSpots: EditorHelper.Instance.SelectedHotSpot = _Service.CreateHotSpot(mousePosition); break; case Enums.StagePanelState.WalkableAreas: EditorHelper.Instance.SelectedHotSpot = _Service.CreateWalkableArea(mousePosition); break; case Enums.StagePanelState.Regions: EditorHelper.Instance.SelectedHotSpot = _Service.CreateRegion(mousePosition); break; } if (EditorHelper.Instance.SelectedHotSpot != null) { _MouseDown = true; EditorHelper.Instance.SelectedHotSpotPoint = 0; MainSurface.Refresh(); } } else { _MouseDown = true; } } //Mode sélection d'objets if (EditorHelper.Instance.SelectedObjects.Count > 0) { Point mousePosition = _Service.GetDragStageCoords(this.PointToClient(Cursor.Position)); foreach (VO_StageObject vObject in EditorHelper.Instance.SelectedObjects) { Rectangle rect = new Rectangle(vObject.Location, vObject.Size); if (rect.IntersectsWith(new Rectangle(mousePosition, new Size(1, 1)))) { _MouseDown = true; _Service.StartObjectDrag(e.Location); return; } } } }
/// <summary> /// Déselectionne les objets /// </summary> public void DeselectStageObjects() { EditorHelper.Instance.SelectedObjects = new List <VO_StageObject>(); MainSurface.Refresh(); }