fixed #231: When doing recording selection proper even size handling

This commit is contained in:
Jaex 2014-08-08 19:13:00 +03:00
parent e0634cfc4a
commit 7ed08a007a
6 changed files with 21 additions and 9 deletions

View file

@ -63,6 +63,15 @@ public static void DrawRoundedRectangle(this Graphics g, Brush brush, Pen pen, i
DrawRoundedRectangle(g, brush, pen, new Rectangle(x, y, width, height), radius);
}
public static void DrawDiamond(this Graphics g, Pen pen, Rectangle rect)
{
using (GraphicsPath gp = new GraphicsPath())
{
gp.AddDiamond(rect);
g.DrawPath(pen, gp);
}
}
public static void DrawCrossRectangle(this Graphics g, Pen pen, Rectangle rect, int crossSize)
{
rect = rect.SizeOffset(-1);

View file

@ -311,8 +311,8 @@ public static Rectangle GetWindowRectangle(IntPtr handle, bool maximizeFix = tru
public static Rectangle EvenRectangleSize(Rectangle rect)
{
rect.Width += rect.Width & 1;
rect.Height += rect.Height & 1;
rect.Width -= rect.Width & 1;
rect.Height -= rect.Height & 1;
return rect;
}
}

View file

@ -59,7 +59,7 @@ internal enum NodePosition
internal enum NodeShape
{
Square, Circle
Square, Circle, Diamond
}
public enum FFmpegVideoCodec

View file

@ -145,7 +145,7 @@ protected override void Draw(Graphics g)
private void CreateNode()
{
NodeObject newNode = new NodeObject() { Shape = NodeShape.Circle };
NodeObject newNode = new NodeObject() { Shape = NodeShape.Diamond };
ActivateNode(newNode);
nodes.Add(newNode);
DrawableObjects.Add(newNode);

View file

@ -70,6 +70,10 @@ public override void Draw(Graphics g)
g.DrawEllipse(Pens.White, rect.RectangleOffset(-1));
g.DrawEllipse(Pens.Black, rect);
break;
case NodeShape.Diamond:
g.DrawDiamond(Pens.White, rect.RectangleOffset(-1));
g.DrawDiamond(Pens.Black, rect);
break;
}
}
}

View file

@ -75,10 +75,7 @@ private void TrayIcon_MouseClick(object sender, MouseEventArgs e)
private void SelectRegion()
{
if (TaskHelpers.SelectRegion(out captureRectangle) && !captureRectangle.IsEmpty)
{
captureRectangle = CaptureHelpers.EvenRectangleSize(captureRectangle);
}
TaskHelpers.SelectRegion(out captureRectangle);
}
private void ActiveWindowRegion(TaskSettings taskSettings)
@ -147,7 +144,9 @@ public void StartRecording(TaskSettings taskSettings)
SelectRegion();
}
if (IsRecording || captureRectangle.IsEmpty || screenRecorder != null)
captureRectangle = CaptureHelpers.EvenRectangleSize(captureRectangle);
if (IsRecording || !captureRectangle.IsValid() || screenRecorder != null)
{
return;
}