Parameters for ViewChangeRequest event.
Inheritance: System.EventArgs
コード例 #1
0
 /// <summary>
 /// Requests a change of view.
 /// </summary>
 /// <param name="view">
 /// The requested view.
 /// </param>
 /// <param name="data">
 /// Optional data for the requested view.
 /// </param>
 protected void RequestViewChange(View view, object data = null)
 {
     if (ViewChangeRequest != null)
     {
         var args = new ViewChangeRequestArgs(view, data);
         ViewChangeRequest(this, args);
     }
 }
コード例 #2
0
 /// <summary>
 /// Requests a change of view.
 /// </summary>
 /// <param name="view">
 /// The requested view.
 /// </param>
 /// <param name="data">
 /// Optional data for the requested view.
 /// </param>
 protected void RequestViewChange(View view, object data = null)
 {
     if (ViewChangeRequest != null)
     {
         var args = new ViewChangeRequestArgs(view, data);
         ViewChangeRequest(this, args);
     }
 }
コード例 #3
0
ファイル: App.xaml.cs プロジェクト: TechnikEmpire/StahpIt-WPF
        /// <summary>
        /// Callback for when a change in the current view has been requested.
        /// </summary>
        /// <param name="sender">
        /// Who requested the change.
        /// </param>
        /// <param name="e">
        /// Arguments for the view change.
        /// </param>
        private void OnViewChangeRequest(object sender, ViewChangeRequestArgs e)
        {
            BaseView viewToLoad = null;
            string windowTitle = string.Empty;

            bool mainMenuEnabled = true;

            switch (e.View)
            {
                case View.Dashboard:
                    {
                        windowTitle = " - Dashboard";
                        viewToLoad = m_viewDashboard;
                    }
                    break;

                case View.ProgressWait:
                    {
                        windowTitle = " - Working";
                        viewToLoad = m_viewProgressWait;
                        if (e.Data != null)
                        {
                            if (e.Data is string)
                            {
                                m_viewProgressWait.SetMessage(e.Data as string);
                            }
                        }

                        mainMenuEnabled = false;
                    }
                    break;

                case View.Statistics:
                    {
                        windowTitle = " - Statistics";
                        viewToLoad = m_viewStatistics;
                    }
                    break;

                case View.Settings:
                    {
                        windowTitle = " - Settings";
                        viewToLoad = m_viewSettings;
                    }
                    break;

                case View.Waste:
                    {
                        windowTitle = " - Waste Cost";
                        viewToLoad = m_viewWaste;
                    }
                    break;

                case View.Tray:
                    {
                        bool showTooltip = false;

                        if (e.Data != null)
                        {
                            if (e.Data is bool)
                            {
                                showTooltip = (bool)e.Data;
                            }
                        }

                        MinimizeToTray(showTooltip);
                    }
                    break;
            }

            if (viewToLoad != null)
            {
                Current.Dispatcher.BeginInvoke(
                    System.Windows.Threading.DispatcherPriority.Normal,
                    (Action)delegate ()
                    {
                        try
                        {
                            // Hide any active flyouts, as the way that we use them, they are always related to
                            // the current view.
                            m_primaryWindow.HideAllFlyouts();

                            // Progress view requires main menu to be disabled
                            if (mainMenuEnabled)
                            {
                                m_primaryWindow.EnableMainMenu();
                            }
                            else
                            {
                                m_primaryWindow.DisableMainMenu();
                            }

                            m_primaryWindow.CurrentView.Content = viewToLoad;
                            m_primaryWindow.Title = "Stahp It" + windowTitle;
                        }
                        catch (Exception err)
                        {
                            Debug.WriteLine(err.Message);
                            Debug.WriteLine(err.InnerException.Message);
                        }
                    }
                );
            }
        }