[12256] | 1 | using System; |
---|
| 2 | using System.Windows.Forms; |
---|
| 3 | |
---|
| 4 | using Com.Piwigo.Lib.DTO; |
---|
| 5 | using System.Collections.Generic; |
---|
| 6 | using Com.Piwigo.Uploader.DTO; |
---|
| 7 | using Com.Piwigo.Uploader.Service; |
---|
| 8 | using Com.Piwigo.Uploader.Helper; |
---|
| 9 | |
---|
| 10 | using System.IO; |
---|
| 11 | |
---|
| 12 | namespace Com.Piwigo.Uploader |
---|
| 13 | { |
---|
| 14 | public partial class MainForm : Form |
---|
| 15 | { |
---|
| 16 | public MainForm() |
---|
| 17 | { |
---|
| 18 | InitializeComponent(); |
---|
[12336] | 19 | selectedPwgAlbumListBindingSource.DataSource = ModelManager.Instance.lstCat; |
---|
[12262] | 20 | modelManagerBaseBindingSource.DataSource = ModelManager.Instance; |
---|
[12256] | 21 | } |
---|
| 22 | |
---|
[12262] | 23 | private void MainForm_Load(object sender, EventArgs e) |
---|
[12256] | 24 | { |
---|
| 25 | string[] args = Environment.GetCommandLineArgs(); |
---|
| 26 | |
---|
| 27 | foreach (string arg in args) |
---|
| 28 | { |
---|
| 29 | if (Directory.Exists(arg)) |
---|
| 30 | { |
---|
| 31 | try |
---|
| 32 | { |
---|
| 33 | ModelManager.Instance.directoryName = arg; |
---|
| 34 | ServiceFactory.GetByType<LoadFromDirectory>().runService(); |
---|
| 35 | } |
---|
| 36 | catch (ApplicationException aex) |
---|
| 37 | { |
---|
| 38 | MainAppHelper.showdErrorMessageBox(aex); |
---|
| 39 | } |
---|
| 40 | } |
---|
| 41 | } |
---|
[12262] | 42 | |
---|
| 43 | MainAppHelper.BuildAlbumTree(AlbumsTV, ModelManager.Instance.lstAlbumLocaux); |
---|
| 44 | |
---|
[12256] | 45 | } |
---|
| 46 | |
---|
| 47 | |
---|
| 48 | private void Connect_Click(object sender, EventArgs e) |
---|
| 49 | { |
---|
| 50 | try |
---|
| 51 | { |
---|
| 52 | String strUri= tbServer.Text.Replace("\\","/"); |
---|
[12262] | 53 | if (!strUri.StartsWith("http")) |
---|
| 54 | { |
---|
| 55 | strUri = "http://" + strUri; |
---|
| 56 | } |
---|
[12256] | 57 | if (!strUri.EndsWith("/ws.php")) |
---|
| 58 | { |
---|
| 59 | if (!strUri.EndsWith("/")) |
---|
| 60 | { |
---|
| 61 | strUri += "/"; |
---|
| 62 | } |
---|
| 63 | strUri += "ws.php"; |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | Uri uriServeur; |
---|
| 67 | if (Uri.TryCreate(strUri, UriKind.Absolute,out uriServeur)) |
---|
| 68 | { |
---|
| 69 | ModelManager.Instance.serveurName = uriServeur; |
---|
| 70 | ModelManager.Instance.userName = tbUser.Text; |
---|
| 71 | ModelManager.Instance.password = tbPassword.Text; |
---|
| 72 | |
---|
| 73 | ServiceFactory.GetByType<Connect>().runService(); |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | } |
---|
| 77 | catch (ApplicationException aex) |
---|
| 78 | { |
---|
| 79 | MainAppHelper.showdErrorMessageBox(aex); |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | |
---|
| 83 | private void Telecharger_Click(object sender, EventArgs e) |
---|
| 84 | { |
---|
| 85 | try |
---|
| 86 | { |
---|
[12262] | 87 | ServiceFactory.GetByType<UploadToPiwigo>().runService(); |
---|
[12256] | 88 | } |
---|
| 89 | catch (ApplicationException aex) |
---|
| 90 | { |
---|
| 91 | MainAppHelper.showdErrorMessageBox(aex); |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | |
---|
[12262] | 95 | private void MainForm_FormClosing(object sender, FormClosingEventArgs e) |
---|
[12256] | 96 | { |
---|
| 97 | try |
---|
| 98 | { |
---|
[12336] | 99 | if (ModelManager.Instance.isConnected) |
---|
| 100 | { |
---|
| 101 | ServiceFactory.GetByType<Disconnect>().runService(); |
---|
| 102 | } |
---|
[12256] | 103 | } |
---|
| 104 | catch (ApplicationException aex) |
---|
| 105 | { |
---|
| 106 | MainAppHelper.showdErrorMessageBox(aex); |
---|
| 107 | } |
---|
| 108 | } |
---|
| 109 | |
---|
| 110 | private void modelManagerBindingSource_CurrentChanged(object sender, EventArgs e) |
---|
| 111 | { |
---|
| 112 | |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | } |
---|