private void btnDeleteSource_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var item = view.GetFocusedRow() as BibliographySource; if (item.IsNotNullOrMissing()) { Microsoft.Office.Interop.Word.Source src = null; foreach (Microsoft.Office.Interop.Word.Source source in Document.Bibliography.Sources) { if (source.Tag == item.Tag) { src = source; break; } } if (src != null) { if (XtraMessageBox.Show($"Czy usunąć źródło '{item.Title}'?", "WBST Bibliografia", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes) { src.Delete(); LoadBibliography(); } } } }
private void btnEditSource_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var item = view.GetFocusedRow() as BibliographySource; if (item.IsNotNullOrMissing()) { using (var dlg = new SourceForm(item, grid.DataSource as List <BibliographySource>)) { if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK) { dlg.Save(); Microsoft.Office.Interop.Word.Source src = null; foreach (Microsoft.Office.Interop.Word.Source source in Document.Bibliography.Sources) { if (source.Tag == dlg.Source.Tag) { src = source; break; } } if (src != null) { var xml = GetXml(dlg.Source); src.Delete(); Document.Bibliography.Sources.Add(xml.Trim()); LoadBibliography(); } } } } }