-
Notifications
You must be signed in to change notification settings - Fork 17
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
8a6c914
commit 5bae762
Showing
5 changed files
with
153 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,83 @@ | ||
// Denovo | ||
// Copyright (c) 2020 Autarkysoft | ||
// Distributed under the MIT software license, see the accompanying | ||
// file LICENCE or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
using Denovo.Models; | ||
using System; | ||
|
||
namespace Denovo.ViewModels | ||
{ | ||
public class MessageBoxViewModel : ViewModelBase | ||
{ | ||
public MessageBoxViewModel() | ||
{ | ||
Message = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et " + | ||
$"dolore magna aliqua. {Environment.NewLine}Ut enim ad minim veniam, quis nostrud exercitation ullamco " + | ||
$"laboris nisi ut aliquip ex ea commodo consequat."; | ||
IsDualCommand = true; | ||
CommandName1 = "cmd1"; | ||
CommandName2 = "cmd2"; | ||
} | ||
|
||
public MessageBoxViewModel(MessageBoxType t, string message) | ||
{ | ||
Message = message; | ||
msgType = t; | ||
switch (t) | ||
{ | ||
case MessageBoxType.Ok: | ||
CommandName1 = "Ok"; | ||
IsDualCommand = false; | ||
break; | ||
case MessageBoxType.OkCancel: | ||
CommandName1 = "OK"; | ||
CommandName2 = "Cancel"; | ||
IsDualCommand = true; | ||
break; | ||
case MessageBoxType.YesNo: | ||
CommandName1 = "Yes"; | ||
CommandName2 = "No"; | ||
IsDualCommand = true; | ||
break; | ||
default: | ||
throw new NotImplementedException(); | ||
} | ||
} | ||
|
||
|
||
private readonly MessageBoxType msgType; | ||
public string Message { get; } | ||
public bool IsDualCommand { get; } | ||
public string CommandName1 { get; } | ||
public string CommandName2 { get; } | ||
|
||
public MessageBoxResult Result { get; private set; } | ||
|
||
public void Command1() | ||
{ | ||
Result = msgType switch | ||
{ | ||
MessageBoxType.Ok => MessageBoxResult.Ok, | ||
MessageBoxType.OkCancel => MessageBoxResult.Ok, | ||
MessageBoxType.YesNo => MessageBoxResult.Yes, | ||
_ => throw new NotImplementedException(), | ||
}; | ||
|
||
RaiseCloseEvent(); | ||
} | ||
|
||
public void Command2() | ||
{ | ||
Result = msgType switch | ||
{ | ||
MessageBoxType.Ok => throw new Exception("This should never happen."), | ||
MessageBoxType.OkCancel => MessageBoxResult.Cancel, | ||
MessageBoxType.YesNo => MessageBoxResult.No, | ||
_ => throw new NotImplementedException(), | ||
}; | ||
|
||
RaiseCloseEvent(); | ||
} | ||
} | ||
} |
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,38 @@ | ||
<UserControl xmlns="https://github.com/avaloniaui" | ||
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:vm="clr-namespace:Denovo.ViewModels;assembly=Denovo" | ||
mc:Ignorable="d" | ||
x:CompileBindings="True" | ||
x:DataType="vm:MessageBoxViewModel" | ||
MaxWidth="400" | ||
x:Class="Denovo.Views.MessageBoxView"> | ||
|
||
<Design.DataContext> | ||
<vm:MessageBoxViewModel/> | ||
</Design.DataContext> | ||
|
||
<Grid RowDefinitions="*,auto"> | ||
<Grid ColumnDefinitions="auto,*" Grid.Row="0"> | ||
<Image Source="/Assets/Attention.png" | ||
Width="40" | ||
Margin="5" | ||
Grid.Column="0"/> | ||
<TextBlock Text="{Binding Message}" | ||
TextWrapping="Wrap" | ||
Margin="10" | ||
Grid.Column="1"/> | ||
</Grid> | ||
|
||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10" Margin="5" Grid.Row="1"> | ||
<Button Content="{Binding CommandName1}" | ||
Command="{Binding Command1}" | ||
Height="30" Width="65"/> | ||
<Button Content="{Binding CommandName2}" | ||
Command="{Binding Command2}" | ||
IsVisible="{Binding IsDualCommand}" | ||
Height="30" Width="65"/> | ||
</StackPanel> | ||
</Grid> | ||
</UserControl> |
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,17 @@ | ||
// Denovo | ||
// Copyright (c) 2020 Autarkysoft | ||
// Distributed under the MIT software license, see the accompanying | ||
// file LICENCE or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
using Avalonia.Controls; | ||
|
||
namespace Denovo.Views | ||
{ | ||
public partial class MessageBoxView : UserControl | ||
{ | ||
public MessageBoxView() | ||
{ | ||
InitializeComponent(); | ||
} | ||
} | ||
} |