2013-11-03 23:53:49 +13:00
#region License Information ( GPL v3 )
/ *
ShareX - A program that allows you to take screenshots and share any file type
2014-05-13 21:06:40 +12:00
Copyright ( C ) 2007 - 2014 ShareX Developers
2013-11-03 23:53:49 +13:00
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 CG.Web.MegaApiClient ;
using HelpersLib ;
using System ;
using System.Collections.Generic ;
using System.Drawing ;
using System.Linq ;
using System.Windows.Forms ;
using UploadersLib.FileUploaders ;
2014-05-30 23:38:23 +12:00
using UploadersLib.HelperClasses ;
2013-11-03 23:53:49 +13:00
using UploadersLib.ImageUploaders ;
2014-05-30 23:38:23 +12:00
using UploadersLib.Properties ;
2013-11-03 23:53:49 +13:00
namespace UploadersLib
{
public partial class UploadersConfigForm : Form
{
public UploadersConfig Config { get ; private set ; }
2014-02-15 05:54:10 +13:00
public UploadersConfigForm ( UploadersConfig uploadersConfig )
2013-11-03 23:53:49 +13:00
{
2014-06-06 13:25:53 +12:00
Config = uploadersConfig ;
2013-11-03 23:53:49 +13:00
InitializeComponent ( ) ;
2014-06-06 13:25:53 +12:00
if ( ! string . IsNullOrEmpty ( Config . FilePath ) )
{
2014-06-17 03:24:30 +12:00
Text + = " - " + Config . FilePath ;
2014-06-06 13:25:53 +12:00
}
2013-11-06 06:58:22 +13:00
Icon = ShareXResources . Icon ;
2013-11-03 23:53:49 +13:00
}
2014-06-04 01:14:06 +12:00
private void UploadersConfigForm_Shown ( object sender , EventArgs e )
{
2014-06-06 13:25:53 +12:00
FormSettings ( ) ;
LoadSettings ( Config ) ;
2014-06-04 01:14:06 +12:00
}
2014-05-30 23:38:23 +12:00
private void UploadersConfigForm_Resize ( object sender , EventArgs e )
2013-11-03 23:53:49 +13:00
{
2014-05-30 23:38:23 +12:00
Refresh ( ) ;
2013-11-03 23:53:49 +13:00
}
2014-05-30 23:38:23 +12:00
private void FormSettings ( )
2013-11-03 23:53:49 +13:00
{
2014-06-04 01:14:06 +12:00
ImageList uploadersImageList = new ImageList ( ) ;
uploadersImageList . ColorDepth = ColorDepth . Depth32Bit ;
uploadersImageList . Images . Add ( "ImageShack" , Resources . ImageShack ) ;
uploadersImageList . Images . Add ( "TinyPic" , Resources . TinyPic ) ;
uploadersImageList . Images . Add ( "Imgur" , Resources . Imgur ) ;
uploadersImageList . Images . Add ( "Flickr" , Resources . Flickr ) ;
uploadersImageList . Images . Add ( "Photobucket" , Resources . Photobucket ) ;
uploadersImageList . Images . Add ( "Picasa" , Resources . Picasa ) ;
uploadersImageList . Images . Add ( "Dropbox" , Resources . Dropbox ) ;
2014-06-06 06:19:45 +12:00
uploadersImageList . Images . Add ( "Copy" , Resources . Copy ) ;
2014-06-04 01:14:06 +12:00
uploadersImageList . Images . Add ( "GoogleDrive" , Resources . GoogleDrive ) ;
uploadersImageList . Images . Add ( "Box" , Resources . Box ) ;
uploadersImageList . Images . Add ( "Minus" , Resources . Minus ) ;
uploadersImageList . Images . Add ( "FTP" , Resources . folder_network ) ;
uploadersImageList . Images . Add ( "RapidShare" , Resources . RapidShare ) ;
uploadersImageList . Images . Add ( "SendSpace" , Resources . SendSpace ) ;
uploadersImageList . Images . Add ( "Gett" , Resources . Gett ) ;
2014-06-16 22:47:35 +12:00
uploadersImageList . Images . Add ( "Hostr" , Resources . Hostr ) ;
2014-06-04 01:14:06 +12:00
uploadersImageList . Images . Add ( "CustomUploader" , Resources . globe_network ) ;
uploadersImageList . Images . Add ( "SharedFolders" , Resources . server_network ) ;
uploadersImageList . Images . Add ( "Email" , Resources . mail ) ;
uploadersImageList . Images . Add ( "Jira" , Resources . jira ) ;
uploadersImageList . Images . Add ( "Mega" , Resources . Mega ) ;
uploadersImageList . Images . Add ( "AmazonS3" , Resources . AmazonS3 ) ;
uploadersImageList . Images . Add ( "Pushbullet" , Resources . Pushbullet ) ;
uploadersImageList . Images . Add ( "Pastebin" , Resources . Pastebin ) ;
2014-06-17 00:20:06 +12:00
uploadersImageList . Images . Add ( "Pasteee" , Resources . page_white_text ) ;
2014-06-04 01:14:06 +12:00
uploadersImageList . Images . Add ( "Gist" , Resources . GitHub ) ;
uploadersImageList . Images . Add ( "Upaste" , Resources . Upaste ) ;
uploadersImageList . Images . Add ( "Google" , Resources . Google ) ;
uploadersImageList . Images . Add ( "Bitly" , Resources . Bitly ) ;
uploadersImageList . Images . Add ( "Yourls" , Resources . Yourls ) ;
uploadersImageList . Images . Add ( "Twitter" , Resources . Twitter ) ;
2014-05-30 23:38:23 +12:00
tpImageShack . ImageKey = "ImageShack" ;
tpTinyPic . ImageKey = "TinyPic" ;
tpImgur . ImageKey = "Imgur" ;
tpFlickr . ImageKey = "Flickr" ;
tpPhotobucket . ImageKey = "Photobucket" ;
tpPicasa . ImageKey = "Picasa" ;
tpDropbox . ImageKey = "Dropbox" ;
2014-06-06 06:19:45 +12:00
tpCopy . ImageKey = "Copy" ;
2014-05-30 23:38:23 +12:00
tpGoogleDrive . ImageKey = "GoogleDrive" ;
tpBox . ImageKey = "Box" ;
tpMinus . ImageKey = "Minus" ;
tpFTP . ImageKey = "FTP" ;
tpRapidShare . ImageKey = "RapidShare" ;
tpSendSpace . ImageKey = "SendSpace" ;
tpSharedFolder . ImageKey = "SharedFolders" ;
tpEmail . ImageKey = "Email" ;
tpJira . ImageKey = "Jira" ;
tpGe_tt . ImageKey = "Gett" ;
2014-06-16 22:47:35 +12:00
tpHostr . ImageKey = "Hostr" ;
2014-05-30 23:38:23 +12:00
tpCustomUploaders . ImageKey = "CustomUploader" ;
tpPastebin . ImageKey = "Pastebin" ;
2014-06-17 00:20:06 +12:00
tpPaste_ee . ImageKey = "Pasteee" ;
2014-05-30 23:38:23 +12:00
tpPushbullet . ImageKey = "Pushbullet" ;
tpGoogleURLShortener . ImageKey = "Google" ;
tpBitly . ImageKey = "Bitly" ;
tpYourls . ImageKey = "Yourls" ;
tpTwitter . ImageKey = "Twitter" ;
tpMega . ImageKey = "Mega" ;
tpGist . ImageKey = "Gist" ;
tpUpaste . ImageKey = "Upaste" ;
tpAmazonS3 . ImageKey = "AmazonS3" ;
2014-06-04 01:14:06 +12:00
ttlvMain . ImageList = uploadersImageList ;
ttlvMain . MainTabControl = tcUploaders ;
2014-06-06 13:25:53 +12:00
ttlvMain . FocusListView ( ) ;
2014-06-04 01:14:06 +12:00
2014-05-30 23:38:23 +12:00
NameParser . CreateCodesMenu ( txtDropboxPath , ReplacementVariables . n , ReplacementVariables . t , ReplacementVariables . pn ) ;
2014-06-28 12:22:56 +12:00
NameParser . CreateCodesMenu ( txtCopyPath , ReplacementVariables . n , ReplacementVariables . t , ReplacementVariables . pn ) ;
2014-05-30 23:38:23 +12:00
NameParser . CreateCodesMenu ( txtAmazonS3ObjectPrefix , ReplacementVariables . n , ReplacementVariables . t , ReplacementVariables . pn ) ;
NameParser . CreateCodesMenu ( txtCustomUploaderArgValue , ReplacementVariables . n ) ;
txtCustomUploaderLog . AddContextMenu ( ) ;
// FTP
ucFTPAccounts . btnAdd . Click + = FTPAccountAddButton_Click ;
ucFTPAccounts . btnRemove . Click + = FTPAccountRemoveButton_Click ;
ucFTPAccounts . btnDuplicate . Click + = FTPAccountDuplicateButton_Click ;
ucFTPAccounts . btnTest . Click + = FTPAccountTestButton_Click ;
ucFTPAccounts . pgSettings . PropertyValueChanged + = FtpAccountSettingsGrid_PropertyValueChanged ;
// Localhost
ucLocalhostAccounts . btnAdd . Click + = LocalhostAccountAddButton_Click ;
ucLocalhostAccounts . btnRemove . Click + = LocalhostAccountRemoveButton_Click ;
ucLocalhostAccounts . btnDuplicate . Click + = LocalhostAccountDuplicateButton_Click ;
ucLocalhostAccounts . btnTest . Visible = false ;
ucLocalhostAccounts . pgSettings . PropertyValueChanged + = SettingsGrid_LocalhostPropertyValueChanged ;
// Twitter
ucTwitterAccounts . btnAdd . Click + = TwitterAccountAddButton_Click ;
ucTwitterAccounts . btnRemove . Click + = TwitterAccountRemoveButton_Click ;
ucTwitterAccounts . btnDuplicate . Click + = TwitterAccountDuplicateButton_Click ;
ucTwitterAccounts . btnTest . Text = "Authorize" ;
ucTwitterAccounts . btnTest . Click + = TwitterAccountAuthButton_Click ;
ucTwitterAccounts . lbAccounts . SelectedIndexChanged + = TwitterAccountSelectedIndexChanged ;
2014-06-07 05:21:03 +12:00
2014-06-07 06:01:02 +12:00
eiFTP . ObjectType = typeof ( FTPAccount ) ;
2014-06-07 05:21:03 +12:00
eiCustomUploaders . ObjectType = typeof ( CustomUploaderItem ) ;
2014-05-30 23:38:23 +12:00
}
public void LoadSettings ( UploadersConfig uploadersConfig )
{
#region Image uploaders
// Imgur
atcImgurAccountType . SelectedAccountType = Config . ImgurAccountType ;
cbImgurThumbnailType . Items . Clear ( ) ;
cbImgurThumbnailType . Items . AddRange ( Helpers . GetEnumDescriptions < ImgurThumbnailType > ( ) ) ;
cbImgurThumbnailType . SelectedIndex = ( int ) Config . ImgurThumbnailType ;
txtImgurAlbumID . Text = Config . ImgurAlbumID ;
if ( OAuth2Info . CheckOAuth ( Config . ImgurOAuth2Info ) )
{
2014-06-17 00:20:06 +12:00
oauth2Imgur . Status = OAuthLoginStatus . LoginSuccessful ;
2014-05-30 23:38:23 +12:00
btnImgurRefreshAlbumList . Enabled = true ;
}
2014-06-16 22:47:35 +12:00
// ImageShack
txtImageShackUsername . Text = Config . ImageShackSettings . Username ;
txtImageShackPassword . Text = Config . ImageShackSettings . Password ;
cbImageShackIsPublic . Checked = Config . ImageShackSettings . IsPublic ;
// TinyPic
atcTinyPicAccountType . SelectedAccountType = Config . TinyPicAccountType ;
txtTinyPicUsername . Text = Config . TinyPicUsername ;
txtTinyPicPassword . Text = Config . TinyPicPassword ;
// Flickr
pgFlickrAuthInfo . SelectedObject = Config . FlickrAuthInfo ;
pgFlickrSettings . SelectedObject = Config . FlickrSettings ;
2014-05-30 23:38:23 +12:00
// Photobucket
if ( OAuthInfo . CheckOAuth ( Config . PhotobucketOAuthInfo ) )
{
lblPhotobucketAccountStatus . Text = "Login successful." ;
txtPhotobucketDefaultAlbumName . Text = Config . PhotobucketAccountInfo . AlbumID ;
lblPhotobucketParentAlbumPath . Text = "Parent album path e.g. " + Config . PhotobucketAccountInfo . AlbumID + "/Personal/" + DateTime . Now . Year ;
}
if ( Config . PhotobucketAccountInfo ! = null )
{
cboPhotobucketAlbumPaths . Items . Clear ( ) ;
if ( Config . PhotobucketAccountInfo . AlbumList . Count > 0 )
{
cboPhotobucketAlbumPaths . Items . AddRange ( Config . PhotobucketAccountInfo . AlbumList . ToArray ( ) ) ;
cboPhotobucketAlbumPaths . SelectedIndex = Config . PhotobucketAccountInfo . ActiveAlbumID .
BetweenOrDefault ( 0 , Config . PhotobucketAccountInfo . AlbumList . Count - 1 ) ;
}
}
// Picasa
if ( OAuth2Info . CheckOAuth ( Config . PicasaOAuth2Info ) )
{
2014-06-17 00:20:06 +12:00
oauth2Picasa . Status = OAuthLoginStatus . LoginSuccessful ;
2014-05-30 23:38:23 +12:00
btnPicasaRefreshAlbumList . Enabled = true ;
}
txtPicasaAlbumID . Text = Config . PicasaAlbumID ;
#endregion Image uploaders
#region Text uploaders
// Pastebin
pgPastebinSettings . SelectedObject = Config . PastebinSettings ;
// Paste.ee
txtPaste_eeUserAPIKey . Text = Config . Paste_eeUserAPIKey ;
// Gist
atcGistAccountType . SelectedAccountType = Config . GistAnonymousLogin ? AccountType . Anonymous : AccountType . User ;
chkGistPublishPublic . Checked = Config . GistPublishPublic ;
if ( OAuth2Info . CheckOAuth ( Config . GistOAuth2Info ) )
{
2014-06-17 00:20:06 +12:00
oAuth2Gist . Status = OAuthLoginStatus . LoginSuccessful ;
2014-05-30 23:38:23 +12:00
}
// Upaste
txtUpasteUserKey . Text = Config . UpasteUserKey ;
cbUpasteIsPublic . Checked = Config . UpasteIsPublic ;
#endregion Text uploaders
#region File uploaders
// Dropbox
2014-06-09 07:59:13 +12:00
if ( OAuth2Info . CheckOAuth ( Config . DropboxOAuth2Info ) )
{
2014-06-17 00:20:06 +12:00
oauth2Dropbox . Status = OAuthLoginStatus . LoginSuccessful ;
2014-06-09 07:59:13 +12:00
}
2014-05-30 23:38:23 +12:00
txtDropboxPath . Text = Config . DropboxUploadPath ;
cbDropboxAutoCreateShareableLink . Checked = Config . DropboxAutoCreateShareableLink ;
cbDropboxURLType . Enabled = Config . DropboxAutoCreateShareableLink ;
cbDropboxURLType . Items . AddRange ( Helpers . GetEnumNamesProper < DropboxURLType > ( ) ) ;
cbDropboxURLType . SelectedIndex = ( int ) Config . DropboxURLType ;
UpdateDropboxStatus ( ) ;
2014-06-06 06:19:45 +12:00
// Copy
if ( OAuthInfo . CheckOAuth ( Config . CopyOAuthInfo ) )
{
2014-06-17 00:20:06 +12:00
oAuthCopy . Status = OAuthLoginStatus . LoginSuccessful ;
2014-06-06 06:19:45 +12:00
}
2014-06-06 07:47:36 +12:00
txtCopyPath . Text = Config . CopyUploadPath ;
2014-06-10 05:26:23 +12:00
cbCopyURLType . Items . AddRange ( Helpers . GetEnumNamesProper < CopyURLType > ( ) ) ;
cbCopyURLType . SelectedIndex = ( int ) Config . CopyURLType ;
2014-06-06 09:06:49 +12:00
UpdateCopyStatus ( ) ;
2014-06-06 07:47:36 +12:00
2014-05-30 23:38:23 +12:00
// Google Drive
if ( OAuth2Info . CheckOAuth ( Config . GoogleDriveOAuth2Info ) )
{
2014-06-17 00:20:06 +12:00
oauth2GoogleDrive . Status = OAuthLoginStatus . LoginSuccessful ;
2014-07-01 22:18:07 +12:00
btnGoogleDriveRefreshFolders . Enabled = true ;
2014-05-30 23:38:23 +12:00
}
cbGoogleDriveIsPublic . Checked = Config . GoogleDriveIsPublic ;
2014-07-02 20:52:05 +12:00
cbGoogleDriveUseFolder . Checked = Config . GoogleDriveUseFolder ;
txtGoogleDriveFolderID . Enabled = Config . GoogleDriveUseFolder ;
2014-07-01 22:18:07 +12:00
txtGoogleDriveFolderID . Text = Config . GoogleDriveFolderID ;
2014-05-30 23:38:23 +12:00
// Minus
cbMinusURLType . Items . Clear ( ) ;
cbMinusURLType . Items . AddRange ( Enum . GetNames ( typeof ( MinusLinkType ) ) ) ;
MinusUpdateControls ( ) ;
// Box
if ( OAuth2Info . CheckOAuth ( Config . BoxOAuth2Info ) )
{
2014-06-17 00:20:06 +12:00
oauth2Box . Status = OAuthLoginStatus . LoginSuccessful ;
2014-05-30 23:38:23 +12:00
btnBoxRefreshFolders . Enabled = true ;
}
cbBoxShare . Checked = Config . BoxShare ;
lblBoxFolderID . Text = "Selected folder: " + Config . BoxSelectedFolder . name ;
// Ge.tt
if ( Config . Ge_ttLogin ! = null & & ! string . IsNullOrEmpty ( Config . Ge_ttLogin . AccessToken ) )
{
lblGe_ttStatus . Text = "Login successful." ;
}
// Localhostr
txtLocalhostrEmail . Text = Config . LocalhostrEmail ;
txtLocalhostrPassword . Text = Config . LocalhostrPassword ;
cbLocalhostrDirectURL . Checked = Config . LocalhostrDirectURL ;
// FTP
if ( Config . FTPAccountList = = null | | Config . FTPAccountList . Count = = 0 )
{
FTPSetup ( new List < FTPAccount > ( ) ) ;
}
else
{
FTPSetup ( Config . FTPAccountList ) ;
if ( ucFTPAccounts . lbAccounts . Items . Count > 0 )
{
ucFTPAccounts . lbAccounts . SelectedIndex = 0 ;
}
}
// Email
txtEmailSmtpServer . Text = Config . EmailSmtpServer ;
nudEmailSmtpPort . Value = Config . EmailSmtpPort ;
txtEmailFrom . Text = Config . EmailFrom ;
txtEmailPassword . Text = Config . EmailPassword ;
chkEmailConfirm . Checked = Config . EmailConfirmSend ;
cbEmailRememberLastTo . Checked = Config . EmailRememberLastTo ;
txtEmailDefaultSubject . Text = Config . EmailDefaultSubject ;
txtEmailDefaultBody . Text = Config . EmailDefaultBody ;
// RapidShare
txtRapidShareUsername . Text = Config . RapidShareUsername ;
txtRapidSharePassword . Text = Config . RapidSharePassword ;
txtRapidShareFolderID . Text = Config . RapidShareFolderID ;
// SendSpace
atcSendSpaceAccountType . SelectedAccountType = Config . SendSpaceAccountType ;
txtSendSpacePassword . Text = Config . SendSpacePassword ;
txtSendSpaceUserName . Text = Config . SendSpaceUsername ;
// Localhost
if ( Config . LocalhostAccountList = = null | | Config . LocalhostAccountList . Count = = 0 )
{
LocalhostAccountsSetup ( new List < LocalhostAccount > ( ) ) ;
}
else
{
LocalhostAccountsSetup ( Config . LocalhostAccountList ) ;
if ( ucLocalhostAccounts . lbAccounts . Items . Count > 0 )
{
ucLocalhostAccounts . lbAccounts . SelectedIndex = 0 ;
cboSharedFolderImages . SelectedIndex = Config . LocalhostSelectedImages . Between ( 0 , ucLocalhostAccounts . lbAccounts . Items . Count - 1 ) ;
cboSharedFolderText . SelectedIndex = Config . LocalhostSelectedText . Between ( 0 , ucLocalhostAccounts . lbAccounts . Items . Count - 1 ) ;
cboSharedFolderFiles . SelectedIndex = Config . LocalhostSelectedFiles . Between ( 0 , ucLocalhostAccounts . lbAccounts . Items . Count - 1 ) ;
}
}
// Custom uploaders
lbCustomUploaderList . Items . Clear ( ) ;
if ( Config . CustomUploadersList = = null )
{
Config . CustomUploadersList = new List < CustomUploaderItem > ( ) ;
}
else
{
foreach ( CustomUploaderItem customUploader in Config . CustomUploadersList )
{
lbCustomUploaderList . Items . Add ( customUploader . Name ) ;
}
PrepareCustomUploaderList ( ) ;
}
cbCustomUploaderRequestType . Items . AddRange ( Enum . GetNames ( typeof ( CustomUploaderRequestType ) ) ) ;
cbCustomUploaderResponseType . Items . AddRange ( Helpers . GetEnumDescriptions < ResponseType > ( ) ) ;
CustomUploaderClear ( ) ;
// Jira
txtJiraHost . Text = Config . JiraHost ;
txtJiraIssuePrefix . Text = Config . JiraIssuePrefix ;
txtJiraConfigHelp . Text = string . Format ( @ "Howto configure your Jira server:
- Go to ' Administration ' - > ' Add - ons '
- Select ' Application Links '
- Add a new ' Application Link ' with following settings :
- Server URL : { 0 }
- Application Name : { 1 }
- Application Type : Generic Application
- Now , you have to configure Incoming Authentication
- Consumer Key : { 2 }
- Consumer Name : { 1 }
- Public Key ( without quotes ) : ' { 3 } '
- You can now authenticate to Jira ", Links.URL_WEBSITE, Application.ProductName, APIKeys.JiraConsumerKey, Jira.PublicKey);
if ( OAuthInfo . CheckOAuth ( Config . JiraOAuthInfo ) )
{
2014-06-17 00:20:06 +12:00
oAuthJira . Status = OAuthLoginStatus . LoginSuccessful ;
2014-05-30 23:38:23 +12:00
}
// Mega
MegaConfigureTab ( false ) ;
//Pushbullet
txtPushbulletUserKey . Text = Config . PushbulletSettings . UserAPIKey ;
if ( Config . PushbulletSettings . DeviceList . Count > 0 )
{
Config . PushbulletSettings . DeviceList . ForEach ( x = > cboPushbulletDevices . Items . Add ( x . Name ? ? "Invalid device name" ) ) ;
if ( Config . PushbulletSettings . DeviceList . IsValidIndex ( Config . PushbulletSettings . SelectedDevice ) )
{
cboPushbulletDevices . SelectedIndex = Config . PushbulletSettings . SelectedDevice ;
}
else
{
cboPushbulletDevices . SelectedIndex = 0 ;
}
}
// Amazon S3
txtAmazonS3AccessKey . Text = Config . AmazonS3Settings . AccessKeyID ;
txtAmazonS3SecretKey . Text = Config . AmazonS3Settings . SecretAccessKey ;
cbAmazonS3Endpoint . Text = Config . AmazonS3Settings . Endpoint ;
txtAmazonS3BucketName . Text = Config . AmazonS3Settings . Bucket ;
txtAmazonS3ObjectPrefix . Text = Config . AmazonS3Settings . ObjectPrefix ;
cbAmazonS3CustomCNAME . Checked = Config . AmazonS3Settings . UseCustomCNAME ;
txtAmazonS3CustomDomain . Enabled = Config . AmazonS3Settings . UseCustomCNAME ;
txtAmazonS3CustomDomain . Text = Config . AmazonS3Settings . CustomDomain ;
cbAmazonS3UseRRS . Checked = Config . AmazonS3Settings . UseReducedRedundancyStorage ;
UpdateAmazonS3Status ( ) ;
#endregion File uploaders
#region URL Shorteners
// Google URL Shortener
atcGoogleURLShortenerAccountType . SelectedAccountType = Config . GoogleURLShortenerAccountType ;
if ( OAuth2Info . CheckOAuth ( Config . GoogleURLShortenerOAuth2Info ) )
{
2014-06-17 00:20:06 +12:00
oauth2GoogleURLShortener . Status = OAuthLoginStatus . LoginSuccessful ;
2014-05-30 23:38:23 +12:00
}
// bit.ly
if ( OAuth2Info . CheckOAuth ( Config . BitlyOAuth2Info ) )
{
2014-06-17 00:20:06 +12:00
oauth2Bitly . Status = OAuthLoginStatus . LoginSuccessful ;
2014-05-30 23:38:23 +12:00
}
2014-06-18 08:10:31 +12:00
txtBitlyDomain . Text = Config . BitlyDomain ;
2014-05-30 23:38:23 +12:00
// yourls.org
txtYourlsAPIURL . Text = Config . YourlsAPIURL ;
txtYourlsSignature . Text = Config . YourlsSignature ;
txtYourlsUsername . Enabled = txtYourlsPassword . Enabled = string . IsNullOrEmpty ( Config . YourlsSignature ) ;
txtYourlsUsername . Text = Config . YourlsUsername ;
txtYourlsPassword . Text = Config . YourlsPassword ;
#endregion URL Shorteners
#region Other Services
ucTwitterAccounts . lbAccounts . Items . Clear ( ) ;
foreach ( OAuthInfo acc in Config . TwitterOAuthInfoList )
{
ucTwitterAccounts . lbAccounts . Items . Add ( acc ) ;
}
if ( ucTwitterAccounts . lbAccounts . Items . Count > 0 )
{
ucTwitterAccounts . lbAccounts . SelectedIndex = Config . TwitterSelectedAccount ;
}
#endregion Other Services
2013-11-03 23:53:49 +13:00
}
#region Image Uploaders
2014-06-16 22:47:35 +12:00
#region Imgur
private void atcImgurAccountType_AccountTypeChanged ( AccountType accountType )
{
Config . ImgurAccountType = accountType ;
}
private void cbImgurThumbnailType_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . ImgurThumbnailType = ( ImgurThumbnailType ) cbImgurThumbnailType . SelectedIndex ;
}
private void txtImgurAlbumID_TextChanged ( object sender , EventArgs e )
{
Config . ImgurAlbumID = txtImgurAlbumID . Text ;
}
2014-06-17 01:01:36 +12:00
private void oauth2Imgur_ClearButtonClicked ( )
{
Config . ImgurOAuth2Info = null ;
}
2014-06-16 22:47:35 +12:00
private void btnImgurRefreshAlbumList_Click ( object sender , EventArgs e )
{
ImgurRefreshAlbumList ( ) ;
}
private void lvImgurAlbumList_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( lvImgurAlbumList . SelectedItems . Count > 0 )
{
ListViewItem lvi = lvImgurAlbumList . SelectedItems [ 0 ] ;
if ( lvi . Tag is ImgurAlbumData )
{
ImgurAlbumData album = ( ImgurAlbumData ) lvi . Tag ;
txtImgurAlbumID . Text = album . id ;
}
}
}
private void oauth2Imgur_OpenButtonClicked ( )
{
ImgurAuthOpen ( ) ;
}
private void oauth2Imgur_CompleteButtonClicked ( string code )
{
ImgurAuthComplete ( code ) ;
}
private void oauth2Imgur_RefreshButtonClicked ( )
{
ImgurAuthRefresh ( ) ;
}
#endregion Imgur
2013-11-03 23:53:49 +13:00
#region ImageShack
private void txtImageShackUsername_TextChanged ( object sender , EventArgs e )
{
2014-01-12 23:44:06 +13:00
Config . ImageShackSettings . Username = txtImageShackUsername . Text ;
2013-11-03 23:53:49 +13:00
}
2014-01-13 00:37:05 +13:00
private void txtImageShackPassword_TextChanged ( object sender , EventArgs e )
2013-11-03 23:53:49 +13:00
{
2014-01-12 23:44:06 +13:00
Config . ImageShackSettings . Password = txtImageShackPassword . Text ;
2013-11-03 23:53:49 +13:00
}
2014-01-13 00:37:05 +13:00
private void btnImageShackLogin_Click ( object sender , EventArgs e )
{
2014-02-15 05:54:10 +13:00
ImageShackUploader imageShackUploader = new ImageShackUploader ( APIKeys . ImageShackKey , Config . ImageShackSettings ) ;
2014-01-13 00:37:05 +13:00
try
{
if ( imageShackUploader . GetAccessToken ( ) )
{
MessageBox . Show ( "Login successful." , Application . ProductName , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
}
else
{
MessageBox . Show ( "Login failed." , Application . ProductName , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
catch ( Exception ex )
{
DebugHelper . WriteException ( ex ) ;
MessageBox . Show ( ex . ToString ( ) , "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
}
}
2014-01-12 23:44:06 +13:00
private void cbImageShackIsPublic_CheckedChanged ( object sender , EventArgs e )
2013-11-03 23:53:49 +13:00
{
2014-01-12 23:44:06 +13:00
Config . ImageShackSettings . IsPublic = cbImageShackIsPublic . Checked ;
2013-11-03 23:53:49 +13:00
}
private void btnImageShackOpenPublicProfile_Click ( object sender , EventArgs e )
{
2014-01-12 23:44:06 +13:00
if ( ! string . IsNullOrEmpty ( Config . ImageShackSettings . Username ) )
2013-11-03 23:53:49 +13:00
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "https://imageshack.com/user/" + Config . ImageShackSettings . Username ) ;
2013-11-03 23:53:49 +13:00
}
else
{
txtImageShackUsername . Focus ( ) ;
}
}
private void btnImageShackOpenMyImages_Click ( object sender , EventArgs e )
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "https://imageshack.com/my/images" ) ;
2013-11-03 23:53:49 +13:00
}
#endregion ImageShack
#region TinyPic
private void atcTinyPicAccountType_AccountTypeChanged ( AccountType accountType )
{
Config . TinyPicAccountType = accountType ;
}
private void txtTinyPicUsername_TextChanged ( object sender , EventArgs e )
{
if ( Config . TinyPicRememberUserPass )
{
Config . TinyPicUsername = txtTinyPicUsername . Text ;
}
}
private void txtTinyPicPassword_TextChanged ( object sender , EventArgs e )
{
if ( Config . TinyPicRememberUserPass )
{
Config . TinyPicPassword = txtTinyPicPassword . Text ;
}
}
private void btnTinyPicLogin_Click ( object sender , EventArgs e )
{
string username = txtTinyPicUsername . Text ;
string password = txtTinyPicPassword . Text ;
if ( ! string . IsNullOrEmpty ( username ) & & ! string . IsNullOrEmpty ( password ) )
{
try
{
TinyPicUploader tpu = new TinyPicUploader ( APIKeys . TinyPicID , APIKeys . TinyPicKey ) ;
string registrationCode = tpu . UserAuth ( username , password ) ;
if ( ! string . IsNullOrEmpty ( registrationCode ) )
{
Config . TinyPicRegistrationCode = registrationCode ;
2014-01-13 00:37:05 +13:00
MessageBox . Show ( "Login successful." , Application . ProductName , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
}
else
{
MessageBox . Show ( "Login failed." , Application . ProductName , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
2013-11-03 23:53:49 +13:00
}
}
catch ( Exception ex )
{
DebugHelper . WriteException ( ex ) ;
2014-01-13 00:37:05 +13:00
MessageBox . Show ( ex . ToString ( ) , "Error" , MessageBoxButtons . OK , MessageBoxIcon . Error ) ;
2013-11-03 23:53:49 +13:00
}
}
}
private void btnTinyPicOpenMyImages_Click ( object sender , EventArgs e )
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "http://tinypic.com/yourstuff.php" ) ;
2013-11-03 23:53:49 +13:00
}
#endregion TinyPic
2014-06-16 22:47:35 +12:00
#region Flickr
2013-11-03 23:53:49 +13:00
2014-06-16 22:47:35 +12:00
private void btnFlickrOpenAuthorize_Click ( object sender , EventArgs e )
2013-11-03 23:53:49 +13:00
{
2014-06-16 22:47:35 +12:00
FlickrAuthOpen ( ) ;
2013-11-03 23:53:49 +13:00
}
2014-06-16 22:47:35 +12:00
private void btnFlickrCompleteAuth_Click ( object sender , EventArgs e )
2013-11-03 23:53:49 +13:00
{
2014-06-16 22:47:35 +12:00
FlickrAuthComplete ( ) ;
2013-11-03 23:53:49 +13:00
}
2014-06-16 22:47:35 +12:00
private void btnFlickrCheckToken_Click ( object sender , EventArgs e )
2013-11-03 23:53:49 +13:00
{
2014-06-16 22:47:35 +12:00
FlickrCheckToken ( ) ;
2013-11-03 23:53:49 +13:00
}
2014-06-16 22:47:35 +12:00
private void btnFlickrOpenImages_Click ( object sender , EventArgs e )
2013-11-03 23:53:49 +13:00
{
2014-06-16 22:47:35 +12:00
FlickrOpenImages ( ) ;
2013-11-03 23:53:49 +13:00
}
2014-06-16 22:47:35 +12:00
#endregion Flickr
2013-11-03 23:53:49 +13:00
#region Photobucket
private void btnPhotobucketAuthOpen_Click ( object sender , EventArgs e )
{
PhotobucketAuthOpen ( ) ;
}
private void btnPhotobucketAuthComplete_Click ( object sender , EventArgs e )
{
PhotobucketAuthComplete ( ) ;
}
private void btnPhotobucketCreateAlbum_Click ( object sender , EventArgs e )
{
PhotobucketCreateAlbum ( ) ;
}
private void cboPhotobucketAlbumPaths_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( Config . PhotobucketAccountInfo ! = null )
{
Config . PhotobucketAccountInfo . ActiveAlbumID = cboPhotobucketAlbumPaths . SelectedIndex ;
}
}
private void btnPhotobucketAddAlbum_Click ( object sender , EventArgs e )
{
string albumPath = cboPhotobucketAlbumPaths . Text ;
if ( ! Config . PhotobucketAccountInfo . AlbumList . Contains ( albumPath ) )
{
Config . PhotobucketAccountInfo . AlbumList . Add ( albumPath ) ;
cboPhotobucketAlbumPaths . Items . Add ( albumPath ) ;
}
}
private void btnPhotobucketRemoveAlbum_Click ( object sender , EventArgs e )
{
if ( cboPhotobucketAlbumPaths . Items . Count > 1 )
{
cboPhotobucketAlbumPaths . Items . RemoveAt ( cboPhotobucketAlbumPaths . SelectedIndex ) ;
cboPhotobucketAlbumPaths . SelectedIndex = cboPhotobucketAlbumPaths . Items . Count - 1 ;
}
}
#endregion Photobucket
#region Picasa
private void oauth2Picasa_OpenButtonClicked ( )
{
PicasaAuthOpen ( ) ;
}
private void oauth2Picasa_CompleteButtonClicked ( string code )
{
PicasaAuthComplete ( code ) ;
}
2014-06-17 01:01:36 +12:00
private void oauth2Picasa_ClearButtonClicked ( )
{
Config . PicasaOAuth2Info = null ;
}
2013-11-03 23:53:49 +13:00
private void oauth2Picasa_RefreshButtonClicked ( )
{
PicasaAuthRefresh ( ) ;
}
private void txtPicasaAlbumID_TextChanged ( object sender , EventArgs e )
{
Config . PicasaAlbumID = txtPicasaAlbumID . Text ;
}
private void btnPicasaRefreshAlbumList_Click ( object sender , EventArgs e )
{
PicasaRefreshAlbumList ( ) ;
}
private void lvPicasaAlbumList_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( lvPicasaAlbumList . SelectedItems . Count > 0 )
{
ListViewItem lvi = lvPicasaAlbumList . SelectedItems [ 0 ] ;
if ( lvi . Tag is PicasaAlbumInfo )
{
PicasaAlbumInfo album = ( PicasaAlbumInfo ) lvi . Tag ;
txtPicasaAlbumID . Text = album . ID ;
}
}
}
#endregion Picasa
#endregion Image Uploaders
2014-03-30 23:28:34 +13:00
#region Text Uploaders
#region Pastebin
private void btnPastebinLogin_Click ( object sender , EventArgs e )
{
PastebinLogin ( ) ;
}
#endregion Pastebin
#region Paste . ee
private void txtPaste_eeUserAPIKey_TextChanged ( object sender , EventArgs e )
{
Config . Paste_eeUserAPIKey = txtPaste_eeUserAPIKey . Text ;
}
#endregion Paste . ee
#region Gist
private void atcGistAccountType_AccountTypeChanged ( AccountType accountType )
{
Config . GistAnonymousLogin = accountType = = AccountType . Anonymous ;
oAuth2Gist . Enabled = ! Config . GistAnonymousLogin ;
}
private void oAuth2Gist_OpenButtonClicked ( )
{
GistAuthOpen ( ) ;
}
private void oAuth2Gist_CompleteButtonClicked ( string code )
{
GistAuthComplete ( code ) ;
}
2014-06-17 01:01:36 +12:00
private void oAuth2Gist_ClearButtonClicked ( )
{
Config . GistOAuth2Info = null ;
}
2014-03-30 23:28:34 +13:00
private void chkGistPublishPublic_CheckedChanged ( object sender , EventArgs e )
{
Config . GistPublishPublic = ( ( CheckBox ) sender ) . Checked ;
}
#endregion Gist
#region uPaste
private void txtUpasteUserKey_TextChanged ( object sender , EventArgs e )
{
Config . UpasteUserKey = txtUpasteUserKey . Text ;
}
private void cbUpasteIsPublic_CheckedChanged ( object sender , EventArgs e )
{
Config . UpasteIsPublic = cbUpasteIsPublic . Checked ;
}
#endregion uPaste
#endregion Text Uploaders
2013-11-03 23:53:49 +13:00
#region File Uploaders
#region Dropbox
private void pbDropboxLogo_Click ( object sender , EventArgs e )
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "https://www.dropbox.com" ) ;
2013-11-03 23:53:49 +13:00
}
private void btnDropboxRegister_Click ( object sender , EventArgs e )
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "http://db.tt/CtPYXvu" ) ;
2013-11-03 23:53:49 +13:00
}
2014-06-09 07:59:13 +12:00
private void oauth2Dropbox_OpenButtonClicked ( )
2013-11-03 23:53:49 +13:00
{
DropboxAuthOpen ( ) ;
}
2014-06-09 07:59:13 +12:00
private void oauth2Dropbox_CompleteButtonClicked ( string code )
2013-11-03 23:53:49 +13:00
{
2014-06-09 07:59:13 +12:00
DropboxAuthComplete ( code ) ;
2013-11-03 23:53:49 +13:00
}
2014-06-17 01:01:36 +12:00
private void oauth2Dropbox_ClearButtonClicked ( )
{
Config . DropboxOAuth2Info = null ;
}
2013-11-03 23:53:49 +13:00
private void txtDropboxPath_TextChanged ( object sender , EventArgs e )
{
Config . DropboxUploadPath = txtDropboxPath . Text ;
UpdateDropboxStatus ( ) ;
}
private void btnDropboxShowFiles_Click ( object sender , EventArgs e )
{
DropboxOpenFiles ( ) ;
}
private void cbDropboxAutoCreateShareableLink_CheckedChanged ( object sender , EventArgs e )
{
Config . DropboxAutoCreateShareableLink = cbDropboxAutoCreateShareableLink . Checked ;
2014-04-20 11:00:19 +12:00
cbDropboxURLType . Enabled = Config . DropboxAutoCreateShareableLink ;
2013-11-03 23:53:49 +13:00
}
2014-04-20 11:00:19 +12:00
private void cbDropboxURLType_SelectedIndexChanged ( object sender , EventArgs e )
2013-11-03 23:53:49 +13:00
{
2014-04-20 11:00:19 +12:00
Config . DropboxURLType = ( DropboxURLType ) cbDropboxURLType . SelectedIndex ;
2013-11-03 23:53:49 +13:00
}
#endregion Dropbox
2014-06-06 06:19:45 +12:00
#region Copy
private void pbCopyLogo_Click ( object sender , EventArgs e )
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "https://copy.com" ) ;
2014-06-06 06:19:45 +12:00
}
private void btnCopyRegister_Click ( object sender , EventArgs e )
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "https://copy.com?r=hC3DMW" ) ;
2014-06-06 06:19:45 +12:00
}
private void txtCopyPath_TextChanged ( object sender , EventArgs e )
{
Config . CopyUploadPath = txtCopyPath . Text ;
UpdateCopyStatus ( ) ;
}
private void oAuthCopy_OpenButtonClicked ( )
{
CopyAuthOpen ( ) ;
}
private void oAuthCopy_CompleteButtonClicked ( string code )
{
CopyAuthComplete ( code ) ;
}
2014-06-17 01:01:36 +12:00
private void oAuthCopy_ClearButtonClicked ( )
{
Config . CopyOAuthInfo = null ;
}
2014-06-10 05:26:23 +12:00
private void cbCopyURLType_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . CopyURLType = ( CopyURLType ) cbCopyURLType . SelectedIndex ;
}
2014-06-06 06:19:45 +12:00
#endregion Copy
2013-11-03 23:53:49 +13:00
#region Google Drive
private void oauth2GoogleDrive_OpenButtonClicked ( )
{
GoogleDriveAuthOpen ( ) ;
}
private void oauth2GoogleDrive_CompleteButtonClicked ( string code )
{
GoogleDriveAuthComplete ( code ) ;
}
private void oauth2GoogleDrive_RefreshButtonClicked ( )
{
GoogleDriveAuthRefresh ( ) ;
}
2014-06-17 01:01:36 +12:00
private void oauth2GoogleDrive_ClearButtonClicked ( )
{
Config . GoogleDriveOAuth2Info = null ;
}
2014-03-18 23:27:22 +13:00
private void cbGoogleDriveIsPublic_CheckedChanged ( object sender , EventArgs e )
{
Config . GoogleDriveIsPublic = cbGoogleDriveIsPublic . Checked ;
}
2014-07-02 20:52:05 +12:00
private void cbGoogleDriveUseFolder_CheckedChanged ( object sender , EventArgs e )
{
Config . GoogleDriveUseFolder = cbGoogleDriveUseFolder . Checked ;
txtGoogleDriveFolderID . Enabled = Config . GoogleDriveUseFolder ;
}
2014-07-01 22:18:07 +12:00
private void txtGoogleDriveFolderID_TextChanged ( object sender , EventArgs e )
{
Config . GoogleDriveFolderID = txtGoogleDriveFolderID . Text ;
}
private void btnGoogleDriveRefreshFolders_Click ( object sender , EventArgs e )
{
GoogleDriveRefreshFolders ( ) ;
}
private void lvGoogleDriveFoldersList_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( lvGoogleDriveFoldersList . SelectedItems . Count > 0 )
{
ListViewItem lvi = lvGoogleDriveFoldersList . SelectedItems [ 0 ] ;
var folder = lvi . Tag as UploadersLib . FileUploaders . GoogleDrive . GoogleDriveFile ;
if ( folder ! = null )
{
txtGoogleDriveFolderID . Text = folder . id ;
}
}
}
2013-11-03 23:53:49 +13:00
#endregion Google Drive
#region Box
2014-04-17 04:18:25 +12:00
private void oauth2Box_OpenButtonClicked ( )
2013-11-03 23:53:49 +13:00
{
BoxAuthOpen ( ) ;
}
2014-04-17 04:18:25 +12:00
private void oauth2Box_CompleteButtonClicked ( string code )
2013-11-03 23:53:49 +13:00
{
2014-04-17 04:18:25 +12:00
BoxAuthComplete ( code ) ;
}
private void oauth2Box_RefreshButtonClicked ( )
{
BoxAuthRefresh ( ) ;
2013-11-03 23:53:49 +13:00
}
2014-06-17 01:01:36 +12:00
private void oauth2Box_ClearButtonClicked ( )
{
Config . BoxOAuth2Info = null ;
}
2014-04-17 08:35:10 +12:00
private void cbBoxShare_CheckedChanged ( object sender , EventArgs e )
{
Config . BoxShare = cbBoxShare . Checked ;
}
2013-11-03 23:53:49 +13:00
private void btnBoxRefreshFolders_Click ( object sender , EventArgs e )
{
BoxListFolders ( ) ;
}
2014-04-17 08:35:10 +12:00
private void lvBoxFolders_SelectedIndexChanged ( object sender , EventArgs e )
2013-11-03 23:53:49 +13:00
{
2014-04-17 08:35:10 +12:00
if ( lvBoxFolders . SelectedItems . Count > 0 )
2013-11-03 23:53:49 +13:00
{
2014-04-17 08:35:10 +12:00
ListViewItem lvi = lvBoxFolders . SelectedItems [ 0 ] ;
BoxFileEntry file = lvi . Tag as BoxFileEntry ;
if ( file ! = null )
{
2014-04-17 11:34:31 +12:00
lblBoxFolderID . Text = "Selected folder: " + file . name ;
}
}
}
private void lvBoxFolders_MouseDoubleClick ( object sender , MouseEventArgs e )
{
if ( e . Button = = MouseButtons . Left & & lvBoxFolders . SelectedItems . Count > 0 )
{
ListViewItem lvi = lvBoxFolders . SelectedItems [ 0 ] ;
BoxFileEntry file = lvi . Tag as BoxFileEntry ;
if ( file ! = null )
{
lvBoxFolders . Items . Clear ( ) ;
BoxListFolders ( file ) ;
2014-04-17 08:35:10 +12:00
}
2013-11-03 23:53:49 +13:00
}
}
#endregion Box
#region Minus
private void btnMinusAuth_Click ( object sender , EventArgs e )
{
MinusAuth ( ) ;
}
private void btnAuthRefresh_Click ( object sender , EventArgs e )
{
MinusAuthRefresh ( ) ;
}
private void cboMinusFolders_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( Config . MinusConfig ! = null )
{
Config . MinusConfig . FolderID = cboMinusFolders . SelectedIndex ;
MinusFolder tempMf = Config . MinusConfig . GetActiveFolder ( ) ;
chkMinusPublic . Checked = tempMf . is_public ;
}
}
private void btnMinusFolderAdd_Click ( object sender , EventArgs e )
{
2014-03-21 12:37:43 +13:00
if ( ! string . IsNullOrEmpty ( cboMinusFolders . Text ) & & ! MinusHasFolder ( cboMinusFolders . Text ) )
2013-11-03 23:53:49 +13:00
{
2014-03-21 12:37:43 +13:00
btnMinusFolderAdd . Enabled = false ;
Minus minus = new Minus ( Config . MinusConfig , Config . MinusOAuth2Info ) ;
2013-11-03 23:53:49 +13:00
MinusFolder dir = minus . CreateFolder ( cboMinusFolders . Text , chkMinusPublic . Checked ) ;
if ( dir ! = null )
{
cboMinusFolders . Items . Add ( dir ) ;
2014-03-21 12:37:43 +13:00
cboMinusFolders . SelectedIndex = cboMinusFolders . Items . Count - 1 ;
2013-11-03 23:53:49 +13:00
}
2014-03-21 12:37:43 +13:00
btnMinusFolderAdd . Enabled = true ;
2013-11-03 23:53:49 +13:00
}
}
private void btnMinusFolderRemove_Click ( object sender , EventArgs e )
{
2014-03-21 12:37:43 +13:00
if ( ! string . IsNullOrEmpty ( cboMinusFolders . Text ) & & MinusHasFolder ( cboMinusFolders . Text ) )
2013-11-03 23:53:49 +13:00
{
2014-03-21 12:37:43 +13:00
btnMinusFolderRemove . Enabled = false ;
2013-11-03 23:53:49 +13:00
2014-03-21 12:37:43 +13:00
Minus minus = new Minus ( Config . MinusConfig , Config . MinusOAuth2Info ) ;
2013-11-03 23:53:49 +13:00
2014-03-21 12:37:43 +13:00
int index = cboMinusFolders . SelectedIndex ;
if ( minus . DeleteFolder ( index ) )
2013-11-03 23:53:49 +13:00
{
2014-03-21 12:37:43 +13:00
cboMinusFolders . Items . RemoveAt ( index ) ;
if ( cboMinusFolders . Items . Count > 0 )
{
cboMinusFolders . SelectedIndex = 0 ;
}
2013-11-03 23:53:49 +13:00
}
2014-03-21 12:37:43 +13:00
btnMinusFolderRemove . Enabled = true ;
2013-11-03 23:53:49 +13:00
}
}
private void btnMinusReadFolderList_Click ( object sender , EventArgs e )
{
if ( Config . MinusConfig ! = null )
{
btnMinusReadFolderList . Enabled = false ;
2014-03-21 12:37:43 +13:00
List < MinusFolder > tempListMf = new Minus ( Config . MinusConfig , Config . MinusOAuth2Info ) . ReadFolderList ( ) ;
2013-11-03 23:53:49 +13:00
if ( tempListMf . Count > 0 )
{
cboMinusFolders . Items . Clear ( ) ;
cboMinusFolders . Items . AddRange ( tempListMf . ToArray ( ) ) ;
cboMinusFolders . SelectedIndex = Config . MinusConfig . FolderID ;
}
btnMinusReadFolderList . Enabled = true ;
}
}
private void cbMinusURLType_SelectedIndexChanged ( object sender , EventArgs e )
{
if ( Config . MinusConfig ! = null )
{
Config . MinusConfig . LinkType = ( MinusLinkType ) cbMinusURLType . SelectedIndex ;
}
}
#endregion Minus
#region FTP
private void cboFtpImages_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . FTPSelectedImage = cboFtpImages . SelectedIndex ;
}
private void cboFtpText_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . FTPSelectedText = cboFtpText . SelectedIndex ;
}
private void cboFtpFiles_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . FTPSelectedFile = cboFtpFiles . SelectedIndex ;
}
private void btnFtpClient_Click ( object sender , EventArgs e )
{
FTPOpenClient ( ) ;
}
2014-06-07 06:01:02 +12:00
private object eiFTP_ExportRequested ( )
2013-11-03 23:53:49 +13:00
{
2014-06-07 06:01:02 +12:00
return GetSelectedFTPAccount ( ) ;
2013-11-03 23:53:49 +13:00
}
2014-06-07 06:01:02 +12:00
private void eiFTP_ImportRequested ( object obj )
2013-11-03 23:53:49 +13:00
{
2014-06-07 06:01:02 +12:00
AddFTPAccount ( obj as FTPAccount ) ;
2013-11-03 23:53:49 +13:00
}
2014-05-30 23:38:23 +12:00
private void FTPSetup ( IEnumerable < FTPAccount > accs )
{
if ( accs ! = null )
{
int selFtpList = ucFTPAccounts . lbAccounts . SelectedIndex ;
ucFTPAccounts . lbAccounts . Items . Clear ( ) ;
ucFTPAccounts . pgSettings . PropertySort = PropertySort . Categorized ;
cboFtpImages . Items . Clear ( ) ;
cboFtpText . Items . Clear ( ) ;
cboFtpFiles . Items . Clear ( ) ;
Config . FTPAccountList = new List < FTPAccount > ( ) ;
Config . FTPAccountList . AddRange ( accs ) ;
foreach ( FTPAccount acc in Config . FTPAccountList )
{
ucFTPAccounts . lbAccounts . Items . Add ( acc ) ;
cboFtpImages . Items . Add ( acc ) ;
cboFtpText . Items . Add ( acc ) ;
cboFtpFiles . Items . Add ( acc ) ;
}
if ( ucFTPAccounts . lbAccounts . Items . Count > 0 )
{
ucFTPAccounts . lbAccounts . SelectedIndex = selFtpList . Between ( 0 , ucFTPAccounts . lbAccounts . Items . Count - 1 ) ;
cboFtpImages . SelectedIndex = Config . FTPSelectedImage . Between ( 0 , ucFTPAccounts . lbAccounts . Items . Count - 1 ) ;
cboFtpText . SelectedIndex = Config . FTPSelectedText . Between ( 0 , ucFTPAccounts . lbAccounts . Items . Count - 1 ) ;
cboFtpFiles . SelectedIndex = Config . FTPSelectedFile . Between ( 0 , ucFTPAccounts . lbAccounts . Items . Count - 1 ) ;
}
}
}
private void FTPAccountAddButton_Click ( object sender , EventArgs e )
{
2014-06-07 06:01:02 +12:00
AddFTPAccount ( new FTPAccount ( ) ) ;
2014-05-30 23:38:23 +12:00
}
private void FTPAccountRemoveButton_Click ( object sender , EventArgs e )
{
int sel = ucFTPAccounts . lbAccounts . SelectedIndex ;
if ( ucFTPAccounts . RemoveItem ( sel ) )
{
Config . FTPAccountList . RemoveAt ( sel ) ;
}
FTPSetup ( Config . FTPAccountList ) ;
}
private void FTPAccountDuplicateButton_Click ( object sender , EventArgs e )
{
FTPAccount src = ( FTPAccount ) ucFTPAccounts . lbAccounts . Items [ ucFTPAccounts . lbAccounts . SelectedIndex ] ;
FTPAccount clone = ( FTPAccount ) src . Clone ( ) ;
2014-06-07 06:01:02 +12:00
AddFTPAccount ( clone ) ;
2014-05-30 23:38:23 +12:00
}
private void FTPAccountTestButton_Click ( object sender , EventArgs e )
{
2014-06-07 06:01:02 +12:00
TestFTPAccountAsync ( GetSelectedFTPAccount ( ) ) ;
2014-05-30 23:38:23 +12:00
}
private void FtpAccountSettingsGrid_PropertyValueChanged ( object s , PropertyValueChangedEventArgs e )
{
FTPSetup ( Config . FTPAccountList ) ;
}
2013-11-03 23:53:49 +13:00
#endregion FTP
#region Email
private void txtSmtpServer_TextChanged ( object sender , EventArgs e )
{
Config . EmailSmtpServer = txtEmailSmtpServer . Text ;
}
private void nudSmtpPort_ValueChanged ( object sender , EventArgs e )
{
Config . EmailSmtpPort = ( int ) nudEmailSmtpPort . Value ;
}
private void txtEmail_TextChanged ( object sender , EventArgs e )
{
Config . EmailFrom = txtEmailFrom . Text ;
}
private void txtPassword_TextChanged ( object sender , EventArgs e )
{
Config . EmailPassword = txtEmailPassword . Text ;
}
private void chkEmailConfirm_CheckedChanged ( object sender , EventArgs e )
{
Config . EmailConfirmSend = chkEmailConfirm . Checked ;
}
private void cbRememberLastToEmail_CheckedChanged ( object sender , EventArgs e )
{
Config . EmailRememberLastTo = cbEmailRememberLastTo . Checked ;
}
private void txtDefaultSubject_TextChanged ( object sender , EventArgs e )
{
Config . EmailDefaultSubject = txtEmailDefaultSubject . Text ;
}
private void txtDefaultBody_TextChanged ( object sender , EventArgs e )
{
Config . EmailDefaultBody = txtEmailDefaultBody . Text ;
}
#endregion Email
#region RapidShare
private void txtRapidShareUsername_TextChanged ( object sender , EventArgs e )
{
Config . RapidShareUsername = txtRapidShareUsername . Text ;
}
private void txtRapidSharePassword_TextChanged ( object sender , EventArgs e )
{
Config . RapidSharePassword = txtRapidSharePassword . Text ;
}
private void txtRapidShareFolderID_TextChanged ( object sender , EventArgs e )
{
Config . RapidShareFolderID = txtRapidShareFolderID . Text ;
}
private void btnRapidShareRefreshFolders_Click ( object sender , EventArgs e )
{
if ( string . IsNullOrEmpty ( Config . RapidShareUsername ) | | string . IsNullOrEmpty ( Config . RapidSharePassword ) )
{
MessageBox . Show ( "RapidShare account username or password is empty." , "RapidShare refresh folders list failed" , MessageBoxButtons . OK , MessageBoxIcon . Warning ) ;
}
else
{
tvRapidShareFolders . Nodes . Clear ( ) ;
RapidShareFolderInfo root = new RapidShare ( Config . RapidShareUsername , Config . RapidSharePassword ) . GetRootFolderWithChilds ( ) ;
RapidShareRecursiveAddChilds ( tvRapidShareFolders . Nodes , root ) ;
tvRapidShareFolders . ExpandAll ( ) ;
}
}
private void RapidShareRecursiveAddChilds ( TreeNodeCollection treeNodes , RapidShareFolderInfo folderInfo )
{
TreeNode treeNode = treeNodes . Add ( folderInfo . FolderName ) ;
treeNode . Tag = folderInfo ;
foreach ( RapidShareFolderInfo folderInfo2 in folderInfo . ChildFolders )
{
RapidShareRecursiveAddChilds ( treeNode . Nodes , folderInfo2 ) ;
}
}
private void tvRapidShareFolders_AfterSelect ( object sender , TreeViewEventArgs e )
{
if ( e . Node ! = null & & e . Node . Tag is RapidShareFolderInfo )
{
RapidShareFolderInfo folderInfo = ( RapidShareFolderInfo ) e . Node . Tag ;
txtRapidShareFolderID . Text = folderInfo . RealFolderID ;
}
}
#endregion RapidShare
#region SendSpace
private void atcSendSpaceAccountType_AccountTypeChanged ( AccountType accountType )
{
Config . SendSpaceAccountType = accountType ;
}
private void btnSendSpaceRegister_Click ( object sender , EventArgs e )
{
using ( UserPassBox upb = SendSpaceRegister ( ) )
{
if ( upb . Success )
{
txtSendSpaceUserName . Text = upb . UserName ;
txtSendSpacePassword . Text = upb . Password ;
atcSendSpaceAccountType . SelectedAccountType = AccountType . User ;
}
}
}
private void txtSendSpaceUserName_TextChanged ( object sender , EventArgs e )
{
Config . SendSpaceUsername = txtSendSpaceUserName . Text ;
}
private void txtSendSpacePassword_TextChanged ( object sender , EventArgs e )
{
Config . SendSpacePassword = txtSendSpacePassword . Text ;
}
#endregion SendSpace
#region Ge . tt
private void btnGe_ttLogin_Click ( object sender , EventArgs e )
{
Ge_ttLogin ( ) ;
}
#endregion Ge . tt
#region Localhostr
private void txtLocalhostrEmail_TextChanged ( object sender , EventArgs e )
{
Config . LocalhostrEmail = txtLocalhostrEmail . Text ;
}
private void txtLocalhostrPassword_TextChanged ( object sender , EventArgs e )
{
Config . LocalhostrPassword = txtLocalhostrPassword . Text ;
}
private void cbLocalhostrDirectURL_CheckedChanged ( object sender , EventArgs e )
{
Config . LocalhostrDirectURL = cbLocalhostrDirectURL . Checked ;
}
#endregion Localhostr
2013-12-07 08:10:23 +13:00
#region Jira
private void txtJiraHost_TextChanged ( object sender , EventArgs e )
{
Config . JiraHost = txtJiraHost . Text ;
}
private void txtJiraIssuePrefix_TextChanged ( object sender , EventArgs e )
{
Config . JiraIssuePrefix = txtJiraIssuePrefix . Text ;
}
private void oAuthJira_OpenButtonClicked ( )
{
JiraAuthOpen ( ) ;
}
private void oAuthJira_CompleteButtonClicked ( string code )
{
JiraAuthComplete ( code ) ;
}
2014-06-17 01:01:36 +12:00
private void oAuthJira_ClearButtonClicked ( )
{
Config . JiraOAuthInfo = null ;
}
2013-12-07 08:10:23 +13:00
private void oAuthJira_RefreshButtonClicked ( )
{
MessageBox . Show ( "Refresh authorization is not supported." , Application . ProductName , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
}
#endregion Jira
#region Mega
private void MegaConfigureTab ( bool tryLogin )
{
Color OkColor = Color . Green ;
Color NokColor = Color . DarkRed ;
tpMega . Enabled = false ;
if ( Config . MegaAuthInfos ! = null )
{
txtMegaEmail . Text = Config . MegaAuthInfos . Email ;
}
2014-03-26 12:03:52 +13:00
if ( Config . MegaAuthInfos = = null )
2013-12-07 08:10:23 +13:00
{
lblMegaStatus . Text = "Not configured" ;
lblMegaStatus . ForeColor = NokColor ;
}
else
{
cbMegaFolder . Items . Clear ( ) ;
Mega mega = new Mega ( Config . MegaAuthInfos ) ;
if ( ! tryLogin | | mega . TryLogin ( ) )
{
lblMegaStatus . Text = "Configured" ;
lblMegaStatus . ForeColor = OkColor ;
if ( tryLogin )
{
Mega . DisplayNode [ ] nodes = mega . GetDisplayNodes ( ) . ToArray ( ) ;
cbMegaFolder . Items . AddRange ( nodes ) ;
cbMegaFolder . SelectedItem = nodes . FirstOrDefault ( n = > n . Node ! = null & & n . Node . Id = = Config . MegaParentNodeId ) ? ? Mega . DisplayNode . EmptyNode ;
}
else
{
2014-06-09 11:29:40 +12:00
cbMegaFolder . Items . Add ( "[Click refresh button]" ) ;
2013-12-07 08:10:23 +13:00
cbMegaFolder . SelectedIndex = 0 ;
}
}
else
{
lblMegaStatus . Text = "Invalid authentication" ;
lblMegaStatus . ForeColor = NokColor ;
}
}
tpMega . Enabled = true ;
}
private void btnMegaLogin_Click ( object sender , EventArgs e )
{
if ( string . IsNullOrEmpty ( txtMegaEmail . Text ) | | string . IsNullOrEmpty ( txtMegaPassword . Text ) )
{
return ;
}
Config . MegaAuthInfos = MegaApiClient . GenerateAuthInfos ( txtMegaEmail . Text , txtMegaPassword . Text ) ;
MegaConfigureTab ( true ) ;
}
private void cbMegaFolder_SelectedIndexChanged ( object sender , EventArgs e )
{
Mega . DisplayNode selectedNode = ( ( ComboBox ) sender ) . SelectedItem as Mega . DisplayNode ;
if ( selectedNode ! = null )
{
Config . MegaParentNodeId = selectedNode = = Mega . DisplayNode . EmptyNode ? null : selectedNode . Node . Id ;
}
}
private void btnMegaRegister_Click ( object sender , EventArgs e )
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "https://mega.co.nz/#register" ) ;
2013-12-07 08:10:23 +13:00
}
private void btnMegaRefreshFolders_Click ( object sender , EventArgs e )
{
MegaConfigureTab ( true ) ;
}
#endregion Mega
2014-03-27 05:56:05 +13:00
#region Amazon S3
private void txtAmazonS3AccessKey_TextChanged ( object sender , EventArgs e )
{
Config . AmazonS3Settings . AccessKeyID = txtAmazonS3AccessKey . Text ;
}
2014-04-16 07:30:46 +12:00
private void btnAmazonS3AccessKeyOpen_Click ( object sender , EventArgs e )
2014-03-27 05:56:05 +13:00
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "https://console.aws.amazon.com/iam/home?#security_credential" ) ;
2014-03-27 05:56:05 +13:00
}
2014-04-16 07:30:46 +12:00
private void txtAmazonS3SecretKey_TextChanged ( object sender , EventArgs e )
2014-03-27 05:56:05 +13:00
{
2014-04-16 07:30:46 +12:00
Config . AmazonS3Settings . SecretAccessKey = txtAmazonS3SecretKey . Text ;
2014-03-27 05:56:05 +13:00
}
private void cbAmazonS3Endpoint_SelectionChangeCommitted ( object sender , EventArgs e )
{
Config . AmazonS3Settings . Endpoint = cbAmazonS3Endpoint . Text ;
}
private void cbAmazonS3Endpoint_TextChanged ( object sender , EventArgs e )
{
Config . AmazonS3Settings . Endpoint = cbAmazonS3Endpoint . Text ;
2014-05-06 11:24:00 +12:00
UpdateAmazonS3Status ( ) ;
2014-03-27 05:56:05 +13:00
}
private void txtAmazonS3BucketName_TextChanged ( object sender , EventArgs e )
{
Config . AmazonS3Settings . Bucket = txtAmazonS3BucketName . Text ;
2014-05-17 18:38:09 +12:00
UpdateAmazonS3Status ( ) ;
2014-03-27 05:56:05 +13:00
}
2014-04-16 07:30:46 +12:00
private void btnAmazonS3BucketNameOpen_Click ( object sender , EventArgs e )
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( "https://console.aws.amazon.com/s3/home" ) ;
2014-04-16 07:30:46 +12:00
}
private void txtAmazonS3ObjectPrefix_TextChanged ( object sender , EventArgs e )
{
Config . AmazonS3Settings . ObjectPrefix = txtAmazonS3ObjectPrefix . Text ;
2014-05-06 11:24:00 +12:00
UpdateAmazonS3Status ( ) ;
2014-04-16 07:30:46 +12:00
}
2014-05-30 21:09:13 +12:00
private void cbAmazonS3CustomCNAME_CheckedChanged ( object sender , EventArgs e )
2014-03-27 05:56:05 +13:00
{
2014-05-30 21:09:13 +12:00
Config . AmazonS3Settings . UseCustomCNAME = cbAmazonS3CustomCNAME . Checked ;
txtAmazonS3CustomDomain . Enabled = Config . AmazonS3Settings . UseCustomCNAME ;
UpdateAmazonS3Status ( ) ;
2014-03-27 05:56:05 +13:00
}
2014-05-30 21:09:13 +12:00
private void txtAmazonS3CustomDomain_TextChanged ( object sender , EventArgs e )
2014-03-27 05:56:05 +13:00
{
2014-05-30 21:09:13 +12:00
Config . AmazonS3Settings . CustomDomain = txtAmazonS3CustomDomain . Text ;
UpdateAmazonS3Status ( ) ;
}
private void cbAmazonS3UseRRS_CheckedChanged ( object sender , EventArgs e )
{
Config . AmazonS3Settings . UseReducedRedundancyStorage = cbAmazonS3UseRRS . Checked ;
2014-05-06 11:24:00 +12:00
UpdateAmazonS3Status ( ) ;
2014-03-27 05:56:05 +13:00
}
#endregion Amazon S3
2014-03-27 20:05:14 +13:00
#region Pushbullet
private void txtPushbulletUserKey_TextChanged ( object sender , EventArgs e )
{
2014-03-31 00:37:38 +13:00
bool enable = ! string . IsNullOrEmpty ( txtPushbulletUserKey . Text . Trim ( ) ) ;
2014-03-27 20:05:14 +13:00
2014-03-31 00:37:38 +13:00
cboPushbulletDevices . Enabled = enable ;
btnPushbulletGetDeviceList . Enabled = enable ;
2014-03-27 20:05:14 +13:00
Config . PushbulletSettings . UserAPIKey = txtPushbulletUserKey . Text ;
}
private void cboPushbulletDevices_SelectedIndexChanged ( object sender , EventArgs e )
{
2014-03-31 00:37:38 +13:00
Config . PushbulletSettings . SelectedDevice = cboPushbulletDevices . SelectedIndex ;
2014-03-27 20:05:14 +13:00
}
private void btnPushbulletGetDeviceList_Click ( object sender , EventArgs e )
{
PushbulletGetDevices ( ) ;
}
#endregion Pushbullet
2014-05-30 23:38:23 +12:00
#region Shared folder
private void LocalhostAccountsSetup ( IEnumerable < LocalhostAccount > accs )
{
if ( accs ! = null )
{
int sel = ucLocalhostAccounts . lbAccounts . SelectedIndex ;
ucLocalhostAccounts . lbAccounts . Items . Clear ( ) ;
Config . LocalhostAccountList = new List < LocalhostAccount > ( ) ;
Config . LocalhostAccountList . AddRange ( accs ) ;
cboSharedFolderFiles . Items . Clear ( ) ;
cboSharedFolderImages . Items . Clear ( ) ;
cboSharedFolderText . Items . Clear ( ) ;
foreach ( LocalhostAccount acc in Config . LocalhostAccountList )
{
ucLocalhostAccounts . lbAccounts . Items . Add ( acc ) ;
cboSharedFolderFiles . Items . Add ( acc ) ;
cboSharedFolderImages . Items . Add ( acc ) ;
cboSharedFolderText . Items . Add ( acc ) ;
}
if ( ucLocalhostAccounts . lbAccounts . Items . Count > 0 )
{
ucLocalhostAccounts . lbAccounts . SelectedIndex = sel . Between ( 0 , ucLocalhostAccounts . lbAccounts . Items . Count - 1 ) ;
cboSharedFolderFiles . SelectedIndex = Config . LocalhostSelectedFiles . Between ( 0 , ucLocalhostAccounts . lbAccounts . Items . Count - 1 ) ;
cboSharedFolderImages . SelectedIndex = Config . LocalhostSelectedImages . Between ( 0 , ucLocalhostAccounts . lbAccounts . Items . Count - 1 ) ;
cboSharedFolderText . SelectedIndex = Config . LocalhostSelectedText . Between ( 0 , ucLocalhostAccounts . lbAccounts . Items . Count - 1 ) ;
}
}
}
private void LocalhostAccountAddButton_Click ( object sender , EventArgs e )
{
LocalhostAccount acc = new LocalhostAccount ( ) ;
Config . LocalhostAccountList . Add ( acc ) ;
ucLocalhostAccounts . AddItem ( acc ) ;
}
private void LocalhostAccountRemoveButton_Click ( object sender , EventArgs e )
{
int sel = ucLocalhostAccounts . lbAccounts . SelectedIndex ;
if ( ucLocalhostAccounts . RemoveItem ( sel ) )
{
Config . LocalhostAccountList . RemoveAt ( sel ) ;
}
}
private void LocalhostAccountDuplicateButton_Click ( object sender , EventArgs e )
{
LocalhostAccount src = ( LocalhostAccount ) ucLocalhostAccounts . lbAccounts . Items [ ucLocalhostAccounts . lbAccounts . SelectedIndex ] ;
LocalhostAccount clone = ( LocalhostAccount ) src . Clone ( ) ;
Config . LocalhostAccountList . Add ( clone ) ;
ucLocalhostAccounts . AddItem ( clone ) ;
}
private void SettingsGrid_LocalhostPropertyValueChanged ( object s , PropertyValueChangedEventArgs e )
{
LocalhostAccountsSetup ( Config . LocalhostAccountList ) ;
}
#endregion Shared folder
2014-03-30 23:28:34 +13:00
#endregion File Uploaders
2013-12-07 08:10:23 +13:00
#region URL Shorteners
2014-06-17 01:01:36 +12:00
#region bit . ly
private void oauth2Bitly_OpenButtonClicked ( )
{
BitlyAuthOpen ( ) ;
}
private void oauth2Bitly_CompleteButtonClicked ( string code )
{
BitlyAuthComplete ( code ) ;
}
private void oauth2Bitly_ClearButtonClicked ( )
{
Config . BitlyOAuth2Info = null ;
}
2014-06-18 08:10:31 +12:00
private void txtBitlyDomain_TextChanged ( object sender , EventArgs e )
{
Config . BitlyDomain = txtBitlyDomain . Text ;
}
2014-06-17 01:01:36 +12:00
#endregion bit . ly
2013-12-21 04:59:26 +13:00
#region Google URL Shortener
2013-12-07 08:10:23 +13:00
private void atcGoogleURLShortenerAccountType_AccountTypeChanged ( AccountType accountType )
{
Config . GoogleURLShortenerAccountType = accountType ;
}
private void oauth2GoogleURLShortener_OpenButtonClicked ( )
{
GoogleURLShortenerAuthOpen ( ) ;
}
private void oauth2GoogleURLShortener_CompleteButtonClicked ( string code )
{
GoogleURLShortenerAuthComplete ( code ) ;
}
private void oauth2GoogleURLShortener_RefreshButtonClicked ( )
{
GoogleURLShortenerAuthRefresh ( ) ;
}
2014-06-17 01:01:36 +12:00
private void oauth2GoogleURLShortener_ClearButtonClicked ( )
2013-12-21 04:59:26 +13:00
{
2014-06-17 01:01:36 +12:00
Config . GoogleURLShortenerOAuth2Info = null ;
2013-12-21 04:59:26 +13:00
}
2014-06-17 01:01:36 +12:00
#endregion Google URL Shortener
2013-12-21 04:59:26 +13:00
2014-01-20 14:04:03 +13:00
#region yourls . org
private void txtYourlsAPIURL_TextChanged ( object sender , EventArgs e )
{
Config . YourlsAPIURL = txtYourlsAPIURL . Text ;
}
private void txtYourlsSignature_TextChanged ( object sender , EventArgs e )
{
2014-01-20 15:49:14 +13:00
Config . YourlsSignature = txtYourlsSignature . Text . Trim ( ) ;
2014-01-20 14:04:03 +13:00
txtYourlsUsername . Enabled = txtYourlsPassword . Enabled = string . IsNullOrEmpty ( Config . YourlsSignature ) ;
}
private void txtYourlsUsername_TextChanged ( object sender , EventArgs e )
{
Config . YourlsUsername = txtYourlsUsername . Text ;
}
private void txtYourlsPassword_TextChanged ( object sender , EventArgs e )
{
Config . YourlsPassword = txtYourlsPassword . Text ;
}
#endregion yourls . org
2013-12-07 08:10:23 +13:00
#endregion URL Shorteners
#region Other Services
2014-05-30 23:38:23 +12:00
private void TwitterAccountAddButton_Click ( object sender , EventArgs e )
{
OAuthInfo acc = new OAuthInfo ( ) ;
Config . TwitterOAuthInfoList . Add ( acc ) ;
ucTwitterAccounts . AddItem ( acc ) ;
}
private void TwitterAccountRemoveButton_Click ( object sender , EventArgs e )
{
int sel = ucTwitterAccounts . lbAccounts . SelectedIndex ;
if ( ucTwitterAccounts . RemoveItem ( sel ) )
{
Config . TwitterOAuthInfoList . RemoveAt ( sel ) ;
}
}
private void TwitterAccountDuplicateButton_Click ( object sender , EventArgs e )
{
OAuthInfo src = ( OAuthInfo ) ucTwitterAccounts . lbAccounts . Items [ ucTwitterAccounts . lbAccounts . SelectedIndex ] ;
OAuthInfo clone = ( OAuthInfo ) src . Clone ( ) ;
Config . TwitterOAuthInfoList . Add ( clone ) ;
ucTwitterAccounts . AddItem ( clone ) ;
}
private void TwitterAccountAuthButton_Click ( object sender , EventArgs e )
{
TwitterAuthOpen ( ) ;
}
2013-12-07 08:10:23 +13:00
private void btnTwitterLogin_Click ( object sender , EventArgs e )
{
2014-05-30 23:38:23 +12:00
TwitterAuthComplete ( ) ;
}
private void TwitterAccountSelectedIndexChanged ( object sender , EventArgs e )
{
if ( ucTwitterAccounts . lbAccounts . SelectedIndex > - 1 )
{
Config . TwitterSelectedAccount = ucTwitterAccounts . lbAccounts . SelectedIndex ;
}
2013-12-07 08:10:23 +13:00
}
private void cboSharedFolderImages_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . LocalhostSelectedImages = cboSharedFolderImages . SelectedIndex ;
}
private void cboSharedFolderText_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . LocalhostSelectedText = cboSharedFolderText . SelectedIndex ;
}
private void cboSharedFolderFiles_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . LocalhostSelectedFiles = cboSharedFolderFiles . SelectedIndex ;
}
#endregion Other Services
#region Custom Uploaders
2013-11-03 23:53:49 +13:00
private void btnCustomUploaderAdd_Click ( object sender , EventArgs e )
{
if ( ! string . IsNullOrEmpty ( txtCustomUploaderName . Text ) )
{
CustomUploaderItem item = GetCustomUploaderFromFields ( ) ;
Config . CustomUploadersList . Add ( item ) ;
lbCustomUploaderList . Items . Add ( item . Name ) ;
lbCustomUploaderList . SelectedIndex = lbCustomUploaderList . Items . Count - 1 ;
PrepareCustomUploaderList ( ) ;
}
}
private void btnCustomUploaderRemove_Click ( object sender , EventArgs e )
{
if ( lbCustomUploaderList . SelectedIndex > - 1 )
{
int index = lbCustomUploaderList . SelectedIndex ;
Config . CustomUploadersList . RemoveAt ( index ) ;
lbCustomUploaderList . Items . RemoveAt ( index ) ;
CustomUploaderClear ( ) ;
FixSelectedUploader ( index ) ;
PrepareCustomUploaderList ( ) ;
}
}
private void FixSelectedUploader ( int removedIndex )
{
if ( Config . CustomImageUploaderSelected = = removedIndex ) Config . CustomImageUploaderSelected = 0 ;
else if ( Config . CustomImageUploaderSelected > removedIndex ) Config . CustomImageUploaderSelected - - ;
if ( Config . CustomTextUploaderSelected = = removedIndex ) Config . CustomTextUploaderSelected = 0 ;
else if ( Config . CustomTextUploaderSelected > removedIndex ) Config . CustomTextUploaderSelected - - ;
if ( Config . CustomFileUploaderSelected = = removedIndex ) Config . CustomFileUploaderSelected = 0 ;
else if ( Config . CustomFileUploaderSelected > removedIndex ) Config . CustomFileUploaderSelected - - ;
if ( Config . CustomURLShortenerSelected = = removedIndex ) Config . CustomURLShortenerSelected = 0 ;
else if ( Config . CustomURLShortenerSelected > removedIndex ) Config . CustomURLShortenerSelected - - ;
}
private void btnCustomUploaderUpdate_Click ( object sender , EventArgs e )
{
UpdateCustomUploader ( ) ;
}
private void lbCustomUploaderList_SelectedIndexChanged ( object sender , EventArgs e )
{
int index = lbCustomUploaderList . SelectedIndex ;
if ( index > - 1 )
{
LoadCustomUploader ( Config . CustomUploadersList [ index ] ) ;
}
}
2014-06-07 05:21:03 +12:00
private object eiCustomUploaders_ExportRequested ( )
2013-12-03 01:08:09 +13:00
{
2014-06-07 05:21:03 +12:00
return GetSelectedCustomUploader ( ) ;
2013-12-03 01:08:09 +13:00
}
2014-06-07 05:21:03 +12:00
private void eiCustomUploaders_ImportRequested ( object obj )
2013-12-03 01:08:09 +13:00
{
2014-06-07 05:21:03 +12:00
AddCustomUploader ( obj as CustomUploaderItem ) ;
2013-12-03 01:08:09 +13:00
}
2013-11-03 23:53:49 +13:00
private void cbCustomUploaderRequestType_SelectedIndexChanged ( object sender , EventArgs e )
{
txtCustomUploaderFileForm . Enabled = ( CustomUploaderRequestType ) cbCustomUploaderRequestType . SelectedIndex = = CustomUploaderRequestType . POST ;
}
private void btnCustomUploaderRegexpAdd_Click ( object sender , EventArgs e )
{
string regexp = txtCustomUploaderRegexp . Text ;
if ( ! string . IsNullOrEmpty ( regexp ) )
{
lvCustomUploaderRegexps . Items . Add ( regexp ) ;
txtCustomUploaderRegexp . Text = string . Empty ;
txtCustomUploaderRegexp . Focus ( ) ;
}
}
private void btnCustomUploaderRegexpRemove_Click ( object sender , EventArgs e )
{
if ( lvCustomUploaderRegexps . SelectedItems . Count > 0 )
{
lvCustomUploaderRegexps . SelectedItems [ 0 ] . Remove ( ) ;
}
}
private void btnCustomUploaderRegexpEdit_Click ( object sender , EventArgs e )
{
string regexp = txtCustomUploaderRegexp . Text ;
if ( lvCustomUploaderRegexps . SelectedItems . Count > 0 & & ! string . IsNullOrEmpty ( regexp ) )
{
lvCustomUploaderRegexps . SelectedItems [ 0 ] . Text = regexp ;
}
}
private void lvCustomUploaderRegexps_SelectedIndexChanged ( object sender , EventArgs e )
{
string regex = string . Empty ;
if ( lvCustomUploaderRegexps . SelectedItems . Count > 0 )
{
regex = lvCustomUploaderRegexps . SelectedItems [ 0 ] . Text ;
}
txtCustomUploaderRegexp . Text = regex ;
}
private void btnCustomUploaderArgAdd_Click ( object sender , EventArgs e )
{
string name = txtCustomUploaderArgName . Text ;
string value = txtCustomUploaderArgValue . Text ;
if ( ! string . IsNullOrEmpty ( name ) )
{
lvCustomUploaderArguments . Items . Add ( name ) . SubItems . Add ( value ) ;
txtCustomUploaderArgName . Text = string . Empty ;
txtCustomUploaderArgValue . Text = string . Empty ;
txtCustomUploaderArgName . Focus ( ) ;
}
}
private void btnCustomUploaderArgRemove_Click ( object sender , EventArgs e )
{
if ( lvCustomUploaderArguments . SelectedItems . Count > 0 )
{
lvCustomUploaderArguments . SelectedItems [ 0 ] . Remove ( ) ;
}
}
private void btnCustomUploaderArgEdit_Click ( object sender , EventArgs e )
{
string name = txtCustomUploaderArgName . Text ;
string value = txtCustomUploaderArgValue . Text ;
if ( lvCustomUploaderArguments . SelectedItems . Count > 0 & & ! string . IsNullOrEmpty ( name ) )
{
lvCustomUploaderArguments . SelectedItems [ 0 ] . Text = name ;
lvCustomUploaderArguments . SelectedItems [ 0 ] . SubItems [ 1 ] . Text = value ;
}
}
private void lvCustomUploaderArguments_SelectedIndexChanged ( object sender , EventArgs e )
{
string name = string . Empty ;
string value = string . Empty ;
if ( lvCustomUploaderArguments . SelectedItems . Count > 0 )
{
name = lvCustomUploaderArguments . SelectedItems [ 0 ] . Text ;
value = lvCustomUploaderArguments . SelectedItems [ 0 ] . SubItems [ 1 ] . Text ;
}
txtCustomUploaderArgName . Text = name ;
txtCustomUploaderArgValue . Text = value ;
}
private void btnCustomUploaderClear_Click ( object sender , EventArgs e )
{
CustomUploaderClear ( ) ;
}
private void cbCustomUploaderImageUploader_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . CustomImageUploaderSelected = cbCustomUploaderImageUploader . SelectedIndex ;
}
private void cbCustomUploaderTextUploader_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . CustomTextUploaderSelected = cbCustomUploaderTextUploader . SelectedIndex ;
}
private void cbCustomUploaderFileUploader_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . CustomFileUploaderSelected = cbCustomUploaderFileUploader . SelectedIndex ;
}
private void cbCustomUploaderURLShortener_SelectedIndexChanged ( object sender , EventArgs e )
{
Config . CustomURLShortenerSelected = cbCustomUploaderURLShortener . SelectedIndex ;
}
private void btnCustomUploaderImageUploaderTest_Click ( object sender , EventArgs e )
{
UpdateCustomUploader ( ) ;
2013-11-25 08:53:52 +13:00
if ( Config . CustomUploadersList . IsValidIndex ( Config . CustomImageUploaderSelected ) )
2013-11-03 23:53:49 +13:00
{
btnCustomUploaderImageUploaderTest . Enabled = btnCustomUploaderTextUploaderTest . Enabled =
btnCustomUploaderFileUploaderTest . Enabled = btnCustomUploaderURLShortenerTest . Enabled = false ;
TestCustomUploader ( CustomUploaderType . Image , Config . CustomUploadersList [ Config . CustomImageUploaderSelected ] ) ;
}
}
private void btnCustomUploaderTextUploaderTest_Click ( object sender , EventArgs e )
{
UpdateCustomUploader ( ) ;
2013-11-25 08:53:52 +13:00
if ( Config . CustomUploadersList . IsValidIndex ( Config . CustomTextUploaderSelected ) )
2013-11-03 23:53:49 +13:00
{
btnCustomUploaderImageUploaderTest . Enabled = btnCustomUploaderTextUploaderTest . Enabled =
btnCustomUploaderFileUploaderTest . Enabled = btnCustomUploaderURLShortenerTest . Enabled = false ;
TestCustomUploader ( CustomUploaderType . Text , Config . CustomUploadersList [ Config . CustomTextUploaderSelected ] ) ;
}
}
private void btnCustomUploaderFileUploaderTest_Click ( object sender , EventArgs e )
{
UpdateCustomUploader ( ) ;
2013-11-25 08:53:52 +13:00
if ( Config . CustomUploadersList . IsValidIndex ( Config . CustomFileUploaderSelected ) )
2013-11-03 23:53:49 +13:00
{
btnCustomUploaderImageUploaderTest . Enabled = btnCustomUploaderTextUploaderTest . Enabled =
btnCustomUploaderFileUploaderTest . Enabled = btnCustomUploaderURLShortenerTest . Enabled = false ;
TestCustomUploader ( CustomUploaderType . File , Config . CustomUploadersList [ Config . CustomFileUploaderSelected ] ) ;
}
}
private void btnCustomUploaderURLShortenerTest_Click ( object sender , EventArgs e )
{
UpdateCustomUploader ( ) ;
2013-11-25 08:53:52 +13:00
if ( Config . CustomUploadersList . IsValidIndex ( Config . CustomURLShortenerSelected ) )
2013-11-03 23:53:49 +13:00
{
btnCustomUploaderImageUploaderTest . Enabled = btnCustomUploaderTextUploaderTest . Enabled =
btnCustomUploaderFileUploaderTest . Enabled = btnCustomUploaderURLShortenerTest . Enabled = false ;
TestCustomUploader ( CustomUploaderType . URL , Config . CustomUploadersList [ Config . CustomURLShortenerSelected ] ) ;
}
}
2013-12-07 08:10:23 +13:00
private void btnCustomUploaderHelp_Click ( object sender , EventArgs e )
{
2014-07-03 06:19:51 +12:00
URLHelpers . OpenURL ( "https://github.com/ShareX/ShareX/wiki/Custom-Uploader" ) ;
}
private void btnCustomUploaderExamples_Click ( object sender , EventArgs e )
{
URLHelpers . OpenURL ( "https://github.com/ShareX/ShareX/wiki/Custom-Uploader-examples" ) ;
2013-12-07 08:10:23 +13:00
}
2013-11-03 23:53:49 +13:00
private void btnCustomUploaderShowLastResponse_Click ( object sender , EventArgs e )
{
string response = btnCustomUploaderShowLastResponse . Tag as string ;
if ( ! string . IsNullOrEmpty ( response ) )
{
using ( ResponseForm form = new ResponseForm ( response ) )
{
form . ShowDialog ( ) ;
}
}
}
private void txtCustomUploaderLog_LinkClicked ( object sender , LinkClickedEventArgs e )
{
2014-06-28 12:22:56 +12:00
URLHelpers . OpenURL ( e . LinkText ) ;
2013-11-03 23:53:49 +13:00
}
2013-12-07 08:10:23 +13:00
#endregion Custom Uploaders
2013-11-03 23:53:49 +13:00
}
}