-
-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e708ef3
commit dc0531e
Showing
11 changed files
with
159 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<ui:UiWindow x:Class="Bloxstrap.UI.ExceptionDialog" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml" | ||
xmlns:local="clr-namespace:Bloxstrap.UI.MessageBox" | ||
mc:Ignorable="d" | ||
Width="480" | ||
MinHeight="0" | ||
SizeToContent="Height" | ||
Background="{ui:ThemeResource ApplicationBackgroundBrush}" | ||
ExtendsContentIntoTitleBar="True" | ||
WindowStartupLocation="CenterScreen"> | ||
<Grid> | ||
<Grid.RowDefinitions> | ||
<RowDefinition Height="Auto" /> | ||
<RowDefinition Height="*" /> | ||
<RowDefinition Height="Auto" /> | ||
</Grid.RowDefinitions> | ||
|
||
<ui:TitleBar Grid.Row="0" Grid.ColumnSpan="2" Padding="8" x:Name="RootTitleBar" ShowMinimize="False" ShowMaximize="False" CanMaximize="False" KeyboardNavigation.TabNavigation="None" /> | ||
|
||
<Grid Grid.Row="1" Margin="16"> | ||
<Grid.ColumnDefinitions> | ||
<ColumnDefinition Width="Auto" /> | ||
<ColumnDefinition Width="*" /> | ||
</Grid.ColumnDefinitions> | ||
<Image Grid.Column="0" Width="32" Height="32" Margin="0,0,15,0" VerticalAlignment="Top" RenderOptions.BitmapScalingMode="HighQuality" Source="pack://application:,,,/Resources/MessageBox/Error.png" /> | ||
<StackPanel Grid.Column="1"> | ||
<TextBlock Text="An exception occurred while running Bloxstrap" FontSize="18" Foreground="{DynamicResource TextFillColorPrimaryBrush}" /> | ||
<RichTextBox x:Name="ErrorRichTextBox" Padding="8" Margin="0,16,0,0" Block.LineHeight="2" FontFamily="Courier New" IsReadOnly="True" /> | ||
<TextBlock Text="Please report this exception through a GitHub issue or in our Discord chat, along with a copy of the log file that was created." Margin="0,16,0,0" TextWrapping="Wrap" Foreground="{DynamicResource TextFillColorPrimaryBrush}" /> | ||
</StackPanel> | ||
</Grid> | ||
|
||
<Border Grid.Row="2" Padding="15" Background="{ui:ThemeResource SolidBackgroundFillColorSecondaryBrush}"> | ||
<StackPanel Orientation="Horizontal" FlowDirection="LeftToRight" HorizontalAlignment="Right"> | ||
<Button x:Name="LocateLogFileButton" Content="Locate log file" /> | ||
<ComboBox x:Name="ReportOptions" SelectedIndex="0" Padding="12,6,12,6" Margin="12,0,0,0"> | ||
<ComboBoxItem Content="Report exception" Visibility="Collapsed" /> | ||
<ComboBoxItem Content="Report via GitHub" /> | ||
<ComboBoxItem Content="Report via Discord" /> | ||
</ComboBox> | ||
<Button x:Name="CloseButton" MinWidth="100" Content="Close" Margin="12,0,0,0" /> | ||
</StackPanel> | ||
</Border> | ||
</Grid> | ||
</ui:UiWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Configuration; | ||
using System.Diagnostics; | ||
using System.Linq; | ||
using System.Media; | ||
using System.Windows; | ||
using System.Windows.Controls; | ||
using System.Windows.Interop; | ||
using System.Windows.Media.Imaging; | ||
|
||
using Bloxstrap.Utility; | ||
|
||
namespace Bloxstrap.UI | ||
{ | ||
// hmm... do i use MVVM for this? | ||
// this is entirely static, so i think im fine without it, and this way is just so much more efficient | ||
|
||
/// <summary> | ||
/// Interaction logic for ExceptionDialog.xaml | ||
/// </summary> | ||
public partial class ExceptionDialog | ||
{ | ||
public ExceptionDialog(Exception exception) | ||
{ | ||
InitializeComponent(); | ||
|
||
Title = RootTitleBar.Title = $"{App.ProjectName} Exception"; | ||
ErrorRichTextBox.Selection.Text = $"{exception.GetType()}: {exception.Message}"; | ||
|
||
if (!App.Logger.Initialized) | ||
LocateLogFileButton.Content = "Copy log contents"; | ||
|
||
LocateLogFileButton.Click += delegate | ||
{ | ||
if (App.Logger.Initialized) | ||
Process.Start("explorer.exe", $"/select,\"{App.Logger.Filename}\""); | ||
else | ||
Clipboard.SetText(String.Join("\r\n", App.Logger.Backlog)); | ||
}; | ||
|
||
ReportOptions.DropDownClosed += (sender, e) => | ||
{ | ||
string? selectionName = ReportOptions.SelectedItem.ToString(); | ||
ReportOptions.SelectedIndex = 0; | ||
if (selectionName is null) | ||
return; | ||
if (selectionName.EndsWith("GitHub")) | ||
Utilities.ShellExecute($"https://github.com/{App.ProjectRepository}/issues"); | ||
else if (selectionName.EndsWith("Discord")) | ||
Utilities.ShellExecute("https://discord.gg/nKjV3mGq6R"); | ||
}; | ||
|
||
CloseButton.Click += delegate | ||
{ | ||
Close(); | ||
}; | ||
|
||
SystemSounds.Hand.Play(); | ||
} | ||
} | ||
} |