﻿using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Controls;
using System.Windows.Input;
using System.Xml.Serialization;
using Microsoft.Practices.Unity;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using System.Windows;
using VEX.Model.Scene.Model.Objects.FBufferObject;
using VEX.Service.Scene;
using VEX.Interface.Scene.Services;
using VEF.Interfaces.Services;
using VEX.Interface.Scene;
using VEF.Interfaces.Controls;
using VEF.Core.Interface.Service;
using VEX.IDAL;
using VEX.Core.Shared.Interface.Net;
using VEF;
using VEX.Core.Model.Services;
using VEX.Interface.DAL;
using VEF.DAL.Interface;
using VEX.Core.ViewModel;
using VEX.Core.Model;
using Module.PFExplorer.Service;
using System.Collections.Specialized;
using VEX.Core.Shared.Service.Scene;
using VEX.Model.Scene.Model.Objects;
using VEX.IDAL.MDB;
using VEF.VEF_Helpers;
using System.Runtime.Serialization;
using VEX.Core.Shared.Interface.DAL;
using System.IO;
using VEX.Model.Scene.Model.Objects.ChildObject;

namespace VEX.Model.Scene.Model
{
    [DataContract(IsReference = true)]
    public class RenderableComponent : ComponentX //, IHasLocalFile
    {                
        public bool Watch { get; set; }

        #region INETID

        public override NetMsg.UComponent UComponent { get { return NetMsg.UComponent.RenderableComponent; } set { } }

        [DataMember]
        [ExpandableObject]
        public FB_Renderable FB_Renderable { get { return FBObject as FB_Renderable; } set { FBObject = value; } }

        #endregion

        //private ObservableCollection<LocalFile> _LocalFiles;

        //public ObservableCollection<LocalFile> LocalFiles {
        //    get
        //    {
        //        if(_LocalFiles == null)
        //         _LocalFiles = new ObservableCollection<LocalFile>();

        //        foreach (var mesh in FB_Renderable.Meshes)
        //        {
        //            var isLocalFile = mesh as MeshObject;

        //            if (isLocalFile != null)
        //            {
        //                _LocalFiles.Add(isLocalFile);// new LocalFile() { FilePath = Path.Combine(isLocalFile.FilePath ?? "", isLocalFile.FileName ?? "") });

        //                foreach (var material in isLocalFile.Materials)
        //                {
        //                    _LocalFiles.Add(material);// new LocalFile() { FilePath = Path.Combine(material.FilePath ?? "", material.FileName ?? "") });
        //                }
        //                continue;
        //            }

        //            var isPlaneObject = mesh as PlaneObject;

        //            if (isPlaneObject != null)
        //            {
        //                foreach (var material in isLocalFile.Materials)
        //                {
        //                    _LocalFiles.Add(isPlaneObject);// new LocalFile() { FilePath = Path.Combine(material.FilePath ?? "", material.FileName ?? "") });
        //                }
        //                continue;
        //            }

        //        }

        //        return _LocalFiles;
        //    }
        //    set {
        //        _LocalFiles = value;
        //    }
        //}

        [Browsable(false)]
        public override List<IMenuItem> MenuOptions
        {
            get
            {
                return base.MenuOptions;
                //List<IMenuItem> list = new List<IMenuItem>() {
                // //   new VEFMenuItem() { Header = "IsVisible" },
                // //   new VEFMenuItem() { Command = new CmdDeleteNode(this), Header = "Delete Node" }
                //    new VEFMenuItem() { Command = new CmdSendToServer(this), Header = "SendToServer" }
                //};
                //return list;
            }
        }

        public RenderableComponent()
        {
            FBObject = new FB_Renderable();
            FBObject.Parent = this;
            Name = typeof(RenderableComponent).Name;
        }
        

    }
}
