Przeglądaj źródła

DataGrid header tooltips work

Kenric Nugteren 1 rok temu
rodzic
commit
4f6accf319

+ 13 - 3
inabox.wpf/DynamicGrid/DynamicGrid.cs

@@ -382,6 +382,7 @@ namespace InABox.DynamicGrid
             DataGrid.CellTapped += DataGrid_CellTapped;
             DataGrid.CellDoubleTapped += DataGrid_CellDoubleTapped;
             DataGrid.SelectionChanging += DataGrid_SelectionChanging;
+            DataGrid.SelectionChanged += DataGrid_SelectionChanged;
             DataGrid.SelectionMode = GridSelectionMode.Extended;
             DataGrid.SelectionUnit = GridSelectionUnit.Row;
             DataGrid.CanMaintainScrollPosition = true;
@@ -631,6 +632,10 @@ namespace InABox.DynamicGrid
             }
         }
 
+        private void DataGrid_SelectionChanged(object? sender, GridSelectionChangedEventArgs e)
+        {
+        }
+
         public bool IsReady { get; private set; }
 
         public UIElement? Header
@@ -902,8 +907,7 @@ namespace InABox.DynamicGrid
                 return;
 
             var row = GetRowFromIndex(e.RowColumnIndex.RowIndex);
-            if (row is null)
-                return;
+
             e.ToolTip.Template = TemplateGenerator.CreateControlTemplate(
                 typeof(ToolTip),
                 () => toolTip.Invoke(col, row)
@@ -1294,9 +1298,13 @@ namespace InABox.DynamicGrid
 
         private void DataGrid_KeyUp(object sender, KeyEventArgs e)
         {
+            if (sender != DataGrid) return;
+
             if (!bFilterVisible && !bSwallowKey && DataGrid.SelectedIndex > -1)
+            {
                 //Logger.Send(LogType.Information, "", String.Format("{0}: KeyUp -> {1}", this.GetType().EntityName(), SelectedRows.Length));          
                 SelectItems(SelectedRows);
+            }
             bSwallowKey = false;
 
             if (IsSequenced)
@@ -1619,6 +1627,7 @@ namespace InABox.DynamicGrid
                         ApplyFilterStyle(newcol, true, true);
 
                         newcol.ShowToolTip = column.ToolTip != null;
+                        newcol.ShowHeaderToolTip = column.ToolTip != null;
 
                         var style = new Style();
                         style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
@@ -1687,7 +1696,7 @@ namespace InABox.DynamicGrid
                         newcol.AllowFiltering = column.Filters != null && column.Filters.Any();
                         newcol.AllowSorting = false;
                         newcol.FilterRowOptionsVisibility = Visibility.Collapsed;
-                        newcol.ShowToolTip = column.ToolTip != null;
+                        newcol.ShowHeaderToolTip = column.ToolTip != null;
 
                         var style = new Style();
                         style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));
@@ -1726,6 +1735,7 @@ namespace InABox.DynamicGrid
                         newcol.AllowSorting = false;
                         newcol.FilterRowOptionsVisibility = Visibility.Collapsed;
                         newcol.ShowToolTip = false;
+                        newcol.ShowHeaderToolTip = false;
 
                         var style = new Style();
                         style.Setters.Add(new Setter(BackgroundProperty, new SolidColorBrush(Colors.Gainsboro)));

+ 45 - 0
inabox.wpf/Forms/MessageWindow.xaml.cs

@@ -306,10 +306,55 @@ public partial class MessageWindow : Window, INotifyPropertyChanged
             .AddOKButton();
     }
 
+    /// <summary>
+    /// Display a message box for a non-exception error, giving options to view the logs.
+    /// </summary>
+    /// <param name="message">The message to display. Set to <see langword="null"/> to default to the exception message.</param>
+    /// <param name="details"></param>
+    /// <param name="title"></param>
+    /// <param name="shouldLog">If <see langword="true"/>, also logs the exception.</param>
+    public static MessageWindow NewError(string message, string? details = null, string title = "Error", bool shouldLog = true, ImageSource? image = null)
+    {
+        if (shouldLog)
+        {
+            Logger.Send(LogType.Error, ClientFactory.UserID, details ?? message);
+        }
+
+        var window = new MessageWindow()
+            .Message(message)
+            .Title(title);
+
+        if(details is not null)
+        {
+            window.Details(details);
+        }
+
+        window.Image(image ?? _warning)
+            .AddButton(new MessageWindowButton("Show Logs", ShowLogs_Click, MessageWindowButtonPosition.Left));
+
+        if(details is not null)
+        {
+            var showDetailsButton = new MessageWindowButton("Show Details", (win, button) =>
+            {
+                win.ShowDetails = !win.ShowDetails;
+                button.Content = win.ShowDetails
+                    ? "Hide Details"
+                    : "Show Details";
+            }, MessageWindowButtonPosition.Left);
+            window.AddButton(showDetailsButton);
+        }
+
+        return window.AddOKButton();
+    }
+
     public static void ShowError(string? message, Exception exception, string title = "Error", bool shouldLog = true, ImageSource? image = null)
     {
         NewError(message, exception, title, shouldLog, image).Display();
     }
+    public static void ShowError(string message, string details, string title = "Error", bool shouldLog = true, ImageSource? image = null)
+    {
+        NewError(message, details, title, shouldLog, image).Display();
+    }
 
     private static void ShowLogs_Click(MessageWindow window, MessageWindowButton button)
     {