Fixed size types

This commit is contained in:
Jaex 2014-05-29 08:39:06 +03:00
parent c11851b34a
commit 6b9c9642d3
7 changed files with 20 additions and 13 deletions

View file

@ -10,7 +10,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CodeWorks</RootNamespace>
<AssemblyName>CodeWorks</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileUpgradeFlags>
</FileUpgradeFlags>
@ -73,6 +73,7 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Licenses\ShareXLicense.txt" />
<Compile Include="MainForm.cs">
<SubType>Form</SubType>

View file

@ -39,7 +39,7 @@ namespace CodeWorks
public partial class MainForm : Form
{
private readonly string folderPath = Path.GetFullPath(@"..\..\..");
private readonly string[] ignoreFolders = new string[] { "bin", "obj", "Properties", "GreenshotImageEditor", "AviFile" };
private readonly string[] ignoreFolders = new string[] { "bin", "obj", "Properties", "GreenshotImageEditor", "AviFile", "packages" };
private readonly string[] ignoreFiles = new string[] { };
private readonly string[] ignoreFilenamesEndsWith = new string[] { ".designer.cs" };
private readonly string[] allowFilenamesEndsWith = new string[] { ".cs" };

View file

@ -1,7 +1,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18047
// Runtime Version:4.0.30319.18444
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@ -65,7 +65,7 @@ internal Resources() {
///
////*
/// ShareX - A program that allows you to take screenshots and share any file type
/// Copyright (C) 2008-2013 ShareX Developers
/// Copyright (C) 2007-2014 ShareX Developers
///
/// This program is free software; you can redistribute it and/or
/// modify it under the terms of the GNU General Public License

3
CodeWorks/app.config Normal file
View file

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

View file

@ -181,9 +181,9 @@ public static T Last<T>(this List<T> list, int index = 0)
public static double ToDouble(this Version value)
{
return Math.Max(value.Major, 0) * Math.Pow(10, 12) +
Math.Max(value.Minor, 0) * Math.Pow(10, 9) +
Math.Max(value.Build, 0) * Math.Pow(10, 6) +
Math.Max(value.Revision, 0);
Math.Max(value.Minor, 0) * Math.Pow(10, 9) +
Math.Max(value.Build, 0) * Math.Pow(10, 6) +
Math.Max(value.Revision, 0);
}
public static bool IsValid(this Rectangle rect)
@ -400,12 +400,17 @@ public static void DisposeHandle(this Icon icon)
private static readonly string[] Suffix_Decimal = new[] { "B", "KB", "MB", "GB", "TB", "PB", "EB" };
private static readonly string[] Suffix_Binary = new[] { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };
public static string GetSizeSuffix(int place, bool binary = false)
{
return binary ? Suffix_Binary[place] : Suffix_Decimal[place];
}
public static string ToSizeString(this long size, bool binary = false, int decimalPlaces = 2)
{
if (size < 1024) return Math.Max(size, 0) + " B";
int place = (int)Math.Floor(Math.Log(size, 1024));
double num = size / Math.Pow(1024, place);
return string.Format("{0} {1}", num.ToDecimalString(decimalPlaces.Between(0, 3)), binary ? Suffix_Binary[place] : Suffix_Decimal[place]);
return string.Format("{0} {1}", num.ToDecimalString(decimalPlaces.Between(0, 3)), GetSizeSuffix(place, binary));
}
public static string ToDecimalString(this double number, int decimalPlaces)

View file

@ -219,10 +219,8 @@ private void ChangeProgress()
if (fileDownloader != null)
{
pbProgress.Value = (int)Math.Round(fileDownloader.DownloadPercentage);
lblProgress.Text = String.Format(CultureInfo.CurrentCulture,
"Progress: {0:0.0}%\nDownload speed: {1:0.0} kB/s\nFile size: {2:n0} / {3:n0} KiB",
fileDownloader.DownloadPercentage, fileDownloader.DownloadSpeed / 1000, fileDownloader.DownloadedSize / 1024,
fileDownloader.FileSize / 1024);
lblProgress.Text = String.Format(CultureInfo.CurrentCulture, "Progress: {0:0.0}%\nDownload speed: {1:0.0} KB/s\nFile size: {2:n0} / {3:n0} KB",
fileDownloader.DownloadPercentage, fileDownloader.DownloadSpeed / 1024, fileDownloader.DownloadedSize / 1024, fileDownloader.FileSize / 1024);
}
}

View file

@ -89,7 +89,7 @@ public IEnumerable<Image> GetImageEnumerator()
{
if (index.Location > int.MaxValue || index.Length > int.MaxValue)
{
MessageBox.Show("Cache file size cannot exceed 2.00 GiB.\r\nPlease use FFmpeg screen recording instead of GIF.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
MessageBox.Show("Cache file size cannot exceed 2.14 GB.\r\nPlease use FFmpeg screen recording instead of GIF.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
yield break;
}