using CommunityToolkit.Mvvm.Input;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.VisualBasic;
using NVelocity.Util.Introspection;
using Prism.Events;
using SlnMesnac.Serilog;
using SlnMesnac.WPF.Attribute;
using SlnMesnac.WPF.Event;
using SlnMesnac.WPF.ViewModel.Base;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SlnMesnac.WPF.ViewModel.Index
{
    [RegisterAsSingletonAttribute]
    public partial class IndexViewModel : BaseViewModel
    {
        public readonly SerilogHelper _logger;

        private readonly IEventAggregator _eventAggregator;

        public IndexViewModel(SerilogHelper logger, IEventAggregator eventAggregator)
        {
            _logger = logger;
            _eventAggregator = eventAggregator;
        }

        /// <summary>
        /// 加载产品信息
        /// </summary>
        /// <param name="deviceCode"></param>
        [RelayCommand]
        private void LoadProductInfo(string deviceCode)
        {
            string code = deviceCode as string;

            _eventAggregator.GetEvent<ProductCodeEvent>().Publish(code);

            var mainWindow = App.ServiceProvider.GetService<MainWindowViewModel>();
            mainWindow.ControlOnClick("ProductInfo");
        }
    }
}
