private void NewPartnerFormClick(object sender, RoutedEventArgs e) { if (DataContext is PartnersVM) { PartnersVM partnersVM = DataContext as PartnersVM; if (partnersVM != null) { PartnerFormVM partnerForm = new PartnerFormVM { ChosenPartner = new Partner(), IsEdit = false }; PartnerFormWindow formWindow = new PartnerFormWindow { DataContext = partnerForm }; partnerForm.ValuesTransmission(); formWindow.ShowDialog(); partnersVM.RefreshList(); } } else { ContactsVM contactsVM = DataContext as ContactsVM; if (contactsVM != null) { ContactFormVM contactForm = new ContactFormVM { ChosenContact = new Contact(), IsEdit = false }; ContactFormWindow formWindow = new ContactFormWindow { DataContext = contactForm }; formWindow.ShowDialog(); contactsVM.RefreshList(); } } }
private void ListBoxDrop(object sender, DragEventArgs e) { if (e.Data.GetDataPresent(DataFormats.FileDrop)) { var formVM = DataContext as PartnerFormVM; formVM.DropFiles = (string[])e.Data.GetData(DataFormats.FileDrop); try { FileOperations.FileFormatValidate(formVM.DropFiles); } catch (FileFormatException) { MessageBox.Show("Nem megfelelő fájlformátum!"); return; } foreach (var file in formVM.DropFiles) { var fileCutting = FileOperations.FileCutting(file); foreach (var item in fileCutting) { var cformVm = new ContactFormVM(); var window = new ContactFormWindow() { DataContext = cformVm }; FileOperations.ProcessingVcardPeople(item, cformVm.ChosenContact = new Contact()); window.ShowDialog(); } } } }
private void PartnerFormClick(object sender, MouseButtonEventArgs e) { if (DataContext is PartnersVM) { PartnersVM partnersVM = DataContext as PartnersVM; if (partnersVM != null && partnersVM.SelectedPartner != null) { PartnerFormVM partnerForm = new PartnerFormVM { ChosenPartner = partnersVM.SelectedPartner, IsEdit = true }; PartnerFormWindow formWindow = new PartnerFormWindow { DataContext = partnerForm }; partnerForm.ValuesTransmission(); formWindow.ShowDialog(); } } else { ContactsVM contactsVM = DataContext as ContactsVM; if (contactsVM != null && contactsVM.SelectedPartner != null && contactsVM.IsPartnerAdd != null) { contactsVM.AddContact(); contactsVM.PartnersList.Remove(contactsVM.SelectedPartner); return; } if (contactsVM != null && contactsVM.SelectedPartner != null) { ContactFormVM contactForm = new ContactFormVM { ChosenContact = contactsVM.SelectedPartner, IsEdit = true }; ContactFormWindow formWindow = new ContactFormWindow { DataContext = contactForm }; contactForm.CopyContact(); formWindow.ShowDialog(); } } }