public void startEllipse(MouseEventArgs e) { PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y); BPaintEllipse new_BPaintEllipse = new BPaintEllipse(); if (ObjectsList.Any()) { new_BPaintEllipse.ObjectID = ObjectsList.Max(x => x.ObjectID) + 1; cmd_Clear_Selection(); cmd_Clear_Editing(); } else { new_BPaintEllipse.ObjectID = 1; } BPaintVertex startVertex = new BPaintVertex(CurrPosition, Color1); VerticesList.Add(startVertex); new_BPaintEllipse.Selected = true; new_BPaintEllipse.EditMode = true; new_BPaintEllipse.Color = Color1; new_BPaintEllipse.LineWidth = LineWidth1; new_BPaintEllipse.Position = startVertex; //new_BPaintEllipse.VerticesList.Add(startVertex); CurrPaintMode = BPaintMode.drawing; ObjectsList.Add(new_BPaintEllipse); }
public void continueEllipse(MouseEventArgs e) { PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y); BPaintEllipse currBPaintEllipse = ObjectsList.Single(o => ((o.EditMode) & (o.ObjectType == BPaintOpbjectType.Ellipse))) as BPaintEllipse; BPaintVertex currVertex = new BPaintVertex(CurrPosition, Color1); VerticesList.Add(currVertex); switch (currBPaintEllipse.VerticesList.Count) { case 1: currBPaintEllipse.pt2 = currVertex; break; case 2: currBPaintEllipse.pt3 = currVertex; currBPaintEllipse.EditMode = false; CurrPaintMode = BPaintMode.idle; break; default: break; } }
public void startCircle(MouseEventArgs e) { PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y); BPaintCircle new_BPaintCircle = new BPaintCircle(); if (ObjectsList.Any()) { new_BPaintCircle.ObjectID = ObjectsList.Max(x => x.ObjectID) + 1; cmd_Clear_Selection(); cmd_Clear_Editing(); } else { new_BPaintCircle.ObjectID = 1; } BPaintVertex startVertex = new BPaintVertex(CurrPosition, Color1); VerticesList.Add(startVertex); new_BPaintCircle.Selected = true; new_BPaintCircle.EditMode = true; new_BPaintCircle.Color = Color1; new_BPaintCircle.LineWidth = LineWidth1; new_BPaintCircle.Position = startVertex; BPaintVertex endVertex = new BPaintVertex(CurrPosition, Color1); new_BPaintCircle.end = endVertex; VerticesList.Add(endVertex); CurrPaintMode = BPaintMode.movingAnElement; bpVertexUnderMousePointer = endVertex; ObjectsList.Add(new_BPaintCircle); }
public void cmd_onmousedown(UIMouseEventArgs e) { Curr_Mode = BPaintMode.draw; if (FigureCode == 1) { cmd_prepareDraw(e); } if (FigureCode == 2) { cmd_prepareLine(e); } }
protected void OperationalModeHasChanged() { btnDrawMode_CSSclass = (CurrOperationalMode == OperationalMode.draw)?("btn btn-primary btn-with-icons") :("btn btn-outline-primary btn-with-icons"); btnSelectMode_CSSclass = (CurrOperationalMode == OperationalMode.select) ? ("btn btn-primary btn-with-icons") : ("btn btn-outline-primary btn-with-icons"); if (CurrOperationalMode == OperationalMode.draw) { CurrPaintMode = BPaintMode.idle; btnDeleteSelectedDisabled = true; btnSelectAllDisabled = true; } else { CurrSelectionMode = SelectionMode.idle; btnDeleteSelectedDisabled = false; btnSelectAllDisabled = false; } StateHasChanged(); }
public void cmd_onmouseup(UIMouseEventArgs e) { Curr_Mode = BPaintMode.none; if (ObjectsList.Any()) { BPaintObject o = ObjectsList.Single(x => x.EditMode == true); switch (o.ObjectType) { case BPaintOpbjectType.HandDraw: if (!(o as BPaintHandDraw).IsValid()) { ObjectsList.Remove(o); } break; case BPaintOpbjectType.Line: if (!(o as BPaintLine).IsValid()) { ObjectsList.Remove(o); } break; default: break; } } cmd_Clear_Editing(); cmd_RefreshSVG(); }
public void onMouseDown(MouseEventArgs e) { if (CurrOperationalMode == OperationalMode.select) { if (CurrSelectionMode == SelectionMode.idle) { if (bpSelectionRectangle != null) { foreach (BPaintVertex vertex in bpSelectionRectangle.VerticesList) { SelectionVerticesList.RemoveAll(x => true); } bpSelectionRectangle = null; } PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y); bpSelectionRectangle = new BPaintRectangle() { ObjectID = 999 }; BPaintVertex startVertex = new BPaintVertex(CurrPosition, "magenta"); SelectionVerticesList.Add(startVertex); bpSelectionRectangle.Selected = false; bpSelectionRectangle.EditMode = true; bpSelectionRectangle.Color = "red"; bpSelectionRectangle.LineWidth = 2; bpSelectionRectangle.Position = startVertex; BPaintVertex endVertex = new BPaintVertex(CurrPosition, "magenta"); bpSelectionRectangle.end = endVertex; SelectionVerticesList.Add(endVertex); CurrSelectionMode = SelectionMode.movingAnElement; bpSelectionVertexUnderMousePointer = endVertex; } else if (CurrSelectionMode == SelectionMode.hoveredAVertex) { if (bpSelectionVertexUnderMousePointer != null) { BPaintVertex currVertex = bpSelectionVertexUnderMousePointer as BPaintVertex; currVertex.Selected = true; CurrSelectionMode = SelectionMode.movingAnElement; } } StateHasChanged(); } else { if (CurrPaintMode == BPaintMode.idle) { if (!ObjectsList.Any(o => o.EditMode)) { switch (FigureCode) { case 2: startLine(e); break; case 3: BPaintVertex newVertex = makeVertex(e); CurrPaintMode = BPaintMode.idle; break; case 4: startCircle(e); break; case 5: //cmd_prepareEllipse(e); break; default: break; } } else { BPaintObject currBPaintObject = ObjectsList.Single(o => o.EditMode); BPaintVertex newVertex = makeVertex(e); switch (currBPaintObject.ObjectType) { case BPaintOpbjectType.Ellipse: BPaintEllipse currEllipse = currBPaintObject as BPaintEllipse; currEllipse.pt3 = newVertex; currEllipse.EditMode = false; break; default: break; } CurrPaintMode = BPaintMode.idle; } } else if (CurrPaintMode == BPaintMode.hoveredAVertex) { if (bpVertexUnderMousePointer != null) { BPaintVertex currVertex = bpVertexUnderMousePointer as BPaintVertex; currVertex.Selected = true; CurrPaintMode = BPaintMode.movingAnElement; } } StateHasChanged(); } }
public void onMouseMove(MouseEventArgs e) { //this.OnScroll(); PointD CurrPosition = new PointD(e.ClientX - LocalData.SVGPosition.X, e.ClientY - LocalData.SVGPosition.Y); currMouseLocation = CurrPosition; strCurrMouseLocation = "x: " + currMouseLocation.X.ToString("F2") + "; y: " + currMouseLocation.Y.ToString("F2"); if (CurrOperationalMode == OperationalMode.select) { switch (CurrSelectionMode) { case SelectionMode.idle: if (SelectionVerticesList.Any(x => (CurrPosition.DistanceTo(x.PtD) <= 10))) { BPaintVertex currVertex = SelectionVerticesList.Single(x => (CurrPosition.DistanceTo(x.PtD) <= 10)); bpSelectionVertexUnderMousePointer = currVertex; bpSelectionVertexUnderMousePointer.Selected = true; CurrSelectionMode = SelectionMode.hoveredAVertex; } else { bpSelectionVertexUnderMousePointer = null; CurrSelectionMode = SelectionMode.idle; } break; case SelectionMode.movingAnElement: BPaintVertex vertex2Move = bpSelectionVertexUnderMousePointer as BPaintVertex; vertex2Move.PtD = CurrPosition; break; case SelectionMode.hoveredAVertex: if (SelectionVerticesList.Any(x => (CurrPosition.DistanceTo(x.PtD) <= 10))) { BPaintVertex currVertex = SelectionVerticesList.Single(x => (CurrPosition.DistanceTo(x.PtD) <= 10)); bpSelectionVertexUnderMousePointer = currVertex; CurrSelectionMode = SelectionMode.hoveredAVertex; } else { bpSelectionVertexUnderMousePointer = null; foreach (BPaintVertex vertex in SelectionVerticesList) { vertex.Selected = false; } CurrSelectionMode = SelectionMode.idle; } break; default: break; } } else { switch (CurrPaintMode) { // TODO: Fix vertices highlighting // category=Appearance issue=none estimate=2h // when there is no selection rectangle, vertices under the mouse cursor are not highlighted case BPaintMode.idle: if (VerticesList.Any(x => (CurrPosition.DistanceTo(x.PtD) <= 10))) { BPaintVertex currVertex = VerticesList.Single(x => (CurrPosition.DistanceTo(x.PtD) <= 10)); bpVertexUnderMousePointer = currVertex; bpVertexUnderMousePointer.Selected = true; CurrPaintMode = BPaintMode.hoveredAVertex; } else { bpVertexUnderMousePointer = null; CurrPaintMode = BPaintMode.idle; } break; case BPaintMode.drawing: break; case BPaintMode.movingAnElement: BPaintVertex vertex2Move = bpVertexUnderMousePointer as BPaintVertex; vertex2Move.PtD = CurrPosition; break; case BPaintMode.hoveredAVertex: if (VerticesList.Any(x => (CurrPosition.DistanceTo(x.PtD) <= 10))) { BPaintVertex currVertex = VerticesList.Single(x => (CurrPosition.DistanceTo(x.PtD) <= 10)); bpVertexUnderMousePointer = currVertex; CurrPaintMode = BPaintMode.hoveredAVertex; } else { bpVertexUnderMousePointer = null; foreach (BPaintObject bpObject in ObjectsList) { //bpObject.Selected = false; bpObject.EditMode = false; } foreach (BPaintVertex vertex in VerticesList) { vertex.Selected = false; } CurrPaintMode = BPaintMode.idle; } break; default: break; } } ProcessSelection(); StateHasChanged(); }
public void onMouseUp(MouseEventArgs e) { if (CurrOperationalMode == OperationalMode.select) { switch (CurrSelectionMode) { case SelectionMode.movingAnElement: CurrSelectionMode = SelectionMode.idle; if (!bpSelectionRectangle.IsValid()) { bpSelectionRectangle = null; SelectionVerticesList.RemoveAll(x => true); } break; default: break; } ProcessSelection(); cmd_RefreshSVG(); StateHasChanged(); } else { switch (CurrPaintMode) { case BPaintMode.idle: // this can be if the object to create need more than 2 vertices switch (FigureCode) { case 5: startEllipse(e); break; default: break; } break; case BPaintMode.movingAnElement: if (ObjectsList.Any(o => o.EditMode)) { BPaintObject currObjectEditing = ObjectsList.Single(o => o.EditMode); if (currObjectEditing.MandatoryVerticesCount > 2) { CurrPaintMode = BPaintMode.idle; } else { CurrPaintMode = BPaintMode.idle; } } else { CurrPaintMode = BPaintMode.hoveredAVertex; cmd_Clear_Editing(); } ProcessSelection(); cmd_RefreshSVG(); break; case BPaintMode.drawing: switch (FigureCode) { case 5: continueEllipse(e); break; default: break; } break; default: break; } StateHasChanged(); } }