more work on gtk & code cleanup
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
using Pilz.Drawing;
|
||||
using Pilz.UI.WinForms.PaintingControl.EventArgs;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
|
||||
@@ -35,7 +31,7 @@ public class DefaultDrawMethodes
|
||||
|
||||
e.Graphics.DrawString(obj.Text, new Font(obj.TextFont.FontFamily, obj.TextFont.Size * zoomFactor, obj.TextFont.Style), b, rect, f);
|
||||
}
|
||||
private static object _DrawPicture_newSyncObj = new object();
|
||||
private static object _DrawPicture_newSyncObj = new();
|
||||
|
||||
public static void DrawPicture(PaintingObjectPaintEventArgs e)
|
||||
{
|
||||
@@ -276,9 +272,11 @@ public class DefaultDrawMethodes
|
||||
public static void DrawAreaSelection(PaintEventArgs e, PaintingControl pc, PointF startMousePos, PointF lastMousePos)
|
||||
{
|
||||
var rectToDraw = HelpfulDrawingFunctions.GetRectangle(startMousePos, lastMousePos);
|
||||
var p = new Pen(pc.AreaSelectionColor);
|
||||
p.DashStyle = startMousePos.X >= lastMousePos.X ? DashStyle.DashDot : DashStyle.Solid;
|
||||
p.Width = 3f;
|
||||
var p = new Pen(pc.AreaSelectionColor)
|
||||
{
|
||||
DashStyle = startMousePos.X >= lastMousePos.X ? DashStyle.DashDot : DashStyle.Solid,
|
||||
Width = 3f
|
||||
};
|
||||
e.Graphics.DrawRectangle(p, rectToDraw.X, rectToDraw.Y, rectToDraw.Width, rectToDraw.Height);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
|
||||
namespace Pilz.UI.WinForms.PaintingControl.EventArgs;
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
|
||||
public class PaintingObjectEventArgs(PaintingObject[] paintingObjects) : EventArgs
|
||||
{
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
|
||||
namespace Pilz.UI.WinForms.PaintingControl.EventArgs;
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
|
||||
public class PaintingObjectPaintEventArgs(PaintingObject obj, Graphics g, PointF offset) : EventArgs
|
||||
{
|
||||
@@ -45,7 +42,7 @@ public class PaintingObjectPaintEventArgs(PaintingObject obj, Graphics g, PointF
|
||||
/// The rectangle of the PaintingObject on Screen.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public RectangleF Rectangle => new RectangleF(X, Y, PaintingObject.Width, PaintingObject.Height);
|
||||
public RectangleF Rectangle => new(X, Y, PaintingObject.Width, PaintingObject.Height);
|
||||
|
||||
public PaintingObjectPaintEventArgs(PaintingObject obj, Graphics g) : this(obj, g, obj.Parent.Offset)
|
||||
{
|
||||
|
||||
@@ -1,15 +1,9 @@
|
||||
using Pilz.Drawing;
|
||||
using Pilz.UI.WinForms.PaintingControl.EventArgs;
|
||||
using Pilz.UI.WinForms.Utilities;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
|
||||
@@ -48,7 +42,7 @@ public class PaintingControl : UserControl, IPaintingObjectContainer
|
||||
public Color GridColor { get; set; } = Color.LightGray;
|
||||
public DelegateDrawPaintingControlGridMethode DrawGridMethode { get; set; } = DefaultDrawMethodes.DrawGrid;
|
||||
public DelegateDrawPaintingControlAreaSelectionMethode DrawAreaSelectionMethode { get; set; } = DefaultDrawMethodes.DrawAreaSelection;
|
||||
private SizeF _ZoomFactor = new SizeF(1f, 1f);
|
||||
private SizeF _ZoomFactor = new(1f, 1f);
|
||||
|
||||
private int _stopDrawing = -1;
|
||||
private Image bufferedImg = null;
|
||||
@@ -57,7 +51,7 @@ public class PaintingControl : UserControl, IPaintingObjectContainer
|
||||
private bool pressedControl = false;
|
||||
private bool pressedAlt = false;
|
||||
|
||||
private Dictionary<PaintingObject, PointF> savedPos = new Dictionary<PaintingObject, PointF>();
|
||||
private Dictionary<PaintingObject, PointF> savedPos = [];
|
||||
|
||||
public event SelectionChangedEventHandler SelectionChanged;
|
||||
|
||||
@@ -413,8 +407,7 @@ public class PaintingControl : UserControl, IPaintingObjectContainer
|
||||
{
|
||||
if (IsResizingObjs(objs))
|
||||
return;
|
||||
if (movedObjs is null)
|
||||
movedObjs = new List<PaintingObject>();
|
||||
movedObjs ??= [];
|
||||
|
||||
SuspendDrawing();
|
||||
|
||||
@@ -663,7 +656,8 @@ public class PaintingControl : UserControl, IPaintingObjectContainer
|
||||
{
|
||||
obj2.X -= modLeft;
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
zoomLocation(obj);
|
||||
|
||||
@@ -674,7 +668,8 @@ public class PaintingControl : UserControl, IPaintingObjectContainer
|
||||
var modW = (int)Math.Round(obj.Width % zoomedGridChunkSize.Width);
|
||||
|
||||
|
||||
void zoomSize(PaintingObject obj2) { if (obj2.EnableResize && !obj2.HardcodedSize) { if (modH > halfHeight) obj2.Height += zoomedGridChunkSize.Height - modH; else { obj2.Height -= modH; } if (modW > halfWidth) obj2.Width += zoomedGridChunkSize.Width - modW; else { obj2.Width -= modW; } } };
|
||||
void zoomSize(PaintingObject obj2) { if (obj2.EnableResize && !obj2.HardcodedSize) { if (modH > halfHeight) obj2.Height += zoomedGridChunkSize.Height - modH; else { obj2.Height -= modH; } if (modW > halfWidth) obj2.Width += zoomedGridChunkSize.Width - modW; else { obj2.Width -= modW; } } }
|
||||
;
|
||||
|
||||
zoomSize(obj);
|
||||
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using Pilz.UI.WinForms.PaintingControl.EventArgs;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
|
||||
|
||||
public delegate void DelegateDrawPaintingObjectMethode(PaintingObjectPaintEventArgs e);
|
||||
|
||||
@@ -1,12 +1,7 @@
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
|
||||
@@ -33,9 +28,9 @@ public class PaintingObject : ICloneable, IPaintingObjectContainer
|
||||
public Font TextFont { get; set; } = new Font(FontFamily.GenericSansSerif, 8.25f);
|
||||
public Color TextColor { get; set; } = Color.Black;
|
||||
[JsonProperty]
|
||||
private PointF _Location = new PointF(50f, 50f);
|
||||
private PointF _Location = new(50f, 50f);
|
||||
[JsonProperty]
|
||||
private SizeF _Size = new SizeF(50f, 80f);
|
||||
private SizeF _Size = new(50f, 80f);
|
||||
public bool EnableFill { get; set; } = true;
|
||||
public bool EnableOutline { get; set; } = true;
|
||||
public Color SelectionColor { get; set; } = Color.CornflowerBlue;
|
||||
@@ -50,9 +45,9 @@ public class PaintingObject : ICloneable, IPaintingObjectContainer
|
||||
[JsonIgnore]
|
||||
public object Tag { get; set; } = null;
|
||||
public string Name { get; set; } = "";
|
||||
public List<PaintingObject> PinnedObjects { get; private set; } = new List<PaintingObject>();
|
||||
public List<PaintingObject> PinnedObjects { get; private set; } = [];
|
||||
[JsonIgnore]
|
||||
public List<DelegateDrawPaintingObjectMethode> DrawMethodes { get; private set; } = new List<DelegateDrawPaintingObjectMethode>();
|
||||
public List<DelegateDrawPaintingObjectMethode> DrawMethodes { get; private set; } = [];
|
||||
[JsonIgnore]
|
||||
public DelegateDrawPaintingObjectMethode DrawSelectionMethode { get; private set; } = DefaultDrawMethodes.DrawSelection;
|
||||
public Cursor Cursor { get; set; } = Cursors.Default;
|
||||
@@ -165,32 +160,32 @@ public class PaintingObject : ICloneable, IPaintingObjectContainer
|
||||
{
|
||||
case "DrawPicture":
|
||||
{
|
||||
tt = tt | PaintingObjectType.Picture;
|
||||
tt |= PaintingObjectType.Picture;
|
||||
break;
|
||||
}
|
||||
case "DrawText":
|
||||
{
|
||||
tt = tt | PaintingObjectType.Text;
|
||||
tt |= PaintingObjectType.Text;
|
||||
break;
|
||||
}
|
||||
case "DrawRectangle":
|
||||
{
|
||||
tt = tt | PaintingObjectType.Rectangle;
|
||||
tt |= PaintingObjectType.Rectangle;
|
||||
break;
|
||||
}
|
||||
case "DrawEllipse":
|
||||
{
|
||||
tt = tt | PaintingObjectType.Elipse;
|
||||
tt |= PaintingObjectType.Elipse;
|
||||
break;
|
||||
}
|
||||
case "DrawTriangle":
|
||||
{
|
||||
tt = tt | PaintingObjectType.Triangle;
|
||||
tt |= PaintingObjectType.Triangle;
|
||||
break;
|
||||
}
|
||||
case "DrawLine":
|
||||
{
|
||||
tt = tt | PaintingObjectType.Line;
|
||||
tt |= PaintingObjectType.Line;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -699,7 +694,8 @@ public class PaintingObject : ICloneable, IPaintingObjectContainer
|
||||
if (!blackFields.Contains(@field.Name))
|
||||
@field.SetValue(dest, @field.GetValue(source));
|
||||
}
|
||||
};
|
||||
}
|
||||
;
|
||||
|
||||
copyFields(this, obj, blackField, metype);
|
||||
copyFields(ImageProperties, obj.ImageProperties, Array.Empty<string>(), ImageProperties.GetType());
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Data;
|
||||
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
|
||||
@@ -10,7 +7,7 @@ public class PaintingObjectListLayering
|
||||
|
||||
|
||||
public PaintingObjectList ObjectList { get; private set; }
|
||||
public Dictionary<int, Func<PaintingObject, bool>> Conditions { get; private set; } = new Dictionary<int, Func<PaintingObject, bool>>();
|
||||
public Dictionary<int, Func<PaintingObject, bool>> Conditions { get; private set; } = [];
|
||||
|
||||
/// <summary>
|
||||
/// Get the order function will checkout the conditions.
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
using Pilz.Drawing;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace Pilz.UI.WinForms.PaintingControl;
|
||||
|
||||
@@ -95,7 +92,7 @@ internal class PaintingObjectResizing
|
||||
private EdgeEnum mEdge = EdgeEnum.None;
|
||||
private int mWidth = 4;
|
||||
private int qWidth = 4 * 4;
|
||||
private Rectangle rect = new Rectangle();
|
||||
private Rectangle rect = new();
|
||||
|
||||
public bool Enabled { get; set; } = true;
|
||||
public SizeF MinimumSize { get; set; } = new SizeF(15f, 15f);
|
||||
@@ -239,11 +236,13 @@ internal class PaintingObjectResizing
|
||||
RectangleF extRect = mObj.RectangleExtended;
|
||||
var oldRect = mObj.Rectangle;
|
||||
|
||||
var newRect = new RectangleF();
|
||||
newRect.X = extRect.X - oldRect.X;
|
||||
newRect.Y = extRect.Y - oldRect.Y;
|
||||
newRect.Width = (extRect.Width - oldRect.Width) / 2f;
|
||||
newRect.Height = (extRect.Height - oldRect.Height) / 2f;
|
||||
var newRect = new RectangleF
|
||||
{
|
||||
X = extRect.X - oldRect.X,
|
||||
Y = extRect.Y - oldRect.Y,
|
||||
Width = (extRect.Width - oldRect.Width) / 2f,
|
||||
Height = (extRect.Height - oldRect.Height) / 2f
|
||||
};
|
||||
|
||||
var setToNone = false;
|
||||
var isOnTop = ReferenceEquals(mObj.Parent.GetObject(new PointF(realX, realY), true), mObj);
|
||||
|
||||
Reference in New Issue
Block a user