private void tsbExportCharts_Click(object sender, EventArgs e) { var chartsToExport = lvCharts.CheckedItems.Cast<ListViewItem>().Select(c => (Entity)c.Tag).ToList(); if (chartsToExport.Count > 0) { try { var cfbDialog = new CustomFolderBrowserDialog(false) { FolderPath = currentFolder }; if (cfbDialog.ShowDialog(ParentForm) == DialogResult.OK) { currentFolder = cfbDialog.FolderPath; foreach (var chart in chartsToExport) { var doc = new XDocument( new XElement("visualization", new XElement("visualizationid", chart.Id.ToString("B")), new XElement("name", chart.GetAttributeValue<string>("name")), new XElement("description", chart.GetAttributeValue<string>("description")), new XElement("primaryentitytypecode", chart.GetAttributeValue<string>("primaryentitytypecode")), new XElement("datadescription", XElement.Parse(chart.GetAttributeValue<string>("datadescription"))), new XElement("presentationdescription", XElement.Parse(chart.GetAttributeValue<string>("presentationdescription"))), new XElement("isdefault", chart.GetAttributeValue<bool>("isdefault")) )); doc.Save(Path.Combine(cfbDialog.FolderPath, chart.GetAttributeValue<string>("name") + ".xml")); } if (MessageBox.Show(ParentForm, "Would you like to open destination folder?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Process.Start(cfbDialog.FolderPath); } } } catch (Exception error) { MessageBox.Show(ParentForm, error.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void importChartsFromFolderToolStripMenuItem_Click(object sender, EventArgs e) { var cfbDialog = new CustomFolderBrowserDialog(true) {FolderPath = currentFolder}; if (cfbDialog.ShowDialog(ParentForm) == DialogResult.OK) { currentFolder = cfbDialog.FolderPath; ExecuteMethod(ProcessFiles, new DirectoryInfo(currentFolder).GetFiles("*.xml").Select(f => f.FullName).ToList()); } }