#region License Information (GPL v3) /* ShareX - A program that allows you to take screenshots and share any file type Copyright (C) 2008-2014 ShareX Developers This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License 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 . */ #endregion License Information (GPL v3) using HelpersLib; using System; using System.Collections.Generic; using System.Windows.Forms; using UploadersLib.FileUploaders; using UploadersLib.HelperClasses; using UploadersLib.ImageUploaders; using UploadersLib.Properties; using UploadersLib.SocialServices; namespace UploadersLib { public partial class UploadersConfigForm : Form { private ContextMenuStrip cmsCustomUploaderArgValue; private void ControlSettings() { ImageList imageUploadersImageList = new ImageList(); imageUploadersImageList.ColorDepth = ColorDepth.Depth32Bit; imageUploadersImageList.Images.Add("ImageShack", Resources.ImageShack); imageUploadersImageList.Images.Add("TinyPic", Resources.TinyPic); imageUploadersImageList.Images.Add("Imgur", Resources.Imgur); imageUploadersImageList.Images.Add("Flickr", Resources.Flickr); imageUploadersImageList.Images.Add("Photobucket", Resources.Photobucket); imageUploadersImageList.Images.Add("Picasa", Resources.Picasa); imageUploadersImageList.Images.Add("TwitPic", Resources.TwitPic); imageUploadersImageList.Images.Add("TwitSnaps", Resources.TwitSnaps); imageUploadersImageList.Images.Add("YFrog", Resources.YFrog); tcImageUploaders.ImageList = imageUploadersImageList; ImageList fileUploadersImageList = new ImageList(); fileUploadersImageList.ColorDepth = ColorDepth.Depth32Bit; fileUploadersImageList.Images.Add("Dropbox", Resources.Dropbox); fileUploadersImageList.Images.Add("GoogleDrive", Resources.GoogleDrive); fileUploadersImageList.Images.Add("Box", Resources.Box); fileUploadersImageList.Images.Add("Minus", Resources.Minus); fileUploadersImageList.Images.Add("FTP", Resources.folder_network); fileUploadersImageList.Images.Add("RapidShare", Resources.RapidShare); fileUploadersImageList.Images.Add("SendSpace", Resources.SendSpace); fileUploadersImageList.Images.Add("Gett", Resources.Gett); fileUploadersImageList.Images.Add("Localhostr", Resources.Localhostr); fileUploadersImageList.Images.Add("CustomUploader", Resources.globe_network); fileUploadersImageList.Images.Add("SharedFolders", Resources.server_network); fileUploadersImageList.Images.Add("Email", Resources.mail); fileUploadersImageList.Images.Add("Jira", Resources.jira); fileUploadersImageList.Images.Add("Mega", Resources.Mega); fileUploadersImageList.Images.Add("AmazonS3", Resources.AmazonS3); fileUploadersImageList.Images.Add("Pushbullet", Resources.Pushbullet); tcFileUploaders.ImageList = fileUploadersImageList; ImageList textUploadersImageList = new ImageList(); textUploadersImageList.ColorDepth = ColorDepth.Depth32Bit; textUploadersImageList.Images.Add("Pastebin", Resources.Pastebin); textUploadersImageList.Images.Add("Gist", Resources.Gist); textUploadersImageList.Images.Add("Upaste", Resources.Upaste); tcTextUploaders.ImageList = textUploadersImageList; ImageList urlShortenersImageList = new ImageList(); urlShortenersImageList.ColorDepth = ColorDepth.Depth32Bit; urlShortenersImageList.Images.Add("Google", Resources.Google); urlShortenersImageList.Images.Add("Bitly", Resources.Bitly); urlShortenersImageList.Images.Add("Yourls", Resources.Yourls); tcURLShorteners.ImageList = urlShortenersImageList; ImageList socialNetworkingServicesImageList = new ImageList(); socialNetworkingServicesImageList.ColorDepth = ColorDepth.Depth32Bit; socialNetworkingServicesImageList.Images.Add("Twitter", Resources.Twitter); tcSocialNetworkingServices.ImageList = socialNetworkingServicesImageList; tpImageShack.ImageKey = "ImageShack"; tpTinyPic.ImageKey = "TinyPic"; tpImgur.ImageKey = "Imgur"; tpFlickr.ImageKey = "Flickr"; tpPhotobucket.ImageKey = "Photobucket"; tpPicasa.ImageKey = "Picasa"; tpTwitPic.ImageKey = "TwitPic"; tpTwitSnaps.ImageKey = "TwitSnaps"; tpYFrog.ImageKey = "YFrog"; tpDropbox.ImageKey = "Dropbox"; 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"; tpHostr.ImageKey = "Localhostr"; tpCustomUploaders.ImageKey = "CustomUploader"; tpPastebin.ImageKey = "Pastebin"; 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"; cmsCustomUploaderArgValue = NameParser.CreateCodesMenu(txtCustomUploaderArgValue, ReplacementVariables.n); txtCustomUploaderLog.AddContextMenu(); } public void LoadSettings(UploadersConfig uploadersConfig) { #region Image uploaders // ImageShack atcImageShackAccountType.SelectedAccountType = Config.ImageShackSettings.AccountType; 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; // Imgur atcImgurAccountType.SelectedAccountType = Config.ImgurAccountType; cbImgurThumbnailType.Items.Clear(); cbImgurThumbnailType.Items.AddRange(Helpers.GetEnumDescriptions()); cbImgurThumbnailType.SelectedIndex = (int)Config.ImgurThumbnailType; txtImgurAlbumID.Text = Config.ImgurAlbumID; if (OAuth2Info.CheckOAuth(Config.ImgurOAuth2Info)) { oauth2Imgur.Status = "Login successful."; oauth2Imgur.LoginStatus = true; btnImgurRefreshAlbumList.Enabled = true; } // Photobucket if (OAuthInfo.CheckOAuth(Config.PhotobucketOAuthInfo)) { lblPhotobucketAccountStatus.Text = "Login successful: " + Config.PhotobucketOAuthInfo.UserToken; 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)) { oauth2Picasa.Status = "Login successful."; oauth2Picasa.LoginStatus = true; btnPicasaRefreshAlbumList.Enabled = true; } txtPicasaAlbumID.Text = Config.PicasaAlbumID; // Flickr pgFlickrAuthInfo.SelectedObject = Config.FlickrAuthInfo; pgFlickrSettings.SelectedObject = Config.FlickrSettings; // TwitPic chkTwitPicShowFull.Checked = Config.TwitPicShowFull; cboTwitPicThumbnailMode.Items.Clear(); cboTwitPicThumbnailMode.Items.AddRange(Helpers.GetEnumDescriptions()); cboTwitPicThumbnailMode.SelectedIndex = (int)Config.TwitPicThumbnailMode; // YFrog txtYFrogUsername.Text = Config.YFrogUsername; txtYFrogPassword.Text = Config.YFrogPassword; #endregion Image uploaders #region Text uploaders // Pastebin pgPastebinSettings.SelectedObject = Config.PastebinSettings; // Paste.ee txtPaste_eeUserAPIKey.Text = Config.Paste_eeUserAPIKey; //Pushbullet txtPushbulletUserKey.Text = Config.PushbulletSettings.UserAPIKey; if (Config.PushbulletSettings.DeviceList.Count > 0) { Config.PushbulletSettings.DeviceList.ForEach(x => cboPushbulletDevices.Items.Add(x.Name)); if (Config.PushbulletSettings.DeviceList.IsValidIndex(Config.PushbulletSettings.SelectedDevice)) { cboPushbulletDevices.SelectedIndex = Config.PushbulletSettings.SelectedDevice; } else { cboPushbulletDevices.SelectedIndex = 0; } } // Gist atcGistAccountType.SelectedAccountType = Config.GistAnonymousLogin ? AccountType.Anonymous : AccountType.User; chkGistPublishPublic.Checked = Config.GistPublishPublic; if (OAuth2Info.CheckOAuth(Config.GistOAuth2Info)) { oAuth2Gist.Status = "Login successful."; oAuth2Gist.LoginStatus = true; } // Upaste txtUpasteUserKey.Text = Config.UpasteUserKey; cbUpasteIsPublic.Checked = Config.UpasteIsPublic; #endregion Text uploaders #region File uploaders // Dropbox txtDropboxPath.Text = Config.DropboxUploadPath; cbDropboxAutoCreateShareableLink.Checked = Config.DropboxAutoCreateShareableLink; cbDropboxURLType.Enabled = Config.DropboxAutoCreateShareableLink; cbDropboxURLType.Items.AddRange(Helpers.GetEnumNamesProper()); cbDropboxURLType.SelectedIndex = (int)Config.DropboxURLType; UpdateDropboxStatus(); // Google Drive if (OAuth2Info.CheckOAuth(Config.GoogleDriveOAuth2Info)) { oauth2GoogleDrive.Status = "Login successful."; oauth2GoogleDrive.LoginStatus = true; } cbGoogleDriveIsPublic.Checked = Config.GoogleDriveIsPublic; // Minus cbMinusURLType.Items.Clear(); cbMinusURLType.Items.AddRange(Enum.GetNames(typeof(MinusLinkType))); MinusUpdateControls(); // Box if (OAuth2Info.CheckOAuth(Config.BoxOAuth2Info)) { oauth2Box.Status = "Login successful."; oauth2Box.LoginStatus = true; btnBoxRefreshFolders.Enabled = true; } cbBoxShare.Checked = Config.BoxShare; lblBoxFolderID.Text = "Selected folder: " + Config.BoxSelectedFolder.name; // Ge.tt lblGe_ttAccessToken.Text = "Access token:"; if (Config.Ge_ttLogin != null && !string.IsNullOrEmpty(Config.Ge_ttLogin.AccessToken)) { lblGe_ttAccessToken.Text += " " + Config.Ge_ttLogin.AccessToken; } // 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()); } else { FTPSetup(Config.FTPAccountList); if (ucFTPAccounts.AccountsList.Items.Count > 0) { ucFTPAccounts.AccountsList.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()); } else { LocalhostAccountsSetup(Config.LocalhostAccountList); if (ucLocalhostAccounts.AccountsList.Items.Count > 0) { ucLocalhostAccounts.AccountsList.SelectedIndex = 0; cboSharedFolderImages.SelectedIndex = Config.LocalhostSelectedImages.Between(0, ucLocalhostAccounts.AccountsList.Items.Count - 1); cboSharedFolderText.SelectedIndex = Config.LocalhostSelectedText.Between(0, ucLocalhostAccounts.AccountsList.Items.Count - 1); cboSharedFolderFiles.SelectedIndex = Config.LocalhostSelectedFiles.Between(0, ucLocalhostAccounts.AccountsList.Items.Count - 1); } } // Custom uploaders lbCustomUploaderList.Items.Clear(); if (Config.CustomUploadersList == null) { Config.CustomUploadersList = new List(); } 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()); 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)) { oAuthJira.Status = "Login successful."; oAuthJira.LoginStatus = true; } // Mega MegaConfigureTab(false); // Amazon S3 txtAmazonS3AccessKey.Text = Config.AmazonS3Settings.AccessKeyID; txtAmazonS3SecretKey.Text = Config.AmazonS3Settings.SecretAccessKey; cbAmazonS3UseRRS.Checked = Config.AmazonS3Settings.UseReducedRedundancyStorage; cbAmazonS3Endpoint.Text = Config.AmazonS3Settings.Endpoint; cbAmazonS3CustomCNAME.Checked = Config.AmazonS3Settings.UseCustomCNAME; txtAmazonS3BucketName.Text = Config.AmazonS3Settings.Bucket; txtAmazonS3ObjectPrefix.Text = Config.AmazonS3Settings.ObjectPrefix; #endregion File uploaders #region URL Shorteners // Google URL Shortener atcGoogleURLShortenerAccountType.SelectedAccountType = Config.GoogleURLShortenerAccountType; if (OAuth2Info.CheckOAuth(Config.GoogleURLShortenerOAuth2Info)) { oauth2GoogleURLShortener.Status = "Login successful."; oauth2GoogleURLShortener.LoginStatus = true; } // bit.ly if (OAuth2Info.CheckOAuth(Config.BitlyOAuth2Info)) { oauth2Bitly.Status = "Login successful."; oauth2Bitly.LoginStatus = true; } // 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.AccountsList.Items.Clear(); foreach (OAuthInfo acc in Config.TwitterOAuthInfoList) { ucTwitterAccounts.AccountsList.Items.Add(acc); } if (ucTwitterAccounts.AccountsList.Items.Count > 0) { ucTwitterAccounts.AccountsList.SelectedIndex = Config.TwitterSelectedAccount; } #endregion Other Services } private void CreateUserControlEvents() { // FTP ucFTPAccounts.btnAdd.Click += FTPAccountAddButton_Click; ucFTPAccounts.btnRemove.Click += FTPAccountRemoveButton_Click; ucFTPAccounts.btnTest.Click += FTPAccountTestButton_Click; ucFTPAccounts.btnClone.Visible = true; ucFTPAccounts.btnClone.Click += FTPAccountCloneButton_Click; ucFTPAccounts.AccountsList.SelectedIndexChanged += FTPAccountsList_SelectedIndexChanged; ucFTPAccounts.SettingsGrid.PropertyValueChanged += FtpAccountSettingsGrid_PropertyValueChanged; // Localhost ucLocalhostAccounts.btnAdd.Click += LocalhostAccountAddButton_Click; ucLocalhostAccounts.btnRemove.Click += LocalhostAccountRemoveButton_Click; ucLocalhostAccounts.btnTest.Visible = false; ucLocalhostAccounts.AccountsList.SelectedIndexChanged += LocalhostAccountsList_SelectedIndexChanged; ucLocalhostAccounts.SettingsGrid.PropertyValueChanged += SettingsGrid_LocalhostPropertyValueChanged; // Twitter ucTwitterAccounts.btnAdd.Text = "Add"; ucTwitterAccounts.btnAdd.Click += TwitterAccountAddButton_Click; ucTwitterAccounts.btnRemove.Click += TwitterAccountRemoveButton_Click; ucTwitterAccounts.btnTest.Text = "Authorize"; ucTwitterAccounts.btnTest.Click += TwitterAccountAuthButton_Click; ucTwitterAccounts.SettingsGrid.PropertySort = PropertySort.NoSort; ucTwitterAccounts.AccountsList.SelectedIndexChanged += TwitterAccountList_SelectedIndexChanged; } #region Localhost private void LocalhostAccountAddButton_Click(object sender, EventArgs e) { LocalhostAccount acc = new LocalhostAccount("New Account"); Config.LocalhostAccountList.Add(acc); ucLocalhostAccounts.AccountsList.Items.Add(acc); ucLocalhostAccounts.AccountsList.SelectedIndex = ucLocalhostAccounts.AccountsList.Items.Count - 1; } private void LocalhostAccountRemoveButton_Click(object sender, EventArgs e) { int sel = ucLocalhostAccounts.AccountsList.SelectedIndex; if (ucLocalhostAccounts.RemoveItem(sel)) { Config.LocalhostAccountList.RemoveAt(sel); } } private void LocalhostAccountsList_SelectedIndexChanged(object sender, EventArgs e) { int sel = ucLocalhostAccounts.AccountsList.SelectedIndex; if (Config.LocalhostAccountList.IsValidIndex(sel)) { LocalhostAccount acc = Config.LocalhostAccountList[sel]; ucLocalhostAccounts.SettingsGrid.SelectedObject = acc; } } private void SettingsGrid_LocalhostPropertyValueChanged(object s, PropertyValueChangedEventArgs e) { LocalhostAccountsSetup(Config.LocalhostAccountList); } private void LocalhostAccountsSetup(IEnumerable accs) { if (accs != null) { int sel = ucLocalhostAccounts.AccountsList.SelectedIndex; ucLocalhostAccounts.AccountsList.Items.Clear(); Config.LocalhostAccountList = new List(); Config.LocalhostAccountList.AddRange(accs); cboSharedFolderFiles.Items.Clear(); cboSharedFolderImages.Items.Clear(); cboSharedFolderText.Items.Clear(); foreach (LocalhostAccount acc in Config.LocalhostAccountList) { ucLocalhostAccounts.AccountsList.Items.Add(acc); cboSharedFolderFiles.Items.Add(acc); cboSharedFolderImages.Items.Add(acc); cboSharedFolderText.Items.Add(acc); } if (ucLocalhostAccounts.AccountsList.Items.Count > 0) { ucLocalhostAccounts.AccountsList.SelectedIndex = sel.Between(0, ucLocalhostAccounts.AccountsList.Items.Count - 1); cboSharedFolderFiles.SelectedIndex = Config.LocalhostSelectedFiles.Between(0, ucLocalhostAccounts.AccountsList.Items.Count - 1); cboSharedFolderImages.SelectedIndex = Config.LocalhostSelectedImages.Between(0, ucLocalhostAccounts.AccountsList.Items.Count - 1); cboSharedFolderText.SelectedIndex = Config.LocalhostSelectedText.Between(0, ucLocalhostAccounts.AccountsList.Items.Count - 1); } } } #endregion Localhost #region FTP private void FTPSetup(IEnumerable accs) { if (accs != null) { int selFtpList = ucFTPAccounts.AccountsList.SelectedIndex; ucFTPAccounts.AccountsList.Items.Clear(); ucFTPAccounts.SettingsGrid.PropertySort = PropertySort.Categorized; cboFtpImages.Items.Clear(); cboFtpText.Items.Clear(); cboFtpFiles.Items.Clear(); Config.FTPAccountList = new List(); Config.FTPAccountList.AddRange(accs); foreach (FTPAccount acc in Config.FTPAccountList) { ucFTPAccounts.AccountsList.Items.Add(acc); cboFtpImages.Items.Add(acc); cboFtpText.Items.Add(acc); cboFtpFiles.Items.Add(acc); } if (ucFTPAccounts.AccountsList.Items.Count > 0) { ucFTPAccounts.AccountsList.SelectedIndex = selFtpList.Between(0, ucFTPAccounts.AccountsList.Items.Count - 1); cboFtpImages.SelectedIndex = Config.FTPSelectedImage.Between(0, ucFTPAccounts.AccountsList.Items.Count - 1); cboFtpText.SelectedIndex = Config.FTPSelectedText.Between(0, ucFTPAccounts.AccountsList.Items.Count - 1); cboFtpFiles.SelectedIndex = Config.FTPSelectedFile.Between(0, ucFTPAccounts.AccountsList.Items.Count - 1); } } } private void FTPAccountAddButton_Click(object sender, EventArgs e) { FTPAccount acc = new FTPAccount("New Account"); Config.FTPAccountList.Add(acc); ucFTPAccounts.AccountsList.Items.Add(acc); ucFTPAccounts.AccountsList.SelectedIndex = ucFTPAccounts.AccountsList.Items.Count - 1; FTPSetup(Config.FTPAccountList); } private void FTPAccountRemoveButton_Click(object sender, EventArgs e) { int sel = ucFTPAccounts.AccountsList.SelectedIndex; if (ucFTPAccounts.RemoveItem(sel)) { Config.FTPAccountList.RemoveAt(sel); } FTPSetup(Config.FTPAccountList); } private void FTPAccountTestButton_Click(object sender, EventArgs e) { if (CheckFTPAccounts()) { TestFTPAccount(Config.FTPAccountList[ucFTPAccounts.AccountsList.SelectedIndex], false); } } private void FTPAccountCloneButton_Click(object sender, EventArgs e) { FTPAccount src = ucFTPAccounts.AccountsList.Items[ucFTPAccounts.AccountsList.SelectedIndex] as FTPAccount; Config.FTPAccountList.Add(src.Clone()); ucFTPAccounts.AccountsList.SelectedIndex = ucFTPAccounts.AccountsList.Items.Count - 1; FTPSetup(Config.FTPAccountList); } private void FTPAccountsList_SelectedIndexChanged(object sender, EventArgs e) { int sel = ucFTPAccounts.AccountsList.SelectedIndex; if (Config.FTPAccountList.IsValidIndex(sel)) { FTPAccount acc = Config.FTPAccountList[sel]; ucFTPAccounts.SettingsGrid.SelectedObject = acc; } } private void FtpAccountSettingsGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e) { FTPSetup(Config.FTPAccountList); } #endregion FTP #region Twitter private void TwitterAccountAuthButton_Click(object sender, EventArgs e) { if (CheckTwitterAccounts()) { OAuthInfo acc = TwitterGetActiveAccount(); Twitter twitter = new Twitter(acc); string url = twitter.GetAuthorizationURL(); if (!string.IsNullOrEmpty(url)) { Config.TwitterOAuthInfoList[Config.TwitterSelectedAccount] = acc; Helpers.LoadBrowserAsync(url); ucTwitterAccounts.SettingsGrid.SelectedObject = acc; } } } private void TwitterAccountRemoveButton_Click(object sender, EventArgs e) { int sel = ucTwitterAccounts.AccountsList.SelectedIndex; if (ucTwitterAccounts.RemoveItem(sel)) { Config.TwitterOAuthInfoList.RemoveAt(sel); } } private void TwitterAccountList_SelectedIndexChanged(object sender, EventArgs e) { int sel = ucTwitterAccounts.AccountsList.SelectedIndex; Config.TwitterSelectedAccount = sel; if (CheckTwitterAccounts()) { OAuthInfo acc = Config.TwitterOAuthInfoList[sel]; ucTwitterAccounts.SettingsGrid.SelectedObject = acc; } } private void TwitterAccountAddButton_Click(object sender, EventArgs e) { OAuthInfo acc = new OAuthInfo(APIKeys.TwitterConsumerKey, APIKeys.TwitterConsumerSecret); Config.TwitterOAuthInfoList.Add(acc); ucTwitterAccounts.AccountsList.Items.Add(acc); ucTwitterAccounts.AccountsList.SelectedIndex = ucTwitterAccounts.AccountsList.Items.Count - 1; if (CheckTwitterAccounts()) { ucTwitterAccounts.SettingsGrid.SelectedObject = acc; } } #endregion Twitter } }