protected override void drawExtras(ref Rectangle?dirty, Context g, ShapeEngine engine) { if (engine.ControlPoints.Count > 0) { //Draw the arrows for the currently active shape. GeneratedPoint[] genPoints = engine.GeneratedPoints; for (int i = 0; i < engine.ControlPoints.Count; ++i) { LineCurveSeriesEngine lCSEngine = (LineCurveSeriesEngine)engine; if (lCSEngine.Arrow1.Show) { if (genPoints.Length > 1) { dirty = dirty.UnionRectangles(lCSEngine.Arrow1.Draw(g, lCSEngine.OutlineColor, genPoints[0].Position, genPoints[1].Position)); } } if (lCSEngine.Arrow2.Show) { if (genPoints.Length > 1) { dirty = dirty.UnionRectangles(lCSEngine.Arrow2.Draw(g, lCSEngine.OutlineColor, genPoints[genPoints.Length - 1].Position, genPoints[genPoints.Length - 2].Position)); } } } } base.drawExtras(ref dirty, g, engine); }
protected override ShapeEngine cloneSpecific() { LineCurveSeriesEngine clonedCE = new LineCurveSeriesEngine(parentLayer, DrawingLayer, ShapeType, AntiAliasing, Closed, OutlineColor, FillColor, BrushWidth); clonedCE.Arrow1 = Arrow1.Clone(); clonedCE.Arrow2 = Arrow2.Clone(); return(clonedCE); }
protected override ShapeEngine createShape(bool ctrlKey, bool clickedOnControlPoint, PointD prevSelPoint) { Document doc = PintaCore.Workspace.ActiveDocument; ShapeEngine newEngine = new LineCurveSeriesEngine(doc.CurrentUserLayer, null, BaseEditEngine.ShapeTypes.ClosedLineCurveSeries, owner.UseAntialiasing, true, BaseEditEngine.OutlineColor, BaseEditEngine.FillColor, owner.EditEngine.BrushWidth); addRectanglePoints(ctrlKey, clickedOnControlPoint, newEngine, prevSelPoint); //Set the new shape's DashPattern option. newEngine.DashPattern = dashPBox.comboBox.ComboBox.ActiveText; return(newEngine); }
protected override ShapeEngine CreateShape(bool ctrlKey, bool clickedOnControlPoint, PointD prevSelPoint) { Document doc = PintaCore.Workspace.ActiveDocument; ShapeEngine newEngine = new LineCurveSeriesEngine(doc.CurrentUserLayer, null, BaseEditEngine.ShapeTypes.ClosedLineCurveSeries, owner.UseAntialiasing, true, BaseEditEngine.OutlineColor, BaseEditEngine.FillColor, owner.EditEngine.BrushWidth); AddRectanglePoints(ctrlKey, clickedOnControlPoint, newEngine, prevSelPoint); //Set the new shape's DashPattern option. newEngine.DashPattern = dash_pattern_box.comboBox.ComboBox.ActiveText; return newEngine; }
/// <summary> /// Set the new arrow's settings to be the same as what's in the toolbar settings. /// </summary> protected void setNewArrowSettings(LineCurveSeriesEngine newEngine) { if (showArrowOneBox != null) { newEngine.Arrow1.Show = ArrowOneEnabled; newEngine.Arrow2.Show = ArrowTwoEnabled; newEngine.Arrow1.ArrowSize = ArrowSize.Widget.Value; newEngine.Arrow1.AngleOffset = ArrowAngleOffset.Widget.Value; newEngine.Arrow1.LengthOffset = ArrowLengthOffset.Widget.Value; newEngine.Arrow2.ArrowSize = newEngine.Arrow1.ArrowSize; newEngine.Arrow2.AngleOffset = newEngine.Arrow1.AngleOffset; newEngine.Arrow2.LengthOffset = newEngine.Arrow1.LengthOffset; } }
protected override ShapeEngine createShape(bool ctrlKey, bool clickedOnControlPoint, PointD prevSelPoint) { Document doc = PintaCore.Workspace.ActiveDocument; LineCurveSeriesEngine newEngine = new LineCurveSeriesEngine(doc.CurrentUserLayer, null, BaseEditEngine.ShapeTypes.OpenLineCurveSeries, owner.UseAntialiasing, false, BaseEditEngine.OutlineColor, BaseEditEngine.FillColor, owner.EditEngine.BrushWidth); addLinePoints(ctrlKey, clickedOnControlPoint, newEngine, prevSelPoint); //Set the new shape's DashPattern option. newEngine.DashPattern = dashPBox.comboBox.ComboBox.ActiveText; //Set the new arrow's settings to be the same as what's in the toolbar settings. setNewArrowSettings(newEngine); return(newEngine); }
protected override ShapeEngine CreateShape(bool ctrlKey, bool clickedOnControlPoint, PointD prevSelPoint) { Document doc = PintaCore.Workspace.ActiveDocument; LineCurveSeriesEngine newEngine = new LineCurveSeriesEngine(doc.CurrentUserLayer, null, BaseEditEngine.ShapeTypes.OpenLineCurveSeries, owner.UseAntialiasing, false, BaseEditEngine.OutlineColor, BaseEditEngine.FillColor, owner.EditEngine.BrushWidth); AddLinePoints(ctrlKey, clickedOnControlPoint, newEngine, prevSelPoint); //Set the new shape's DashPattern option. newEngine.DashPattern = dash_pattern_box.comboBox.ComboBox.ActiveText; //Set the new arrow's settings to be the same as what's in the toolbar settings. setNewArrowSettings(newEngine); return newEngine; }
/// <summary> /// Converts the ShapeEngine instance into a new instance of a different ShapeEngine (child) type, copying the common data. /// </summary> /// <param name="newShapeType">The new ShapeEngine type to create.</param> /// <param name="shapeIndex">The index to insert the ShapeEngine clone into SEngines at. /// This ensures that the clone is as transparent as possible.</param> /// <returns>A new ShapeEngine instance of the specified type with the common data copied over.</returns> public ShapeEngine GenericClone(BaseEditEngine.ShapeTypes newShapeType, int shapeIndex) { //Remove the old ShapeEngine instance. BaseEditEngine.SEngines.Remove(this); ShapeEngine clonedEngine; switch (newShapeType) { case BaseEditEngine.ShapeTypes.ClosedLineCurveSeries: clonedEngine = new LineCurveSeriesEngine(parentLayer, DrawingLayer, newShapeType, AntiAliasing, true, OutlineColor, FillColor, BrushWidth); break; case BaseEditEngine.ShapeTypes.Ellipse: clonedEngine = new EllipseEngine(parentLayer, DrawingLayer, AntiAliasing, OutlineColor, FillColor, BrushWidth); break; case BaseEditEngine.ShapeTypes.RoundedLineSeries: clonedEngine = new RoundedLineEngine(parentLayer, DrawingLayer, RoundedLineEditEngine.DefaultRadius, AntiAliasing, OutlineColor, FillColor, BrushWidth); break; default: //Defaults to OpenLineCurveSeries. clonedEngine = new LineCurveSeriesEngine(parentLayer, DrawingLayer, newShapeType, AntiAliasing, false, OutlineColor, FillColor, BrushWidth); break; } clonedEngine.ControlPoints = ControlPoints.Select(i => i.Clone()).ToList(); //Don't clone the GeneratedPoints or OrganizedPoints, as they will be calculated. clonedEngine.DashPattern = DashPattern; //Add the new ShapeEngine instance at the specified index to ensure as transparent of a cloning as possible. BaseEditEngine.SEngines.Insert(shapeIndex, clonedEngine); return(clonedEngine); }
/// <summary> /// Set the new arrow's settings to be the same as what's in the toolbar settings. /// </summary> protected void setNewArrowSettings(LineCurveSeriesEngine newEngine) { if (showArrowOneBox != null) { newEngine.Arrow1.Show = showArrowOneBox.Active; newEngine.Arrow2.Show = showArrowTwoBox.Active; Double.TryParse((arrowSize.ComboBox as Gtk.ComboBoxEntry).Entry.Text, out newEngine.Arrow1.ArrowSize); Double.TryParse((arrowAngleOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text, out newEngine.Arrow1.AngleOffset); Double.TryParse((arrowLengthOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text, out newEngine.Arrow1.LengthOffset); newEngine.Arrow1.ArrowSize = Utility.Clamp(newEngine.Arrow1.ArrowSize, 1d, 100d); newEngine.Arrow2.ArrowSize = newEngine.Arrow1.ArrowSize; newEngine.Arrow1.AngleOffset = Utility.Clamp(newEngine.Arrow1.AngleOffset, -89d, 89d); newEngine.Arrow2.AngleOffset = newEngine.Arrow1.AngleOffset; newEngine.Arrow1.LengthOffset = Utility.Clamp(newEngine.Arrow1.LengthOffset, -100d, 100d); newEngine.Arrow2.LengthOffset = newEngine.Arrow1.LengthOffset; } }
public override void updateToolbarSettings(ShapeEngine engine) { if (engine != null && engine.ShapeType == ShapeTypes.OpenLineCurveSeries) { if (showArrowOneBox != null) { LineCurveSeriesEngine lCSEngine = (LineCurveSeriesEngine)engine; showArrowOneBox.Active = lCSEngine.Arrow1.Show; showArrowTwoBox.Active = lCSEngine.Arrow2.Show; if (showOtherArrowOptions) { (arrowSize.ComboBox as Gtk.ComboBoxEntry).Entry.Text = lCSEngine.Arrow1.ArrowSize.ToString(); (arrowAngleOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = lCSEngine.Arrow1.AngleOffset.ToString(); (arrowLengthOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = lCSEngine.Arrow1.LengthOffset.ToString(); } } base.updateToolbarSettings(engine); } }
public override void UpdateToolbarSettings(ShapeEngine engine) { if (engine != null && engine.ShapeType == ShapeTypes.OpenLineCurveSeries) { if (showArrowOneBox != null) { LineCurveSeriesEngine lCSEngine = (LineCurveSeriesEngine)engine; ArrowOneEnabledCheckBox.Widget.Active = lCSEngine.Arrow1.Show; ArrowTwoEnabledCheckBox.Widget.Active = lCSEngine.Arrow2.Show; if (ArrowOneEnabled || ArrowTwoEnabled) { ArrowSize.Widget.Value = lCSEngine.Arrow1.ArrowSize; ArrowAngleOffset.Widget.Value = lCSEngine.Arrow1.AngleOffset; ArrowLengthOffset.Widget.Value = lCSEngine.Arrow1.LengthOffset; } } base.UpdateToolbarSettings(engine); } }
public override void HandleBuildToolBar(Gtk.Toolbar tb) { base.HandleBuildToolBar(tb); #region Show Arrows //Arrow separator. if (arrowSep == null) { arrowSep = new Gtk.SeparatorToolItem(); showOtherArrowOptions = false; } tb.AppendItem(arrowSep); if (arrowLabel == null) { arrowLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Arrow"))); } tb.AppendItem(arrowLabel); //Show arrow 1. showArrowOneBox = new Gtk.CheckButton("1"); showArrowOneBox.Active = previousSettings1.Show; showArrowOneBox.Toggled += (o, e) => { //Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding. if (!showArrowOneBox.Active && !showArrowTwoBox.Active) { if (showOtherArrowOptions) { tb.Remove(arrowSizeLabel); tb.Remove(arrowSizeMinus); tb.Remove(arrowSize); tb.Remove(arrowSizePlus); tb.Remove(arrowAngleOffsetLabel); tb.Remove(arrowAngleOffsetMinus); tb.Remove(arrowAngleOffset); tb.Remove(arrowAngleOffsetPlus); tb.Remove(arrowLengthOffsetLabel); tb.Remove(arrowLengthOffsetMinus); tb.Remove(arrowLengthOffset); tb.Remove(arrowLengthOffsetPlus); showOtherArrowOptions = false; } } else { if (!showOtherArrowOptions) { tb.Add(arrowSizeLabel); tb.Add(arrowSizeMinus); tb.Add(arrowSize); tb.Add(arrowSizePlus); tb.Add(arrowAngleOffsetLabel); tb.Add(arrowAngleOffsetMinus); tb.Add(arrowAngleOffset); tb.Add(arrowAngleOffsetPlus); tb.Add(arrowLengthOffsetLabel); tb.Add(arrowLengthOffsetMinus); tb.Add(arrowLengthOffset); tb.Add(arrowLengthOffsetPlus); showOtherArrowOptions = true; } } LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow1.Show = showArrowOneBox.Active; DrawActiveShape(false, false, true, false, false); storePreviousSettings(); } }; tb.AddWidgetItem(showArrowOneBox); //Show arrow 2. showArrowTwoBox = new Gtk.CheckButton("2"); showArrowTwoBox.Active = previousSettings2.Show; showArrowTwoBox.Toggled += (o, e) => { //Determine whether to change the visibility of Arrow options in the toolbar based on the updated Arrow showing/hiding. if (!showArrowOneBox.Active && !showArrowTwoBox.Active) { if (showOtherArrowOptions) { tb.Remove(arrowSizeLabel); tb.Remove(arrowSizeMinus); tb.Remove(arrowSize); tb.Remove(arrowSizePlus); tb.Remove(arrowAngleOffsetLabel); tb.Remove(arrowAngleOffsetMinus); tb.Remove(arrowAngleOffset); tb.Remove(arrowAngleOffsetPlus); tb.Remove(arrowLengthOffsetLabel); tb.Remove(arrowLengthOffsetMinus); tb.Remove(arrowLengthOffset); tb.Remove(arrowLengthOffsetPlus); showOtherArrowOptions = false; } } else { if (!showOtherArrowOptions) { tb.Add(arrowSizeLabel); tb.Add(arrowSizeMinus); tb.Add(arrowSize); tb.Add(arrowSizePlus); tb.Add(arrowAngleOffsetLabel); tb.Add(arrowAngleOffsetMinus); tb.Add(arrowAngleOffset); tb.Add(arrowAngleOffsetPlus); tb.Add(arrowLengthOffsetLabel); tb.Add(arrowLengthOffsetMinus); tb.Add(arrowLengthOffset); tb.Add(arrowLengthOffsetPlus); showOtherArrowOptions = true; } } LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow2.Show = showArrowTwoBox.Active; DrawActiveShape(false, false, true, false, false); storePreviousSettings(); } }; tb.AddWidgetItem(showArrowTwoBox); #endregion Show Arrows #region Arrow Size if (arrowSizeLabel == null) { arrowSizeLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Size"))); } if (arrowSizeMinus == null) { arrowSizeMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease arrow size")); arrowSizeMinus.Clicked += new EventHandler(arrowSizeMinus_Clicked); } if (arrowSize == null) { arrowSize = new ToolBarComboBox(65, 7, true, "3", "4", "5", "6", "7", "8", "9", "10", "12", "15", "18", "20", "25", "30", "40", "50", "60", "70", "80", "90", "100"); arrowSize.ComboBox.Changed += (o, e) => { if (arrowSize.ComboBox.ActiveText.Length < 1) { //Ignore the change until the user enters something. return; } else { double newSize = 10d; if (arrowSize.ComboBox.ActiveText == "-") { //The user is trying to enter a negative value: change it to 1. newSize = 1d; } else { if (Double.TryParse(arrowSize.ComboBox.ActiveText, out newSize)) { if (newSize < 1d) { //Less than 1: change it to 1. newSize = 1d; } else if (newSize > 100d) { //Greater than 100: change it to 100. newSize = 100d; } } else { //Not a number: wait until the user enters something. return; } } (arrowSize.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newSize.ToString(); LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow1.ArrowSize = newSize; activeEngine.Arrow2.ArrowSize = newSize; DrawActiveShape(false, false, true, false, false); storePreviousSettings(); } } }; } if (arrowSizePlus == null) { arrowSizePlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase arrow size")); arrowSizePlus.Clicked += new EventHandler(arrowSizePlus_Clicked); } #endregion Arrow Size #region Angle Offset if (arrowAngleOffsetLabel == null) { arrowAngleOffsetLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Angle"))); } if (arrowAngleOffsetMinus == null) { arrowAngleOffsetMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease angle offset")); arrowAngleOffsetMinus.Clicked += new EventHandler(arrowAngleOffsetMinus_Clicked); } if (arrowAngleOffset == null) { arrowAngleOffset = new ToolBarComboBox(65, 9, true, "-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30"); arrowAngleOffset.ComboBox.Changed += (o, e) => { if (arrowAngleOffset.ComboBox.ActiveText.Length < 1) { //Ignore the change until the user enters something. return; } else if (arrowAngleOffset.ComboBox.ActiveText == "-") { //The user is trying to enter a negative value: ignore the change until the user enters more. return; } else { double newAngle = 15d; if (Double.TryParse(arrowAngleOffset.ComboBox.ActiveText, out newAngle)) { if (newAngle < -89d) { //Less than -89: change it to -89. newAngle = -89d; } else if (newAngle > 89d) { //Greater than 89: change it to 89. newAngle = 89d; } } else { //Not a number: wait until the user enters something. return; } (arrowAngleOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newAngle.ToString(); LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow1.AngleOffset = newAngle; activeEngine.Arrow2.AngleOffset = newAngle; DrawActiveShape(false, false, true, false, false); storePreviousSettings(); } } }; } if (arrowAngleOffsetPlus == null) { arrowAngleOffsetPlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase angle offset")); arrowAngleOffsetPlus.Clicked += new EventHandler(arrowAngleOffsetPlus_Clicked); } #endregion Angle Offset #region Length Offset if (arrowLengthOffsetLabel == null) { arrowLengthOffsetLabel = new ToolBarLabel(string.Format(" {0}: ", Catalog.GetString("Length"))); } if (arrowLengthOffsetMinus == null) { arrowLengthOffsetMinus = new ToolBarButton("Toolbar.MinusButton.png", "", Catalog.GetString("Decrease length offset")); arrowLengthOffsetMinus.Clicked += new EventHandler(arrowLengthOffsetMinus_Clicked); } if (arrowLengthOffset == null) { arrowLengthOffset = new ToolBarComboBox(65, 8, true, "-30", "-25", "-20", "-15", "-10", "-5", "0", "5", "10", "15", "20", "25", "30"); arrowLengthOffset.ComboBox.Changed += (o, e) => { if (arrowLengthOffset.ComboBox.ActiveText.Length < 1) { //Ignore the change until the user enters something. return; } else if (arrowLengthOffset.ComboBox.ActiveText == "-") { //The user is trying to enter a negative value: ignore the change until the user enters more. return; } else { double newLength = 10d; if (Double.TryParse(arrowLengthOffset.ComboBox.ActiveText, out newLength)) { if (newLength < -100d) { //Less than -100: change it to -100. newLength = -100d; } else if (newLength > 100d) { //Greater than 100: change it to 100. newLength = 100d; } } else { //Not a number: wait until the user enters something. return; } (arrowLengthOffset.ComboBox as Gtk.ComboBoxEntry).Entry.Text = newLength.ToString(); LineCurveSeriesEngine activeEngine = (LineCurveSeriesEngine)ActiveShapeEngine; if (activeEngine != null) { activeEngine.Arrow1.LengthOffset = newLength; activeEngine.Arrow2.LengthOffset = newLength; DrawActiveShape(false, false, true, false, false); storePreviousSettings(); } } }; } if (arrowLengthOffsetPlus == null) { arrowLengthOffsetPlus = new ToolBarButton("Toolbar.PlusButton.png", "", Catalog.GetString("Increase length offset")); arrowLengthOffsetPlus.Clicked += new EventHandler(arrowLengthOffsetPlus_Clicked); } #endregion Length Offset if (showOtherArrowOptions) { tb.Add(arrowSizeLabel); tb.Add(arrowSizeMinus); tb.Add(arrowSize); tb.Add(arrowSizePlus); tb.Add(arrowAngleOffsetLabel); tb.Add(arrowAngleOffsetMinus); tb.Add(arrowAngleOffset); tb.Add(arrowAngleOffsetPlus); tb.Add(arrowLengthOffsetLabel); tb.Add(arrowLengthOffsetMinus); tb.Add(arrowLengthOffset); tb.Add(arrowLengthOffsetPlus); } }
private LineCurveSeriesEngine (LineCurveSeriesEngine src) : base (src) { Arrow1 = src.Arrow1.Clone (); Arrow2 = src.Arrow2.Clone (); }
private LineCurveSeriesEngine(LineCurveSeriesEngine src) : base(src) { Arrow1 = src.Arrow1.Clone(); Arrow2 = src.Arrow2.Clone(); }