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;
using FLY.Thick.Base.UI.OnInit;
using MultiLayout;

namespace FLY.Thick.Base.UI
{
    /// <summary>
    /// Page_ErrorTable.xaml 的交互逻辑
    /// </summary>
    public partial class PgErrorsTable : Page
    {
        WarningSystemManager warningSystemManager;
        IUnityContainer container;
        FlyLayoutManager manager;
        /// <summary>
        /// 
        /// </summary>
        public PgErrorsTable()
        {
            InitializeComponent();

        }


        [InjectionMethod]
        public void Init(
            FlyLayoutManager manager,
            IUnityContainer container,
            WarningSystemManager warningSystemManager
            )
        {
            this.manager = manager;
            this.container = container;
            this.warningSystemManager = warningSystemManager;
            this.DataContext = warningSystemManager;

            manager.IsInOption = true;
            cbSelectList.SelectedIndex = 0;

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

        private void button_reset_click(object sender, RoutedEventArgs e)
        {
            foreach (var warning in warningSystemManager.Warnings) {
                warning.Reset();
            }
        }

        private void button_database_click(object sender, RoutedEventArgs e)
        {
            var warning = (WarningSystem2ServiceClientWithName)cbSelectList.SelectedItem;
            if (warning == null)
                return;

            PgErrorAllTable p = container.Resolve<PgErrorAllTable>(
                    new Unity.Resolution.ParameterOverride("warning", warning));
            NavigationService.Navigate(p);
        }
    }
}
