After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 2.7 KiB |
After Width: | Height: | Size: 3.2 KiB |
After Width: | Height: | Size: 1.5 KiB |
After Width: | Height: | Size: 2.0 KiB |
After Width: | Height: | Size: 2.4 KiB |
After Width: | Height: | Size: 2.6 KiB |
After Width: | Height: | Size: 154 KiB |
After Width: | Height: | Size: 61 KiB |
After Width: | Height: | Size: 20 KiB |
@ -0,0 +1,91 @@ |
||||
<Window x:Class="SparkClient.Views.Dialog.MessageBox" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
||||
xmlns:local="clr-namespace:SparkClient.Views.Dialog" |
||||
mc:Ignorable="d" |
||||
WindowStyle="None" |
||||
AllowsTransparency="True" |
||||
Background="Transparent" |
||||
ResizeMode="NoResize" |
||||
Title="MessageBox" Height="Auto" Width="600"> |
||||
<Grid MouseLeftButtonDown="Grid_MouseLeftButtonDown"> |
||||
<Border CornerRadius="20" |
||||
BorderThickness="1" |
||||
BorderBrush="LightGray" |
||||
Background="White"> |
||||
<Grid> |
||||
<Grid.RowDefinitions> |
||||
<RowDefinition Height="50"/> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition Height="Auto"/> |
||||
<RowDefinition Height="Auto"/> |
||||
</Grid.RowDefinitions> |
||||
<Button Grid.Row="0" Background="Transparent" BorderBrush="Transparent" Height="32" Width="32" Click="CloseButton_OnClick" |
||||
HorizontalAlignment="Right" Padding="0" Margin="0 0 15 0 " x:Name="CloseButton" > |
||||
<Image Source="../../Resource/Images/UIResource/01-8.png" Width="30" Height="30" /> |
||||
</Button> |
||||
|
||||
<TextBlock Grid.Row="1" Width="600" TextWrapping = "Wrap" Padding="30 0" HorizontalAlignment="Center" |
||||
VerticalAlignment="Center" TextAlignment="Center" FontSize="18" x:Name="TextBlockCenterBox" Margin="0 20" |
||||
/> |
||||
<Border Grid.Row="2" Width="500" Height="40" CornerRadius="20" BorderBrush="#ebeef5" |
||||
BorderThickness="1" Background="#ebeef5" x:Name="BorderInput" Margin="0 20"> |
||||
<TextBox Width="500" BorderThickness="0" FontSize="18" HorizontalAlignment="Center" |
||||
Background="Transparent" Height="50" Padding="20 0" |
||||
VerticalAlignment="Center" TextAlignment="Center" x:Name="TextBoxInput" |
||||
/> |
||||
</Border> |
||||
<Grid Grid.Row="3" x:Name="GridButtons" Margin="0 20"> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="*" /> |
||||
<ColumnDefinition Width="*" /> |
||||
<ColumnDefinition Width="Auto" /> |
||||
<ColumnDefinition Width="*" /> |
||||
<ColumnDefinition Width="*" /> |
||||
</Grid.ColumnDefinitions> |
||||
|
||||
<Button x:Name="ConfirmButton" Grid.Column="1" Padding="0" Margin="0" Height="50" Click="ConfirmButton_OnClick" |
||||
BorderThickness="0" Background="Transparent" FocusVisualStyle="{x:Null}"> |
||||
<Border |
||||
HorizontalAlignment="Center" |
||||
VerticalAlignment="Center" |
||||
Margin="0 0 0 0" |
||||
Padding="10, 10" |
||||
Width="120" |
||||
BorderThickness="0" |
||||
CornerRadius="20"> |
||||
<Border.Background> |
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> |
||||
<GradientStop Color="#40b1ff" Offset="0"/> |
||||
<GradientStop Color="#3c9ce6" Offset="1"/> |
||||
</LinearGradientBrush> |
||||
</Border.Background> |
||||
<TextBlock FontSize="18" x:Name="ConfirmButtonText" TextAlignment="Center" Foreground="#ffffff"></TextBlock> |
||||
</Border> |
||||
</Button> |
||||
<Button x:Name="CancelButton" Grid.Column="3" Padding="0" Margin="0" Height="50" Click="CancelButton_OnClick" |
||||
BorderThickness="0" Background="Transparent" FocusVisualStyle="{x:Null}"> |
||||
<Border |
||||
HorizontalAlignment="Center" |
||||
VerticalAlignment="Center" |
||||
Margin="0 0 0 0" |
||||
Padding="10, 10" |
||||
Width="120" |
||||
BorderThickness="0" |
||||
CornerRadius="20"> |
||||
<Border.Background> |
||||
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> |
||||
<GradientStop Color="#a88ae4" Offset="0"/> |
||||
<GradientStop Color="#9072ca" Offset="1"/> |
||||
</LinearGradientBrush> |
||||
</Border.Background> |
||||
<TextBlock FontSize="18" x:Name="CancelButtonText" TextAlignment="Center" Foreground="#ffffff" /> |
||||
</Border> |
||||
</Button> |
||||
</Grid> |
||||
</Grid> |
||||
</Border> |
||||
</Grid> |
||||
</Window> |
@ -0,0 +1,124 @@ |
||||
|
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using SparkClient.Model.Helper; |
||||
|
||||
namespace SparkClient.Views.Dialog; |
||||
|
||||
public partial class MessageBox : Window |
||||
{ |
||||
public MessageBox() |
||||
{ |
||||
InitializeComponent(); |
||||
WindowStartupLocation = WindowStartupLocation.CenterScreen; |
||||
|
||||
} |
||||
private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
if (e.ButtonState == MouseButtonState.Pressed) |
||||
{ |
||||
this.DragMove(); |
||||
} |
||||
} |
||||
|
||||
private int _showType = -1; |
||||
private bool _result = false; |
||||
public void Show(String message, String btnStr = "") |
||||
{ |
||||
BorderInput.Visibility = Visibility.Hidden; |
||||
Grid.SetRow(GridButtons, 2); |
||||
CancelButton.Visibility = Visibility.Hidden; |
||||
Grid.SetColumn(ConfirmButton, 2); |
||||
TextBlockCenterBox.Text = message; |
||||
_showType = 0; |
||||
this.Height = 200; |
||||
if (!string.IsNullOrWhiteSpace(btnStr)) |
||||
{ |
||||
ConfirmButtonText.Text = btnStr; |
||||
} |
||||
else |
||||
{ |
||||
ConfirmButtonText.Text = MultilingualHelper.getString("DialogConfirmDefaultTitle"); |
||||
} |
||||
this.ShowDialog(); |
||||
|
||||
} |
||||
public MessageBoxResult ShowAsk(String message, String confirmButtonTitle = "", String cancelButtonTitle ="") |
||||
{ |
||||
BorderInput.Visibility = Visibility.Hidden; |
||||
Grid.SetRow(GridButtons, 2); |
||||
_showType = 1; |
||||
this.Height = 250; |
||||
TextBlockCenterBox.Text = message; |
||||
if (!string.IsNullOrWhiteSpace(confirmButtonTitle) && !string.IsNullOrWhiteSpace(cancelButtonTitle)) |
||||
{ |
||||
ConfirmButtonText.Text = confirmButtonTitle; |
||||
CancelButtonText.Text = cancelButtonTitle; |
||||
} |
||||
else |
||||
{ |
||||
ConfirmButtonText.Text = MultilingualHelper.getString("DialogConfirmDefaultTitle"); |
||||
CancelButtonText.Text = MultilingualHelper.getString("DialogCancelDefaultTitle"); |
||||
} |
||||
this.ShowDialog(); |
||||
|
||||
return _result==true ? MessageBoxResult.OK : MessageBoxResult.Cancel; |
||||
} |
||||
// |
||||
public MessageBoxResult ShowInput(String message, out String inputStr , String confirmButtonTitle = "", String cancelButtonTitle ="") |
||||
{ |
||||
_showType = 2; |
||||
this.Height = 350; |
||||
TextBlockCenterBox.Text = message; |
||||
if (!string.IsNullOrWhiteSpace(confirmButtonTitle) && !string.IsNullOrWhiteSpace(cancelButtonTitle)) |
||||
{ |
||||
ConfirmButtonText.Text = confirmButtonTitle; |
||||
CancelButtonText.Text = cancelButtonTitle; |
||||
} |
||||
else |
||||
{ |
||||
ConfirmButtonText.Text = MultilingualHelper.getString("DialogConfirmDefaultTitle"); |
||||
CancelButtonText.Text = MultilingualHelper.getString("DialogCancelDefaultTitle"); |
||||
} |
||||
this.ShowDialog(); |
||||
|
||||
inputStr = TextBoxInput.Text; |
||||
return _result==true ? MessageBoxResult.OK : MessageBoxResult.Cancel; |
||||
} |
||||
private void CloseButton_OnClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
this.Close(); |
||||
|
||||
} |
||||
|
||||
private void ConfirmButton_OnClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
if (_showType == 0) |
||||
{ |
||||
this.Close(); |
||||
}else if (_showType == 1) |
||||
{ |
||||
_result = true; |
||||
this.Close(); |
||||
}else if (_showType == 2) |
||||
{ |
||||
if (string.IsNullOrWhiteSpace(TextBoxInput.Text)) |
||||
{ |
||||
BorderInput.BorderBrush = Brushes.Red; |
||||
return; |
||||
} |
||||
else |
||||
{ |
||||
_result = true; |
||||
this.Close(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private void CancelButton_OnClick(object sender, RoutedEventArgs e) |
||||
{ |
||||
this.Close(); |
||||
} |
||||
} |