/// <summary> /// Attachment window closed /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OnChildWindowsClosed(object sender, EventArgs e) { AttachmentWindow attachmentWindow = sender as AttachmentWindow; int index = attachmentWindow.ChildWindowId; if (index >= 0 && index < _childWindows.Count) { // Already closed set it to null _childWindows[index] = null; // Enable save button IsSaved = false; } }
/// <summary> /// Attached an item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ListView_Drop(object sender, DragEventArgs e) { string[] droppedFiles = (string[])e.Data.GetData(DataFormats.FileDrop); if (droppedFiles.Length > 0) { // Something is changed IsSaved = false; } foreach (string path in droppedFiles) { string fullFilename = GetFileName(path); string filename = GetFileNameWithoutExt(path); string extension = GetExtension(path); if (String.Compare(extension, ".jpg", true) != 0) { ShowMessageBox("Sorry\nYou dropped " + fullFilename + "\nWe only accept \".jpg\" files right now"); continue; } // Create a new object and added to the list AttachmentInfo attachment = new AttachmentInfo(); attachment.Path = path; attachment.Filename = filename; attachment.Extension = extension; // Preview the image AttachmentWindow attWindow = new AttachmentWindow(attachment); attWindow.ShowDialog(); _personalInfo.AddAttachment(attachment); // Add child window _childWindows.Add(null); } }
/// <summary> /// Attachment clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ItemDoubleClicked(object sender, MouseButtonEventArgs e) { // Selected index int index = Attachments_ListView.SelectedIndex; if (index != -1) { // Get the corresponding item AttachmentInfo attachmentInfo = Attachments_ListView.Items.GetItemAt(index) as AttachmentInfo; // Bring up attachment window if (_childWindows[index] == null) { _childWindows[index] = new AttachmentWindow(_dataVaultInterface, attachmentInfo, index); _childWindows[index].Closed += OnChildWindowsClosed; _childWindows[index].Show(); } else { // Bring up the window _childWindows[index].Focus(); } } }