Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Exmaple2.0/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
<Button Name="Standard_Show" Classes="View" Click="Standard_Show_OnClick" Content="Standard Show"/>
<Button Name="Standard_Dialog" Classes="View" Click="Standard_Dialog_OnClick" Content="Standard Dialog"/>
<Button Name="Standard_Popup" Classes="View" Click="Standard_Popup_OnClick" Content="Custom PopUp"/>
<Button Name="StandardInput_PopUp" Classes="View" Click="StandardInput_PopUp_OnClick" Content="Standard input popup"/>
<Button Name="StandardInputPassword_PopUp" Classes="View" Click="StandardInputPassword_PopUp_OnClick" Content="Standard input password popup"/>
<Button Name="Custom_Show" Classes="View" Click="Custom_Dialog_OnClick" Content="Custom Show"/>
<Button Name="Custom_MarkDown" Classes="View" Click="Custom_MarkDown_OnClick" Content="Custom Markdown"/>
<Button Name="Custom_Dialog" Classes="View" Click="Custom_Dialog_OnClick" Content="Custom dialog with image"/>
Expand Down
45 changes: 45 additions & 0 deletions Exmaple2.0/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,49 @@ await MessageBoxManager.GetMessageBoxCustom(
CloseOnClickAway = true
}).ShowAsPopupAsync(this);
}

private async void StandardInput_PopUp_OnClick(object? sender, RoutedEventArgs e)
{
var msBox = MessageBoxManager.GetMessageBoxStandard(
new MessageBoxStandardParams
{
ContentTitle = "Input",
Icon = MsBox.Avalonia.Enums.Icon.Question,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
CanResize = false,
MaxWidth = 500,
MaxHeight = 800,
SizeToContent = SizeToContent.WidthAndHeight,
ShowInCenter = true,
Topmost = false,
CloseOnClickAway = true,
InputParams = new InputParams { Label = "Your Name" }
});
await msBox.ShowAsPopupAsync(this);

Console.WriteLine("Your name is: " + msBox.InputValue);
}

private async void StandardInputPassword_PopUp_OnClick(object? sender, RoutedEventArgs e)
{
var msBox = MessageBoxManager.GetMessageBoxStandard(
new MessageBoxStandardParams
{
ContentTitle = "Password Input",
Icon = MsBox.Avalonia.Enums.Icon.Question,
WindowStartupLocation = WindowStartupLocation.CenterOwner,
CanResize = false,
MaxWidth = 500,
MaxHeight = 800,
SizeToContent = SizeToContent.WidthAndHeight,
ShowInCenter = true,
Topmost = false,
CloseOnClickAway = true,
InputParams = new InputParams { Label = "Your Password", IsPassword = true, }
});

await msBox.ShowAsPopupAsync(this);

Console.WriteLine("Your password is: " + msBox.InputValue);
}
}
7 changes: 5 additions & 2 deletions MsBox.Avalonia/Controls/MsBoxCustomView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock FontFamily="{Binding FontFamily}" IsVisible="{Binding IsInputVisible}" Text="{Binding InputLabel}" VerticalAlignment="Center" Margin="0,0,15,0" />
<TextBox Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding InputValue, Mode=TwoWay}" FontFamily="{Binding FontFamily}" IsVisible="{Binding IsInputVisible}"
AcceptsReturn="{Binding IsInputMultiline}" />
<TextBox Grid.Column="1" Text="{Binding InputValue, Mode=TwoWay}"
FontFamily="{Binding FontFamily}"
IsVisible="{Binding IsInputVisible}"
AcceptsReturn="{Binding IsInputMultiline}"
PasswordChar="{Binding InputPasswordChar}" />
</Grid>
<!--Buttons-->
<ItemsControl Name="ButtonItemsPresenter" Classes="buttons-item-presenter"
Expand Down
7 changes: 5 additions & 2 deletions MsBox.Avalonia/Controls/MsBoxStandardView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,11 @@
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock FontFamily="{Binding FontFamily}" IsVisible="{Binding IsInputVisible}" Text="{Binding InputLabel}" VerticalAlignment="Center" Margin="0,0,15,0" />
<TextBox Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding InputValue, Mode=TwoWay}" FontFamily="{Binding FontFamily}" IsVisible="{Binding IsInputVisible}"
AcceptsReturn="{Binding IsInputMultiline}" />
<TextBox Grid.Column="1" Text="{Binding InputValue, Mode=TwoWay}"
FontFamily="{Binding FontFamily}"
IsVisible="{Binding IsInputVisible}"
AcceptsReturn="{Binding IsInputMultiline}"
PasswordChar="{Binding InputPasswordChar}" />
</Grid>
<!--Buttons-->
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch" Grid.Row="4" Grid.Column="0" Grid.ColumnSpan="2"
Expand Down
4 changes: 4 additions & 0 deletions MsBox.Avalonia/Dto/AbstractMessageBoxParams.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,8 @@ public class InputParams
/// Input multiline
/// </summary>
public bool Multiline { get; set; }
/// <summary>
/// Input is password
/// </summary>
public bool IsPassword { get; set; }
}
2 changes: 2 additions & 0 deletions MsBox.Avalonia/ViewModels/AbstractMsBoxViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ protected AbstractMsBoxViewModel(AbstractMessageBoxParams @params, Icon icon = I
InputLabel = @params.InputParams.Label;
InputValue = @params.InputParams.DefaultValue;
IsInputMultiline = @params.InputParams.Multiline;
InputPasswordChar = @params.InputParams.IsPassword ? '*' : '\0';
IsInputVisible = true;
}
}
Expand Down Expand Up @@ -110,6 +111,7 @@ protected AbstractMsBoxViewModel(AbstractMessageBoxParams @params, Icon icon = I
public abstract string InputLabel { get; internal set; }
public abstract string InputValue { get; set; }
public abstract bool IsInputMultiline { get; internal set; }
public abstract char InputPasswordChar { get; internal set; }
public abstract bool IsInputVisible { get; internal set; }

#endregion
Expand Down
1 change: 1 addition & 0 deletions MsBox.Avalonia/ViewModels/MsBoxCustomViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public void SetFullApi(IFullApi<string> fullApi)
public override string InputLabel { get; internal set; }
public override string InputValue { get; set; }
public override bool IsInputMultiline { get; internal set; }
public override char InputPasswordChar { get; internal set; }
public override bool IsInputVisible { get; internal set; }
#endregion

Expand Down
1 change: 1 addition & 0 deletions MsBox.Avalonia/ViewModels/MsBoxStandardViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public void SetFullApi(IFullApi<ButtonResult> fullApi)
public override string InputLabel { get; internal set; }
public override string InputValue { get; set; }
public override bool IsInputMultiline { get; internal set; }
public override char InputPasswordChar { get; internal set; }
public override bool IsInputVisible { get; internal set; }
#endregion

Expand Down