PageRenderTime 96ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 1ms

/UploadersLib/GUI/UploadersConfigForm.cs

https://github.com/llehouerou/ShareX
C# | 2104 lines | 1622 code | 427 blank | 55 comment | 138 complexity | 8c40180bfc0b17097b21de91b12ce9ed MD5 | raw file
Possible License(s): GPL-3.0

Large files files are truncated, but you can click here to view the full file

  1. #region License Information (GPL v3)
  2. /*
  3. ShareX - A program that allows you to take screenshots and share any file type
  4. Copyright (C) 2007-2014 ShareX Developers
  5. This program is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 2
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. Optionally you can also view the license at <http://www.gnu.org/licenses/>.
  17. */
  18. #endregion License Information (GPL v3)
  19. using CG.Web.MegaApiClient;
  20. using HelpersLib;
  21. using System;
  22. using System.Collections.Generic;
  23. using System.Drawing;
  24. using System.Linq;
  25. using System.Windows.Forms;
  26. using UploadersLib.FileUploaders;
  27. using UploadersLib.HelperClasses;
  28. using UploadersLib.ImageUploaders;
  29. using UploadersLib.Properties;
  30. namespace UploadersLib
  31. {
  32. public partial class UploadersConfigForm : Form
  33. {
  34. public UploadersConfig Config { get; private set; }
  35. public UploadersConfigForm(UploadersConfig uploadersConfig)
  36. {
  37. Config = uploadersConfig;
  38. InitializeComponent();
  39. string title = "ShareX - Outputs Configuration";
  40. if (!string.IsNullOrEmpty(Config.FilePath))
  41. {
  42. title += " - " + Config.FilePath;
  43. }
  44. Text = title;
  45. Icon = ShareXResources.Icon;
  46. }
  47. private void UploadersConfigForm_Shown(object sender, EventArgs e)
  48. {
  49. FormSettings();
  50. LoadSettings(Config);
  51. }
  52. private void UploadersConfigForm_Resize(object sender, EventArgs e)
  53. {
  54. Refresh();
  55. }
  56. private void FormSettings()
  57. {
  58. ImageList uploadersImageList = new ImageList();
  59. uploadersImageList.ColorDepth = ColorDepth.Depth32Bit;
  60. uploadersImageList.Images.Add("ImageShack", Resources.ImageShack);
  61. uploadersImageList.Images.Add("TinyPic", Resources.TinyPic);
  62. uploadersImageList.Images.Add("Imgur", Resources.Imgur);
  63. uploadersImageList.Images.Add("Flickr", Resources.Flickr);
  64. uploadersImageList.Images.Add("Photobucket", Resources.Photobucket);
  65. uploadersImageList.Images.Add("Picasa", Resources.Picasa);
  66. uploadersImageList.Images.Add("TwitPic", Resources.TwitPic);
  67. uploadersImageList.Images.Add("TwitSnaps", Resources.TwitSnaps);
  68. uploadersImageList.Images.Add("YFrog", Resources.YFrog);
  69. uploadersImageList.Images.Add("Dropbox", Resources.Dropbox);
  70. uploadersImageList.Images.Add("Copy", Resources.Copy);
  71. uploadersImageList.Images.Add("GoogleDrive", Resources.GoogleDrive);
  72. uploadersImageList.Images.Add("Box", Resources.Box);
  73. uploadersImageList.Images.Add("Minus", Resources.Minus);
  74. uploadersImageList.Images.Add("FTP", Resources.folder_network);
  75. uploadersImageList.Images.Add("RapidShare", Resources.RapidShare);
  76. uploadersImageList.Images.Add("SendSpace", Resources.SendSpace);
  77. uploadersImageList.Images.Add("Gett", Resources.Gett);
  78. uploadersImageList.Images.Add("Localhostr", Resources.Localhostr);
  79. uploadersImageList.Images.Add("CustomUploader", Resources.globe_network);
  80. uploadersImageList.Images.Add("SharedFolders", Resources.server_network);
  81. uploadersImageList.Images.Add("Email", Resources.mail);
  82. uploadersImageList.Images.Add("Jira", Resources.jira);
  83. uploadersImageList.Images.Add("Mega", Resources.Mega);
  84. uploadersImageList.Images.Add("AmazonS3", Resources.AmazonS3);
  85. uploadersImageList.Images.Add("Pushbullet", Resources.Pushbullet);
  86. uploadersImageList.Images.Add("Pastebin", Resources.Pastebin);
  87. uploadersImageList.Images.Add("Gist", Resources.GitHub);
  88. uploadersImageList.Images.Add("Upaste", Resources.Upaste);
  89. uploadersImageList.Images.Add("Google", Resources.Google);
  90. uploadersImageList.Images.Add("Bitly", Resources.Bitly);
  91. uploadersImageList.Images.Add("Yourls", Resources.Yourls);
  92. uploadersImageList.Images.Add("Twitter", Resources.Twitter);
  93. tpImageShack.ImageKey = "ImageShack";
  94. tpTinyPic.ImageKey = "TinyPic";
  95. tpImgur.ImageKey = "Imgur";
  96. tpFlickr.ImageKey = "Flickr";
  97. tpPhotobucket.ImageKey = "Photobucket";
  98. tpPicasa.ImageKey = "Picasa";
  99. tpTwitPic.ImageKey = "TwitPic";
  100. tpTwitSnaps.ImageKey = "TwitSnaps";
  101. tpYFrog.ImageKey = "YFrog";
  102. tpDropbox.ImageKey = "Dropbox";
  103. tpCopy.ImageKey = "Copy";
  104. tpGoogleDrive.ImageKey = "GoogleDrive";
  105. tpBox.ImageKey = "Box";
  106. tpMinus.ImageKey = "Minus";
  107. tpFTP.ImageKey = "FTP";
  108. tpRapidShare.ImageKey = "RapidShare";
  109. tpSendSpace.ImageKey = "SendSpace";
  110. tpSharedFolder.ImageKey = "SharedFolders";
  111. tpEmail.ImageKey = "Email";
  112. tpJira.ImageKey = "Jira";
  113. tpGe_tt.ImageKey = "Gett";
  114. tpHostr.ImageKey = "Localhostr";
  115. tpCustomUploaders.ImageKey = "CustomUploader";
  116. tpPastebin.ImageKey = "Pastebin";
  117. tpPushbullet.ImageKey = "Pushbullet";
  118. tpGoogleURLShortener.ImageKey = "Google";
  119. tpBitly.ImageKey = "Bitly";
  120. tpYourls.ImageKey = "Yourls";
  121. tpTwitter.ImageKey = "Twitter";
  122. tpMega.ImageKey = "Mega";
  123. tpGist.ImageKey = "Gist";
  124. tpUpaste.ImageKey = "Upaste";
  125. tpAmazonS3.ImageKey = "AmazonS3";
  126. ttlvMain.ImageList = uploadersImageList;
  127. ttlvMain.MainTabControl = tcUploaders;
  128. ttlvMain.FocusListView();
  129. NameParser.CreateCodesMenu(txtDropboxPath, ReplacementVariables.n, ReplacementVariables.t, ReplacementVariables.pn);
  130. NameParser.CreateCodesMenu(txtAmazonS3ObjectPrefix, ReplacementVariables.n, ReplacementVariables.t, ReplacementVariables.pn);
  131. NameParser.CreateCodesMenu(txtCustomUploaderArgValue, ReplacementVariables.n);
  132. txtCustomUploaderLog.AddContextMenu();
  133. // FTP
  134. ucFTPAccounts.btnAdd.Click += FTPAccountAddButton_Click;
  135. ucFTPAccounts.btnRemove.Click += FTPAccountRemoveButton_Click;
  136. ucFTPAccounts.btnDuplicate.Click += FTPAccountDuplicateButton_Click;
  137. ucFTPAccounts.btnTest.Click += FTPAccountTestButton_Click;
  138. ucFTPAccounts.pgSettings.PropertyValueChanged += FtpAccountSettingsGrid_PropertyValueChanged;
  139. // Localhost
  140. ucLocalhostAccounts.btnAdd.Click += LocalhostAccountAddButton_Click;
  141. ucLocalhostAccounts.btnRemove.Click += LocalhostAccountRemoveButton_Click;
  142. ucLocalhostAccounts.btnDuplicate.Click += LocalhostAccountDuplicateButton_Click;
  143. ucLocalhostAccounts.btnTest.Visible = false;
  144. ucLocalhostAccounts.pgSettings.PropertyValueChanged += SettingsGrid_LocalhostPropertyValueChanged;
  145. // Twitter
  146. ucTwitterAccounts.btnAdd.Click += TwitterAccountAddButton_Click;
  147. ucTwitterAccounts.btnRemove.Click += TwitterAccountRemoveButton_Click;
  148. ucTwitterAccounts.btnDuplicate.Click += TwitterAccountDuplicateButton_Click;
  149. ucTwitterAccounts.btnTest.Text = "Authorize";
  150. ucTwitterAccounts.btnTest.Click += TwitterAccountAuthButton_Click;
  151. ucTwitterAccounts.lbAccounts.SelectedIndexChanged += TwitterAccountSelectedIndexChanged;
  152. eiFTP.ObjectType = typeof(FTPAccount);
  153. eiCustomUploaders.ObjectType = typeof(CustomUploaderItem);
  154. }
  155. public void LoadSettings(UploadersConfig uploadersConfig)
  156. {
  157. #region Image uploaders
  158. // ImageShack
  159. atcImageShackAccountType.SelectedAccountType = Config.ImageShackSettings.AccountType;
  160. txtImageShackUsername.Text = Config.ImageShackSettings.Username;
  161. txtImageShackPassword.Text = Config.ImageShackSettings.Password;
  162. cbImageShackIsPublic.Checked = Config.ImageShackSettings.IsPublic;
  163. // TinyPic
  164. atcTinyPicAccountType.SelectedAccountType = Config.TinyPicAccountType;
  165. txtTinyPicUsername.Text = Config.TinyPicUsername;
  166. txtTinyPicPassword.Text = Config.TinyPicPassword;
  167. // Imgur
  168. atcImgurAccountType.SelectedAccountType = Config.ImgurAccountType;
  169. cbImgurThumbnailType.Items.Clear();
  170. cbImgurThumbnailType.Items.AddRange(Helpers.GetEnumDescriptions<ImgurThumbnailType>());
  171. cbImgurThumbnailType.SelectedIndex = (int)Config.ImgurThumbnailType;
  172. txtImgurAlbumID.Text = Config.ImgurAlbumID;
  173. if (OAuth2Info.CheckOAuth(Config.ImgurOAuth2Info))
  174. {
  175. oauth2Imgur.Status = "Login successful.";
  176. oauth2Imgur.LoginStatus = true;
  177. btnImgurRefreshAlbumList.Enabled = true;
  178. }
  179. // Photobucket
  180. if (OAuthInfo.CheckOAuth(Config.PhotobucketOAuthInfo))
  181. {
  182. lblPhotobucketAccountStatus.Text = "Login successful.";
  183. txtPhotobucketDefaultAlbumName.Text = Config.PhotobucketAccountInfo.AlbumID;
  184. lblPhotobucketParentAlbumPath.Text = "Parent album path e.g. " + Config.PhotobucketAccountInfo.AlbumID + "/Personal/" + DateTime.Now.Year;
  185. }
  186. if (Config.PhotobucketAccountInfo != null)
  187. {
  188. cboPhotobucketAlbumPaths.Items.Clear();
  189. if (Config.PhotobucketAccountInfo.AlbumList.Count > 0)
  190. {
  191. cboPhotobucketAlbumPaths.Items.AddRange(Config.PhotobucketAccountInfo.AlbumList.ToArray());
  192. cboPhotobucketAlbumPaths.SelectedIndex = Config.PhotobucketAccountInfo.ActiveAlbumID.
  193. BetweenOrDefault(0, Config.PhotobucketAccountInfo.AlbumList.Count - 1);
  194. }
  195. }
  196. // Picasa
  197. if (OAuth2Info.CheckOAuth(Config.PicasaOAuth2Info))
  198. {
  199. oauth2Picasa.Status = "Login successful.";
  200. oauth2Picasa.LoginStatus = true;
  201. btnPicasaRefreshAlbumList.Enabled = true;
  202. }
  203. txtPicasaAlbumID.Text = Config.PicasaAlbumID;
  204. // Flickr
  205. pgFlickrAuthInfo.SelectedObject = Config.FlickrAuthInfo;
  206. pgFlickrSettings.SelectedObject = Config.FlickrSettings;
  207. // TwitPic
  208. chkTwitPicShowFull.Checked = Config.TwitPicShowFull;
  209. cboTwitPicThumbnailMode.Items.Clear();
  210. cboTwitPicThumbnailMode.Items.AddRange(Helpers.GetEnumDescriptions<TwitPicThumbnailType>());
  211. cboTwitPicThumbnailMode.SelectedIndex = (int)Config.TwitPicThumbnailMode;
  212. // YFrog
  213. txtYFrogUsername.Text = Config.YFrogUsername;
  214. txtYFrogPassword.Text = Config.YFrogPassword;
  215. #endregion Image uploaders
  216. #region Text uploaders
  217. // Pastebin
  218. pgPastebinSettings.SelectedObject = Config.PastebinSettings;
  219. // Paste.ee
  220. txtPaste_eeUserAPIKey.Text = Config.Paste_eeUserAPIKey;
  221. // Gist
  222. atcGistAccountType.SelectedAccountType = Config.GistAnonymousLogin ? AccountType.Anonymous : AccountType.User;
  223. chkGistPublishPublic.Checked = Config.GistPublishPublic;
  224. if (OAuth2Info.CheckOAuth(Config.GistOAuth2Info))
  225. {
  226. oAuth2Gist.Status = "Login successful.";
  227. oAuth2Gist.LoginStatus = true;
  228. }
  229. // Upaste
  230. txtUpasteUserKey.Text = Config.UpasteUserKey;
  231. cbUpasteIsPublic.Checked = Config.UpasteIsPublic;
  232. #endregion Text uploaders
  233. #region File uploaders
  234. // Dropbox
  235. if (OAuth2Info.CheckOAuth(Config.DropboxOAuth2Info))
  236. {
  237. oauth2Dropbox.Status = "Login successful.";
  238. oauth2Dropbox.LoginStatus = true;
  239. }
  240. txtDropboxPath.Text = Config.DropboxUploadPath;
  241. cbDropboxAutoCreateShareableLink.Checked = Config.DropboxAutoCreateShareableLink;
  242. cbDropboxURLType.Enabled = Config.DropboxAutoCreateShareableLink;
  243. cbDropboxURLType.Items.AddRange(Helpers.GetEnumNamesProper<DropboxURLType>());
  244. cbDropboxURLType.SelectedIndex = (int)Config.DropboxURLType;
  245. UpdateDropboxStatus();
  246. // Copy
  247. if (OAuthInfo.CheckOAuth(Config.CopyOAuthInfo))
  248. {
  249. oAuthCopy.Status = "Login successful.";
  250. oAuthCopy.LoginStatus = true;
  251. }
  252. txtCopyPath.Text = Config.CopyUploadPath;
  253. cbCopyURLType.Items.AddRange(Helpers.GetEnumNamesProper<CopyURLType>());
  254. cbCopyURLType.SelectedIndex = (int)Config.CopyURLType;
  255. UpdateCopyStatus();
  256. // Google Drive
  257. if (OAuth2Info.CheckOAuth(Config.GoogleDriveOAuth2Info))
  258. {
  259. oauth2GoogleDrive.Status = "Login successful.";
  260. oauth2GoogleDrive.LoginStatus = true;
  261. }
  262. cbGoogleDriveIsPublic.Checked = Config.GoogleDriveIsPublic;
  263. // Minus
  264. cbMinusURLType.Items.Clear();
  265. cbMinusURLType.Items.AddRange(Enum.GetNames(typeof(MinusLinkType)));
  266. MinusUpdateControls();
  267. // Box
  268. if (OAuth2Info.CheckOAuth(Config.BoxOAuth2Info))
  269. {
  270. oauth2Box.Status = "Login successful.";
  271. oauth2Box.LoginStatus = true;
  272. btnBoxRefreshFolders.Enabled = true;
  273. }
  274. cbBoxShare.Checked = Config.BoxShare;
  275. lblBoxFolderID.Text = "Selected folder: " + Config.BoxSelectedFolder.name;
  276. // Ge.tt
  277. if (Config.Ge_ttLogin != null && !string.IsNullOrEmpty(Config.Ge_ttLogin.AccessToken))
  278. {
  279. lblGe_ttStatus.Text = "Login successful.";
  280. }
  281. // Localhostr
  282. txtLocalhostrEmail.Text = Config.LocalhostrEmail;
  283. txtLocalhostrPassword.Text = Config.LocalhostrPassword;
  284. cbLocalhostrDirectURL.Checked = Config.LocalhostrDirectURL;
  285. // FTP
  286. if (Config.FTPAccountList == null || Config.FTPAccountList.Count == 0)
  287. {
  288. FTPSetup(new List<FTPAccount>());
  289. }
  290. else
  291. {
  292. FTPSetup(Config.FTPAccountList);
  293. if (ucFTPAccounts.lbAccounts.Items.Count > 0)
  294. {
  295. ucFTPAccounts.lbAccounts.SelectedIndex = 0;
  296. }
  297. }
  298. // Email
  299. txtEmailSmtpServer.Text = Config.EmailSmtpServer;
  300. nudEmailSmtpPort.Value = Config.EmailSmtpPort;
  301. txtEmailFrom.Text = Config.EmailFrom;
  302. txtEmailPassword.Text = Config.EmailPassword;
  303. chkEmailConfirm.Checked = Config.EmailConfirmSend;
  304. cbEmailRememberLastTo.Checked = Config.EmailRememberLastTo;
  305. txtEmailDefaultSubject.Text = Config.EmailDefaultSubject;
  306. txtEmailDefaultBody.Text = Config.EmailDefaultBody;
  307. // RapidShare
  308. txtRapidShareUsername.Text = Config.RapidShareUsername;
  309. txtRapidSharePassword.Text = Config.RapidSharePassword;
  310. txtRapidShareFolderID.Text = Config.RapidShareFolderID;
  311. // SendSpace
  312. atcSendSpaceAccountType.SelectedAccountType = Config.SendSpaceAccountType;
  313. txtSendSpacePassword.Text = Config.SendSpacePassword;
  314. txtSendSpaceUserName.Text = Config.SendSpaceUsername;
  315. // Localhost
  316. if (Config.LocalhostAccountList == null || Config.LocalhostAccountList.Count == 0)
  317. {
  318. LocalhostAccountsSetup(new List<LocalhostAccount>());
  319. }
  320. else
  321. {
  322. LocalhostAccountsSetup(Config.LocalhostAccountList);
  323. if (ucLocalhostAccounts.lbAccounts.Items.Count > 0)
  324. {
  325. ucLocalhostAccounts.lbAccounts.SelectedIndex = 0;
  326. cboSharedFolderImages.SelectedIndex = Config.LocalhostSelectedImages.Between(0, ucLocalhostAccounts.lbAccounts.Items.Count - 1);
  327. cboSharedFolderText.SelectedIndex = Config.LocalhostSelectedText.Between(0, ucLocalhostAccounts.lbAccounts.Items.Count - 1);
  328. cboSharedFolderFiles.SelectedIndex = Config.LocalhostSelectedFiles.Between(0, ucLocalhostAccounts.lbAccounts.Items.Count - 1);
  329. }
  330. }
  331. // Custom uploaders
  332. lbCustomUploaderList.Items.Clear();
  333. if (Config.CustomUploadersList == null)
  334. {
  335. Config.CustomUploadersList = new List<CustomUploaderItem>();
  336. }
  337. else
  338. {
  339. foreach (CustomUploaderItem customUploader in Config.CustomUploadersList)
  340. {
  341. lbCustomUploaderList.Items.Add(customUploader.Name);
  342. }
  343. PrepareCustomUploaderList();
  344. }
  345. cbCustomUploaderRequestType.Items.AddRange(Enum.GetNames(typeof(CustomUploaderRequestType)));
  346. cbCustomUploaderResponseType.Items.AddRange(Helpers.GetEnumDescriptions<ResponseType>());
  347. CustomUploaderClear();
  348. // Jira
  349. txtJiraHost.Text = Config.JiraHost;
  350. txtJiraIssuePrefix.Text = Config.JiraIssuePrefix;
  351. txtJiraConfigHelp.Text = string.Format(@"Howto configure your Jira server:
  352. - Go to 'Administration' -> 'Add-ons'
  353. - Select 'Application Links'
  354. - Add a new 'Application Link' with following settings:
  355. - Server URL: {0}
  356. - Application Name: {1}
  357. - Application Type: Generic Application
  358. - Now, you have to configure Incoming Authentication
  359. - Consumer Key: {2}
  360. - Consumer Name: {1}
  361. - Public Key (without quotes): '{3}'
  362. - You can now authenticate to Jira", Links.URL_WEBSITE, Application.ProductName, APIKeys.JiraConsumerKey, Jira.PublicKey);
  363. if (OAuthInfo.CheckOAuth(Config.JiraOAuthInfo))
  364. {
  365. oAuthJira.Status = "Login successful.";
  366. oAuthJira.LoginStatus = true;
  367. }
  368. // Mega
  369. MegaConfigureTab(false);
  370. //Pushbullet
  371. txtPushbulletUserKey.Text = Config.PushbulletSettings.UserAPIKey;
  372. if (Config.PushbulletSettings.DeviceList.Count > 0)
  373. {
  374. Config.PushbulletSettings.DeviceList.ForEach(x => cboPushbulletDevices.Items.Add(x.Name ?? "Invalid device name"));
  375. if (Config.PushbulletSettings.DeviceList.IsValidIndex(Config.PushbulletSettings.SelectedDevice))
  376. {
  377. cboPushbulletDevices.SelectedIndex = Config.PushbulletSettings.SelectedDevice;
  378. }
  379. else
  380. {
  381. cboPushbulletDevices.SelectedIndex = 0;
  382. }
  383. }
  384. // Amazon S3
  385. txtAmazonS3AccessKey.Text = Config.AmazonS3Settings.AccessKeyID;
  386. txtAmazonS3SecretKey.Text = Config.AmazonS3Settings.SecretAccessKey;
  387. cbAmazonS3Endpoint.Text = Config.AmazonS3Settings.Endpoint;
  388. txtAmazonS3BucketName.Text = Config.AmazonS3Settings.Bucket;
  389. txtAmazonS3ObjectPrefix.Text = Config.AmazonS3Settings.ObjectPrefix;
  390. cbAmazonS3CustomCNAME.Checked = Config.AmazonS3Settings.UseCustomCNAME;
  391. txtAmazonS3CustomDomain.Enabled = Config.AmazonS3Settings.UseCustomCNAME;
  392. txtAmazonS3CustomDomain.Text = Config.AmazonS3Settings.CustomDomain;
  393. cbAmazonS3UseRRS.Checked = Config.AmazonS3Settings.UseReducedRedundancyStorage;
  394. UpdateAmazonS3Status();
  395. #endregion File uploaders
  396. #region URL Shorteners
  397. // Google URL Shortener
  398. atcGoogleURLShortenerAccountType.SelectedAccountType = Config.GoogleURLShortenerAccountType;
  399. if (OAuth2Info.CheckOAuth(Config.GoogleURLShortenerOAuth2Info))
  400. {
  401. oauth2GoogleURLShortener.Status = "Login successful.";
  402. oauth2GoogleURLShortener.LoginStatus = true;
  403. }
  404. // bit.ly
  405. if (OAuth2Info.CheckOAuth(Config.BitlyOAuth2Info))
  406. {
  407. oauth2Bitly.Status = "Login successful.";
  408. oauth2Bitly.LoginStatus = true;
  409. }
  410. // yourls.org
  411. txtYourlsAPIURL.Text = Config.YourlsAPIURL;
  412. txtYourlsSignature.Text = Config.YourlsSignature;
  413. txtYourlsUsername.Enabled = txtYourlsPassword.Enabled = string.IsNullOrEmpty(Config.YourlsSignature);
  414. txtYourlsUsername.Text = Config.YourlsUsername;
  415. txtYourlsPassword.Text = Config.YourlsPassword;
  416. #endregion URL Shorteners
  417. #region Other Services
  418. ucTwitterAccounts.lbAccounts.Items.Clear();
  419. foreach (OAuthInfo acc in Config.TwitterOAuthInfoList)
  420. {
  421. ucTwitterAccounts.lbAccounts.Items.Add(acc);
  422. }
  423. if (ucTwitterAccounts.lbAccounts.Items.Count > 0)
  424. {
  425. ucTwitterAccounts.lbAccounts.SelectedIndex = Config.TwitterSelectedAccount;
  426. }
  427. #endregion Other Services
  428. }
  429. #region Image Uploaders
  430. #region ImageShack
  431. private void atcImageShackAccountType_AccountTypeChanged(AccountType accountType)
  432. {
  433. Config.ImageShackSettings.AccountType = accountType;
  434. }
  435. private void txtImageShackUsername_TextChanged(object sender, EventArgs e)
  436. {
  437. Config.ImageShackSettings.Username = txtImageShackUsername.Text;
  438. }
  439. private void txtImageShackPassword_TextChanged(object sender, EventArgs e)
  440. {
  441. Config.ImageShackSettings.Password = txtImageShackPassword.Text;
  442. }
  443. private void btnImageShackLogin_Click(object sender, EventArgs e)
  444. {
  445. ImageShackUploader imageShackUploader = new ImageShackUploader(APIKeys.ImageShackKey, Config.ImageShackSettings);
  446. try
  447. {
  448. if (imageShackUploader.GetAccessToken())
  449. {
  450. MessageBox.Show("Login successful.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
  451. }
  452. else
  453. {
  454. MessageBox.Show("Login failed.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
  455. }
  456. }
  457. catch (Exception ex)
  458. {
  459. DebugHelper.WriteException(ex);
  460. MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  461. }
  462. }
  463. private void cbImageShackIsPublic_CheckedChanged(object sender, EventArgs e)
  464. {
  465. Config.ImageShackSettings.IsPublic = cbImageShackIsPublic.Checked;
  466. }
  467. private void btnImageShackOpenPublicProfile_Click(object sender, EventArgs e)
  468. {
  469. if (!string.IsNullOrEmpty(Config.ImageShackSettings.Username))
  470. {
  471. Helpers.OpenURL("https://imageshack.com/user/" + Config.ImageShackSettings.Username);
  472. }
  473. else
  474. {
  475. txtImageShackUsername.Focus();
  476. }
  477. }
  478. private void btnImageShackOpenMyImages_Click(object sender, EventArgs e)
  479. {
  480. Helpers.OpenURL("https://imageshack.com/my/images");
  481. }
  482. #endregion ImageShack
  483. #region TinyPic
  484. private void atcTinyPicAccountType_AccountTypeChanged(AccountType accountType)
  485. {
  486. Config.TinyPicAccountType = accountType;
  487. }
  488. private void txtTinyPicUsername_TextChanged(object sender, EventArgs e)
  489. {
  490. if (Config.TinyPicRememberUserPass)
  491. {
  492. Config.TinyPicUsername = txtTinyPicUsername.Text;
  493. }
  494. }
  495. private void txtTinyPicPassword_TextChanged(object sender, EventArgs e)
  496. {
  497. if (Config.TinyPicRememberUserPass)
  498. {
  499. Config.TinyPicPassword = txtTinyPicPassword.Text;
  500. }
  501. }
  502. private void btnTinyPicLogin_Click(object sender, EventArgs e)
  503. {
  504. string username = txtTinyPicUsername.Text;
  505. string password = txtTinyPicPassword.Text;
  506. if (!string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(password))
  507. {
  508. try
  509. {
  510. TinyPicUploader tpu = new TinyPicUploader(APIKeys.TinyPicID, APIKeys.TinyPicKey);
  511. string registrationCode = tpu.UserAuth(username, password);
  512. if (!string.IsNullOrEmpty(registrationCode))
  513. {
  514. Config.TinyPicRegistrationCode = registrationCode;
  515. MessageBox.Show("Login successful.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Information);
  516. }
  517. else
  518. {
  519. MessageBox.Show("Login failed.", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
  520. }
  521. }
  522. catch (Exception ex)
  523. {
  524. DebugHelper.WriteException(ex);
  525. MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
  526. }
  527. }
  528. }
  529. private void btnTinyPicOpenMyImages_Click(object sender, EventArgs e)
  530. {
  531. Helpers.OpenURL("http://tinypic.com/yourstuff.php");
  532. }
  533. #endregion TinyPic
  534. #region Imgur
  535. private void atcImgurAccountType_AccountTypeChanged(AccountType accountType)
  536. {
  537. Config.ImgurAccountType = accountType;
  538. }
  539. private void cbImgurThumbnailType_SelectedIndexChanged(object sender, EventArgs e)
  540. {
  541. Config.ImgurThumbnailType = (ImgurThumbnailType)cbImgurThumbnailType.SelectedIndex;
  542. }
  543. private void txtImgurAlbumID_TextChanged(object sender, EventArgs e)
  544. {
  545. Config.ImgurAlbumID = txtImgurAlbumID.Text;
  546. }
  547. private void btnImgurRefreshAlbumList_Click(object sender, EventArgs e)
  548. {
  549. ImgurRefreshAlbumList();
  550. }
  551. private void lvImgurAlbumList_SelectedIndexChanged(object sender, EventArgs e)
  552. {
  553. if (lvImgurAlbumList.SelectedItems.Count > 0)
  554. {
  555. ListViewItem lvi = lvImgurAlbumList.SelectedItems[0];
  556. if (lvi.Tag is ImgurAlbumData)
  557. {
  558. ImgurAlbumData album = (ImgurAlbumData)lvi.Tag;
  559. txtImgurAlbumID.Text = album.id;
  560. }
  561. }
  562. }
  563. private void oauth2Imgur_OpenButtonClicked()
  564. {
  565. ImgurAuthOpen();
  566. }
  567. private void oauth2Imgur_CompleteButtonClicked(string code)
  568. {
  569. ImgurAuthComplete(code);
  570. }
  571. private void oauth2Imgur_RefreshButtonClicked()
  572. {
  573. ImgurAuthRefresh();
  574. }
  575. #endregion Imgur
  576. #region Photobucket
  577. private void btnPhotobucketAuthOpen_Click(object sender, EventArgs e)
  578. {
  579. PhotobucketAuthOpen();
  580. }
  581. private void btnPhotobucketAuthComplete_Click(object sender, EventArgs e)
  582. {
  583. PhotobucketAuthComplete();
  584. }
  585. private void btnPhotobucketCreateAlbum_Click(object sender, EventArgs e)
  586. {
  587. PhotobucketCreateAlbum();
  588. }
  589. private void cboPhotobucketAlbumPaths_SelectedIndexChanged(object sender, EventArgs e)
  590. {
  591. if (Config.PhotobucketAccountInfo != null)
  592. {
  593. Config.PhotobucketAccountInfo.ActiveAlbumID = cboPhotobucketAlbumPaths.SelectedIndex;
  594. }
  595. }
  596. private void btnPhotobucketAddAlbum_Click(object sender, EventArgs e)
  597. {
  598. string albumPath = cboPhotobucketAlbumPaths.Text;
  599. if (!Config.PhotobucketAccountInfo.AlbumList.Contains(albumPath))
  600. {
  601. Config.PhotobucketAccountInfo.AlbumList.Add(albumPath);
  602. cboPhotobucketAlbumPaths.Items.Add(albumPath);
  603. }
  604. }
  605. private void btnPhotobucketRemoveAlbum_Click(object sender, EventArgs e)
  606. {
  607. if (cboPhotobucketAlbumPaths.Items.Count > 1)
  608. {
  609. cboPhotobucketAlbumPaths.Items.RemoveAt(cboPhotobucketAlbumPaths.SelectedIndex);
  610. cboPhotobucketAlbumPaths.SelectedIndex = cboPhotobucketAlbumPaths.Items.Count - 1;
  611. }
  612. }
  613. #endregion Photobucket
  614. #region Picasa
  615. private void oauth2Picasa_OpenButtonClicked()
  616. {
  617. PicasaAuthOpen();
  618. }
  619. private void oauth2Picasa_CompleteButtonClicked(string code)
  620. {
  621. PicasaAuthComplete(code);
  622. }
  623. private void oauth2Picasa_RefreshButtonClicked()
  624. {
  625. PicasaAuthRefresh();
  626. }
  627. private void txtPicasaAlbumID_TextChanged(object sender, EventArgs e)
  628. {
  629. Config.PicasaAlbumID = txtPicasaAlbumID.Text;
  630. }
  631. private void btnPicasaRefreshAlbumList_Click(object sender, EventArgs e)
  632. {
  633. PicasaRefreshAlbumList();
  634. }
  635. private void lvPicasaAlbumList_SelectedIndexChanged(object sender, EventArgs e)
  636. {
  637. if (lvPicasaAlbumList.SelectedItems.Count > 0)
  638. {
  639. ListViewItem lvi = lvPicasaAlbumList.SelectedItems[0];
  640. if (lvi.Tag is PicasaAlbumInfo)
  641. {
  642. PicasaAlbumInfo album = (PicasaAlbumInfo)lvi.Tag;
  643. txtPicasaAlbumID.Text = album.ID;
  644. }
  645. }
  646. }
  647. #endregion Picasa
  648. #region Flickr
  649. private void btnFlickrOpenAuthorize_Click(object sender, EventArgs e)
  650. {
  651. FlickrAuthOpen();
  652. }
  653. private void btnFlickrCompleteAuth_Click(object sender, EventArgs e)
  654. {
  655. FlickrAuthComplete();
  656. }
  657. private void btnFlickrCheckToken_Click(object sender, EventArgs e)
  658. {
  659. FlickrCheckToken();
  660. }
  661. private void btnFlickrOpenImages_Click(object sender, EventArgs e)
  662. {
  663. FlickrOpenImages();
  664. }
  665. #endregion Flickr
  666. #region TwitPic
  667. private void cboTwitPicThumbnailMode_SelectedIndexChanged(object sender, EventArgs e)
  668. {
  669. Config.TwitPicThumbnailMode = (TwitPicThumbnailType)cboTwitPicThumbnailMode.SelectedIndex;
  670. }
  671. private void chkTwitPicShowFull_CheckedChanged(object sender, EventArgs e)
  672. {
  673. Config.TwitPicShowFull = chkTwitPicShowFull.Checked;
  674. }
  675. #endregion TwitPic
  676. #region YFrog
  677. private void txtYFrogUsername_TextChanged(object sender, EventArgs e)
  678. {
  679. Config.YFrogUsername = txtYFrogUsername.Text;
  680. }
  681. private void txtYFrogPassword_TextChanged(object sender, EventArgs e)
  682. {
  683. Config.YFrogPassword = txtYFrogPassword.Text;
  684. }
  685. #endregion YFrog
  686. #endregion Image Uploaders
  687. #region Text Uploaders
  688. #region Pastebin
  689. private void btnPastebinLogin_Click(object sender, EventArgs e)
  690. {
  691. PastebinLogin();
  692. }
  693. #endregion Pastebin
  694. #region Paste.ee
  695. private void txtPaste_eeUserAPIKey_TextChanged(object sender, EventArgs e)
  696. {
  697. Config.Paste_eeUserAPIKey = txtPaste_eeUserAPIKey.Text;
  698. }
  699. #endregion Paste.ee
  700. #region Gist
  701. private void atcGistAccountType_AccountTypeChanged(AccountType accountType)
  702. {
  703. Config.GistAnonymousLogin = accountType == AccountType.Anonymous;
  704. oAuth2Gist.Enabled = !Config.GistAnonymousLogin;
  705. }
  706. private void oAuth2Gist_OpenButtonClicked()
  707. {
  708. GistAuthOpen();
  709. }
  710. private void oAuth2Gist_CompleteButtonClicked(string code)
  711. {
  712. GistAuthComplete(code);
  713. }
  714. private void chkGistPublishPublic_CheckedChanged(object sender, EventArgs e)
  715. {
  716. Config.GistPublishPublic = ((CheckBox)sender).Checked;
  717. }
  718. #endregion Gist
  719. #region uPaste
  720. private void txtUpasteUserKey_TextChanged(object sender, EventArgs e)
  721. {
  722. Config.UpasteUserKey = txtUpasteUserKey.Text;
  723. }
  724. private void cbUpasteIsPublic_CheckedChanged(object sender, EventArgs e)
  725. {
  726. Config.UpasteIsPublic = cbUpasteIsPublic.Checked;
  727. }
  728. #endregion uPaste
  729. #endregion Text Uploaders
  730. #region File Uploaders
  731. #region Dropbox
  732. private void pbDropboxLogo_Click(object sender, EventArgs e)
  733. {
  734. Helpers.OpenURL("https://www.dropbox.com");
  735. }
  736. private void btnDropboxRegister_Click(object sender, EventArgs e)
  737. {
  738. Helpers.OpenURL("http://db.tt/CtPYXvu");
  739. }
  740. private void oauth2Dropbox_OpenButtonClicked()
  741. {
  742. DropboxAuthOpen();
  743. }
  744. private void oauth2Dropbox_CompleteButtonClicked(string code)
  745. {
  746. DropboxAuthComplete(code);
  747. }
  748. private void txtDropboxPath_TextChanged(object sender, EventArgs e)
  749. {
  750. Config.DropboxUploadPath = txtDropboxPath.Text;
  751. UpdateDropboxStatus();
  752. }
  753. private void btnDropboxShowFiles_Click(object sender, EventArgs e)
  754. {
  755. DropboxOpenFiles();
  756. }
  757. private void cbDropboxAutoCreateShareableLink_CheckedChanged(object sender, EventArgs e)
  758. {
  759. Config.DropboxAutoCreateShareableLink = cbDropboxAutoCreateShareableLink.Checked;
  760. cbDropboxURLType.Enabled = Config.DropboxAutoCreateShareableLink;
  761. }
  762. private void cbDropboxURLType_SelectedIndexChanged(object sender, EventArgs e)
  763. {
  764. Config.DropboxURLType = (DropboxURLType)cbDropboxURLType.SelectedIndex;
  765. }
  766. #endregion Dropbox
  767. #region Copy
  768. private void pbCopyLogo_Click(object sender, EventArgs e)
  769. {
  770. Helpers.OpenURL("https://copy.com");
  771. }
  772. private void btnCopyRegister_Click(object sender, EventArgs e)
  773. {
  774. Helpers.OpenURL("https://copy.com?r=hC3DMW");
  775. }
  776. private void txtCopyPath_TextChanged(object sender, EventArgs e)
  777. {
  778. Config.CopyUploadPath = txtCopyPath.Text;
  779. UpdateCopyStatus();
  780. }
  781. private void oAuthCopy_OpenButtonClicked()
  782. {
  783. CopyAuthOpen();
  784. }
  785. private void oAuthCopy_CompleteButtonClicked(string code)
  786. {
  787. CopyAuthComplete(code);
  788. }
  789. private void cbCopyURLType_SelectedIndexChanged(object sender, EventArgs e)
  790. {
  791. Config.CopyURLType = (CopyURLType)cbCopyURLType.SelectedIndex;
  792. }
  793. #endregion Copy
  794. #region Google Drive
  795. private void oauth2GoogleDrive_OpenButtonClicked()
  796. {
  797. GoogleDriveAuthOpen();
  798. }
  799. private void oauth2GoogleDrive_CompleteButtonClicked(string code)
  800. {
  801. GoogleDriveAuthComplete(code);
  802. }
  803. private void oauth2GoogleDrive_RefreshButtonClicked()
  804. {
  805. GoogleDriveAuthRefresh();
  806. }
  807. private void cbGoogleDriveIsPublic_CheckedChanged(object sender, EventArgs e)
  808. {
  809. Config.GoogleDriveIsPublic = cbGoogleDriveIsPublic.Checked;
  810. }
  811. #endregion Google Drive
  812. #region Box
  813. private void oauth2Box_OpenButtonClicked()
  814. {
  815. BoxAuthOpen();
  816. }
  817. private void oauth2Box_CompleteButtonClicked(string code)
  818. {
  819. BoxAuthComplete(code);
  820. }
  821. private void oauth2Box_RefreshButtonClicked()
  822. {
  823. BoxAuthRefresh();
  824. }
  825. private void cbBoxShare_CheckedChanged(object sender, EventArgs e)
  826. {
  827. Config.BoxShare = cbBoxShare.Checked;
  828. }
  829. private void btnBoxRefreshFolders_Click(object sender, EventArgs e)
  830. {
  831. BoxListFolders();
  832. }
  833. private void lvBoxFolders_SelectedIndexChanged(object sender, EventArgs e)
  834. {
  835. if (lvBoxFolders.SelectedItems.Count > 0)
  836. {
  837. ListViewItem lvi = lvBoxFolders.SelectedItems[0];
  838. BoxFileEntry file = lvi.Tag as BoxFileEntry;
  839. if (file != null)
  840. {
  841. lblBoxFolderID.Text = "Selected folder: " + file.name;
  842. }
  843. }
  844. }
  845. private void lvBoxFolders_MouseDoubleClick(object sender, MouseEventArgs e)
  846. {
  847. if (e.Button == MouseButtons.Left && lvBoxFolders.SelectedItems.Count > 0)
  848. {
  849. ListViewItem lvi = lvBoxFolders.SelectedItems[0];
  850. BoxFileEntry file = lvi.Tag as BoxFileEntry;
  851. if (file != null)
  852. {
  853. lvBoxFolders.Items.Clear();
  854. BoxListFolders(file);
  855. }
  856. }
  857. }
  858. #endregion Box
  859. #region Minus
  860. private void btnMinusAuth_Click(object sender, EventArgs e)
  861. {
  862. MinusAuth();
  863. }
  864. private void btnAuthRefresh_Click(object sender, EventArgs e)
  865. {
  866. MinusAuthRefresh();
  867. }
  868. private void cboMinusFolders_SelectedIndexChanged(object sender, EventArgs e)
  869. {
  870. if (Config.MinusConfig != null)
  871. {
  872. Config.MinusConfig.FolderID = cboMinusFolders.SelectedIndex;
  873. MinusFolder tempMf = Config.MinusConfig.GetActiveFolder();
  874. chkMinusPublic.Checked = tempMf.is_public;
  875. }
  876. }
  877. private void btnMinusFolderAdd_Click(object sender, EventArgs e)
  878. {
  879. if (!string.IsNullOrEmpty(cboMinusFolders.Text) && !MinusHasFolder(cboMinusFolders.Text))
  880. {
  881. btnMinusFolderAdd.Enabled = false;
  882. Minus minus = new Minus(Config.MinusConfig, Config.MinusOAuth2Info);
  883. MinusFolder dir = minus.CreateFolder(cboMinusFolders.Text, chkMinusPublic.Checked);
  884. if (dir != null)
  885. {
  886. cboMinusFolders.Items.Add(dir);
  887. cboMinusFolders.SelectedIndex = cboMinusFolders.Items.Count - 1;
  888. }
  889. btnMinusFolderAdd.Enabled = true;
  890. }
  891. }
  892. private void btnMinusFolderRemove_Click(object sender, EventArgs e)
  893. {
  894. if (!string.IsNullOrEmpty(cboMinusFolders.Text) && MinusHasFolder(cboMinusFolders.Text))
  895. {
  896. btnMinusFolderRemove.Enabled = false;
  897. Minus minus = new Minus(Config.MinusConfig, Config.MinusOAuth2Info);
  898. int index = cboMinusFolders.SelectedIndex;
  899. if (minus.DeleteFolder(index))
  900. {
  901. cboMinusFolders.Items.RemoveAt(index);
  902. if (cboMinusFolders.Items.Count > 0)
  903. {
  904. cboMinusFolders.SelectedIndex = 0;
  905. }
  906. }
  907. btnMinusFolderRemove.Enabled = true;
  908. }
  909. }
  910. private void btnMinusReadFolderList_Click(object sender, EventArgs e)
  911. {
  912. if (Config.MinusConfig != null)
  913. {
  914. btnMinusReadFolderList.Enabled = false;
  915. List<MinusFolder> tempListMf = new Minus(Config.MinusConfig, Config.MinusOAuth2Info).ReadFolderList();
  916. if (tempListMf.Count > 0)
  917. {
  918. cboMinusFolders.Items.Clear();
  919. cboMinusFolders.Items.AddRange(tempListMf.ToArray());
  920. cboMinusFolders.SelectedIndex = Config.MinusConfig.FolderID;
  921. }
  922. btnMinusReadFolderList.Enabled = true;
  923. }
  924. }
  925. private void cbMinusURLType_SelectedIndexChanged(object sender, EventArgs e)
  926. {
  927. if (Config.MinusConfig != null)
  928. {
  929. Config.MinusConfig.LinkType = (MinusLinkType)cbMinusURLType.SelectedIndex;
  930. }
  931. }
  932. #endregion Minus
  933. #region FTP
  934. private void cboFtpImages_SelectedIndexChanged(object sender, EventArgs e)
  935. {
  936. Config.FTPSelectedImage = cboFtpImages.SelectedIndex;
  937. }
  938. private void cboFtpText_SelectedIndexChanged(object sender, EventArgs e)
  939. {
  940. Config.FTPSelectedText = cboFtpText.SelectedIndex;
  941. }
  942. private void cboFtpFiles_SelectedIndexChanged(object sender, EventArgs e)
  943. {
  944. Config.FTPSelectedFile = cboFtpFiles.SelectedIndex;
  945. }
  946. private void btnFtpClient_Click(object sender, EventArgs e)
  947. {
  948. FTPOpenClient();
  949. }
  950. private object eiFTP_ExportRequested()
  951. {
  952. return GetSelectedFTPAccount();
  953. }
  954. private void eiFTP_ImportRequested(object obj)
  955. {
  956. AddFTPAccount(obj as FTPAccount);
  957. }
  958. private void FTPSetup(IEnumerable<FTPAccount> accs)
  959. {
  960. if (accs != null)
  961. {
  962. int selFtpList = ucFTPAccounts.lbAccounts.SelectedIndex;
  963. ucFTPAccounts.lbAccounts.Items.Clear();
  964. ucFTPAccounts.pgSettings.PropertySort = PropertySort.Categorized;
  965. cboFtpImages.Items.Clear();
  966. cboFtpText.Items.Clear();
  967. cboFtpFiles.Items.Clear();
  968. Config.FTPAccountList = new List<FTPAccount>();
  969. Config.FTPAccountList.AddRange(accs);
  970. foreach (FTPAccount acc in Config.FTPAccountList)
  971. {
  972. ucFTPAccounts.lbAccounts.Items.Add(acc);
  973. cboFtpImages.Items.Add(acc);
  974. cboFtpText.Items.Add(acc);
  975. cboFtpFiles.Items.Add(acc);
  976. }
  977. if (ucFTPAccounts.lbAccounts.Items.Count > 0)
  978. {
  979. ucFTPAccounts.lbAccounts.SelectedIndex = selFtpList.Between(0, ucFTPAccounts.lbAccounts.Items.Count - 1);
  980. cboFtpImages.SelectedIndex = Config.FTPSelectedImage.Between(0, ucFTPAccounts.lbAccounts.Items.Count - 1);
  981. cboFtpText.SelectedIndex = Config.FTPSelectedText.Between(0, ucFTPAccounts.lbAccounts.Items.Count - 1);
  982. cboFtpFiles.SelectedIndex = Config.FTPSelectedFile.Between(0, ucFTPAccounts.lbAccounts.Items.Count - 1);
  983. }
  984. }
  985. }
  986. private void FTPAccountAddButton_Click(object sender, EventArgs e)
  987. {
  988. AddFTPAccount(new FTPAccount());
  989. }
  990. private void FTPAccountRemoveButton_Click(object sender, EventArgs e)
  991. {
  992. int sel = ucFTPAccounts.lbAccounts.SelectedIndex;
  993. if (ucFTPAccounts.RemoveItem(sel))
  994. {
  995. Config.FTPAccountList.RemoveAt(sel);
  996. }
  997. FTPSetup(Config.FTPAccountList);
  998. }
  999. private void FTPAccountDuplicateButton_Click(object sender, EventArgs e)
  1000. {
  1001. FTPAccount src = (FTPAccount)ucFTPAccounts.lbAccounts.Items[ucFTPAccounts.lbAccounts.SelectedIndex];
  1002. FTPAccount clone = (FTPAccount)src.Clone();
  1003. AddFTPAccount(clone);
  1004. }
  1005. private void FTPAccountTestButton_Click(object sender, EventArgs e)
  1006. {
  1007. TestFTPAccountAsync(GetSelectedFTPAccount());
  1008. }
  1009. private void FtpAccountSettingsGrid_PropertyValueChanged(object s, PropertyValueChangedEventArgs e)
  1010. {
  1011. FTPSetup(Config.FTPAccountList);
  1012. }
  1013. #endregion FTP
  1014. #region Email
  1015. private void txtSmtpServer_TextChanged(object sender, EventArgs e)
  1016. {
  1017. Config.EmailSmtpServer = txtEmailSmtpServer.Text;
  1018. }
  1019. private void nudSmtpPort_ValueChanged(object sender, EventArgs e)
  1020. {
  1021. Config.EmailSmtpPort = (int)nudEmailSmtpPort.Value;
  1022. }
  1023. private void txtEmail_TextChanged(object sender, EventArgs e)
  1024. {
  1025. Config.EmailFrom = txtEmailFrom.Text;
  1026. }
  1027. private void txtPassword_TextChanged(object sender, EventArgs e)
  1028. {
  1029. Config.EmailPassword = txtEmailPassword.Text;
  1030. }
  1031. private void chkEmailConfirm_CheckedChanged(object sender, EventArgs e)
  1032. {
  1033. Config.EmailConfirmSend = chkEmailConfirm.Checked;
  1034. }
  1035. private void cbRememberLastToEmail_CheckedChanged(object sender, EventArgs e)
  1036. {
  1037. Config.EmailRememberLastTo = cbEmailRememberLastTo.Checked;
  1038. }
  1039. private void txtDefaultSubject_TextChanged(object sender, EventArgs e)
  1040. {
  1041. Config.EmailDefaultSubject = txtEmailDefaultSubject.Text;
  1042. }
  1043. private void txtDefaultBody_TextChanged(object sender, EventArgs e)
  1044. {
  1045. Config.EmailDefaultBody = txtEmailDefaultBody.Text;
  1046. }
  1047. #endregion Email
  1048. #region RapidShare
  1049. private void txtRapidShareUsername_TextChanged(object sender, EventArgs e)
  1050. {
  1051. Config.RapidShareUsername = txtRapidShareUsername.Text;
  1052. }
  1053. private void txtRapidSharePassword_TextChanged(object sender, EventArgs e)
  1054. {
  1055. Config.RapidSharePassword = txtRapidSharePassword.Text;
  1056. }
  1057. private void txtRapidShareFolderID_TextChanged(object sender, EventArgs e)
  1058. {
  1059. Config.RapidShareFolderID = txtRapidShareFolderID.Text;
  1060. }
  1061. private void btnRapidShareRefreshFolders_Click(object sender, EventArgs e)
  1062. {
  1063. if (string.IsNullOrEmpty(Config.RapidShareUsername) || string.IsNullOrEmpty(Config.RapidSharePassword))
  1064. {
  1065. MessageBox.Show("RapidShare account username or password is empty.", "RapidShare refresh folders list failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
  1066. }
  1067. else
  1068. {
  1069. tvRapidShareFolders.Nodes.Clear();
  1070. RapidShareFolderInfo root = new RapidShare(Config.RapidShareUsername, Config.RapidSharePassword).GetRootFolderWithChilds();
  1071. RapidShareRecursiveAddChilds(tvRapidShareFolders.Nodes, root);
  1072. tvRapidShareFolders.ExpandAll();
  1073. }
  1074. }
  1075. private void RapidShareRecursiveAddChilds(TreeNodeCollection treeNodes, RapidShareFolderInfo folderInfo)
  1076. {
  1077. TreeNode treeNode = treeNodes.Add(folderInfo.FolderName);
  1078. treeNode.Tag = folderInfo;
  1079. foreach (RapidShareFolderInfo folderInfo2 in folderInfo.ChildFolders)
  1080. {
  1081. RapidShareRecursiveAddChilds(treeNode.Nodes, folderInfo2);
  1082. }
  1083. }
  1084. private void tvRapidShareFolders_AfterSelect(object sender, TreeViewEventArgs e)
  1085. {
  1086. if (e.Node != null && e.Node.Tag is RapidShareFolderInfo)
  1087. {
  1088. RapidShareFolderInfo folderInfo = (RapidShareFolderInfo)e.Node.Tag;
  1089. txtRapidShareFolderID.Text = folderInfo.RealFolderID;
  1090. }
  1091. }
  1092. #endregion RapidShare
  1093. #region SendSpace
  1094. private void atcSendSpaceAccountType_AccountTypeChanged(AccountType accountType)
  1095. {
  1096. Config.SendSpaceAccountType = accountType;
  1097. }
  1098. private void btnSendSpaceRegister_Click(object sender, EventArgs e)
  1099. {
  1100. using (UserPassBox upb = SendSpaceRegister())
  1101. {
  1102. if (upb.Success)
  1103. {
  1104. txtSendSpaceUserName.Text = upb.UserName;
  1105. txtSendSpacePassword.Text = upb.Password;
  1106. atcSendSpaceAccountType.SelectedAccountType = AccountType.User;
  1107. }
  1108. }
  1109. }
  1110. private void txtSendSpaceUserName_TextChanged(object sender, EventArgs e)
  1111. {
  1112. Config.SendSpaceUsername = txtSendSpaceUserName.Text;
  1113. }
  1114. private void txtSendSpacePassword_TextChanged(object sender, EventArgs e)
  1115. {
  1116. Config.SendSpacePassword = txtSendSpacePassword.Text;
  1117. }
  1118. #endregion SendSpace
  1119. #region Ge.tt
  1120. private void btnGe_ttLogin_Click(object sender, EventArgs e)
  1121. {
  1122. Ge_ttLogin();
  1123. }
  1124. #endregion Ge.tt
  1125. #region Localhostr
  1126. private void txtLocalhostrEmail_TextChanged(object sender, EventArgs e)
  1127. {
  1128. Config.LocalhostrEmail = txtLocalhostrEmail.Text;
  1129. }
  1130. private void txtLocalhostrPassword_TextChanged(object sender, EventArgs e)
  1131. {
  1132. Config.LocalhostrPassword = txtLocalhost

Large files files are truncated, but you can click here to view the full file