mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-28 23:42:13 +12:00
Code refactoring
This commit is contained in:
parent
661d9e3668
commit
0529a8af31
6 changed files with 107 additions and 15 deletions
|
@ -235,11 +235,16 @@ public static bool UseImmersiveDarkMode(IntPtr handle, bool enabled)
|
|||
{
|
||||
if (Helpers.IsWindows10OrGreater(17763))
|
||||
{
|
||||
var attribute = DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
|
||||
DwmWindowAttribute attribute;
|
||||
|
||||
if (Helpers.IsWindows10OrGreater(18985))
|
||||
{
|
||||
attribute = DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE;
|
||||
}
|
||||
else
|
||||
{
|
||||
attribute = DwmWindowAttribute.DWMWA_USE_IMMERSIVE_DARK_MODE_BEFORE_20H1;
|
||||
}
|
||||
|
||||
int useImmersiveDarkMode = enabled ? 1 : 0;
|
||||
return DwmSetWindowAttribute(handle, (int)attribute, ref useImmersiveDarkMode, sizeof(int)) == 0;
|
||||
|
|
|
@ -117,15 +117,6 @@ public override UploadResult UploadText(string text, string fileName)
|
|||
|
||||
if (!string.IsNullOrEmpty(text) && !string.IsNullOrEmpty(fileName))
|
||||
{
|
||||
var gistUploadObject = new
|
||||
{
|
||||
@public = PublicUpload,
|
||||
files = new Dictionary<string, object>
|
||||
{
|
||||
{ fileName, new { content = text } }
|
||||
}
|
||||
};
|
||||
|
||||
string url;
|
||||
|
||||
if (!string.IsNullOrEmpty(CustomURLAPI))
|
||||
|
@ -139,7 +130,17 @@ public override UploadResult UploadText(string text, string fileName)
|
|||
|
||||
url = URLHelpers.CombineURL(url, "gists");
|
||||
|
||||
string json = JsonConvert.SerializeObject(gistUploadObject);
|
||||
GistUpload gistUpload = new GistUpload()
|
||||
{
|
||||
description = "",
|
||||
@public = PublicUpload,
|
||||
files = new Dictionary<string, GistUploadFileInfo>()
|
||||
{
|
||||
{ fileName, new GistUploadFileInfo() { content = text } }
|
||||
}
|
||||
};
|
||||
|
||||
string json = JsonConvert.SerializeObject(gistUpload);
|
||||
|
||||
Dictionary<string, string> args = new Dictionary<string, string>();
|
||||
args.Add("access_token", AuthInfo.Token.access_token);
|
||||
|
@ -164,13 +165,25 @@ public override UploadResult UploadText(string text, string fileName)
|
|||
return ur;
|
||||
}
|
||||
|
||||
private class GistUpload
|
||||
{
|
||||
public string description { get; set; }
|
||||
public bool @public { get; set; }
|
||||
public Dictionary<string, GistUploadFileInfo> files { get; set; }
|
||||
}
|
||||
|
||||
private class GistUploadFileInfo
|
||||
{
|
||||
public string content { get; set; }
|
||||
}
|
||||
|
||||
private class GistResponse
|
||||
{
|
||||
public string html_url { get; set; }
|
||||
public Dictionary<string, GistFileInfo> files { get; set; }
|
||||
public Dictionary<string, GistResponseFileInfo> files { get; set; }
|
||||
}
|
||||
|
||||
private class GistFileInfo
|
||||
private class GistResponseFileInfo
|
||||
{
|
||||
public string filename { get; set; }
|
||||
public string raw_url { get; set; }
|
||||
|
|
36
ShareX/ChromeManifest.cs
Normal file
36
ShareX/ChromeManifest.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2019 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)
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class ChromeManifest
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string description { get; set; }
|
||||
public string path { get; set; }
|
||||
public string type { get; set; }
|
||||
public string[] allowed_origins { get; set; }
|
||||
}
|
||||
}
|
36
ShareX/FirefoxManifest.cs
Normal file
36
ShareX/FirefoxManifest.cs
Normal file
|
@ -0,0 +1,36 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2019 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)
|
||||
|
||||
namespace ShareX
|
||||
{
|
||||
public class FirefoxManifest
|
||||
{
|
||||
public string name { get; set; }
|
||||
public string description { get; set; }
|
||||
public string path { get; set; }
|
||||
public string type { get; set; }
|
||||
public string[] allowed_extensions { get; set; }
|
||||
}
|
||||
}
|
|
@ -253,7 +253,7 @@ private static void CreateChromeHostManifest(string filepath)
|
|||
{
|
||||
Helpers.CreateDirectoryFromFilePath(filepath);
|
||||
|
||||
var manifest = new
|
||||
ChromeManifest manifest = new ChromeManifest()
|
||||
{
|
||||
name = "com.getsharex.sharex",
|
||||
description = "ShareX",
|
||||
|
@ -323,7 +323,7 @@ private static void CreateFirefoxHostManifest(string filepath)
|
|||
{
|
||||
Helpers.CreateDirectoryFromFilePath(filepath);
|
||||
|
||||
var manifest = new
|
||||
FirefoxManifest manifest = new FirefoxManifest()
|
||||
{
|
||||
name = "ShareX",
|
||||
description = "ShareX",
|
||||
|
|
|
@ -149,6 +149,7 @@
|
|||
<Compile Include="CaptureHelpers\CaptureMonitor.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureRegion.cs" />
|
||||
<Compile Include="CaptureHelpers\CaptureWindow.cs" />
|
||||
<Compile Include="ChromeManifest.cs" />
|
||||
<Compile Include="Controls\BeforeUploadControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
|
@ -178,6 +179,7 @@
|
|||
</Compile>
|
||||
<Compile Include="EasterEggAboutAnimation.cs" />
|
||||
<Compile Include="EasterEggBounce.cs" />
|
||||
<Compile Include="FirefoxManifest.cs" />
|
||||
<Compile Include="Forms\TextUploadForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
|
|
Loading…
Reference in a new issue