//.################################################
//# Copyright © 2006-2010 Evolving Software Ltd   #
//# Author: Vijay Patel                           #
//################################################'

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Text;
using TestApplicationDomainModel.BasicTypes;

namespace TestApplicationDomainModel.Objects
{
    /// <summary>
    /// This class is not inherited, and doesn't use custom attributes.
    /// It is configured externally by the PocoObjectConfiguration class in the launcher application.
    /// </summary>
    [Serializable]
    public class PocoObject
    {

        public PocoObject()
            : base()
        {
            this.ChildObjects = new List<PocoObject>();
            this.NormalDate = DateTime.Now;
        }

        public Guid ID { get; set; }

        public long Version { get; set; }

        /// <summary>
        /// This is a normal Boolean
        /// </summary>
        public bool NormalBoolean { get; set; }


        /// <summary>
        /// This is a Rich Text field, and should appear as a large editor
        /// </summary>
        public string FormattedText { get; set; }

        /// <summary>
        /// This is an unformatted Date.
        /// Clicking the down-arrow will reveal the DatePicker dialog.
        /// </summary>
        public DateTime NormalDate { get; set; }

        /// <summary>
        /// This enum should be shown as a drop-down list.
        /// </summary>
        public EnumValues.IndividualOptions EnumValue { get; set; }

        /// <summary>
        /// This enum should be shown as a check-list.
        /// </summary>
        public CombinationOptions EnumSwitches { get; set; }

        /// <summary>
        /// This is a normal Text
        /// </summary>
        public string NormalText { get; set; }

        /// <summary>
        /// It should be possible to clear this value.
        /// It should also be possible to 'Cut' this value using the clipboard commands.
        /// </summary>
        public int? NullableInt { get; set; }

        /// <summary>
        /// This will show a PropertyGrid with X/Y values.
        /// The background colour should change when the control gets focus
        /// </summary>
        public System.Drawing.Point Point { get; set; }

        public IList<PocoObject> ChildObjects { get; set; }

        /// <summary>
        /// This wil add some objects to the "Child Objects" property.
        /// Actions can only be invoked if there are no dirty objects on the Workbench.
        /// </summary>
        public void AddSomeChildObjects()
        {
            this.ChildObjects.Add(new PocoObject());
            this.ChildObjects.Add(new PocoObject());
            this.ChildObjects.Add(new PocoObject());
        }

        /// <summary>
        /// This static method will appear on the Class item in the Library.
        /// All Objects that are created will be automatically persisted.
        /// </summary>
        /// <returns></returns>
        public static PocoObject CreateWithSomeChildObjects()
        {
            var result = new PocoObject();
            result.FormattedText = "I was created from a Static method";
            
            result.AddSomeChildObjects();

            return result;
        }

    }
}
