From a74d510365587fd3e8aaa520594636ee96a2ac4c Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 24 Nov 2017 17:07:39 +0300 Subject: [PATCH] Show image pan tip in image editor until first time panned --- .../Forms/RegionCaptureForm.cs | 40 ++++++++++++++++++- .../RegionCaptureOptions.cs | 1 + .../Shapes/ShapeManager.cs | 2 + 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs b/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs index 85e10a304..57a15905b 100644 --- a/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/RegionCaptureForm.cs @@ -98,6 +98,7 @@ public Color CurrentColor private int frameCount; private bool pause, isKeyAllowed; private RectangleAnimation regionAnimation; + private TextAnimation editorPanTipAnimation; private Bitmap bmpBackgroundImage; private Cursor defaultCursor; @@ -119,6 +120,15 @@ public RegionCaptureForm(RegionCaptureMode mode, RegionCaptureOptions options) { Duration = TimeSpan.FromMilliseconds(200) }; + if (IsEditorMode && Options.ShowEditorPanTip) + { + editorPanTipAnimation = new TextAnimation() + { + Duration = TimeSpan.FromMilliseconds(5000), + FadeOutDuration = TimeSpan.FromMilliseconds(1000), + Text = "Tip: You can pan image by holding mouse middle button and dragging." + }; + } borderPen = new Pen(Color.Black); borderDotPen = new Pen(Color.White) { DashPattern = new float[] { 5, 5 } }; @@ -425,6 +435,11 @@ private void RegionCaptureForm_Shown(object sender, EventArgs e) OnMoved(); CenterCanvas(); + + if (IsEditorMode && Options.ShowEditorPanTip && editorPanTipAnimation != null) + { + editorPanTipAnimation.Start(); + } } private void RegionCaptureForm_Resize(object sender, EventArgs e) @@ -820,6 +835,12 @@ private void Draw(Graphics g) DrawCrosshair(g); } + // Draw image editor bottom tip + if (IsEditorMode && Options.ShowEditorPanTip && editorPanTipAnimation != null && editorPanTipAnimation.Update()) + { + DrawBottomTipAnimation(g, editorPanTipAnimation); + } + // Draw menu tooltips if (IsAnnotationMode && ShapeManager.MenuTextAnimation.Update()) { @@ -950,8 +971,14 @@ private void DrawTextAnimation(Graphics g, TextAnimation textAnimation) { Size textSize = g.MeasureString(textAnimation.Text, infoFontMedium).ToSize(); int padding = 3; - Rectangle textRectangle = new Rectangle(textAnimation.Position.X, textAnimation.Position.Y, textSize.Width + padding * 2, textSize.Height + padding * 2); + textSize.Width += padding * 2; + textSize.Height += padding * 2; + Rectangle textRectangle = new Rectangle(textAnimation.Position.X, textAnimation.Position.Y, textSize.Width, textSize.Height); + DrawTextAnimation(g, textAnimation, textRectangle, padding); + } + private void DrawTextAnimation(Graphics g, TextAnimation textAnimation, Rectangle textRectangle, int padding) + { using (Brush backgroundBrush = new SolidBrush(Color.FromArgb((int)(textAnimation.Opacity * 175), Color.FromArgb(44, 135, 206)))) using (Pen outerBorderPen = new Pen(Color.FromArgb((int)(textAnimation.Opacity * 175), Color.White))) using (Pen innerBorderPen = new Pen(Color.FromArgb((int)(textAnimation.Opacity * 175), Color.FromArgb(0, 81, 145)))) @@ -962,6 +989,17 @@ private void DrawTextAnimation(Graphics g, TextAnimation textAnimation) } } + private void DrawBottomTipAnimation(Graphics g, TextAnimation textAnimation) + { + Size textSize = g.MeasureString(textAnimation.Text, infoFontMedium).ToSize(); + int padding = 5; + textSize.Width += padding * 2; + textSize.Height += padding * 2; + int margin = 20; + Rectangle textRectangle = new Rectangle(ClientArea.Width / 2 - textSize.Width / 2, ClientArea.Height - textSize.Height - margin, textSize.Width, textSize.Height); + DrawTextAnimation(g, textAnimation, textRectangle, padding); + } + private void WriteTips(StringBuilder sb) { sb.AppendLine(Resources.RectangleRegion_WriteTips__F1__Hide_tips); diff --git a/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs b/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs index 9209aaac2..057ff0ac1 100644 --- a/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs +++ b/ShareX.ScreenCaptureLib/RegionCaptureOptions.cs @@ -82,5 +82,6 @@ public class RegionCaptureOptions public ImageEditorStartMode ImageEditorStartMode = ImageEditorStartMode.Maximized; public WindowState ImageEditorWindowState = new WindowState(); public Color ImageEditorBackgroundColor = Color.FromArgb(200, 200, 200); + public bool ShowEditorPanTip = true; } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs index aa0aa6118..4bd7972ff 100644 --- a/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/Shapes/ShapeManager.cs @@ -777,6 +777,8 @@ private void StartPanning() IsPanning = true; Form.PanningStrech = new Point(0, 0); Form.Cursor = Cursors.SizeAll; + + Options.ShowEditorPanTip = false; } private void EndPanning()