Added FPS limit option to region capture options menu

This commit is contained in:
Jaex 2022-01-18 08:22:31 +03:00
parent 51d55059f9
commit 621c8db965
3 changed files with 19 additions and 6 deletions

View File

@ -69,6 +69,7 @@ namespace ShareX.ScreenCaptureLib
internal ShapeManager ShapeManager { get; private set; }
internal bool IsClosing { get; private set; }
internal FPSManager FPSManager { get; private set; }
internal Bitmap DimmedCanvas;
internal Image CustomNodeImage = Resources.CircleNode;
@ -86,7 +87,6 @@ namespace ShareX.ScreenCaptureLib
private TextAnimation editorPanTipAnimation;
private Cursor defaultCursor, openHandCursor, closedHandCursor;
private Color canvasBackgroundColor, canvasBorderColor, textColor, textShadowColor, textBackgroundColor, textOuterBorderColor, textInnerBorderColor;
private FPSManager fpsManager;
public RegionCaptureForm(RegionCaptureMode mode, RegionCaptureOptions options, Bitmap canvas = null)
{
@ -104,11 +104,11 @@ namespace ShareX.ScreenCaptureLib
CanvasRectangle = ClientArea;
timerStart = new Stopwatch();
fpsManager = new FPSManager()
FPSManager = new FPSManager()
{
FPSLimit = 100
};
fpsManager.FPSUpdated += FpsManager_FPSChanged;
FPSManager.FPSUpdated += FpsManager_FPSChanged;
regionAnimation = new RectangleAnimation()
{
Duration = TimeSpan.FromMilliseconds(200)
@ -272,7 +272,7 @@ namespace ShareX.ScreenCaptureLib
if (!IsFullscreen && Options.ShowFPS)
{
text += " - FPS: " + fpsManager.FPS.ToString();
text += " - FPS: " + FPSManager.FPS.ToString();
}
}
else
@ -722,7 +722,7 @@ namespace ShareX.ScreenCaptureLib
timerStart.Start();
}
fpsManager.Update();
FPSManager.Update();
UpdateCoordinates();
@ -970,7 +970,7 @@ namespace ShareX.ScreenCaptureLib
textPosition = textPosition.Add(rectScreen.Location);
}
g.DrawTextWithShadow(fpsManager.FPS.ToString(), textPosition, infoFontBig, Brushes.White, Brushes.Black, new Point(0, 1));
g.DrawTextWithShadow(FPSManager.FPS.ToString(), textPosition, infoFontBig, Brushes.White, Brushes.Black, new Point(0, 1));
}
private void DrawInfoText(Graphics g, string text, Rectangle rect, Font font, int padding)

View File

@ -71,6 +71,7 @@ namespace ShareX.ScreenCaptureLib
public bool IsFixedSize = false;
public Size FixedSize = new Size(250, 250);
public bool ShowFPS = false;
public int FPSLimit = 100;
public int MenuIconSize = 0;
public bool MenuLocked = false;
public bool RememberMenuState = false;

View File

@ -989,6 +989,18 @@ namespace ShareX.ScreenCaptureLib
};
tsddbOptions.DropDownItems.Add(tsmiShowFPS);
// TODO: Translate
ToolStripLabeledNumericUpDown tslnudFPSLimit = new ToolStripLabeledNumericUpDown("FPS limit:");
tslnudFPSLimit.Content.Minimum = 0;
tslnudFPSLimit.Content.Maximum = 300;
tslnudFPSLimit.Content.Value = Options.FPSLimit;
tslnudFPSLimit.Content.ValueChanged = (sender, e) =>
{
Options.FPSLimit = (int)tslnudFPSLimit.Content.Value;
Form.FPSManager.FPSLimit = Options.FPSLimit;
};
tsddbOptions.DropDownItems.Add(tslnudFPSLimit);
ToolStripMenuItem tsmiSwitchToDrawingToolAfterSelection = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_SwitchToDrawingToolAfterSelection);
tsmiSwitchToDrawingToolAfterSelection.Checked = Options.SwitchToDrawingToolAfterSelection;
tsmiSwitchToDrawingToolAfterSelection.CheckOnClick = true;