Skip to content

Commit

Permalink
A lot and a less (see in description)
Browse files Browse the repository at this point in the history
- IconSource default size
- More Msgbox overloads
- Gallery: API-in-action page for msgbox
Something I forgot to mention before:
- Msgbox use mica by default now
  • Loading branch information
NotYoojun committed Dec 22, 2024
1 parent de7098f commit a150575
Show file tree
Hide file tree
Showing 5 changed files with 256 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public static MessageBoxResult Show(Window owner, string messageBoxText, string
/// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the default result of the message box.</param>
/// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns>
/// <remarks>Use an overload of the Show method, which enables you to specify an owner window. Otherwise, the message box is owned by the window that is currently active.</remarks>
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult? defaultResult)=>
Show(GetActiveWindow(), messageBoxText, caption, button, icon, defaultResult);
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult? defaultResult, SystemSound sound = null) =>
Show(GetActiveWindow(), messageBoxText, caption, button, icon, defaultResult, sound);

/// <summary>
/// Displays a message box that has a message, title bar caption, button, and icon; and that accepts a default message box result and returns a result.
Expand All @@ -138,8 +138,8 @@ public static MessageBoxResult Show(string messageBoxText, string caption, Messa
/// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the default result of the message box.</param>
/// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns>
/// <remarks>Use an overload of the Show method, which enables you to specify an owner window. Otherwise, the message box is owned by the window that is currently active.</remarks>
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, FontIconData icon, MessageBoxResult? defaultResult) =>
Show(GetActiveWindow(), messageBoxText, caption, button, icon, defaultResult);
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, FontIconData icon, MessageBoxResult? defaultResult, SystemSound sound = null) =>
Show(GetActiveWindow(), messageBoxText, caption, button, icon, defaultResult, sound);

/// <summary>
/// Displays a message box that has a message, title bar caption, button, and icon; and that accepts a default message box result and returns a result.
Expand All @@ -151,8 +151,8 @@ public static MessageBoxResult Show(string messageBoxText, string caption, Messa
/// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the default result of the message box.</param>
/// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns>
/// <remarks>Use an overload of the Show method, which enables you to specify an owner window. Otherwise, the message box is owned by the window that is currently active.</remarks>
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, IconSource icon, MessageBoxResult? defaultResult) =>
Show(GetActiveWindow(), messageBoxText, caption, button, icon, defaultResult);
public static MessageBoxResult Show(string messageBoxText, string caption, MessageBoxButton button, IconSource icon, MessageBoxResult? defaultResult, SystemSound sound = null) =>
Show(GetActiveWindow(), messageBoxText, caption, button, icon, defaultResult, sound);

/// <summary>
/// Displays a message box in front of the specified window. The message box displays a message, title bar caption, button, and icon; and it also returns a result.
Expand Down Expand Up @@ -192,7 +192,7 @@ public static MessageBoxResult Show(Window owner, string messageBoxText, string
/// <remarks>By default, the message box appears in front of the window that is currently active.</remarks>
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, IconSource icon) =>
Show(owner, messageBoxText, caption, button, icon, null);

/// <summary>
/// Displays a message box in front of the specified window. The message box displays a message, title bar caption, button, and icon; and accepts a default message box result and returns a result.
/// </summary>
Expand All @@ -204,8 +204,9 @@ public static MessageBoxResult Show(Window owner, string messageBoxText, string
/// <param name="defaultResult">A <see cref="MessageBoxResult"/> value that specifies the default result of the message box.</param>
/// <returns>A <see cref="MessageBoxResult"/> value that specifies which message box button is clicked by the user.</returns>
/// <remarks>By default, the message box appears in front of the window that is currently active.</remarks>
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult? defaultResult) =>
Show(owner, messageBoxText, caption, button, icon.ToSymbol(), defaultResult, icon.ToAlertSound());
public static MessageBoxResult Show(Window owner, string messageBoxText, string caption, MessageBoxButton button, MessageBoxImage icon, MessageBoxResult? defaultResult, SystemSound sound = null) =>
Show(owner, messageBoxText, caption, button, icon.ToSymbol(), defaultResult, sound ?? icon.ToAlertSound());


/// <summary>
/// Displays a message box in front of the specified window. The message box displays a message, title bar caption, button, and icon; and accepts a default message box result and returns a result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
Title="Border" d:DesignWidth="800"
Loaded="Page_Loaded" mc:Ignorable="d">
<FrameworkElement.Resources>
<BitmapImage x:Key="WpfLibraryLogo" UriSource="/Assets/WpfLibrary_256w.png"/>
</FrameworkElement.Resources>
<StackPanel>
<local:ControlExample x:Name="Example1" HeaderText="A simple MessageBox with just message">
<local:ControlExample.Example>
Expand All @@ -30,6 +33,7 @@
<Button x:Name="Button_ShowMsg2_Question" Content="Question" Click="Button_ShowMsg2_Question_Click"/>
<Button x:Name="Button_ShowMsg2_Error" Content="Error" Click="Button_ShowMsg2_Error_Click"/>
<Button x:Name="Button_ShowMsg2_FontIconData" Content="Custom (using FontIconData)" Click="Button_ShowMsg2_FontIconData_Click"/>
<Button x:Name="Button_ShowMsg2_IconSource" Content="Custom (using IconSource)" Click="Button_ShowMsg2_IconSource_Click"/>
</ikw:SimpleStackPanel>

</ikw:SimpleStackPanel>
Expand All @@ -38,21 +42,24 @@

<local:ControlExample x:Name="Example3" HeaderText="MessageBoxes with Buttons">
<local:ControlExample.Example>
<ikw:SimpleStackPanel Spacing="8" Orientation="Horizontal">
<Button x:Name="Button_ShowMsg3_YesNo" Content="YesNo" Click="Button_ShowMsg3_YesNo_Click"/>
<Button x:Name="Button_ShowMsg3_YesNoCancel" Content="YesNoCancel" Click="Button_ShowMsg3_YesNoCancel_Click"/>
<Button x:Name="Button_ShowMsg3_OKCancel" Content="OKCancel" Click="Button_ShowMsg3_OKCancel_Click"/>
<ikw:SimpleStackPanel Spacing="10">
<ikw:SimpleStackPanel Spacing="8" Orientation="Horizontal">
<Button x:Name="Button_ShowMsg3_YesNo" Content="YesNo" Click="Button_ShowMsg3_YesNo_Click"/>
<Button x:Name="Button_ShowMsg3_YesNoCancel" Content="YesNoCancel" Click="Button_ShowMsg3_YesNoCancel_Click"/>
<Button x:Name="Button_ShowMsg3_OKCancel" Content="OKCancel" Click="Button_ShowMsg3_OKCancel_Click"/>
</ikw:SimpleStackPanel>
<TextBlock x:Name="TextBlock_Example3_Result" Text="Not clicked yet."/>

</ikw:SimpleStackPanel>
</local:ControlExample.Example>
</local:ControlExample>


<local:ControlExample x:Name="Example4" HeaderText="Change the backdrop of MessageBoxes">
<local:ControlExample.Example>
<ikw:SimpleStackPanel Spacing="8">
<ikw:SimpleStackPanel Spacing="8" Orientation="Vertical">
<TextBlock>
Select the backdrop style you want, and click the buttons (in other examples of this page) to see the effect.
Select the backdrop style you want, and click the buttons (in other examples elsewhere in this page) to see the effect.
</TextBlock>
<ui:RadioButtons x:Name="RadioButtons_DefaultBackdropStyle"
ItemsSource="{Binding Source={x:Type ui:BackdropType}, Converter={StaticResource EnumValuesConverter}}"
Expand All @@ -62,5 +69,57 @@
</local:ControlExample.Example>
</local:ControlExample>


<local:ControlExample x:Name="Example5" HeaderText="API in action">
<local:ControlExample.Example>
<ikw:SimpleStackPanel HorizontalAlignment="Center" VerticalAlignment="Center" Spacing="10">
<Button x:Name="Button_ShowMsg5" Content="Show Message" HorizontalAlignment="Center" Click="Button_ShowMsg5_Click"/>
<TextBlock x:Name="TextBlock_Example5_Result" Text="Not clicked yet." HorizontalAlignment="Center"/>
</ikw:SimpleStackPanel>
</local:ControlExample.Example>
<local:ControlExample.Options>
<ikw:SimpleStackPanel Style="{StaticResource OptionsPanelStyle}"
MaxWidth="280">
<FrameworkElement.Resources>
<Style TargetType="TextBox" BasedOn="{StaticResource {x:Static ui:ThemeKeys.DefaultTextBoxStyleKey}}">
<Setter Property="TextWrapping" Value="Wrap"/>
</Style>
<Style TargetType="ComboBox" BasedOn="{StaticResource {x:Static ui:ThemeKeys.DefaultComboBoxStyleKey}}">
<Setter Property="HorizontalAlignment" Value="Stretch" />
</Style>
</FrameworkElement.Resources>
<TextBox x:Name="TextBox_Example5_Message"
ui:ControlHelper.Header="Message"
Text="Always wondered why people never use their strongest attack first. What? You think i'm just gonna stand there and take it?"
TextChanged="TextBox_Example5_Message_TextChanged"/>
<TextBox x:Name="TextBox_Example5_Title"
ui:ControlHelper.Header="Title"
Text="sans."
TextChanged="TextBox_Example5_Title_TextChanged"/>
<ComboBox x:Name="ComboBox_Example5_Button"
ui:ControlHelper.Header="Button"
ItemsSource="{Binding Source={x:Type MessageBoxButton}, Converter={StaticResource EnumValuesConverter}}"
SelectedIndex="1"
SelectionChanged="ComboBox_Example5_Button_SelectionChanged"/>
<ComboBox x:Name="ComboBox_Example5_Image"
ui:ControlHelper.Header="Button"
ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ui:Page}, Path=Example5_IconSelects}"
SelectedIndex="1"
SelectionChanged="ComboBox_Example5_Image_SelectionChanged"/>
<ComboBox x:Name="ComboBox_Example5_DefaultButton"
ui:ControlHelper.Header="DefaultButton"
ItemsSource="{Binding Source={x:Type MessageBoxResult}, Converter={StaticResource EnumValuesConverter}}"
SelectedIndex="1"
SelectionChanged="ComboBox_Example5_DefaultButton_SelectionChanged"/>
<ComboBox x:Name="ComboBox_Example5_Sound"
ui:ControlHelper.Header="Sound"
ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=ui:Page}, Path=Example5_SoundSelects}"
SelectedIndex="1"
SelectionChanged="ComboBox_Example5_Sound_SelectionChanged"/>

</ikw:SimpleStackPanel>
</local:ControlExample.Options>

</local:ControlExample>
</StackPanel>
</ui:Page>
Loading

0 comments on commit a150575

Please sign in to comment.