Ejemplo n.º 1
0
        //CONSTRUCTOR
        public MainWindowViewModel(IRegionManager regionManager, IEventAggregator eventAggregator)
        {
            _regionManager = regionManager;
            _regionManager.RegisterViewWithRegion(Regions.ContentRegion, typeof(SegmentSummaryPage)); //Sets default user control as SegmentSummaryPage
            _regionManager.RegisterViewWithRegion(Regions.TitleMenuRegion, typeof(TitleMenu));
            _regionManager.RegisterViewWithRegion(Regions.ButtonsMenuRegion, typeof(ButtonsMenu));

            _eventAggregator  = eventAggregator;
            countSubscription = 0;

            //Start a new thread that runs the loading window independently(in order to allow the progress ring to appear)
            loadingWindowThread = new Thread(new ThreadStart(() =>
            {
                // Create and show the Window
                LoadingWindow tempWindow = new LoadingWindow();
                tempWindow.Show();
                tempWindow.Activate();
                // Start the Dispatcher Processing
                try
                {
                    System.Windows.Threading.Dispatcher.Run();
                }
                catch (Exception) { }
            }));
            loadingWindowThread.SetApartmentState(ApartmentState.STA);
            loadingWindowThread.IsBackground = true;
            loadingWindowThread.Start();

            eventAggregator.GetEvent <IsSubscriptionCompleted>().Subscribe(CountSubscription);
            eventAggregator.GetEvent <UpdatedSourceEvent>().Subscribe(WriteOPCValue);
        }
Ejemplo n.º 2
0
        public void FocusLast(WindowType activatedWindowType)
        {
            System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
            {
                if (openWindows.Count > 0)
                {
                    var windowType = openWindows.Last();

                    if (windowType != activatedWindowType)
                    {
                        if (windowType == WindowType.AddFieldWindow)
                        {
                            addFieldWindow.Activate();
                        }
                        else if (windowType == WindowType.PickupWindow)
                        {
                            if (pickupWindow != null)
                            {
                                pickupWindow.Activate();
                            }
                        }
                        else if (windowType == WindowType.LoadingWindow)
                        {
                            loadingWindow.Activate();
                        }
                        else if (windowType == WindowType.LoadingIncorrectModuleWindow)
                        {
                            loadingIncorrectModuleWindow.Activate();
                        }
                        else if (windowType == WindowType.WaitingForUnloadWindow)
                        {
                            waitingForUnloadWindow.Activate();
                        }
                        else if (windowType == WindowType.UnloadCorrectionWindow)
                        {
                            unloadCorrectionWindow.Activate();
                        }
                        else if (windowType == WindowType.ChangeListWindow)
                        {
                            changeFieldWindow.Activate();
                        }
                        else if (windowType == WindowType.LoadingAtGin)
                        {
                            loadingAtGinWindow.Activate();
                        }
                        else if (windowType == WindowType.UnloadingAtGin)
                        {
                            unloadingAtGinWindow.Activate();
                        }
                        else if (windowType == WindowType.TruckSetupWindow)
                        {
                            firstRunWindow.Activate();
                        }
                    }
                }
            }));
        }