示例#1
0
 public void ShowDialogWindow(object args)
 {
     if (args is ShowWindowMessage msg)
     {
         if (msg.windowName is "ChangePassword")
         {
             var viewModel = new ChangePasswordViewModel(msg.args as UserDetail);
             ShowChangePasswordDialog(viewModel);
         }
         else
         {
             logger.Trace("Showing " + msg.windowName);
             // retrieve window with possibly updated ViewModel with any other msg parameters, e.g. SearchText
             Window window = ViewModelToWindowMapper.GetWindow(msg.windowName, msg.searchText, msg.args);
             if (window != null)
             {
                 window.Owner = App.Current.MainWindow; /* this */
                 if (msg.modal)
                 {
                     window.ShowDialog();
                 }
                 else
                 {
                     window.Show();
                 }
             }
         }
     }
 }
示例#2
0
        /// <summary>
        /// Route to appropriate window
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void MainMenuAction(object param)
        {
            Window         newWin       = null;
            SimpleTreeItem selectedItem = param as SimpleTreeItem;

            logger.Info($"MainMenuAction - invoking: { selectedItem?.tag ?? "null" }");
            if (selectedItem?.label != null)
            {
                StatusLabel.Content = selectedItem.label;
            }
            else
            {
                StatusLabel.Content = "";
            }

            switch (selectedItem?.tag)
            {
            // expandable section or other control with no action associated with it
            case null:
                return;     // exit early and don't show internal error message

            // log off
            case "LogOut":
                LogOutBtn();
                return;

            // reports
            case "ReportSummary":
                newWin = new ReportWindow("Inventory Report");
                initializeInventorySummaryReport((ReportWindow)newWin);
                break;

            case "ReportItemStatus":
                newWin = new ReportWindow("Item Status Report");
                initializeItemStatusReport((ReportWindow)newWin);
                break;

            case "ReportVendorCost":
                newWin = new ReportWindow("Vendor Cost Report");
                initializeVendorCostReport((ReportWindow)newWin);
                break;

            case "ReportWeight":
                newWin = new ReportWindow("Weight Report");
                initializeWeightReport((ReportWindow)newWin);
                break;

            case "ReportExpiration":
                newWin = new ReportWindow("Expiration Report");
                initializeExpirationReport((ReportWindow)newWin);
                break;

            case "ReportService":
                newWin = new ReportWindow("Service Report");
                initializeServiceReport((ReportWindow)newWin);
                break;

            case "ReportDeployment":
                newWin = new ReportWindow("Deployment Report");
                initializeDeploymentReport((ReportWindow)newWin);
                break;

            case "ReportDamaged":
                newWin = new ReportWindow("Missing/Damaged Report");
                initializeDamagedOrMissingReport((ReportWindow)newWin);
                break;

            default:
                newWin = ViewModelToWindowMapper.GetWindow(selectedItem?.tag);
                break;
            }

            if (newWin == null)
            {
                MessageBox.Show("Internal Error selecting item", "Internal Error:", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                try
                {
                    App.Current.MainWindow = newWin;
                    newWin.Owner           = this;
                    newWin.ShowDialog();
                }
                catch (Exception e)
                {
                    logger.Error(e, $"Internal error - {e.Message}");
                    throw;
                }
            }
        }