Beispiel #1
0
        public MainProgram()
        {
            tm = new TransmissionManager();
            transmission = tm.DefaultTransmission;
            exeDirectory = Path.GetDirectoryName(Application.ExecutablePath);
            dataDirectory = Path.Combine(exeDirectory, "data");

            canExit = false;
            isExiting = false;

            web = transmission.Crawler;

            if(!web.Internet())
            {
                MessageBox.Show("Per usare questo programma devi essere connesso ad Internet.", "Errore", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
                return;
            }

            sw = new ExternalSoftware(transmission.MplayerEndsWithError);

            var appData = Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
            configDirectory = Path.Combine(appData, "la_storia_in_giallo");
            if (!Directory.Exists(configDirectory)) Directory.CreateDirectory(configDirectory);

            Text = "La storia in giallo";
            Font = new Font("Tahoma", 8);
            StartPosition = FormStartPosition.CenterScreen;
            ClientSize = new Size(400, 600);
            Icon = new Icon(Path.Combine(dataDirectory, "icon.ico"));
            FormClosing += CheckClosing;

            // Top
            lbTrasmission = new Label();
            lbTrasmission.Text = "Trasmissione";
            Controls.Add(lbTrasmission);

            cbTrasmission = new ComboBox();
            foreach (string t in tm.TransmissionNames) cbTrasmission.Items.Add(t);
            cbTrasmission.DropDownStyle = ComboBoxStyle.DropDownList;
            cbTrasmission.SelectedValueChanged += delegate { ChangeTransmission(); };
            Controls.Add(cbTrasmission);

            lbSearch = new Label();
            lbSearch.Text = "Cerca titolo";
            Controls.Add(lbSearch);

            txSearch = new TextBox();
            txSearch.TextChanged += delegate { SearchEpisode(); };
            txSearchBackground = txSearch.BackColor;
            Controls.Add(txSearch);

            // Middle
            lsEpisodes = new ListBox();
            Controls.Add(lsEpisodes);

            Resize += delegate { ResizeControls(); };

            // Bottom
            btDownload = new Button();
            btDownload.Text = "Scarica in formato MP3";
            btDownload.Font = new Font("Times New Roman", 12, FontStyle.Bold | FontStyle.Italic);
            btDownload.Click += delegate { new Thread(new ThreadStart(DownloadEpisode)).Start(); };
            Controls.Add(btDownload);

            // Bottom (continues...)
            lbDownload = new Label();
            lbDownload.Text = "Scaricamento";
            Controls.Add(lbDownload);

            pgDownload = new ProgressBar();
            pgDownload.Style = ProgressBarStyle.Continuous;
            pgDownload.Minimum = 0;
            pgDownload.Maximum = 100;
            Controls.Add(pgDownload);

            lbConvert = new Label();
            lbConvert.Text = "Conversione in MP3";
            Controls.Add(lbConvert);

            pgConvert = new ProgressBar();
            pgConvert.Style = ProgressBarStyle.Continuous;
            pgConvert.Minimum = 0;
            pgConvert.Maximum = 100;
            Controls.Add(pgConvert);

            ResizeControls();
            EnableControls(true);

            // Initializes with the default radio program
            cbTrasmission.SelectedItem = "La Storia in Giallo";
        }