public FormLocalFile(LocalFile localFile) { InitializeComponent(); this.localFile = localFile; textBoxFilename.Text = localFile.Filename; textBoxFilesize.Text = Filesize.ConvertByteToMegaByte(new FileInfo(localFile.Filename).Length).ToString() + " MB"; textBoxTitle.Text = localFile.Title; textBoxDescription.Text = localFile.Description; if (localFile.Privacy == Privacy.@private) { radioButtonPrivate.Checked = true; } else { radioButtonPublic.Checked = true; } // The default value for the ComboBox. comboBoxCategories.Items.Add(new ComboBoxItem("<Niet ingedeeld>", null)); comboBoxCategories.SelectedIndex = 0; // Fills the ComboBox with the categories correctly nested. foreach (Category category in Category.GetAll()) { if (category.ParentId < 1) { AddCategoryToComboboxRecursive(category, 0); } } }
private void buttonUploadAdd_Click(object sender, EventArgs e) { // Create an dialog which enabled the user to select multiple files to upload. OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Multiselect = true; if (fileDialog.ShowDialog() != DialogResult.OK) { return; } foreach (string fileName in fileDialog.FileNames) { LocalFile file = new LocalFile(fileName); // Checks if the file doesn't exceed the users upload limit. if (new FileInfo(file.Filename).Length + user.GetFilesizeCurrentlyUploaded() > user.UploadLimit) { MessageBox.Show( "Bestandsgrootte is te hoog. Verwijder een aantal bestanden en probeer het nogmaals a.u.b.."); } else { listViewUpload.Items.Add(new ListViewItemLocalFile(file)); } } RefreshInterfaceUpload(); }
/// <summary> /// Uploads the file to the FTP server, with the owner(user). /// </summary> /// <param name="localFile"></param> /// <param name="user"></param> public static void Upload(LocalFile localFile, User user) { FtpUpload.localFile = localFile; FtpUpload.user = user; backgroundWorker.RunWorkerAsync(); }
public ListViewItemLocalFile(LocalFile file) { LocalFile = file; Refresh(); }