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

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

editing local data v0

File size: 4.3 KB
RevLine 
[12256]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();
[12336]19            selectedPwgAlbumListBindingSource.DataSource = ModelManager.Instance.lstCat;
[12262]20            modelManagerBaseBindingSource.DataSource = ModelManager.Instance;
[12407]21            localAlbumBindingSource.DataSource = ModelManager.Instance.AlbumEdited;
22            localImageBindingSource.DataSource = ModelManager.Instance.ImageEdited;
[12256]23        }
24
[12262]25        private void MainForm_Load(object sender, EventArgs e)
[12256]26        {
27            string[] args = Environment.GetCommandLineArgs();
28
29            foreach (string arg in args)
30            {
31                if (Directory.Exists(arg))
32                {
33                    try
34                    {
35                        ModelManager.Instance.directoryName = arg;
36                        ServiceFactory.GetByType<LoadFromDirectory>().runService();
37                    }
38                    catch (ApplicationException aex)
39                    {
40                        MainAppHelper.showdErrorMessageBox(aex);
41                    }
42                }                   
43            }
[12262]44
45            MainAppHelper.BuildAlbumTree(AlbumsTV, ModelManager.Instance.lstAlbumLocaux);
46
[12256]47        }
48
49
50        private void Connect_Click(object sender, EventArgs e)
51        {
52            try
53            {
54                String strUri= tbServer.Text.Replace("\\","/");
[12262]55                if (!strUri.StartsWith("http"))
56                {
57                    strUri = "http://" + strUri;
58                }
[12256]59                if (!strUri.EndsWith("/ws.php"))
60                {
61                    if (!strUri.EndsWith("/"))
62                    {
63                        strUri += "/";
64                    }
65                    strUri += "ws.php";
66                }
67
68                Uri uriServeur;
69                if (Uri.TryCreate(strUri, UriKind.Absolute,out uriServeur))
70                {
71                    ModelManager.Instance.serveurName = uriServeur;
72                    ModelManager.Instance.userName = tbUser.Text;
73                    ModelManager.Instance.password = tbPassword.Text;
74
75                    ServiceFactory.GetByType<Connect>().runService();
76                }
77
78            }
79            catch (ApplicationException aex)
80            {
81                MainAppHelper.showdErrorMessageBox(aex);
82            }
83        }
84
85        private void Telecharger_Click(object sender, EventArgs e)
86        {
87            try
88            {
[12262]89                ServiceFactory.GetByType<UploadToPiwigo>().runService();
[12256]90            }
91            catch (ApplicationException aex)
92            {
93                MainAppHelper.showdErrorMessageBox(aex);
94            }
95        }
96
[12262]97        private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
[12256]98        {
99            try
100            {
[12336]101                if (ModelManager.Instance.isConnected)
102                {
103                    ServiceFactory.GetByType<Disconnect>().runService();
104                }
[12256]105            }
106            catch (ApplicationException aex)
107            {
108                MainAppHelper.showdErrorMessageBox(aex);
109            }
110        }
111
112        private void modelManagerBindingSource_CurrentChanged(object sender, EventArgs e)
113        {
114
[12407]115        }
116
117        private void AlbumsTV_AfterSelect(object sender, TreeViewEventArgs e)
118        {
119            if (e.Node.Tag is LocalAlbum)
120            {
121                ModelManager.Instance.AlbumEdited = (LocalAlbum)e.Node.Tag;
122                tabControl1.SelectedTab = tabPageAlbum;
123            }
124            else if (e.Node.Tag is LocalImage)
125            {
126                ModelManager.Instance.ImageEdited = (LocalImage)e.Node.Tag;
127                tabControl1.SelectedTab = tabPageImg;
128            }
129
130            System.Diagnostics.Debug.Print(label5.Visible.ToString());
131        }
132
133        private void selectedPwgAlbumListBindingSource_CurrentChanged(object sender, EventArgs e)
134        {
135
[12256]136        }       
137    }
138}
Note: See TracBrowser for help on using the repository browser.