Beispiel #1
0
        /// <summary>
        /// Клик кнопки Добавление новой закачки
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void AddDownload(object sender, EventArgs e)
        {
            bool flagD=true;
            int countDownload=0;
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                if (dataGridView1["ColumnLoad", i].Value.ToString() == "Загружается")
                {
                    countDownload++;
                }
            }
            if (countDownload >= Properties.Settings.Default.numFileDownload)
                flagD = false;
            if (flagD)
            {
                AddDownloadForm form = new AddDownloadForm();
                if (form.ShowDialog() == DialogResult.OK)
                {
                    RowGrid download = new RowGrid(form.Uri, form.FileName);
                    download.State = StateDownload.Created;
                    download.Size = 0;
                    download.BytesDownload = 0;
                    downloaders.Add(download);
                    AddDownloadItem(download, true);

                    client.SignalServerDownload(form.Uri.ToString());

                }
            }
            else
            {
                MessageBox.Show("Превышено число возможных загрузок на сервер.");
            }
        }
Beispiel #2
0
 /// <summary>
 /// Создает загрузку и добавляет его в таблицу
 /// </summary>
 /// <param name="download"></param>
 void AddDownloadItem(RowGrid download, bool selectAddedRow)
 {
     int rowIndex = dataGridView1.Rows.Add(new DataGridViewRow());
     dataGridView1["ColumnURI", rowIndex].Value = download.Uri.AbsoluteUri;
     dataGridView1["ColumnNameFile", rowIndex].Value = download.FileName;
     dataGridView1["ColumnSize", rowIndex].Value =GetFormattingSize(download.Size)+" "+GetFormattingSize(download.BytesDownload);
     dataGridView1["ColumnLocation", rowIndex].Value = download.Location;
     dataGridView1["ColumnLoad", rowIndex].Value = download.NameState(download.State);
 }
Beispiel #3
0
        public static RowGrid FromXml(XmlReader reader)
        {
            RowGrid result = new RowGrid();

                reader.ReadStartElement("download");

                if (reader.Name != "uri") throw new FormatException();
                result.Uri = new Uri(reader.ReadString());
                reader.Read();
                if (reader.Name != "namefile") throw new FormatException();
                result.FileName = reader.ReadString();
                reader.Read();
                if (reader.Name != "filePath") throw new FormatException();
                result.Location = reader.ReadString();
                reader.Read();
                if (reader.Name != "size") throw new FormatException();
                result.Size = long.Parse(reader.ReadString());
                reader.Read();
                if (reader.Name != "bytesDownload") throw new FormatException();
                result.BytesDownload = Int64.Parse(reader.ReadString());
                reader.Read();
                if (reader.Name != "downloadState") throw new FormatException();
                result.State = (StateDownload)(Convert.ToInt32(reader.ReadString()));

                reader.ReadEndElement();
                return result;
        }