#1298 redo the changes

This commit is contained in:
Jevan Pipitone 2016-02-14 23:12:53 +11:00
parent ba60313cab
commit bd89f3d18c
10 changed files with 1452 additions and 1189 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 KiB

File diff suppressed because it is too large Load diff

View file

@ -112,6 +112,7 @@ private void FormSettings()
AddIconToTab(tpSeafile, Resources.Seafile);
AddIconToTab(tpSendSpace, Resources.SendSpace);
AddIconToTab(tpSharedFolder, Resources.server_network);
AddIconToTab(tpSomeImage, Resources.SomeImage);
AddIconToTab(tpStreamable, Resources.Streamable);
AddIconToTab(tpSul, Resources.Sul);
AddIconToTab(tpTinyPic, Resources.TinyPic);
@ -242,6 +243,11 @@ public void LoadSettings()
txtCheveretoAPIKey.Text = Config.CheveretoAPIKey;
cbCheveretoDirectURL.Checked = Config.CheveretoDirectURL;
// SomeImage
txtSomeImageAPIKey.Text = Config.SomeImageAPIKey;
cbSomeImageDirectURL.Checked = Config.SomeImageDirectURL;
// vgy.me
txtVgymeUserKey.Text = Config.VgymeUserKey;
@ -998,6 +1004,25 @@ private void cbCheveretoDirectURL_CheckedChanged(object sender, EventArgs e)
#endregion Chevereto
#region SomeImage
private void txtSomeImageAPIKey_TextChanged(object sender, EventArgs e)
{
Config.SomeImageAPIKey = txtSomeImageAPIKey.Text;
}
private void cbSomeImageDirectURL_CheckedChanged(object sender, EventArgs e)
{
Config.SomeImageDirectURL = cbSomeImageDirectURL.Checked;
}
private void linkLblSomeImageAPIKey_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start("https://someimage.com/api");
}
#endregion SomeImage
#region vgy.me
private void txtVgymeUserKey_TextChanged(object sender, EventArgs e)

View file

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
@ -12706,6 +12706,141 @@ Using an encrypted library disables sharing.</value>
<data name="&gt;&gt;tpChevereto.ZOrder" xml:space="preserve">
<value>6</value>
</data>
<data name="linkLblSomeImageAPIKey.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="linkLblSomeImageAPIKey.Location" type="System.Drawing.Point, System.Drawing">
<value>376, 46</value>
</data>
<data name="linkLblSomeImageAPIKey.Size" type="System.Drawing.Size, System.Drawing">
<value>300, 17</value>
</data>
<data name="linkLblSomeImageAPIKey.TabIndex" type="System.Int32, mscorlib">
<value>4</value>
</data>
<data name="linkLblSomeImageAPIKey.Text" xml:space="preserve">
<value>To get API key visit https://someimage.com/api</value>
</data>
<data name="&gt;&gt;linkLblSomeImageAPIKey.Name" xml:space="preserve">
<value>linkLblSomeImageAPIKey</value>
</data>
<data name="&gt;&gt;linkLblSomeImageAPIKey.Type" xml:space="preserve">
<value>System.Windows.Forms.LinkLabel, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;linkLblSomeImageAPIKey.Parent" xml:space="preserve">
<value>tpSomeImage</value>
</data>
<data name="&gt;&gt;linkLblSomeImageAPIKey.ZOrder" xml:space="preserve">
<value>0</value>
</data>
<data name="txtSomeImageAPIKey.Location" type="System.Drawing.Point, System.Drawing">
<value>25, 43</value>
</data>
<data name="txtSomeImageAPIKey.Size" type="System.Drawing.Size, System.Drawing">
<value>319, 22</value>
</data>
<data name="txtSomeImageAPIKey.TabIndex" type="System.Int32, mscorlib">
<value>2</value>
</data>
<data name="&gt;&gt;txtSomeImageAPIKey.Name" xml:space="preserve">
<value>txtSomeImageAPIKey</value>
</data>
<data name="&gt;&gt;txtSomeImageAPIKey.Type" xml:space="preserve">
<value>System.Windows.Forms.TextBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;txtSomeImageAPIKey.Parent" xml:space="preserve">
<value>tpSomeImage</value>
</data>
<data name="&gt;&gt;txtSomeImageAPIKey.ZOrder" xml:space="preserve">
<value>1</value>
</data>
<data name="lblSomeImageAPIKey.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="lblSomeImageAPIKey.Location" type="System.Drawing.Point, System.Drawing">
<value>22, 23</value>
</data>
<data name="lblSomeImageAPIKey.Size" type="System.Drawing.Size, System.Drawing">
<value>59, 17</value>
</data>
<data name="lblSomeImageAPIKey.TabIndex" type="System.Int32, mscorlib">
<value>1</value>
</data>
<data name="lblSomeImageAPIKey.Text" xml:space="preserve">
<value>API key:</value>
</data>
<data name="&gt;&gt;lblSomeImageAPIKey.Name" xml:space="preserve">
<value>lblSomeImageAPIKey</value>
</data>
<data name="&gt;&gt;lblSomeImageAPIKey.Type" xml:space="preserve">
<value>System.Windows.Forms.Label, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;lblSomeImageAPIKey.Parent" xml:space="preserve">
<value>tpSomeImage</value>
</data>
<data name="&gt;&gt;lblSomeImageAPIKey.ZOrder" xml:space="preserve">
<value>2</value>
</data>
<data name="cbSomeImageDirectURL.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
<data name="cbSomeImageDirectURL.Location" type="System.Drawing.Point, System.Drawing">
<value>25, 88</value>
</data>
<data name="cbSomeImageDirectURL.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="cbSomeImageDirectURL.Size" type="System.Drawing.Size, System.Drawing">
<value>99, 21</value>
</data>
<data name="cbSomeImageDirectURL.TabIndex" type="System.Int32, mscorlib">
<value>0</value>
</data>
<data name="cbSomeImageDirectURL.Text" xml:space="preserve">
<value>Direct URL</value>
</data>
<data name="&gt;&gt;cbSomeImageDirectURL.Name" xml:space="preserve">
<value>cbSomeImageDirectURL</value>
</data>
<data name="&gt;&gt;cbSomeImageDirectURL.Type" xml:space="preserve">
<value>System.Windows.Forms.CheckBox, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;cbSomeImageDirectURL.Parent" xml:space="preserve">
<value>tpSomeImage</value>
</data>
<data name="&gt;&gt;cbSomeImageDirectURL.ZOrder" xml:space="preserve">
<value>3</value>
</data>
<data name="tpSomeImage.Location" type="System.Drawing.Point, System.Drawing">
<value>4, 25</value>
</data>
<data name="tpSomeImage.Margin" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="tpSomeImage.Padding" type="System.Windows.Forms.Padding, System.Windows.Forms">
<value>4, 4, 4, 4</value>
</data>
<data name="tpSomeImage.Size" type="System.Drawing.Size, System.Drawing">
<value>1301, 612</value>
</data>
<data name="tpSomeImage.TabIndex" type="System.Int32, mscorlib">
<value>10</value>
</data>
<data name="tpSomeImage.Text" xml:space="preserve">
<value>SomeImage</value>
</data>
<data name="&gt;&gt;tpSomeImage.Name" xml:space="preserve">
<value>tpSomeImage</value>
</data>
<data name="&gt;&gt;tpSomeImage.Type" xml:space="preserve">
<value>System.Windows.Forms.TabPage, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
<data name="&gt;&gt;tpSomeImage.Parent" xml:space="preserve">
<value>tcImageUploaders</value>
</data>
<data name="&gt;&gt;tpSomeImage.ZOrder" xml:space="preserve">
<value>7</value>
</data>
<data name="llVgymeAccountDetailsPage.AutoSize" type="System.Boolean, mscorlib">
<value>True</value>
</data>
@ -13102,4 +13237,4 @@ Using an encrypted library disables sharing.</value>
<data name="&gt;&gt;$this.Type" xml:space="preserve">
<value>System.Windows.Forms.Form, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
</root>

View file

@ -28,6 +28,7 @@
using Newtonsoft.Json;
using System.Collections.Generic;
using System.IO;
using System;
namespace ShareX.UploadersLib.ImageUploaders
{
@ -35,6 +36,8 @@ public sealed class SomeImage : ImageUploader
{
private const string API_ENDPOINT = "https://someimage.com/api/2/image/upload";
public bool DirectURL { get; set; }
private string API_KEY = "";
public SomeImage(string apiKey)
@ -58,8 +61,31 @@ public override UploadResult Upload(Stream stream, string fileName)
if (jsonResponse != null)
{
result.URL = jsonResponse.imagelink;
if (DirectURL)
{
if (jsonResponse.imagelink == null)
{
result.URL = null;
}
else {
Uri responseUri = new Uri(jsonResponse.imagelink); // http://someimage.com/asdf
string host = responseUri.Host; // someimage.com
string filename = Path.GetFileName(responseUri.AbsolutePath); // /asdf
if (filename.StartsWith("/"))
{
filename = filename.Remove(0, 1); // asdf
}
if (host.StartsWith("www."))
{
host = host.Remove(0, 4);
}
result.URL = "https://i1." + host + "/" + filename + ".jpg";
}
} else
{
result.URL = jsonResponse.imagelink;
}
}
}
}
@ -76,4 +102,4 @@ public class SomeImageResponse
public string embedhtml { get; set; }
public string embedbb { get; set; }
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -1,17 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
@ -26,36 +26,36 @@
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
@ -440,6 +440,9 @@ Created folders:</value>
<data name="Chevereto" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Favicons\Chevereto.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="SomeImage" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Favicons\SomeImage.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="AmazonS3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Favicons\AmazonS3.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
@ -494,4 +497,4 @@ Created folders:</value>
<data name="Vgyme" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\favicons\vgyme.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>
</root>

View file

@ -884,6 +884,7 @@
<None Include="Resources\question-button.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Favicons\SomeImage.png" />
<Content Include="Favicons\Streamable.ico" />
<Content Include="Favicons\Sul.png" />
<Content Include="Favicons\Vgyme.ico" />
@ -907,4 +908,4 @@ if not exist APIKeysLocal.cs (
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View file

@ -82,6 +82,11 @@ public class UploadersConfig : SettingsBase<UploadersConfig>
public string CheveretoAPIKey = string.Empty;
public bool CheveretoDirectURL = true;
// SomeImage
public string SomeImageAPIKey = string.Empty;
public bool SomeImageDirectURL = true;
// vgy.me
public string VgymeUserKey = string.Empty;
@ -392,6 +397,8 @@ public bool IsValid(ImageDestination destination)
return TwitterOAuthInfoList != null && TwitterOAuthInfoList.IsValidIndex(TwitterSelectedAccount) && OAuthInfo.CheckOAuth(TwitterOAuthInfoList[TwitterSelectedAccount]);
case ImageDestination.Chevereto:
return !string.IsNullOrEmpty(CheveretoWebsite) && !string.IsNullOrEmpty(CheveretoAPIKey);
case ImageDestination.SomeImage:
return !string.IsNullOrEmpty(SomeImageAPIKey);
case ImageDestination.CustomImageUploader:
return CustomUploadersList != null && CustomUploadersList.IsValidIndex(CustomImageUploaderSelected);
}

View file

@ -827,7 +827,15 @@ public UploadResult UploadImage(Stream stream, string fileName)
};
break;
case ImageDestination.SomeImage:
imageUploader = new SomeImage(APIKeys.SomeImageKey);
String someImageAPIKey = Program.UploadersConfig.SomeImageAPIKey;
if (someImageAPIKey == "")
{
someImageAPIKey = APIKeys.SomeImageKey;
}
imageUploader = new SomeImage(someImageAPIKey)
{
DirectURL = Program.UploadersConfig.SomeImageDirectURL
};
break;
case ImageDestination.CustomImageUploader:
CustomUploaderItem customUploader = GetCustomUploader(Program.UploadersConfig.CustomImageUploaderSelected);