using NEIntelligentControl2.Service.Station;
using SVGViewer.Models.Info;
using SVGViewer.Views;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace NEIntelligentControl2.Views.BoostStation
{
    /// <summary>
    /// 二次图视图
    /// </summary>
    public partial class SubStationView : UserControl
    {
        private ShapeInfo _ShapeInfo;
        /// <summary>
        /// 右键菜单事件
        /// </summary>
        public Action<SubStationView, ShapeInfo, string> ContentMenuAction { get; set; }
        private Dictionary<string, ShapeInfo> _CustomizeShapes;
        private StationManager _StationManager;

        public SubStationView()
        {
            InitializeComponent();
        }

        public SubStationView(ShapeInfo v) : this()
        {
            this._ShapeInfo = v;

            _StationManager = App.ServiceProvider.GetService(typeof(StationManager)) as StationManager;

            _CustomizeShapes = _StationManager.GetCustomizeShapesDic();
        }

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            //_svg.InitInfo(_ShapeInfo);
            var sv = new SVGCanvas(_ShapeInfo, _CustomizeShapes, false);
            _vb.Child = sv;
            _TBTitle.Text = _ShapeInfo.Name;
        }

        private void MenuItem_Click(object sender, RoutedEventArgs e)
        {
            ContentMenuAction?.Invoke(this, _ShapeInfo, ((Control)sender).Tag as string);
        }

        internal void SwitchInfo(ShapeInfo info)
        {
            var sv = new SVGCanvas(info, _CustomizeShapes, false);
            _vb.Child = sv;
        }
    }
}
