Skip to content

Commit

Permalink
Merge pull request #21 from amkuchta/GH17-18_AdditionalContentArea
Browse files Browse the repository at this point in the history
GH 17/18 - Implements additional content areas
  • Loading branch information
AleksandarDev authored Jun 9, 2018
2 parents 5df9070 + f1db25e commit 5aa7e47
Show file tree
Hide file tree
Showing 9 changed files with 484 additions and 35 deletions.
12 changes: 11 additions & 1 deletion Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
VerticalAlignment="Top"
Background="#E0A030"
Click="ButtonBaseWarningOnClick"
Content="Warning"
Content="Warning (with header)"
Style="{StaticResource NotificationMessageButtonStyle}" />

<Button
Expand All @@ -85,6 +85,16 @@
Content="Animated info message with delayed dismiss (5s)"
Style="{StaticResource NotificationMessageButtonStyle}" />

<Button
Margin="8"
Padding="12,8"
HorizontalAlignment="Left"
VerticalAlignment="Top"
Background="#1751C3"
Click="ButtonBaseAdditionalContentOnClick"
Content="Additional Content Areas"
Style="{StaticResource NotificationMessageButtonStyle}" />

</StackPanel>
</Grid>
</controls1:MetroWindow>
Expand Down
72 changes: 72 additions & 0 deletions Enterwell.Clients.Wpf.Notifications.Sample/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ private void ButtonBaseWarningOnClick(object sender, RoutedEventArgs e)
.Accent("#E0A030")
.Background("#333")
.HasBadge("Warn")
.HasHeader("Error")
.HasMessage("Failed to retrieve data.")
.WithButton("Try again", button => { })
.Dismiss().WithButton("Ignore", button => { })
Expand Down Expand Up @@ -89,6 +90,77 @@ private void ButtonBaseInfoDelayOnClick(object sender, RoutedEventArgs e)
.Queue();
}

private void ButtonBaseAdditionalContentOnClick(object sender, RoutedEventArgs e)
{
Thickness margin = new Thickness();
margin.Top = margin.Bottom = margin.Left = margin.Right = 5;
this.Manager
.CreateMessage()
.Accent("#1751C3")
.Animates(true)
.AnimationInDuration(0.5)
.AnimationOutDuration(0.5)
.Background("#333")
.Foreground("#000")
.HasBadge("Info")
.HasHeader("Header")
.HasMessage("This is the message!")
.WithAdditionalContent(ContentLocation.Top, new Border
{
Height = 25,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Red
})
.WithAdditionalContent(ContentLocation.Bottom, new Border
{
Height = 25,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Green
})
.WithAdditionalContent(ContentLocation.Left, new Border
{
Width = 25,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Yellow
})
.WithAdditionalContent(ContentLocation.Right, new Border
{
Width = 25,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Violet
})
.WithAdditionalContent(ContentLocation.Main, new Border
{
MinHeight = 50,
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
Background = Brushes.Orange
})
.WithAdditionalContent(ContentLocation.OverBadge, new Border
{
Height = 40,
Width = 40,
Background = Brushes.Indigo
})
.WithOverlay(new ProgressBar
{
VerticalAlignment = VerticalAlignment.Bottom,
HorizontalAlignment = HorizontalAlignment.Stretch,
Height = 3,
BorderThickness = new Thickness(0),
Foreground = new SolidColorBrush(Color.FromArgb(128, 255, 255, 255)),
Background = Brushes.Transparent,
IsIndeterminate = true,
IsHitTestVisible = false
})
.Dismiss().WithButton("Dismiss", button => { })
.Queue();
}

/// <summary>
/// Gets the notification message manager.
/// </summary>
Expand Down
18 changes: 18 additions & 0 deletions Enterwell.Clients.Wpf.Notifications/ContentLocation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Enterwell.Clients.Wpf.Notifications
{
public enum ContentLocation
{
Top,
Bottom,
Left,
Right,
Main,
OverBadge
}
}
108 changes: 108 additions & 0 deletions Enterwell.Clients.Wpf.Notifications/Controls/NotificationMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,78 @@ public object OverlayContent
set => SetValue(OverlayContentProperty, value);
}

/// <summary>
/// Gets or sets the content of the top additional content area.
/// </summary>
/// <value>
/// The content of the top additional content area.
/// </value>
public object AdditionalContentTop
{
get => GetValue(AdditionalContentTopProperty);
set => SetValue(AdditionalContentTopProperty, value);
}

/// <summary>
/// Gets or sets the content of the bottom additional content area.
/// </summary>
/// <value>
/// The content of the bottom additional content area.
/// </value>
public object AdditionalContentBottom
{
get => GetValue(AdditionalContentBottomProperty);
set => SetValue(AdditionalContentBottomProperty, value);
}

/// <summary>
/// Gets or sets the content of the left additional content area.
/// </summary>
/// <value>
/// The content of the left additional content area.
/// </value>
public object AdditionalContentLeft
{
get => GetValue(AdditionalContentLeftProperty);
set => SetValue(AdditionalContentLeftProperty, value);
}

/// <summary>
/// Gets or sets the content of the right additional content area.
/// </summary>
/// <value>
/// The content of the right additional content area.
/// </value>
public object AdditionalContentRight
{
get => GetValue(AdditionalContentRightProperty);
set => SetValue(AdditionalContentRightProperty, value);
}

/// <summary>
/// Gets or sets the content of the center additional content area.
/// </summary>
/// <value>
/// The content of the center additional content area.
/// </value>
public object AdditionalContentMain
{
get => GetValue(AdditionalContentMainProperty);
set => SetValue(AdditionalContentMainProperty, value);
}

/// <summary>
/// Gets or sets the content of the top additional content area.
/// </summary>
/// <value>
/// The content of the top additional content area.
/// </value>
public object AdditionalContentOverBadge
{
get => GetValue(AdditionalContentOverBadgeProperty);
set => SetValue(AdditionalContentOverBadgeProperty, value);
}

/// <summary>
/// Gets or sets the accent brush.
/// </summary>
Expand Down Expand Up @@ -279,6 +351,42 @@ public DependencyProperty AnimationOutDependencyProperty
public static readonly DependencyProperty OverlayContentProperty =
DependencyProperty.Register("OverlayContent", typeof(object), typeof(NotificationMessage), new PropertyMetadata(null));

/// <summary>
/// The additional content top property.
/// </summary>
public static readonly DependencyProperty AdditionalContentTopProperty =
DependencyProperty.Register("AdditionalContentTop", typeof(object), typeof(NotificationMessage), new PropertyMetadata(null));

/// <summary>
/// The additional content bottom property.
/// </summary>
public static readonly DependencyProperty AdditionalContentBottomProperty =
DependencyProperty.Register("AdditionalContentBottom", typeof(object), typeof(NotificationMessage), new PropertyMetadata(null));

/// <summary>
/// The additional content left property.
/// </summary>
public static readonly DependencyProperty AdditionalContentLeftProperty =
DependencyProperty.Register("AdditionalContentLeft", typeof(object), typeof(NotificationMessage), new PropertyMetadata(null));

/// <summary>
/// The additional content right property.
/// </summary>
public static readonly DependencyProperty AdditionalContentRightProperty =
DependencyProperty.Register("AdditionalContentRight", typeof(object), typeof(NotificationMessage), new PropertyMetadata(null));

/// <summary>
/// The additional content center property.
/// </summary>
public static readonly DependencyProperty AdditionalContentMainProperty =
DependencyProperty.Register("AdditionalContentMain", typeof(object), typeof(NotificationMessage), new PropertyMetadata(null));

/// <summary>
/// The additional content over badge property.
/// </summary>
public static readonly DependencyProperty AdditionalContentOverBadgeProperty =
DependencyProperty.Register("AdditionalContentOverBadge", typeof(object), typeof(NotificationMessage), new PropertyMetadata(null));

/// <summary>
/// The accent brush property.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="ActionExtensions.cs" />
<Compile Include="ContentLocation.cs" />
<Compile Include="Controls\NotificationMessage.cs" />
<Compile Include="Controls\NotificationMessageButton.cs" />
<Compile Include="Controls\NotificationMessageContainer.cs" />
Expand Down
48 changes: 48 additions & 0 deletions Enterwell.Clients.Wpf.Notifications/INotificationMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,54 @@ public interface INotificationMessage
/// </value>
object OverlayContent { get; set; }

/// <summary>
/// Gets or sets the content of the top additional content area.
/// </summary>
/// <value>
/// The content of the top additional content area.
/// </value>
object AdditionalContentTop { get; set; }

/// <summary>
/// Gets or sets the content of the bottom additional content area.
/// </summary>
/// <value>
/// The additional content.
/// </value>
object AdditionalContentBottom { get; set; }

/// <summary>
/// Gets or sets the content of the left additional content area.
/// </summary>
/// <value>
/// The additional content.
/// </value>
object AdditionalContentLeft { get; set; }

/// <summary>
/// Gets or sets the content of the right additional content area.
/// </summary>
/// <value>
/// The additional content.
/// </value>
object AdditionalContentRight { get; set; }

/// <summary>
/// Gets or sets the content of the center additional content area.
/// </summary>
/// <value>
/// The additional content.
/// </value>
object AdditionalContentMain { get; set; }

/// <summary>
/// Gets or sets the content of the over badge additional content area.
/// </summary>
/// <value>
/// The additional content.
/// </value>
object AdditionalContentOverBadge { get; set; }

/// <summary>
/// Gets or sets the brush of the text.
/// </summary>
Expand Down
54 changes: 54 additions & 0 deletions Enterwell.Clients.Wpf.Notifications/NotificationMessageBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,60 @@ public void SetOverlay(object overlay)
this.Message.OverlayContent = overlay;
}

/// <summary>
/// Sets the top additional content.
/// </summary>
/// <param name="additionalContentTop">The additional content.</param>
public void SetAdditionalContentTop(object additionalContentTop)
{
this.Message.AdditionalContentTop = additionalContentTop;
}

/// <summary>
/// Sets the bottom additional content.
/// </summary>
/// <param name="additionalContentBottom">The additional content.</param>
public void SetAdditionalContentBottom(object additionalContentBottom)
{
this.Message.AdditionalContentBottom = additionalContentBottom;
}

/// <summary>
/// Sets the left additional content.
/// </summary>
/// <param name="additionalContentLeft">The additional content.</param>
public void SetAdditionalContentLeft(object additionalContentLeft)
{
this.Message.AdditionalContentLeft = additionalContentLeft;
}

/// <summary>
/// Sets the right additional content.
/// </summary>
/// <param name="additionalContentRight">The additional content.</param>
public void SetAdditionalContentRight(object additionalContentRight)
{
this.Message.AdditionalContentRight = additionalContentRight;
}

/// <summary>
/// Sets the center additional content.
/// </summary>
/// <param name="additionalContentMain">The additional content.</param>
public void SetAdditionalContentMain(object additionalContentMain)
{
this.Message.AdditionalContentMain = additionalContentMain;
}

/// <summary>
/// Sets the additional content over the badge.
/// </summary>
/// <param name="additionalContentOverBadge">The additional content.</param>
public void SetAdditionalContentOverBadge(object additionalContentOverBadge)
{
this.Message.AdditionalContentOverBadge = additionalContentOverBadge;
}

/// <summary>
/// Sets the text brush.
/// </summary>
Expand Down
Loading

0 comments on commit 5aa7e47

Please sign in to comment.