Page_Main.xaml.cs 9.15 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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
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 FLY.ControlLibrary;
using System.Collections.ObjectModel;

using FLY.Thick.BulkDataModule;
using FLY.Thick.Base.Client;
using FLY.Thick.Base.Common;
using ThickTcpUiInWindow;
using FLY.Thick.BlowingScan.Client;
using FLY.Thick.Blowing.Client;

namespace FLY.Thick.BlowingScan.UI.Client
{
    /// <summary>
    /// Page_Main.xaml 的交互逻辑
    /// </summary>
    public partial class Page_Main : Page
    {
        private ThickTcpUiInWindow.UIModule.FLYLayout mLayout;
        private FLYLayoutManager mManager;
        TDGage gage;
        public Page_Main()
        {
            InitializeComponent();
        }
        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;
                grid_initparam.DataContext = gage.mInitParamService;
                Init_Border_Blowing();
                Init_Border_Width();
                Init_Border_GetSample();
                lp.Progress += 10;
            }));
            System.Threading.Thread.Sleep(10);
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                mLayout = new ThickTcpUiInWindow.UIModule.FLYLayout();
                mLayout.Load();
                grid_layout.DataContext = mLayout;
                mManager = new FLYLayoutManager();
60 61
                Application.Current.Properties["LayoutManager"] = mManager;

潘栩锋's avatar
潘栩锋 committed
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
                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()
                    {
83
                        UIModule = new UIModule.UIModule_FixGraph(),
潘栩锋's avatar
潘栩锋 committed
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
                        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
                    }
                });
105 106 107 108 109 110 111 112 113
                mManager.myUIModules.Add("dyareaio", new FLY.UI.Module.UIModuleInfo()
                {
                    UIModule = new UIModule.UIModule_DynAreaIO(),
                    Param = new FLY.UI.Module.UIModuleParam()
                    {
                        IsDynAreaComponent = true,
                        IsUnique = true
                    }
                });
潘栩锋's avatar
潘栩锋 committed
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
                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);


133
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
潘栩锋's avatar
潘栩锋 committed
134
            {
135 136
                Misc.BindingOperations.SetBinding(gage.mDynArea, "ControllerState", UpdateControllerState);
                
潘栩锋's avatar
潘栩锋 committed
137 138 139 140
                lp.Progress = 100;
            }));
            System.Threading.Thread.Sleep(10);
        }
141 142 143 144 145 146 147 148 149
        void UpdateControllerState()
        {
            var st = mLayout.ControllerStates.Find(_st => _st.ControllerState == gage.mDynArea.ControllerState.ToString());
            if (st != null)
            {
                if (st.No >= 0 && st.No < this.tabControl1.Items.Count)
                    this.tabControl1.SelectedIndex = st.No;
            }
        }
潘栩锋's avatar
潘栩锋 committed
150 151 152 153 154 155


        BlowingScanServiceClient mRenZiJiaService;
        BlowingDetectServiceClient mBDetect;
        void Init_Border_Blowing()
        {
156 157
            mRenZiJiaService = new BlowingScanServiceClient(FLY.Thick.BlowingScan.OBJ_INTERFACE.OBJ_INTERFACE_ID.RENZIJIA_ID);
            mBDetect = new BlowingDetectServiceClient(FLY.Thick.BlowingScan.OBJ_INTERFACE.OBJ_INTERFACE_ID.BDETECT_ID);
潘栩锋's avatar
潘栩锋 committed
158 159 160 161 162 163 164

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

            Border_Blowing.DataContext = mBDetect;
        }

165
        BorderSearchServiceClient mBorderSearchService;
潘栩锋's avatar
潘栩锋 committed
166 167
        void Init_Border_Width()
        {
168
            mBorderSearchService = new BorderSearchServiceClient(FLY.Thick.BlowingScan.OBJ_INTERFACE.OBJ_INTERFACE_ID.BORDERSEARCH_ID);
潘栩锋's avatar
潘栩锋 committed
169 170 171 172

            FObjBase.FObjSys.Current.Connect_to_Another_OBJSys(
                gage.mSysParam.ServerIPEP, mBorderSearchService.ID);
        }
173
        GetSampleServiceClient mGetSampleService;
潘栩锋's avatar
潘栩锋 committed
174 175
        void Init_Border_GetSample()
        {
176
            mGetSampleService = new GetSampleServiceClient(FLY.Thick.BlowingScan.OBJ_INTERFACE.OBJ_INTERFACE_ID.GET_SAMPLE_ID);
潘栩锋's avatar
潘栩锋 committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210

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

            Border_Sample.DataContext = mGetSampleService;
        }


        private void button_sysparam_click(object sender, RoutedEventArgs e)
        {
            if (stackpanel_menu.Children.Count > 0)
            {
                mLayout.IsInMenuSelect = true;
            }
            else
            {
                button_menu_click(sender, e);
            }
        }
        private void button_backmenu_click(object sender, RoutedEventArgs e)
        {
            mLayout.IsInMenuSelect = false;
        }
        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();
211
            p.Init(gage.mSysParam.ServerIPEP, FLY.Thick.BlowingScan.OBJ_INTERFACE.OBJ_INTERFACE_ID.PROFILE_ID);
潘栩锋's avatar
潘栩锋 committed
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 259 260 261 262 263 264 265 266
            NavigationService.Navigate(p);
        }

        private void Border_AD_Click(object sender, RoutedEventArgs e)
        {

        }

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

        private void Border_Width_Click(object sender, RoutedEventArgs e)
        {
            Page_BorderSearch p = new Page_BorderSearch();
            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.ShowDialog();
        }

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

        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);
        }

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




}