Beispiel #1
0
        /// <summary>
        /// Initialize a new empty instance of the <c>Graphmatic.Interaction.Plotting.Graph</c> class from serialized XML data.
        /// </summary>
        /// <param name="xml">The XML data to use for deserializing this Resource.</param>
        public Graph(XElement xml)
        {
            UnresolvedResources = new Dictionary <Guid, PlottableParameters>();
            Resources           = new Dictionary <IPlottable, PlottableParameters>();
            Parameters          = new GraphParameters(xml.Element("GraphParameters"));
            XElement contents = xml.Element("Content");

            foreach (XElement content in contents.Elements())
            {
                XElement plottable = content.Elements()
                                     .Where(x => x.Name != "PlottableParameters")
                                     .First();
                PlottableParameters parameters = new PlottableParameters(content.Element("PlottableParameters"));
                if (plottable.Name == "Reference")
                {
                    UnresolvedResources.Add(Guid.Parse(plottable.Attribute("ID").Value), parameters);
                }
                else
                {
                    IPlottable resource = plottable.Deserialize <IPlottable>();
                    Resources.Add(resource, parameters);
                    if (resource is GraphKey)
                    {
                        Key = resource as GraphKey;
                    }
                    else if (resource is GraphAxis)
                    {
                        Axes = resource as GraphAxis;
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// Initialize a new empty instance of the <c>Graphmatic.Interaction.Plotting.Graph</c> class with the given parameter set.
 /// </summary>
 /// <param name="graphParameters">The parameters to use for plotting the graph.</param>
 public Graph(GraphParameters graphParameters)
 {
     Parameters = graphParameters;
     Resources  = new Dictionary <IPlottable, PlottableParameters>();
     Axes       = new GraphAxis(1, 5);
     Key        = new GraphKey();
     Resources.Add(Axes, new PlottableParameters()
     {
         PlotColor = Properties.Settings.Default.DefaultGraphFeatureColor
     });
     Resources.Add(Key, new PlottableParameters()
     {
         PlotColor = Properties.Settings.Default.DefaultGraphFeatureColor
     });
 }