source: extensions/PiwigoLib/PiwigoUpload/MainForm.cs @ 12262

Last change on this file since 12262 was 12262, checked in by bayral, 13 years ago

piwigo.upload retrieve data, and ready to upload

File size: 3.3 KB
Line 
1using System;
2using System.Windows.Forms;
3
4using Com.Piwigo.Lib.DTO;
5using System.Collections.Generic;
6using Com.Piwigo.Uploader.DTO;
7using Com.Piwigo.Uploader.Service;
8using Com.Piwigo.Uploader.Helper;
9
10using System.IO;
11
12namespace Com.Piwigo.Uploader
13{
14    public partial class MainForm : Form
15    {
16        public MainForm()
17        {
18            InitializeComponent();
19            selectedPwgCategoryListBindingSource.DataSource = ModelManager.Instance.lstCat;
20            modelManagerBaseBindingSource.DataSource = ModelManager.Instance;
21        }
22
23        private void MainForm_Load(object sender, EventArgs e)
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            }
42
43            MainAppHelper.BuildAlbumTree(AlbumsTV, ModelManager.Instance.lstAlbumLocaux);
44
45        }
46
47
48        private void Connect_Click(object sender, EventArgs e)
49        {
50            try
51            {
52                String strUri= tbServer.Text.Replace("\\","/");
53                if (!strUri.StartsWith("http"))
54                {
55                    strUri = "http://" + strUri;
56                }
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            {
87                ServiceFactory.GetByType<UploadToPiwigo>().runService();
88            }
89            catch (ApplicationException aex)
90            {
91                MainAppHelper.showdErrorMessageBox(aex);
92            }
93        }
94
95        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
96        {
97            try
98            {
99                ServiceFactory.GetByType<Disconnect>().runService();
100            }
101            catch (ApplicationException aex)
102            {
103                MainAppHelper.showdErrorMessageBox(aex);
104            }
105        }
106
107        private void modelManagerBindingSource_CurrentChanged(object sender, EventArgs e)
108        {
109
110        }       
111    }
112}
Note: See TracBrowser for help on using the repository browser.