using Earthblend.Tts.Common.Core.Enumerations;
using Earthblend.Tts.Common.Core.Extentions;
using Earthblend.Tts.Common.Core.Interfaces;
using Earthblend.Tts.Common.Core.Members;
using Earthblend.Tts.Common.Core.Statics;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;

namespace Earthblend.Tts.Common.Core.Services
{
    public class RibbonService : IDisposable
    {
        BitmapService bitmapService = null;
        ICommands commands = null;

        #region Constructor(s)

        public RibbonService(ICommands cmds)
        {
            commands = cmds;
            bitmapService = new BitmapService();
        }

        #endregion

        public IEnumerable<RibbonItem> CreateMainRibbon()
        {
            #region Create Ribbon

            IList<RibbonItem> items = new List<RibbonItem>();

            BitmapService bitmapService = new BitmapService();

            FileInfo fileInfo = new FileInfo(System.Reflection.Assembly.GetExecutingAssembly().Location);
            var executingAssembly = fileInfo.DirectoryName + @"\";
            fileInfo = null;

            String startSmallPath = executingAssembly + @"\Resources\Images\" + @"StartSmall.png";
            String stopSmallPath = executingAssembly + @"\Resources\Images\" + @"StopSmall.png";

            if (!File.Exists(startSmallPath)) return items;
            if (!File.Exists(stopSmallPath)) return items;

            var startSmall = bitmapService.GetBitmapImage(startSmallPath);
            var stopSmall = bitmapService.GetBitmapImage(stopSmallPath);

            #region File Tab

            RibbonItem ribbonItemFileTab = new RibbonItem() { Header = "File" };

            #region File Group

            //var groupRibbonItemOperations = new RibbonItem() { Header = "Operations" };

            //groupRibbonItemOperations.Items.Add(new RibbonItem() { Header = "Run", Command = commands.RunCommandIc, DefaultImageSource = bitmapService.GetBitmapImage(VirtualSystemUtil.AppImagesStorageFolder + @"Start.png") });
            //groupRibbonItemOperations.Items.Add(new RibbonItem() { Header = "Stop", Command = commands.StopCommandIc, DefaultImageSource = bitmapService.GetBitmapImage(VirtualSystemUtil.AppImagesStorageFolder + @"Stop.png") });

            //ribbonItemFileTab.Items.Add(CreateSaveGroup());
            //ribbonItemFileTab.Items.Add(groupRibbonItemOperations);

            #endregion


            #region File Group

            var groupRibbonItemOperationsSpin = new RibbonItem() { Header = "Start Spin - (Axis)" }; //DefaultImageSource = bitmapService.GetBitmapImage(VirtualSystemUtil.AppImagesStorageFolder + @"StartSmall.png") });

            groupRibbonItemOperationsSpin.Items.Add(new RibbonItem() { Header = "X", Command = commands.StartSpinXCommandIc, DefaultImageSource = startSmall});
            groupRibbonItemOperationsSpin.Items.Add(new RibbonItem() { Header = "Y", Command = commands.StartSpinYCommandIc, DefaultImageSource = startSmall});
            groupRibbonItemOperationsSpin.Items.Add(new RibbonItem() { Header = "Z", Command = commands.StartSpinZCommandIc, DefaultImageSource = startSmall});

            ribbonItemFileTab.Items.Add(groupRibbonItemOperationsSpin);

            #endregion


            #region File Group

            var groupRibbonItemOperationsStopSpin = new RibbonItem() { Header = "Stop Spin - (Axis)" };

            groupRibbonItemOperationsStopSpin.Items.Add(new RibbonItem() { Header = "X", Command = commands.StopSpinXCommandIc, DefaultImageSource = stopSmall});
            groupRibbonItemOperationsStopSpin.Items.Add(new RibbonItem() { Header = "Y", Command = commands.StopSpinYCommandIc, DefaultImageSource = stopSmall});
            groupRibbonItemOperationsStopSpin.Items.Add(new RibbonItem() { Header = "Z", Command = commands.StopSpinZCommandIc, DefaultImageSource = stopSmall});

            ribbonItemFileTab.Items.Add(groupRibbonItemOperationsStopSpin);

            #endregion

            #endregion

            #endregion

            #region Add Tabs

            items.Add(ribbonItemFileTab);

            #endregion

            bitmapService = null;

            return items;
        }


        //private RibbonItem CreateSaveGroup()
        //{
        //    var groupSave = new RibbonItem() { Header = "File" };

        //    groupSave.Items.Add(new RibbonItem() { Header = "Save", Command = commands.SaveCommandIc, DefaultImageSource = bitmapService.GetBitmapImage(VirtualSystemUtil.AppImagesStorageFolder + @"SaveDrive.png"), SmallImageSource = bitmapService.GetBitmapImage(VirtualSystemUtil.AppImagesStorageFolder + @"SaveDrive.png") });

        //    return groupSave;
        //}

        public void Dispose()
        {
            commands = null;
            bitmapService = null;
        }
    }
}