Example #1
0
        protected virtual bool ExportChartsToFolder(Document document, IEnumerable <ChartPage> charts, string directory)
        {
            if (document == null || charts.IsNullOrEmpty())
            {
                return(false);
            }

            if (!OptionsInitalizated && !GetOptions())
            {
                return(false);
            }

            var  ext     = DocumentType.DefaultExtension;
            var  files   = new List <string>();
            bool success = false;

            foreach (var c in charts)
            {
                string filename = ST.EscapeFileName(c.Name);
                int    index    = 1;
                while (files.Contains(filename))
                {
                    filename = ST.EscapeFileName(c.Name) + index.ToString();
                    index++;
                }

                filename = Path.Combine(directory, filename + ext);
                success |= ExportChartToFile(document, c, filename);
            }

            return(success);
        }
Example #2
0
        public void Save(ChartThemeFolder folder, string directory)
        {
            foreach (ChartThemeFolder subFolder in folder.Folders)
            {
                Save(subFolder, Path.Combine(directory, ST.EscapeFileName(subFolder.Name)));
            }

            foreach (ChartTheme theme in folder.Themes)
            {
                string filename = Path.Combine(directory, GetThemeFilename(theme.Name));

                if (!string.IsNullOrEmpty(theme.Filename) && !StringComparer.OrdinalIgnoreCase.Equals(filename, theme.Filename))
                {
                    try
                    {
                        File.Delete(theme.Filename);
                    }
                    catch (System.Exception ex)
                    {
                        Helper.WriteLog(ex);
                    }
                }

                SaveTheme(theme, filename);
            }
        }
Example #3
0
        public virtual void Export(Document document, IEnumerable <ChartPage> charts)
        {
            if (document == null || charts == null)
            {
                throw new ArgumentNullException();
            }

            if (charts.IsEmpty())
            {
                return;
            }

            var documentType = DocumentType;

            if (documentType == null)
            {
                return;
            }

            if (charts.Count() > 1 && !SupportMultiCharts)
            {
                var dialog = new FolderBrowserDialog();
                dialog.Description = Lang.GetText("Select a folder to export charts");
                if (dialog.ShowDialog(Program.MainForm) == DialogResult.OK)
                {
                    ExportChartsToFolder(document, charts, dialog.SelectedPath);
                }
            }
            else
            {
                var dialog = new SaveFileDialog();
                dialog.Filter     = documentType.FileDialogFilter;
                dialog.DefaultExt = documentType.DefaultExtension;
                dialog.Title      = Lang.GetText("Export");
                dialog.FileName   = ST.EscapeFileName(document.Name);
                if (dialog.ShowDialog(Program.MainForm) == DialogResult.OK)
                {
                    if (ExportChartsToFile(document, charts, dialog.FileName))
                    {
                        var fld = new FileLocationDialog(dialog.FileName, dialog.FileName);
                        fld.Text = Lang.GetText("Export Success");
                        fld.ShowDialog(Program.MainForm);
                    }
                }
            }
        }
Example #4
0
 public static string GetThemeFilename(string directory, string themeName)
 {
     return(Path.Combine(directory, ST.EscapeFileName(string.Format("{0}.xml", themeName))));
 }