Page_Main.xaml.cs 8.38 KB
Newer Older
潘栩锋's avatar
潘栩锋 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
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.Collections.ObjectModel;

using FLY.Thick.Base.Client;
using FLY.Thick.Base.Common;
using FLY.ControlLibrary;
using FLY.Thick.BulkDataModule;
using ThickTcpUiInWindow;
using FLY.Thick.Blowing.Client;
using System.ComponentModel;

namespace FLY.Thick.Blowing.UI.Fix.Client
{
    /// <summary>
    /// Page_Main.xaml 的交互逻辑
    /// </summary>
    public partial class Page_Main : Page, INotifyPropertyChanged
    {
        private ThickTcpUiInWindow.UIModule.FLYLayout mLayout;
        private FLYLayoutManager mManager;
35
        
潘栩锋's avatar
潘栩锋 committed
36 37 38 39 40
        TDGage gage;
        public Page_Main()
        {
            InitializeComponent();

41
            
潘栩锋's avatar
潘栩锋 committed
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
        }
        public void Init(TDGage gage) 
        {
            LoadingProgress lp = Application.Current.Properties["LoadingProgress"] as LoadingProgress;

            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                this.gage = gage;            
                stackpanel_dynarea.DataContext = gage.mDynArea;

                Init_Border_Blowing();
                Init_Border_Profile();
                lp.Progress += 10;
            }));
            System.Threading.Thread.Sleep(10);

            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                mLayout = new ThickTcpUiInWindow.UIModule.FLYLayout();
61
                mLayout.Load();
潘栩锋's avatar
潘栩锋 committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
                grid_layout.DataContext = mLayout;
                mManager = new FLYLayoutManager();
                mManager.myUIModules.Add("scangraph",
                new FLY.UI.Module.UIModuleInfo()
                {
                    UIModule = new ThickTcpUiInWindow.UIModule.UIModule_ScanGraph(),
                    Param = new FLY.UI.Module.UIModuleParam()
                    {
                        IsGraphCompnonent = true
                    }
                });
                mManager.myUIModules.Add("trendgraph",
                    new FLY.UI.Module.UIModuleInfo()
                    {
                        UIModule = new ThickTcpUiInWindow.UIModule.UIModule_TrendGraph(),
                        Param = new FLY.UI.Module.UIModuleParam()
                        {
                            IsGraphCompnonent = true
                        }
                    });
                mManager.myUIModules.Add("fixgraph",
                    new FLY.UI.Module.UIModuleInfo()
                    {
                        UIModule = new ThickTcpUiInWindow.UIModule.UIModule_FixGraph(),
                        Param = new FLY.UI.Module.UIModuleParam()
                        {
                            IsGraphCompnonent = true
                        }
                    });
                mManager.myUIModules.Add("scangraph2", new FLY.UI.Module.UIModuleInfo()
                {
                    UIModule = new UIModule.UIModule_ScanGraph2(),
                    Param = new FLY.UI.Module.UIModuleParam()
                    {
                        IsGraphCompnonent = true
                    }
                });
                mManager.myUIModules.Add("trendgraphcircular", new FLY.UI.Module.UIModuleInfo()
                {
                    UIModule = new UIModule.UIModule_ScanGraphCircular(),
                    Param = new FLY.UI.Module.UIModuleParam()
                    {
                        IsGraphCompnonent = true
                    }
                });
                mManager.Init(
                    tabControl1,
                    stackpanel_dynarea,
                    stackpanel_menu,
                    mLayout);
                lp.Progress += 10;
            }));
            System.Threading.Thread.Sleep(10);

            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                mManager.LoadModule();
                lp.Progress += 10;
            }));
            System.Threading.Thread.Sleep(10);

            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                gage.mDynArea.PropertyChanged += (s, e) =>
                {
                    DynArea dynarea = s as DynArea;
                    if (e.PropertyName == "ControllerState")
                    {
                        var st = mLayout.ControllerStates.Find(_st => _st.ControllerState == dynarea.ControllerState.ToString());
                        if (st != null)
                        {
                            if (st.No >= 0 && st.No < this.tabControl1.Items.Count)
                                this.tabControl1.SelectedIndex = st.No;
                        }
                    }
                };
                lp.Progress = 100;
            }));
            System.Threading.Thread.Sleep(10);
        }


144
        BlowingFixProfileServiceClient mProfile;
潘栩锋's avatar
潘栩锋 committed
145 146
        void Init_Border_Profile()
        {
147
            mProfile = new BlowingFixProfileServiceClient();
潘栩锋's avatar
潘栩锋 committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177

            FObjBase.FObjSys.Current.Connect_to_Another_OBJSys(
                gage.mSysParam.ServerIPEP, mProfile.ID);

            Border_Profile.DataContext = mProfile.Param;
        }

        BlowingFixServiceClient mRenZiJiaService;
        BlowingDetectServiceClient mBDetect;

        

        void Init_Border_Blowing() 
        {
            mRenZiJiaService = new BlowingFixServiceClient();
            mBDetect = new BlowingDetectServiceClient();

            FObjBase.FObjSys.Current.Connect_to_Another_OBJSys(
                gage.mSysParam.ServerIPEP, mRenZiJiaService.ID, mBDetect.ID);

            Border_Blowing.DataContext = mRenZiJiaService;
            border_bDetect.DataContext = mBDetect;
            Border_Width.DataContext = mBDetect;
            
        }

        private void button_sysparam_click(object sender, RoutedEventArgs e)
        {
            if (stackpanel_menu.Children.Count > 0)
            {
178
                mLayout.IsInMenuSelect = true;
潘栩锋's avatar
潘栩锋 committed
179 180 181 182 183 184 185 186
            }
            else
            {
                button_menu_click(sender, e);
            }
        }
        private void button_backmenu_click(object sender, RoutedEventArgs e)
        {
187
            mLayout.IsInMenuSelect = false;
潘栩锋's avatar
潘栩锋 committed
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
        }
        private void button_menu_click(object sender, RoutedEventArgs e)
        {
            Page_Menu p = new Page_Menu();
            p.Init(gage);
            NavigationService.Navigate(p);
        }
        private void button_profile_click(object sender, RoutedEventArgs e)
        {

            Page_ProfileBlowing p = new Page_ProfileBlowing();
            p.Init(gage.mSysParam.ServerIPEP);
            NavigationService.Navigate(p);

        }

        private void Border_AD_Click(object sender, RoutedEventArgs e)
        {

        }

        private void Border_Blowing_Click(object sender, RoutedEventArgs e)
        {
            Page_Blowing p = new Page_Blowing();
            p.Init(gage.mSysParam.ServerIPEP);
            NavigationService.Navigate(p);
        }

        private void Border_FlyAD_Click(object sender, RoutedEventArgs e)
        {
            Window_FlyADAccess w = new Window_FlyADAccess();
            w.Init(gage.mSysParam.ServerIPEP);
            w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
            w.ShowDialog();
        }

        private void Border_IO_Click(object sender, RoutedEventArgs e)
        {
            Window_IOTip w = new Window_IOTip();
            w.ShowDialog();
        }

        private void button_epc_start_click(object sender, RoutedEventArgs e)
        {
            mRenZiJiaService.EPCStart();
        }
        private void button_epc_stop_click(object sender, RoutedEventArgs e)
        {
            mRenZiJiaService.EPCStop();
        }

        private void button_option_click(object sender, RoutedEventArgs e)
        {
            ThickTcpUiInWindow.MainEdit.Page_MainEdit p = new ThickTcpUiInWindow.MainEdit.Page_MainEdit();
            p.Init(mManager);
            NavigationService.Navigate(p);
        }


        protected void NotifyPropertyChanged(string propertyName)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
        }
        public event PropertyChangedEventHandler PropertyChanged;


    }



}