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;
namespace ThickTcpUiInWindow
{
    /// <summary>
    /// Page_CoatingSegment.xaml 的交互逻辑
    /// </summary>
    public partial class Page_CoatingSegment : Page
    {
        CoatingSegmentService mCoatingSegmentService;
        bool NeedKeepContext = false;


        public Page_CoatingSegment()
        {
            InitializeComponent();
        }


        private void button_profile_Click(object sender, RoutedEventArgs e)
        {
            Page_CoatingSegmentProfile w = new Page_CoatingSegmentProfile();
            w.Init(mCoatingSegmentService);

            NeedKeepContext = true;
            NavigationService.Navigate(w);
        }
        public void Init(IPEndPoint serverep) 
        {
            mCoatingSegmentService = new CoatingSegmentService();

            FObjBase.FObjSys.Current.Connect_to_Another_OBJSys(
               serverep, mCoatingSegmentService.ID);
            this.DataContext = mCoatingSegmentService;
        }
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
            if (NeedKeepContext)
            {
                NeedKeepContext = false;
                return;
            }            
        }

        private void Page_Unloaded(object sender, RoutedEventArgs e)
        {
            if (!NeedKeepContext)
                mCoatingSegmentService.Dispose();
        }

        private void button_apply_Click(object sender, RoutedEventArgs e)
        {
            mCoatingSegmentService.Apply();
            FLY.ControlLibrary.Window_Tip.Show("应用 & 保存成功",
                null,
                TimeSpan.FromSeconds(2));
        }
    }
}
