mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Using SnapSize class for workaround size collection editor problem
This commit is contained in:
parent
9ecbf3c30f
commit
3217d78fe0
7 changed files with 111 additions and 12 deletions
|
@ -263,7 +263,7 @@ private Point SnapPosition(Point posOnClick, Point posCurrent)
|
|||
Rectangle currentRect = CaptureHelpers.CreateRectangle(posOnClick, posCurrent);
|
||||
Point newPosition = posCurrent;
|
||||
|
||||
foreach (Size size in surface.Config.SnapSizes)
|
||||
foreach (SnapSize size in surface.Config.SnapSizes)
|
||||
{
|
||||
if (currentRect.Width.IsBetween(size.Width - surface.Config.SnapDistance, size.Width + surface.Config.SnapDistance) ||
|
||||
currentRect.Height.IsBetween(size.Height - surface.Config.SnapDistance, size.Height + surface.Config.SnapDistance))
|
||||
|
|
|
@ -100,6 +100,7 @@
|
|||
<Compile Include="RegionHelpers\NodeObject.cs" />
|
||||
<Compile Include="RegionHelpers\ResizeManager.cs" />
|
||||
<Compile Include="RegionHelpers\ShapeCaptureHelpers.cs" />
|
||||
<Compile Include="SnapSize.cs" />
|
||||
<Compile Include="SurfaceOptions.cs" />
|
||||
<Compile Include="Screencast\ScreenRecorder.cs" />
|
||||
<Compile Include="Screencast\HardDiskCache.cs" />
|
||||
|
|
84
ShareX.ScreenCaptureLib/SnapSize.cs
Normal file
84
ShareX.ScreenCaptureLib/SnapSize.cs
Normal file
|
@ -0,0 +1,84 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2015 ShareX Team
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ShareX.ScreenCaptureLib
|
||||
{
|
||||
public class SnapSize
|
||||
{
|
||||
private const int MinimumWidth = 2;
|
||||
|
||||
private int width;
|
||||
|
||||
public int Width
|
||||
{
|
||||
get
|
||||
{
|
||||
return width;
|
||||
}
|
||||
set
|
||||
{
|
||||
width = Math.Max(value, MinimumWidth);
|
||||
}
|
||||
}
|
||||
|
||||
private const int MinimumHeight = 2;
|
||||
|
||||
private int height;
|
||||
|
||||
public int Height
|
||||
{
|
||||
get
|
||||
{
|
||||
return height;
|
||||
}
|
||||
set
|
||||
{
|
||||
height = Math.Max(value, MinimumHeight);
|
||||
}
|
||||
}
|
||||
|
||||
public SnapSize()
|
||||
{
|
||||
width = MinimumWidth;
|
||||
height = MinimumHeight;
|
||||
}
|
||||
|
||||
public SnapSize(int width, int height)
|
||||
{
|
||||
Width = width;
|
||||
Height = height;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"{Width}x{Height}";
|
||||
}
|
||||
}
|
||||
}
|
|
@ -95,8 +95,8 @@ public class SurfaceOptions
|
|||
[DefaultValue(10), Description("How much region size must be close to snap size for it to snap.")]
|
||||
public int SnapDistance { get; set; }
|
||||
|
||||
[Description("When you hold snap modifier key it will check these sizes and if your region size close to them then it will snap to this size.")]
|
||||
public List<Size> SnapSizes { get; set; }
|
||||
[Description("How close to a snap size you must be for it to snap.")]
|
||||
public List<SnapSize> SnapSizes { get; set; }
|
||||
|
||||
[DefaultValue(RegionShape.Rectangle), Description("Current region shape.")]
|
||||
public RegionShape CurrentRegionShape { get; set; }
|
||||
|
@ -105,12 +105,12 @@ public SurfaceOptions()
|
|||
{
|
||||
this.ApplyDefaultPropertyValues();
|
||||
|
||||
SnapSizes = new List<Size>()
|
||||
SnapSizes = new List<SnapSize>()
|
||||
{
|
||||
new Size(800, 600),
|
||||
new Size(1280, 720),
|
||||
new Size(1024, 768),
|
||||
new Size(1920, 1080)
|
||||
new SnapSize(800, 600),
|
||||
new SnapSize(1280, 720),
|
||||
new SnapSize(1024, 768),
|
||||
new SnapSize(1920, 1080)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
11
ShareX/Properties/Resources.Designer.cs
generated
11
ShareX/Properties/Resources.Designer.cs
generated
|
@ -1958,6 +1958,17 @@ public static string UploadTask_DoUploadJob_Uploading {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to You are attempting to upload a large file.
|
||||
///
|
||||
///Are you sure you want to continue?.
|
||||
/// </summary>
|
||||
public static string UploadTask_DoUploadJob_You_are_attempting_to_upload_a_large_file {
|
||||
get {
|
||||
return ResourceManager.GetString("UploadTask_DoUploadJob_You_are_attempting_to_upload_a_large_file", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Done.
|
||||
/// </summary>
|
||||
|
|
|
@ -760,4 +760,9 @@ Would you like to restart ShareX?</value>
|
|||
<data name="br" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\br.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
<data name="UploadTask_DoUploadJob_You_are_attempting_to_upload_a_large_file" xml:space="preserve">
|
||||
<value>You are attempting to upload a large file.
|
||||
|
||||
Are you sure you want to continue?</value>
|
||||
</data>
|
||||
</root>
|
|
@ -311,14 +311,12 @@ private void DoUploadJob()
|
|||
Stop();
|
||||
}
|
||||
|
||||
if (Program.Settings.LargeFileSizeWarning != 0)
|
||||
if (Program.Settings.LargeFileSizeWarning > 0)
|
||||
{
|
||||
long dataSize = Program.Settings.BinaryUnits ? Program.Settings.LargeFileSizeWarning * 1024 * 1024 : Program.Settings.LargeFileSizeWarning * 1000 * 1000;
|
||||
if (Data != null && Data.Length > dataSize)
|
||||
{
|
||||
using (MyMessageBox msgbox = new MyMessageBox(
|
||||
"You are attempting to upload a large file.\n\nAre you sure you want to continue?",
|
||||
Application.ProductName,
|
||||
using (MyMessageBox msgbox = new MyMessageBox(Resources.UploadTask_DoUploadJob_You_are_attempting_to_upload_a_large_file, "ShareX",
|
||||
MessageBoxButtons.YesNo, Resources.UploadManager_IsUploadConfirmed_Don_t_show_this_message_again_))
|
||||
{
|
||||
msgbox.ShowDialog();
|
||||
|
|
Loading…
Reference in a new issue