Using SnapSize class for workaround size collection editor problem

This commit is contained in:
Jaex 2015-08-15 04:09:04 +03:00
parent 9ecbf3c30f
commit 3217d78fe0
7 changed files with 111 additions and 12 deletions

View file

@ -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))

View file

@ -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" />

View 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}";
}
}
}

View file

@ -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)
};
}
}

View file

@ -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>

View file

@ -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>

View file

@ -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();