From 5aef55152bb09b9ed0fbd7a1d720e9f8c2f67198 Mon Sep 17 00:00:00 2001 From: Jaex Date: Sun, 8 May 2016 22:23:47 +0300 Subject: [PATCH] Added "Show FPS" to options sub menu --- .../Forms/RectangleRegionForm.cs | 4 ++-- ShareX.ScreenCaptureLib/Forms/SurfaceForm.cs | 18 ++++++++++-------- .../RegionHelpers/AreaManager.cs | 12 +++++++++--- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs index 01fa4f103..da4a88d45 100644 --- a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs @@ -356,14 +356,14 @@ private void DrawMenuTip(Graphics g) { // TODO: Translate string tipText = "Tip: Right click to open options menu"; - Size textSize = g.MeasureString(tipText, textFont).ToSize(); + Size textSize = g.MeasureString(tipText, infoFontMedium).ToSize(); int offset = 10; int padding = 3; int rectWidth = textSize.Width + padding * 2; int rectHeight = textSize.Height + padding * 2; Rectangle primaryScreenBounds = CaptureHelpers.GetPrimaryScreenBounds0Based(); Rectangle textRectangle = new Rectangle(primaryScreenBounds.X + (primaryScreenBounds.Width / 2) - (rectWidth / 2), primaryScreenBounds.Y + offset, rectWidth, rectHeight); - DrawInfoText(g, tipText, textRectangle, textFont, padding); + DrawInfoText(g, tipText, textRectangle, infoFontMedium, padding); } protected virtual void WriteTips(StringBuilder sb) diff --git a/ShareX.ScreenCaptureLib/Forms/SurfaceForm.cs b/ShareX.ScreenCaptureLib/Forms/SurfaceForm.cs index 5a9fd40dc..7f6c4d40d 100644 --- a/ShareX.ScreenCaptureLib/Forms/SurfaceForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/SurfaceForm.cs @@ -53,7 +53,7 @@ public abstract class SurfaceForm : Form protected GraphicsPath regionFillPath, regionDrawPath; protected Pen borderPen, borderDotPen, textBackgroundPenWhite, textBackgroundPenBlack, markerPen; protected Brush nodeBackgroundBrush, textBackgroundBrush; - protected Font textFont, infoFont; + protected Font infoFont, infoFontMedium, infoFontBig; protected Stopwatch timerStart, timerFPS; protected int frameCount; protected bool isKeyAllowed; @@ -84,8 +84,9 @@ public SurfaceForm() borderDotPen = new Pen(Color.White); borderDotPen.DashPattern = new float[] { 5, 5 }; nodeBackgroundBrush = new SolidBrush(Color.White); - textFont = new Font("Verdana", 12); infoFont = new Font("Verdana", 9); + infoFontMedium = new Font("Verdana", 12); + infoFontBig = new Font("Verdana", 16, FontStyle.Bold); textBackgroundBrush = new SolidBrush(Color.FromArgb(75, Color.Black)); textBackgroundPenWhite = new Pen(Color.FromArgb(50, Color.White)); textBackgroundPenBlack = new Pen(Color.FromArgb(150, Color.Black)); @@ -249,7 +250,7 @@ protected override void OnPaint(PaintEventArgs e) if (Config.ShowFPS) { CheckFPS(); - DrawInfo(g); + DrawFPS(g); } if (!pause) @@ -397,13 +398,13 @@ private void CheckFPS() } } - private void DrawInfo(Graphics g) + private void DrawFPS(Graphics g) { string text = "FPS: " + FPS; - SizeF textSize = g.MeasureString(text, textFont); + SizeF textSize = g.MeasureString(text, infoFontBig); - int offset = 30; + int offset = 10; Rectangle primaryScreenBounds = CaptureHelpers.GetPrimaryScreenBounds0Based(); Rectangle textRectangle = new Rectangle(primaryScreenBounds.X + offset, primaryScreenBounds.Y + offset, (int)textSize.Width, (int)textSize.Height); @@ -413,7 +414,7 @@ private void DrawInfo(Graphics g) textRectangle.Y = primaryScreenBounds.Height - textRectangle.Height - offset; } - ImageHelpers.DrawTextWithOutline(g, text, textRectangle.Location, textFont, Color.White, Color.Black); + ImageHelpers.DrawTextWithOutline(g, text, textRectangle.Location, infoFontBig, Color.White, Color.Black); } protected Rectangle CalculateAreaFromNodes() @@ -470,8 +471,9 @@ protected override void Dispose(bool disposing) if (borderPen != null) borderPen.Dispose(); if (borderDotPen != null) borderDotPen.Dispose(); if (nodeBackgroundBrush != null) nodeBackgroundBrush.Dispose(); - if (textFont != null) textFont.Dispose(); if (infoFont != null) infoFont.Dispose(); + if (infoFontMedium != null) infoFontMedium.Dispose(); + if (infoFontBig != null) infoFontBig.Dispose(); if (textBackgroundBrush != null) textBackgroundBrush.Dispose(); if (textBackgroundPenWhite != null) textBackgroundPenWhite.Dispose(); if (textBackgroundPenBlack != null) textBackgroundPenBlack.Dispose(); diff --git a/ShareX.ScreenCaptureLib/RegionHelpers/AreaManager.cs b/ShareX.ScreenCaptureLib/RegionHelpers/AreaManager.cs index 80ecb1dce..65b2df8c8 100644 --- a/ShareX.ScreenCaptureLib/RegionHelpers/AreaManager.cs +++ b/ShareX.ScreenCaptureLib/RegionHelpers/AreaManager.cs @@ -362,13 +362,13 @@ private void CreateContextMenu() tsmiQuickCrop.Click += (sender, e) => config.QuickCrop = !tsmiQuickCrop.Checked; tsmiOptions.DropDownItems.Add(tsmiQuickCrop); - ToolStripMenuItem tsmiShowInfo = new ToolStripMenuItem("Position and size info"); + ToolStripMenuItem tsmiShowInfo = new ToolStripMenuItem("Show position and size info"); tsmiShowInfo.Checked = config.ShowInfo; tsmiShowInfo.CheckOnClick = true; tsmiShowInfo.Click += (sender, e) => config.ShowInfo = tsmiShowInfo.Checked; tsmiOptions.DropDownItems.Add(tsmiShowInfo); - ToolStripMenuItem tsmiShowMagnifier = new ToolStripMenuItem("Magnifier"); + ToolStripMenuItem tsmiShowMagnifier = new ToolStripMenuItem("Show magnifier"); tsmiShowMagnifier.Checked = config.ShowMagnifier; tsmiShowMagnifier.CheckOnClick = true; tsmiShowMagnifier.Click += (sender, e) => config.ShowMagnifier = tsmiShowMagnifier.Checked; @@ -397,12 +397,18 @@ private void CreateContextMenu() tslnudMagnifierPixelSize.LabeledNumericUpDownControl.ValueChanged = (sender, e) => config.MagnifierPixelSize = (int)tslnudMagnifierPixelSize.LabeledNumericUpDownControl.Value; tsmiOptions.DropDownItems.Add(tslnudMagnifierPixelSize); - ToolStripMenuItem tsmiShowCrosshair = new ToolStripMenuItem("Screen wide crosshair"); + ToolStripMenuItem tsmiShowCrosshair = new ToolStripMenuItem("Show screen wide crosshair"); tsmiShowCrosshair.Checked = config.ShowCrosshair; tsmiShowCrosshair.CheckOnClick = true; tsmiShowCrosshair.Click += (sender, e) => config.ShowCrosshair = tsmiShowCrosshair.Checked; tsmiOptions.DropDownItems.Add(tsmiShowCrosshair); + ToolStripMenuItem tsmiShowFPS = new ToolStripMenuItem("Show FPS"); + tsmiShowFPS.Checked = config.ShowFPS; + tsmiShowFPS.CheckOnClick = true; + tsmiShowFPS.Click += (sender, e) => config.ShowFPS = tsmiShowFPS.Checked; + tsmiOptions.DropDownItems.Add(tsmiShowFPS); + CurrentShapeTypeChanged += shapeType => { foreach (ToolStripMenuItem tsmi in cmsContextMenu.Items.OfType().Where(x => x.Tag is ShapeType))