using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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;
using System.Net;
using FLY.Thick.Base.Client;
using Unity;

namespace FLY.Thick.Base.UI
{
    /// <summary>
    /// Page_ErrorTable.xaml 的交互逻辑
    /// </summary>
    public partial class PgErrorTable : Page
    {
        FLY.OBJComponents.IService.IWarningService warningService;
        WarningReasonWindow warningReasonWindow;
        IUnityContainer container;
        /// <summary>
        /// 
        /// </summary>
        public PgErrorTable()
        {
            InitializeComponent();

        }


        [InjectionMethod]
        public void Init(
            IUnityContainer container, 
            FLY.OBJComponents.IService.IWarningService warningService,
            WarningReasonWindow warningReasonWindow
            ) 
        {
            this.container = container;
            this.warningService = warningService;
            this.warningReasonWindow = warningReasonWindow;
            gridFlows.ItemsSource = this.warningReasonWindow.Record;

        }
        private void button_back_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.GoBack();
        }

        private void button_reset_click(object sender, RoutedEventArgs e)
        {
            warningService.Reset();
        }

        private void button_iotip_click(object sender, RoutedEventArgs e)
        {
            Window w;
            if (container.IsRegistered<Window>("wdIOTip")) 
            {
                w = container.Resolve<Window>("wdIOTip");
            }
            else
            {
                w = new WdIOTip();
            }
            w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
            w.ShowDialog();
        }

        private void button_access_click(object sender, RoutedEventArgs e)
        {
            WdFlyADAccess w = new WdFlyADAccess();
            var flyAdService = container.Resolve<FLY.Thick.Base.IService.IFlyADService>();
            w.Init(flyAdService);
            w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
            w.ShowDialog();
        }

        private void button_silence_click(object sender, RoutedEventArgs e)
        {
            warningService.Silence();
        }

        private void button_database_click(object sender, RoutedEventArgs e)
        {
            PgErrorAllTable p = container.Resolve<PgErrorAllTable>(
                    new Unity.Resolution.ParameterOverride("warningService", warningService));
            NavigationService.Navigate(p);
        }
    }
}