public override void Activate() { // Reset. View.FilePicture.ImageLocation = "Icons\\spinner.gif"; View.FilePicture.SizeMode = PictureBoxSizeMode.CenterImage; View.FilePicture.Visible = false; _userAccount = ((FormMain)MainForm).UserSession; _file = Values.SafeGetValue <File>("File"); string ext = Path.GetExtension(_file.Name); View.TextBoxTitel.Text = _file.Name; View.TextBoxOmschrijving.Text = _file.Description; View.LabelDescription.Text = _file.Description; if (new[] { ".png", ".jpg", ".gif" }.Contains(ext)) { View.FilePicture.Visible = true; DownloadPhoto(); } FillCommentSection(); CalculateScore(); }
public ControllerAddFile() { View.ButtonUploadFile.Click += (sender, args) => { var ofd = new OpenFileDialog(); ofd.Filter = "Media bestanden | *.png; *.jpg; *.gif; *.mp4; *.wmv; *.mp3; *.wav; *.aac"; DialogResult result = ofd.ShowDialog(); if (result == DialogResult.OK) { _filePath = ofd.FileName.ToLower(); View.TextBoxFilePath.Text = _filePath; } }; View.ButtonCancel.Click += (sender, args) => { Close(); }; View.ButtonSave.Click += (sender, args) => { if (!String.IsNullOrEmpty(View.TextBoxDescription.Text) && !String.IsNullOrEmpty(View.TextBoxFilePath.Text)) { var selectedNode = Values.SafeGetValue <TreeNode>("selectedNode"); IEnumerable <string> directoryNames = FileTransfer.GetDirectoryNames(selectedNode); FileTransfer.UploadFile(_filePath, directoryNames); // Insert file into database. var file = new File(); file.Name = Path.GetFileName(_filePath); file.PostTime = DateTime.Now; file.ReportCount = 0; file.CategoryId = (int)selectedNode.Tag; file.Description = View.TextBoxDescription.Text; // TODO: Use user session. #if DEBUG file.UserAccountId = 1; #else file.UserAccountId = _userAccount.Id; #endif file.Insert(); Close(); } else { MessageBox.Show("Vul alstublieft beide velden in."); } }; }
private void FillFileFlowPanel(int id) { View.CategoryFiles.FileFlowLayout.Controls.Clear(); IEnumerable <File> files = File.Select("CATEGORYID = " + id.ToSqlFormat()); foreach (File file in files) { var pt = new PanelTile(file.Name, file.Description); pt.Tag = file; pt.pictureBox1.ImageLocation = setFileImage(file.Name); pt.pictureBox1.Click += pt_Click; View.CategoryFiles.FileFlowLayout.Controls.Add(pt); } }