private void ApplyXmlModel(XmlModel xmlModel)
        {
            if (CircleDiagramModel == null ||
                !CircleDiagramModel.IsCorrect() ||
                xmlModel == null)
            {
                return;
            }

            var countLevels        = xmlModel.CountLevels;
            var mainBackground     = SerializeUtils.IntToBrush(xmlModel.MainBackgroundColor);
            var ringBackground     = SerializeUtils.IntToBrush(xmlModel.RingBackgroundColor);
            var intervalBackground = SerializeUtils.IntToBrush(xmlModel.IntervalBackgroundColor);
            var nodeBorder         = new Pen(SerializeUtils.IntToColor(xmlModel.NodeBorderColor),
                                             xmlModel.NodeBorderThickness);
            var ringBorder = new Pen(SerializeUtils.IntToColor(xmlModel.RingBorderColor),
                                     xmlModel.RingBorderThickness);
            var relationshipPen = new Pen(SerializeUtils.IntToColor(xmlModel.RelationshipPenColor),
                                          xmlModel.RelationshipPenThickness);
            var numerationBrush       = SerializeUtils.IntToBrush(xmlModel.NumerationColor);
            var numerationFont        = SerializeUtils.StringToFont(xmlModel.NumerationFont);
            var numerationBeginNumber = xmlModel.NumerationBeginNumber;
            var numerationIsInverted  = xmlModel.NumerationIsInverted;
            var nodes = xmlModel.Nodes
                        .Select(GetCircleDiagramNode)
                        .Where(g => g != null).ToList();
            var relationships = xmlModel.Relationships
                                .Select(g => GetCircleDiagramRelationship(g, nodes))
                                .Where(g => g != null).ToList();

            CircleDiagramModel.ChangeParametersValues(countLevels, mainBackground, ringBackground,
                                                      intervalBackground, nodeBorder, ringBorder, relationshipPen,
                                                      numerationBrush, numerationFont, numerationBeginNumber, numerationIsInverted,
                                                      nodes, relationships);
        }
Ejemplo n.º 2
0
 public static void WriteXmlToStream(XmlModel xmlModel, Stream stream)
 {
     try
     {
         if (xmlModel == null || stream == null)
         {
             return;
         }
         var xmlSerializer = new XmlSerializer(typeof(XmlModel));
         xmlSerializer.Serialize(stream, xmlModel);
     }
     catch (Exception)
     {
         return;
     }
 }