Skip to content

Commit

Permalink
feat: add new features for overlay dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Stéphane ANDRE (E104915) committed Aug 17, 2024
1 parent 43c427d commit cbff89c
Show file tree
Hide file tree
Showing 11 changed files with 99 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/MyNet.Wpf.DragAndDrop/MyNet.Wpf.DragAndDrop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Offers a robust set of tools for seamlessly integrating drag-and-drop functionality into WPF applications.</Description>
<PackageTags>MyNet;UI;Xaml;Drag;Drop;Wpf</PackageTags>
<VersionPrefix>4.4.2</VersionPrefix>
<VersionPrefix>5.1.0</VersionPrefix>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/MyNet.Wpf.LiveCharts/MyNet.Wpf.LiveCharts.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Extends the functionality of the LiveCharts library, enhancing its capabilities for data visualization in .NET applications.</Description>
<PackageTags>MyNet;UI;Charts;Wpf;LiveCharts</PackageTags>
<VersionPrefix>4.4.2</VersionPrefix>
<VersionPrefix>5.1.0</VersionPrefix>
</PropertyGroup>

<PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/MyNet.Wpf.Presentation/MyNet.Wpf.Presentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>A comprehensive collection of controls, graphical elements, and views designed for accelerating WPF application development.</Description>
<PackageTags>MyNet;UI;Xaml;Presentation;Wpf</PackageTags>
<VersionPrefix>5.0.12</VersionPrefix>
<VersionPrefix>5.1.0</VersionPrefix>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/MyNet.Wpf.Web/MyNet.Wpf.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<PropertyGroup>
<Description>Provides developers with powerful tools to seamlessly integrate web components into WPF applications.</Description>
<PackageTags>MyNet;UI;Web;Xaml;Wpf</PackageTags>
<VersionPrefix>4.4.2</VersionPrefix>
<VersionPrefix>5.1.0</VersionPrefix>
</PropertyGroup>

<ItemGroup>
Expand Down
64 changes: 64 additions & 0 deletions src/MyNet.Wpf/Controls/OverlayDialogControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,70 @@ public Brush? OverlayBackground

#endregion

#region ContentMaxWidth

public static readonly DependencyProperty ContentMaxWidthProperty = DependencyProperty.Register(
nameof(ContentMaxWidth), typeof(double), typeof(OverlayDialogControl), new PropertyMetadata(double.PositiveInfinity));

/// <summary>
/// Represents the overlay brush that is used to dim the background behind the dialog
/// </summary>
public double ContentMaxWidth
{
get => (double)GetValue(ContentMaxWidthProperty);
set => SetValue(ContentMaxWidthProperty, value);
}

#endregion

#region ContentMinWidth

public static readonly DependencyProperty ContentMinWidthProperty = DependencyProperty.Register(
nameof(ContentMinWidth), typeof(double), typeof(OverlayDialogControl), new PropertyMetadata(0.0D));

/// <summary>
/// Represents the overlay brush that is used to dim the background behind the dialog
/// </summary>
public double ContentMinWidth
{
get => (double)GetValue(ContentMinWidthProperty);
set => SetValue(ContentMinWidthProperty, value);
}

#endregion

#region ContentMaxHeight

public static readonly DependencyProperty ContentMaxHeightProperty = DependencyProperty.Register(
nameof(ContentMaxHeight), typeof(double), typeof(OverlayDialogControl), new PropertyMetadata(double.PositiveInfinity));

/// <summary>
/// Represents the overlay brush that is used to dim the background behind the dialog
/// </summary>
public double ContentMaxHeight
{
get => (double)GetValue(ContentMaxHeightProperty);
set => SetValue(ContentMaxHeightProperty, value);
}

#endregion

#region ContentMinHeight

public static readonly DependencyProperty ContentMinHeightProperty = DependencyProperty.Register(
nameof(ContentMinHeight), typeof(double), typeof(OverlayDialogControl), new PropertyMetadata(0.0D));

/// <summary>
/// Represents the overlay brush that is used to dim the background behind the dialog
/// </summary>
public double ContentMinHeight
{
get => (double)GetValue(ContentMinHeightProperty);
set => SetValue(ContentMinHeightProperty, value);
}

#endregion

#region open dialog events/callbacks

public static readonly RoutedEvent OpenedEvent =
Expand Down
8 changes: 8 additions & 0 deletions src/MyNet.Wpf/Dialogs/IOverlayDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,13 @@ public interface IOverlayDialog
VerticalAlignment VerticalAlignment { get; }

HorizontalAlignment HorizontalAlignment { get; }

double MaxHeight { get; set; }

double MinHeight { get; set; }

double MinWidth { get; set; }

double MaxWidth { get; set; }
}
}
13 changes: 9 additions & 4 deletions src/MyNet.Wpf/Dialogs/OverlayDialogService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using MyNet.UI.Dialogs.Models;
using MyNet.Wpf.Controls;

Expand Down Expand Up @@ -74,10 +75,14 @@ private OverlayDialogControl GetOverlayDialogControl(object view, IDialogViewMod

if (overlayDialogObject is not null)
{
control.CloseOnClickAway = overlayDialogObject.CloseOnClickAway;
control.FocusOnShow = overlayDialogObject.FocusOnShow;
control.VerticalContentAlignment = overlayDialogObject.VerticalAlignment;
control.HorizontalContentAlignment = overlayDialogObject.HorizontalAlignment;
control.SetBinding(OverlayDialogControl.CloseOnClickAwayProperty, new Binding(nameof(IOverlayDialog.CloseOnClickAway)) { Source = overlayDialogObject });
control.SetBinding(OverlayDialogControl.FocusOnShowProperty, new Binding(nameof(IOverlayDialog.FocusOnShow)) { Source = overlayDialogObject });
control.SetBinding(Control.VerticalContentAlignmentProperty, new Binding(nameof(IOverlayDialog.VerticalAlignment)) { Source = overlayDialogObject });
control.SetBinding(Control.HorizontalContentAlignmentProperty, new Binding(nameof(IOverlayDialog.HorizontalAlignment)) { Source = overlayDialogObject });
control.SetBinding(OverlayDialogControl.ContentMaxHeightProperty, new Binding(nameof(IOverlayDialog.MaxHeight)) { Source = overlayDialogObject });
control.SetBinding(OverlayDialogControl.ContentMinHeightProperty, new Binding(nameof(IOverlayDialog.MinHeight)) { Source = overlayDialogObject });
control.SetBinding(OverlayDialogControl.ContentMaxWidthProperty, new Binding(nameof(IOverlayDialog.MaxWidth)) { Source = overlayDialogObject });
control.SetBinding(OverlayDialogControl.ContentMinWidthProperty, new Binding(nameof(IOverlayDialog.MinWidth)) { Source = overlayDialogObject });
}

// Load view Model on openning control
Expand Down
8 changes: 6 additions & 2 deletions src/MyNet.Wpf/Styles/MyNet.OverlayDialogControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
<Setter Property="FontFamily" Value="{me:RobotoFont}" />
<Setter Property="FontSize" Value="{Binding Path=(TextElement.FontSize), RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}}" />
<Setter Property="Foreground" Value="{DynamicResource MyNet.Brushes.Application.Foreground}" />
<Setter Property="OverlayBackground" Value="{DynamicResource MyNet.Brushes.Overlay}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="OverlayBackground" Value="{DynamicResource MyNet.Brushes.Overlay}" />
<Setter Property="Padding" Value="50" />
<Setter Property="Template">
<Setter.Value>
Expand Down Expand Up @@ -145,6 +144,10 @@
</Border.InputBindings>
</Border>
<ctrl:Card x:Name="PART_ContentElement"
MinWidth="{TemplateBinding ContentMinWidth}"
MinHeight="{TemplateBinding ContentMinHeight}"
MaxWidth="{TemplateBinding ContentMaxWidth}"
MaxHeight="{TemplateBinding ContentMaxHeight}"
Margin="{TemplateBinding Padding}"
Padding="0"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Expand Down Expand Up @@ -191,6 +194,7 @@
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="p:ElevationAssist.Elevation" Value="{StaticResource MyNet.Elevation.Popup}" />
</Style>
</ResourceDictionary>
6 changes: 3 additions & 3 deletions src/MyNet.Wpf/Themes/MyNet.Styles.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7632,9 +7632,8 @@ Styles\MyNet.VirtualizingWrapPanel.xaml
<Setter Property="FontFamily" Value="{me:RobotoFont}" />
<Setter Property="FontSize" Value="{Binding Path=(TextElement.FontSize), RelativeSource={RelativeSource AncestorType={x:Type FrameworkElement}}}" />
<Setter Property="Foreground" Value="{DynamicResource MyNet.Brushes.Application.Foreground}" />
<Setter Property="OverlayBackground" Value="{DynamicResource MyNet.Brushes.Overlay}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="OverlayBackground" Value="{DynamicResource MyNet.Brushes.Overlay}" />
<Setter Property="Padding" Value="50" />
<Setter Property="Template">
<Setter.Value>
Expand Down Expand Up @@ -7741,7 +7740,7 @@ Styles\MyNet.VirtualizingWrapPanel.xaml
<MouseBinding Command="{x:Static ctrl:OverlayDialogControl.CloseDialogCommand}" MouseAction="LeftClick" />
</Border.InputBindings>
</Border>
<ctrl:Card x:Name="PART_ContentElement" Margin="{TemplateBinding Padding}" Padding="0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" p:ElevationAssist.Elevation="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(p:ElevationAssist.Elevation)}" Background="{TemplateBinding Background}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" FocusManager.IsFocusScope="False" Focusable="False" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" IsHitTestVisible="True" IsTabStop="False" Opacity="0" RenderTransformOrigin=".5,.5" TextElement.FontFamily="{TemplateBinding FontFamily}" TextElement.FontSize="{TemplateBinding FontSize}" TextElement.FontStretch="{TemplateBinding FontStretch}" TextElement.FontStyle="{TemplateBinding FontStyle}" TextElement.FontWeight="{TemplateBinding FontWeight}" TextElement.Foreground="{TemplateBinding Foreground}" TextOptions.TextFormattingMode="Ideal" TextOptions.TextRenderingMode="Auto" UniformCornerRadius="{StaticResource MyNet.UniformCornerRadius.Container}">
<ctrl:Card x:Name="PART_ContentElement" MinWidth="{TemplateBinding ContentMinWidth}" MinHeight="{TemplateBinding ContentMinHeight}" MaxWidth="{TemplateBinding ContentMaxWidth}" MaxHeight="{TemplateBinding ContentMaxHeight}" Margin="{TemplateBinding Padding}" Padding="0" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" p:ElevationAssist.Elevation="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(p:ElevationAssist.Elevation)}" Background="{TemplateBinding Background}" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" FocusManager.IsFocusScope="False" Focusable="False" FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" IsHitTestVisible="True" IsTabStop="False" Opacity="0" RenderTransformOrigin=".5,.5" TextElement.FontFamily="{TemplateBinding FontFamily}" TextElement.FontSize="{TemplateBinding FontSize}" TextElement.FontStretch="{TemplateBinding FontStretch}" TextElement.FontStyle="{TemplateBinding FontStyle}" TextElement.FontWeight="{TemplateBinding FontWeight}" TextElement.Foreground="{TemplateBinding Foreground}" TextOptions.TextFormattingMode="Ideal" TextOptions.TextRenderingMode="Auto" UniformCornerRadius="{StaticResource MyNet.UniformCornerRadius.Container}">
<ctrl:Card.RenderTransform>
<TransformGroup>
<ScaleTransform x:Name="CardScaleTransform" ScaleX="0" ScaleY="0" />
Expand All @@ -7758,6 +7757,7 @@ Styles\MyNet.VirtualizingWrapPanel.xaml
</ControlTemplate>
</Setter.Value>
</Setter>
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="p:ElevationAssist.Elevation" Value="{StaticResource MyNet.Elevation.Popup}" />
</Style>
<Style x:Key="MyNet.Styles.PictureControl" TargetType="{x:Type ctrl:PictureControl}">
Expand Down
2 changes: 1 addition & 1 deletion src/tests/MyNet.Wpf.TestApp/MyNet.Wpf.TestApp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.6.24327.7" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.0-preview.7.24405.7" />
<PackageReference Include="Fody" Version="6.8.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:my="http://mynet.com/xaml/themes"
Width="500"
Height="200"
MaxWidth="500"
MaxHeight="200"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
d:DataContext="{d:DesignInstance Type=contents:LoginDialogViewModel}"
d:DesignHeight="450"
d:DesignWidth="800"
Expand Down

0 comments on commit cbff89c

Please sign in to comment.