Browse Source

Fixed a compile error

Kenric Nugteren 1 month ago
parent
commit
43f000f527
1 changed files with 27 additions and 22 deletions
  1. 27 22
      prs.desktop/MainWindow.xaml.cs

+ 27 - 22
prs.desktop/MainWindow.xaml.cs

@@ -663,11 +663,6 @@ public partial class MainWindow : IPanelHostControl
         DynamicGridUtils.FilterBackground = ThemeManager.FilterBackgroundBrush;
         DynamicGridUtils.FilterForeground = ThemeManager.FilterForegroundBrush;
         
-        //_ribbon.Background =  new SolidColorBrush(Colors.White);
-        //_ribbon.BackStageColor = ThemeConverter.GetBrush(ElementType.Ribbon, BrushType.Background);
-        ////_ribbon.BackStage.Background = ThemeConverter.GetBrush(ElementType.Ribbon, BrushType.Background);
-        ////_ribbon.BackStage.Foreground = ThemeConverter.GetBrush(ElementType.Ribbon, BrushType.Foreground);
-
         UpdateRibbonColors();
         PanelHost.Refresh();
 
@@ -1239,6 +1234,19 @@ public partial class MainWindow : IPanelHostControl
 
     #endregion
 
+    private Fluent.Button? FindModuleButton(string name)
+    {
+        foreach (var tab in _ribbon.Tabs)
+        {
+            foreach (var bar in tab.Groups)
+            {
+                var item = bar.Items.OfType<Fluent.Button>().FirstOrDefault(x => Equals(x.Header, name));
+                if (item is not null) return item;
+            }
+        }
+        return null;
+    }
+
     private void LoadApplicationState()
     {
         if (ClientFactory.UserGuid != Guid.Empty)
@@ -1251,17 +1259,20 @@ public partial class MainWindow : IPanelHostControl
                     + "\n\nAccess to PRS is restricted until this is corrected.",
                     "Outstanding Reports");
 
-                var dailyReportPanel = LoadWindow<DailyReport>(ProjectDailyReportButton);
-                if(dailyReportPanel is not null)
+                if(FindModuleButton("Daily Report") is Fluent.Button button)
                 {
-                    dailyReportPanel.OnTimeSheetConfirmed += e =>
+                    var dailyReportPanel = LoadWindow<DailyReport>(button);
+                    if(dailyReportPanel is not null)
                     {
-                        if (!OutstandingDailyReports(true))
+                        dailyReportPanel.OnTimeSheetConfirmed += e =>
                         {
-                            ConfigureMainScreen(null);
-                            LoadApplicationState();
-                        }
-                    };
+                            if (!OutstandingDailyReports(true))
+                            {
+                                ConfigureMainScreen(null);
+                                LoadApplicationState();
+                            }
+                        };
+                    }
                 }
                 return;
             }
@@ -1698,11 +1709,6 @@ public partial class MainWindow : IPanelHostControl
             {
                 Dispatcher.Invoke(LoadSecondaryWindows);
             }
-
-            //if (_ribbon.Menu.IsVisible)
-            //{
-            //    _ribbon.;
-            //}
         }
         catch (Exception e)
         {
@@ -1991,13 +1997,12 @@ public partial class MainWindow : IPanelHostControl
     {
         foreach (Fluent.RibbonTabItem tab in _ribbon.Tabs)
             foreach (Fluent.RibbonGroupBox bar in tab.Groups)
-                foreach (var item in bar.Items)
+                foreach (var item in bar.Items.OfType<RibbonButton>())
                     Dispatcher.Invoke(() =>
                     {
-                        var button = item as RibbonButton;
-                        if (button != null && button.Label != "Refresh")
+                        if (item.Label != "Refresh")
                             if (bar.Header.Equals("Actions"))
-                                Modules.Register(button.Label);
+                                Modules.Register(item.Label);
                     });
     }