Spring – Rev 1

Subversion Repositories:
Rev:
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Xml.Serialization;
using Configuration.Properties;

namespace Configuration
{
    [XmlRoot(ElementName = "Position")]
    public class Position : INotifyPropertyChanged
    {
#region Public Events & Delegates

        public event PropertyChangedEventHandler PropertyChanged;

#endregion

#region Public Enums, Properties and Fields

        [XmlElement(ElementName = "X")]
        public float X
        {
            get => _x;
            set
            {
                if (value == _x)
                {
                    return;
                }

                _x = value;
                OnPropertyChanged();
            }
        }

        [XmlElement(ElementName = "Y")]
        public float Y
        {
            get => _y;
            set
            {
                if (value == _y)
                {
                    return;
                }

                _y = value;
                OnPropertyChanged();
            }
        }

#endregion

#region Private Delegates, Events, Enums, Properties, Indexers and Fields

        private float _x = 50;

        private float _y = 10;

#endregion

#region Constructors, Destructors and Finalizers

        [UsedImplicitly]
        public Position()
        {
        }

        public Position(float x, float y) : this()
        {
            _x = x;
            _y = y;
        }

#endregion

#region Private Methods

        [NotifyPropertyChangedInvocator]
        protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }

#endregion
    }
}