public class ElectronConfiguration
{
    public ElectronConfiguration()
    {

    }
     
    public int Ring { get; set; } = 0;
    public int Electrons { get; set; } = 0;
}

public class PeriodicElement
{
   public PeriodicElement()
   {

   }

    public int Rings { get; set; } = 0;
    public int Number { get; set; } = 0;
    public String Name { get;set; } = String.Empty;
    public List<ElectronConfiguration> ElectronConfigurations = new List<ElectronConfiguration>();
    public Boolean CheckEven { get; set; } = true;
}



public class Result
{
    public BigInteger Sequence { get; set;} = 0;
    public Double Ttx { get; set; } = 0;
    public Double Tty { get; set; } = 0;
    public Double Ttz { get; set; } = 0;
    public String Text { get; set; } = "Z";
    public String MeshType { get; set; } = "Box";
    public Double Radius { get; set; } = 1;
    public String ImageName { get; set; } = "Point5.png";
    public Boolean UseConnector { get; set; } = true;
}

public String ResultsXml
{
    get { return SaveToXml<List<Result>>(Results,null); }
}

        private Boolean IsXml(String xml)
        {
            try
            {
                XmlDocument myDoc = new XmlDocument();
                myDoc.LoadXml(xml);
                return true;
            }
            catch (XmlException ex)
            {
                return false;
            }
        }

[Description("Results")]
public List<Result> Results { get; set; } = new List<Result>();

public List<PeriodicElement> PeriodicElements { get; set; } = new List<PeriodicElement>();

 public String SaveToXml<T>(Object rsd, Type[] types) where T : class
        {
            String xml = String.Empty;

            if (rsd != null)
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(T), types);
                StringBuilder stringBuilder = new StringBuilder();
                using (StringWriter writer = new StringWriter(stringBuilder))
                {
                    xmlSerializer.Serialize(writer, rsd as T);
                    xml = stringBuilder.ToString();
                }
            }

            return xml;
        }

        public T LoadFromXml<T>(String xml,Type[] types = null) where T : class
        {           
            if (!String.IsNullOrEmpty(xml) && IsXml(xml))
            {
                Object data = null;
                XmlSerializer deSerializer = new XmlSerializer(typeof(T), types);
                StringReader reader = new StringReader(xml);
                data = (T)deSerializer.Deserialize(reader);
                reader.Close(); reader.Dispose(); reader = null;
                return (T)data;
            }

            return null;
        }

    public class CircleService
    {
        public int Points { get; set; } = 0;


        #region Classes


        #endregion

        #region Class Handles


        #endregion


        public const Double GoldenRatio = 1.61803398874989484820458683436;

        public const Double Mascheroni = .57721566490153286060651209008240243;

        public long Factorial(int n)
        {
            if (n == 0)
            {
                return 1;
            }
            return n * Factorial(n - 1);
        }

        #region Constructor(s)

        public CircleService() //CircleService
        {
            ExecuteLiterals();
        }

        public CircleService(Double radius, Double slices)
        {
            ExecuteLiterals();

            Radius = radius;
            Slices = slices;
        }

        #endregion

        #region Literals


        #endregion

        #region Public Clr Properties

/*
        private ICommand _decreaseThetaCommandIc = null; [XmlIgnore] public ICommand DecreaseThetaCommandIc => _decreaseThetaCommandIc ?? (_decreaseThetaCommandIc = new RelayCommand<Object>(DecreaseThetaCommandIcExecuted)); public void DecreaseThetaCommandIcExecuted(Object obj) { Theta -= 1; }
        private ICommand _increaseThetaCommandIc = null; [XmlIgnore] public ICommand IncreaseThetaCommandIc => _increaseThetaCommandIc ?? (_increaseThetaCommandIc = new RelayCommand<Object>(DecreaseThetaCommandIcExecuted)); public void IncreaseThetaCommandIcExecuted(Object obj) { Theta += 1; }
*/
        private Double _theta = 0; public Double Theta { get { return EvaluateEquationTheta(null); } set { _theta = value; } }
        private Double _offsetX = 0; public Double OffsetX { get { return _offsetX; } set { _offsetX = value; } }
        private Double _offsetY = 0; public Double OffsetY { get { return _offsetY; } set { _offsetY = value; } }

        #endregion

        #region Adjustable Functions

        private Double _slices = 16; public Double Slices { get { return _slices; } set { _slices = value; } }
        private Double _radius = 5; public Double Radius { get { return _radius; } set { _radius = value; } }


        #endregion

        #region Function-Methods


        #endregion

        #region Canvas Functions

        public Double FX(Double X)
        {
            return -Radius * Math.Sin(X * Theta) + OffsetX;
        }
        public Double FY(Double X)
        {
            return -Radius * Math.Cos(X * Theta) + OffsetY;
        }

        #endregion

        #region Public Functions - Update Equations

        public void UpdateEquations()
        {
        }

        #endregion

        public void ExecuteLiterals()
        {
            //Test in Literals 
        }

        #region Public Functions - Evaluate Equations

        #region Theta=2D*(Math.PI/Slices)

        public Double EvaluateEquationTheta(Object obj)
        {
            Double result = 0;
            result = 2D * (Math.PI / Slices);
            return result;
        }

        #endregion

        #endregion

    }







