using Earthblend.Tts.Common.Core.Enumerations;
using Earthblend.Tts.Common.Core.Interfaces;
using System;
using System.Collections.ObjectModel;
using System.Numerics;
using System.Windows.Input;
using System.Windows.Media.Media3D;
using System.Xml.Serialization;

namespace Earthblend.Tts.Common.Core.Members
{
    public class VirtualCanvasPluginDataItem : ImageDataItem, IVirtualCanvasDataItem
    {
        #region Constructor(s)

        public VirtualCanvasPluginDataItem()
        {

        }

        public VirtualCanvasPluginDataItem(ICommand command, Double left, Double top, Double width, Double height)
        {
            Command = command;
            Left = left;
            Top = top;
            Width = width;
            Height = height;
        }

        #endregion

        #region Private Variables

        private String _overscriptDisplayText = "";
        private String _underscriptDisplayText = "";
        private String _backscriptDisplayText = "";
        private String _frontscriptDisplayText = "";
        private Guid _nodeId = Guid.Empty;
        private ObservableCollection<TargetDefinition> _targetDefinitions = new ObservableCollection<TargetDefinition>();
        private Double _left = 0;
        private Double _top = 0;
        private Double _width = 0;
        private Double _height = 0;
        private Double _scaleX = 1;
        private Double _scaleY = 1;
        private Double _fontSize = 20;
        private String _groupBrushColor = "Transparent";

        private String _displayText = "";
        private MathSymbolType _symbolType = MathSymbolType.Unknown;
        private ICommand _command = null;
        private Guid _equationId = Guid.Empty;
        private Boolean _isSelected = false;
        private int _sequence = 0;
        private String _equationText;
        private String _class;
        private StatementType _statement = StatementType.Function;
        private Boolean _isEnabled = true;
        private ReturnDataType _dataType = ReturnDataType.Point3D;
        private String _variable = String.Empty;
        private String _group = String.Empty;
        private Guid _parentId = Guid.Empty;
        private int _level = 0;
        private String _hierarchyName = "";
        private Boolean _isVisible = true;
        private CanvasElementRenderMode _elementRenderMode = CanvasElementRenderMode.Solid;

        #endregion

        //Target Definitions are not cloned
        public VirtualCanvasPluginDataItem Clone()
        {
            return new VirtualCanvasPluginDataItem()
            {
                IsEnabled = IsEnabled,
                IsSelected = IsSelected,
                IsVisible = IsVisible,
                OverscriptDisplayText = OverscriptDisplayText,
                UnderscriptDisplayText = UnderscriptDisplayText,
                BackscriptDisplayText = BackscriptDisplayText,
                FrontscriptDisplayText = FrontscriptDisplayText,
                HierarchyName = HierarchyName,
                Variable = Variable,
                Group = Group,
                Class = Class,
                EquationText = EquationText,
                DisplayText = DisplayText,
                Sequence = Sequence,
                Level = Level,
                Left = Left,
                Top = Top,
                Width = Width,
                Height = Height,
                EquationId = EquationId,
                NodeId = NodeId,
                ParentId = ParentId,
                DataType = DataType,
                SymbolType = SymbolType,
                Statement = Statement,
                Command = Command

            };
        }

        #region Public Clr Properties


        private Model3DGroup _canvasModel3DGroup = new Model3DGroup();
        [XmlIgnore] public Model3DGroup CanvasModel3DGroup { get { return _canvasModel3DGroup; } set { SetProperty(ref _canvasModel3DGroup, value); } }

        public CanvasElementRenderMode ElementRenderMode { get { return _elementRenderMode; } set { SetProperty(ref _elementRenderMode, value); } }
        public String GroupBrushColor { get { return _groupBrushColor; } set { SetProperty(ref _groupBrushColor, value); } }

        public Double ScaleX { get { return _scaleX; } set { SetProperty(ref _scaleX, value); } }
        public Double ScaleY { get { return _scaleY; } set { SetProperty(ref _scaleY, value); } }
        public Double FontSize { get { return _fontSize; } set { SetProperty(ref _fontSize, value); } }


        public Boolean IsVisible { get { return _isVisible; } set { SetProperty(ref _isVisible, value); } }
        public Boolean IsSelected { get { return _isSelected; } set { SetProperty(ref _isSelected, value); } }
        public Boolean IsEnabled { get { return _isEnabled; } set { SetProperty(ref _isEnabled, value); } }

        public String OverscriptDisplayText { get { return _overscriptDisplayText; } set { SetProperty(ref _overscriptDisplayText, value); } }
        public String UnderscriptDisplayText { get { return _underscriptDisplayText; } set { SetProperty(ref _underscriptDisplayText, value); } }
        public String BackscriptDisplayText { get { return _backscriptDisplayText; } set { SetProperty(ref _backscriptDisplayText, value); } }
        public String FrontscriptDisplayText { get { return _frontscriptDisplayText; } set { SetProperty(ref _frontscriptDisplayText, value); } }

        public String HierarchyName { get { return _hierarchyName; } set { SetProperty(ref _hierarchyName, value); } }
        public String Variable { get { return _variable; } set { SetProperty(ref _variable, value); } }
        public String Group { get { return _group; } set { SetProperty(ref _group, value); } }
        public String Class { get { return _class; } set { SetProperty(ref _class, value); } }
        public String EquationText { get { return _equationText; } set { SetProperty(ref _equationText, value); } }
        public String DisplayText { get { return _displayText; } set { SetProperty(ref _displayText, value); } }

        public int Sequence { get { return _sequence; } set { SetProperty(ref _sequence, value); } }
        public int Level { get { return _level; } set { SetProperty(ref _level, value); } }

        public Double Left { get { return _left; } set { SetProperty(ref _left, value); } }
        public Double Top { get { return _top; } set { SetProperty(ref _top, value); } }
        public Double Width { get { return _width; } set { SetProperty(ref _width, value); } }
        public Double Height { get { return _height; } set { SetProperty(ref _height, value); } }

        public Guid EquationId { get { return _equationId; } set { SetProperty(ref _equationId, value); } }
        public Guid NodeId { get { return _nodeId; } set { SetProperty(ref _nodeId, value); } }
        public Guid ParentId { get { return _parentId; } set { SetProperty(ref _parentId, value); } }

        public ReturnDataType DataType { get { return _dataType; } set { SetProperty(ref _dataType, value); } }
        public MathSymbolType SymbolType { get { return _symbolType; } set { SetProperty(ref _symbolType, value); } }
        public StatementType Statement { get { return _statement; } set { SetProperty(ref _statement, value); } }

        [XmlIgnore] public ICommand Command { get { return _command; } set { SetProperty(ref _command, value); } }

        public ObservableCollection<TargetDefinition> TargetDefinitions { get { return _targetDefinitions; } set { SetProperty(ref _targetDefinitions, value); } }

        #endregion

        #region Public Methods

        public void UpdateEquationText()
        {
            EquationText = "TestSymbols";
        }

        #endregion
    }
}