Small DrawableObject changes

This commit is contained in:
Jaex 2017-12-10 15:44:02 +03:00
parent 4085e5a5e4
commit 0a9a479264
2 changed files with 23 additions and 19 deletions

View file

@ -625,7 +625,7 @@ private void UpdateCoordinates()
UpdateCoordinates();
UpdateDrawableObjects();
UpdateObjects();
if (ShapeManager.IsPanning)
{
@ -643,7 +643,7 @@ private void UpdateCoordinates()
}
}
private void UpdateDrawableObjects()
private void UpdateObjects()
{
DrawableObject[] objects = DrawableObjects.OrderByDescending(x => x.Order).ToArray();
@ -651,7 +651,7 @@ private void UpdateDrawableObjects()
if (objects.All(x => !x.IsDragging))
{
for (int i = 0; i < objects.Count(); i++)
for (int i = 0; i < objects.Length; i++)
{
DrawableObject obj = objects[i];
@ -666,9 +666,9 @@ private void UpdateDrawableObjects()
obj.OnMousePressed(position);
}
for (int y = i + 1; y < objects.Count(); y++)
for (int j = i + 1; j < objects.Length; j++)
{
objects[y].IsCursorHover = false;
objects[j].IsCursorHover = false;
}
break;
@ -691,6 +691,17 @@ private void UpdateDrawableObjects()
}
}
private void DrawObjects(Graphics g)
{
foreach (DrawableObject obj in DrawableObjects)
{
if (obj.Visible)
{
obj.OnDraw(g);
}
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
//base.OnPaintBackground(e);
@ -907,17 +918,6 @@ internal void DrawRegionArea(Graphics g, Rectangle rect, bool isAnimated)
}
}
private void DrawObjects(Graphics g)
{
foreach (DrawableObject drawObject in DrawableObjects)
{
if (drawObject.Visible)
{
drawObject.OnDraw(g);
}
}
}
private void CheckFPS()
{
frameCount++;

View file

@ -27,17 +27,21 @@ You should have received a copy of the GNU General Public License
namespace ShareX.ScreenCaptureLib
{
internal class DrawableObject
internal abstract class DrawableObject
{
public bool Visible { get; set; }
public Rectangle Rectangle { get; set; }
public bool IsCursorHover { get; set; }
public bool IsDragging { get; set; }
public bool IsDragging { get; protected set; }
public int Order { get; set; }
public virtual void OnDraw(Graphics g)
{
if (IsCursorHover)
if (IsDragging)
{
g.FillRectangle(Brushes.Blue, Rectangle);
}
else if (IsCursorHover)
{
g.FillRectangle(Brushes.Green, Rectangle);
}