Esempio n. 1
0
        private static List <object> DoExportGraphs(MultiRenameData mrData)
        {
            var failedItems = new List <object>();
            var errors      = new StringBuilder();

            bool allPathsRooted = true;

            for (int i = 0; i < mrData.ObjectsToRenameCount; ++i)
            {
                var fileName = mrData.GetNewNameForObject(i);
                if (!System.IO.Path.IsPathRooted(fileName))
                {
                    allPathsRooted = false;
                    break;
                }
            }

            if (!allPathsRooted)
            {
                //Current.Gui.ShowFolderDialog();
                // http://wpfdialogs.codeplex.com/
            }

            for (int i = 0; i < mrData.ObjectsToRenameCount; ++i)
            {
                var graph    = (GraphDocumentBase)mrData.GetObjectToRename(i);
                var fileName = mrData.GetNewNameForObject(i);
                try
                {
                    DoExportGraph(graph, fileName, _graphExportOptionsToFile);
                }
                catch (Exception ex)
                {
                    failedItems.Add(graph);
                    errors.AppendFormat("Graph {0} -> file name {1}: export failed, {2}\n", graph.Name, fileName, ex.Message);
                }
            }

            if (errors.Length != 0)
            {
                Current.Gui.ErrorMessageBox(errors.ToString(), "Export failed for some items");
            }
            else
            {
                Current.Gui.InfoMessageBox(string.Format("{0} graphs successfully exported.", mrData.ObjectsToRenameCount));
            }

            return(failedItems);
        }