/// <summary>
        /// Loads a graph from a file.
        /// </summary>
        private void LoadGraph()
        {
            string path = this.FileSelector.GetFileNameForOpening();

            if (!string.IsNullOrEmpty(path))
            {
                try
                {
                    var graph = GraphSerializer.ReadFromXmlFile(path);
                    this.GraphViewModel.Graph = graph;
                }
                catch (GraphSerializationException ex)
                {
                    Logger.Error("Loading graph form path '" + path + "' failed.", ex);
                    this.MessageHandler.ShowError(ex.Message);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Loads a graph from a file if path is supplied as argument.
        /// </summary>
        /// <returns><c>null</c> if no path is supplied, otherwise the graph.</returns>
        private static IGraph <NodeData, EdgeData> LoadGraph()
        {
            var path = Environment.GetCommandLineArgs().ElementAtOrDefault(1);

            if (string.IsNullOrEmpty(path) || !File.Exists(path))
            {
                return(null);
            }
            else
            {
                try
                {
                    var graph = GraphSerializer.ReadFromXmlFile(path);
                    Logger.Debug("Loaded graph from path: " + path);
                    return(graph);
                }
                catch (GraphSerializationException ex)
                {
                    Logger.Error("Loading graph form path '" + path + "' failed.", ex);
                    MessageBox.Show(ex.Message, Palmmedia.WpfGraph.UI.Properties.Resources.Error);
                    return(null);
                }
            }
        }