Skip to content

Commit

Permalink
Merge pull request #27 from bkeiren/cubrr-https-links-checkbox
Browse files Browse the repository at this point in the history
Cubrr https links checkbox
  • Loading branch information
bkeiren committed Jun 10, 2015
2 parents 2ab319f + 5e1fbe5 commit e254be3
Show file tree
Hide file tree
Showing 7 changed files with 196 additions and 112 deletions.
224 changes: 130 additions & 94 deletions EasyImgur/Form1.Designer.cs

Large diffs are not rendered by default.

46 changes: 36 additions & 10 deletions EasyImgur/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,9 @@ private void UploadClipboard( bool _Anonymous )
// this doesn't need an invocation guard because this function can't be called from the context menu
if (Properties.Settings.Default.copyLinks)
{
Clipboard.SetText(resp.data.link);
Clipboard.SetText(Properties.Settings.Default.copyHttpsLinks
? resp.data.link.Replace("http://", "https://")
: resp.data.link);
}

ShowBalloonTip(2000, "Success!", Properties.Settings.Default.copyLinks ? "Link copied to clipboard" : "Upload placed in history: " + resp.data.link, ToolTipIcon.None);
Expand Down Expand Up @@ -357,13 +359,22 @@ private void UploadAlbum( bool _Anonymous, string[] _Paths, string _AlbumTitle )
return;
}
APIResponses.AlbumResponse response = ImgurAPI.UploadAlbum(images.ToArray(), _AlbumTitle, _Anonymous, titles.ToArray(), descriptions.ToArray());
if(response.success)
if (response.success)
{
// clipboard calls can only be made on an STA thread, threading model is MTA when invoked from context menu
if(System.Threading.Thread.CurrentThread.GetApartmentState() != System.Threading.ApartmentState.STA)
this.Invoke(new Action(delegate { Clipboard.SetText(response.data.link); }));
if (System.Threading.Thread.CurrentThread.GetApartmentState() != System.Threading.ApartmentState.STA)
{
this.Invoke(new Action(() =>
Clipboard.SetText(Properties.Settings.Default.copyHttpsLinks
? response.data.link.Replace("http://", "https://")
: response.data.link)));
}
else
Clipboard.SetText(response.data.link);
{
Clipboard.SetText(Properties.Settings.Default.copyHttpsLinks
? response.data.link.Replace("http://", "https://")
: response.data.link);
}

ShowBalloonTip(2000, "Success!", Properties.Settings.Default.copyLinks ? "Link copied to clipboard" : "Upload placed in history: " + response.data.link, ToolTipIcon.None);

Expand All @@ -377,7 +388,7 @@ private void UploadAlbum( bool _Anonymous, string[] _Paths, string _AlbumTitle )
item.anonymous = _Anonymous;
item.album = true;
item.thumbnail = response.CoverImage.GetThumbnailImage(pictureBox1.Width, pictureBox1.Height, null, System.IntPtr.Zero);
Invoke(new Action(() => { History.StoreHistoryItem(item); }));
Invoke(new Action(() => History.StoreHistoryItem(item)));
}
else
ShowBalloonTip(2000, "Failed", "Could not upload album (" + response.status + "): " + response.data.error, ToolTipIcon.None, true);
Expand Down Expand Up @@ -437,10 +448,20 @@ private void UploadFile( bool _Anonymous, string[] _Paths = null )
if (Properties.Settings.Default.copyLinks)
{
// clipboard calls can only be made on an STA thread, threading model is MTA when invoked from context menu
if(System.Threading.Thread.CurrentThread.GetApartmentState() != System.Threading.ApartmentState.STA)
this.Invoke(new Action(delegate { Clipboard.SetText(resp.data.link); }));
if (System.Threading.Thread.CurrentThread.GetApartmentState() !=
System.Threading.ApartmentState.STA)
{
this.Invoke(new Action(() =>
Clipboard.SetText(Properties.Settings.Default.copyHttpsLinks
? resp.data.link.Replace("http://", "https://")
: resp.data.link)));
}
else
Clipboard.SetText(resp.data.link);
{
Clipboard.SetText(Properties.Settings.Default.copyHttpsLinks
? resp.data.link.Replace("http://", "https://")
: resp.data.link);
}
}

ShowBalloonTip(2000, "Success!" + fileCounterString, Properties.Settings.Default.copyLinks ? "Link copied to clipboard" : "Upload placed in history: " + resp.data.link, ToolTipIcon.None);
Expand All @@ -454,7 +475,7 @@ private void UploadFile( bool _Anonymous, string[] _Paths = null )
item.description = resp.data.description;
item.anonymous = _Anonymous;
item.thumbnail = img.GetThumbnailImage(pictureBox1.Width, pictureBox1.Height, null, System.IntPtr.Zero);
Invoke(new Action(() => { History.StoreHistoryItem(item); }));
Invoke(new Action(() => History.StoreHistoryItem(item)));
}
else
{
Expand Down Expand Up @@ -805,5 +826,10 @@ private void btnOpenImageLinkInBrowser_Click(object sender, EventArgs e)
System.Diagnostics.Process.Start(item.link);
}
}

private void checkBoxCopyLinks_CheckedChanged(object sender, EventArgs e)
{
this.clipboardSettingsContainer.Enabled = this.checkBoxCopyLinks.Checked;
}
}
}
3 changes: 3 additions & 0 deletions EasyImgur/Form1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ To revoke authorization of any tokens this application has, visit http://imgur.c
<metadata name="historyItemBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>368, 17</value>
</metadata>
<metadata name="historyItemBindingSource.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>368, 17</value>
</metadata>
<metadata name="trayMenu.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>264, 17</value>
</metadata>
Expand Down
14 changes: 13 additions & 1 deletion EasyImgur/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions EasyImgur/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,8 @@
<Setting Name="uploadMultipleImagesAsGallery" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="copyHttpsLinks" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
</Settings>
</SettingsFile>
11 changes: 7 additions & 4 deletions EasyImgur/app.config
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<value>True</value>
</setting>
<setting name="accountInfo" serializeAs="String">
<value/>
<value />
</setting>
<setting name="copyLinks" serializeAs="String">
<value>False</value>
Expand All @@ -20,16 +20,16 @@
<value>%filename%</value>
</setting>
<setting name="descriptionFormat" serializeAs="String">
<value/>
<value />
</setting>
<setting name="imageFormat" serializeAs="String">
<value>0</value>
</setting>
<setting name="accessToken" serializeAs="String">
<value/>
<value />
</setting>
<setting name="refreshToken" serializeAs="String">
<value/>
<value />
</setting>
<setting name="showNotificationOnTokenRefresh" serializeAs="String">
<value>False</value>
Expand All @@ -40,6 +40,9 @@
<setting name="uploadMultipleImagesAsGallery" serializeAs="String">
<value>True</value>
</setting>
<setting name="copyHttpsLinks" serializeAs="String">
<value>False</value>
</setting>
</EasyImgur.Properties.Settings>
</userSettings>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ Settings

EasyImgur has a number of different customizable settings. These can be accessed from the *General* tab in the EasyImgur settings window:

![](http://i.imgur.com/dt7bu7s.png)
![Settings tab screenshot](http://i.imgur.com/ssvIAZl.png)

- **Clear clipboard on upload**: This option determines whether the clipboard will be cleared after uploading from it.
- **Automatically copy links to clipboard**: Determines whether links to images that have succesfully been uploaded are automatically placed on your clipboard (ready to be pasted somewhere with Ctrl+V).
- **Clear clipboard immediately on upload**: This option determines whether the clipboard will be cleared after uploading from it.
- **Copy links to clipboard**: Determines whether links to images that have successfully been uploaded are automatically placed on your clipboard (ready to be pasted somewhere with Ctrl+V).
- **Copy HTTPS links**: Determines whether copied links will use [HTTPS](http://en.wikipedia.org/wiki/HTTPS) instead of HTTP.
- **Upload multiple images as gallery**: Determines whether multiple images upload using the file dialog window are uploaded as separate images or contained in an album.
- **Preferred image format**: This option gives a hint to Imgur as to what image format is preferred. Note that it only hints at this by providing the source image in a certain format. Imgur can (and sometimes will) change the format to something else if it chooses to do so.
- **Use this title format** and **Use this description format**: These define two strings that are used as the title and description for every uploaded image. The strings can contain special symbols which are converted to set values before uploading. For a complete set of symbols, click the *Format?* button. An example string containing special symbols and its final form is: *Image_%n%_%date%_%time%*, might turn out to be *Image_0_19-08-2013_13:37:00* because *%n%* is converted to an integer denoting how many images have currently been uploaded, *%date* is converted to the current date in DD-MM-YYYY format, and *%time%* is converted to the current time in HH-MM-SS format.
Expand Down

0 comments on commit e254be3

Please sign in to comment.