Skip to content

Instantly share code, notes, and snippets.

[TestMethod]
[TestCategory("Windows - Bootstrap - ClientConnection")]
public async Task Connected_event_fires_on_connection()
{
// Arrange
int port = 1000;
var result = this.StartServer(port);
var serverInfo = new ServerConnectionInfo { Url = "127.0.0.1", Port = port };
var userInfo = new UserInformation { Nickname = "Unit", PrimaryNickname = "Unit" };
public async Task<NotificationManager> Connect(ServerConnectionInfo serverInfo, UserInformation userInfo)
{
this.tcpClient = new TcpClient();
this.ServerInformation = serverInfo;
this.UserInformation = userInfo;
try
{
await this.tcpClient.ConnectAsync(serverInfo.Url, serverInfo.Port);
}
public interface ILocalizationService
{
string GetLocalizedMessage(ResourceManager manager, string key);
}
public class LocalizationService : ILocalizationService
{
public string CurrentLocal { get; set; } = string.Empty;
public string GetLocalizedMessage(ResourceManager manager, string key)
public void Dispose()
{
this.networkCommunicator.Dispose();
}
<Window x:Class="WpfApplication1.MainWindow"
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:local="clr-namespace:WpfApplication1"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<Style x:Key="RootStyle" />
public class BaseBindableEntity : BaseEditableEntity
{
private static Dictionary<Type, IEnumerable<PropertyInfo>> bindableProperties =
new Dictionary<Type, IEnumerable<PropertyInfo>>();
public BaseBindableEntity()
{
Type thisType = this.GetType();
if (!bindableProperties.ContainsKey(thisType))
{
<Window x:Class="WpfApplication2.MainWindow"
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:local="clr-namespace:WpfApplication2"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
<ItemsControl ItemsSource="{Binding MyCollection}">
<Window x:Class="WpfApplication2.MainWindow"
x:Name="mainWindow"
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:local="clr-namespace:WpfApplication2"
mc:Ignorable="d"
Title="MainWindow" Height="350" Width="525">
<Grid>
private async void ShowAlert_Clicked(object sender, RoutedEventArgs e)
{
var alertService = ServiceFactory.CreateService<IAlertService>();
Debug.WriteLine("Entering Show Alert");
await alertService.ShowAlertAsync(
"Save Item",
"You have unsaved changes, would you like to save before closing?",
new CallbackDelegate( // Follow-up alert.
"Yes",
async () =>
<controls:MetroWindow x:Class="Pen.Apps.Desktop.Views.AlertDialog"
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:viewModels="clr-namespace:Pen.Apps.Presentation.ViewModels;assembly=Pen.Apps.Presentation"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:converters="clr-namespace:Pen.Apps.Desktop.Converters"
mc:Ignorable="d"
d:DataContext="{d:DesignInstance Type=viewModels:AlertDialogViewModel}"