aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-10-11 18:15:09 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-10-11 18:15:09 +0300
commitb8e83094d2a83708a985b44de0cb838a13c52cc2 (patch)
tree7f055521314988819d062c18116da49b8c45a3be /Software/Visual_Studio
parentac3f1ee33017e1823cfff46073b1a617b438d612 (diff)
parent0d7ae57d3c908fb192fd4ac668458b4e69945807 (diff)
downloadTango-b8e83094d2a83708a985b44de0cb838a13c52cc2.tar.gz
Tango-b8e83094d2a83708a985b44de0cb838a13c52cc2.zip
Merged Notification_Control Branch.
Diffstat (limited to 'Software/Visual_Studio')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs10
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml14
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml14
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs211
-rw-r--r--Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml18
5 files changed, 90 insertions, 177 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs
index cf81237ca..6a29511a9 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItem.cs
@@ -32,16 +32,6 @@ namespace Tango.PPC.Common.Notifications
Priority = NotificationPriority.Normal;
}
- private bool _isExpanded;
- /// <summary>
- /// Gets or sets a value indicating whether the notification panel is expanded.
- /// </summary>
- public bool IsExpanded
- {
- get { return _isExpanded; }
- set { _isExpanded = value; RaisePropertyChangedAuto(); }
- }
-
private bool _canClose;
/// <summary>
/// Gets or sets a value indicating whether this instance can close.
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml
index e79696a55..a6df8876e 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Notifications/NotificationItems/MessageNotificationItemView.xaml
@@ -8,7 +8,7 @@
xmlns:common="clr-namespace:Tango.PPC.Common.Converters"
mc:Ignorable="d"
x:Name="MessageNotificationItemControl"
- d:DesignHeight="60" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=local:MessageNotificationItem, IsDesignTimeCreatable=False}" MinHeight="90" Height="90" MaxHeight="150" Background="White">
+ d:DesignHeight="60" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=local:MessageNotificationItem, IsDesignTimeCreatable=False}" MinHeight="90" MaxHeight="150" Background="White">
<UserControl.Resources>
<common:HeightToOpacityConverter x:Key="heightToOpacityConverter" />
@@ -111,20 +111,20 @@
</touch:TouchIcon.Style>
</touch:TouchIcon>
- <StackPanel Margin="10 0 0 0" VerticalAlignment="Center">
+ <StackPanel Margin="10 5 0 5" VerticalAlignment="Center">
<TextBlock Text="{Binding Message}" TextTrimming="CharacterEllipsis" TextWrapping="Wrap" Foreground="Black" VerticalAlignment="Center" ></TextBlock>
- <Canvas Margin="0 5 0 0">
- <TextBlock Foreground="{StaticResource TangoDarkForegroundBrush}" Text="{Binding ExpandedMessage}" TextWrapping="Wrap" VerticalAlignment="Center">
- <TextBlock.Opacity>
+
+ <TextBlock Margin="0 5 0 0" Foreground="{StaticResource TangoDarkForegroundBrush}" Text="{Binding ExpandedMessage}" TextWrapping="Wrap" VerticalAlignment="Center" >
+ <!--<TextBlock.Opacity>
<MultiBinding Converter="{StaticResource heightToOpacityConverter}">
<Binding Path="ActualHeight" ElementName="MessageNotificationItemControl" />
<Binding Path="MinHeight" ElementName="MessageNotificationItemControl" />
<Binding Path="MaxHeight" ElementName="MessageNotificationItemControl" />
</MultiBinding>
- </TextBlock.Opacity>
+ </TextBlock.Opacity>-->
</TextBlock>
- </Canvas>
+
</StackPanel>
</DockPanel>
</ContentControl>
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml
index b2a267b19..76e20a817 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml
+++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Views/LayoutView.xaml
@@ -249,9 +249,7 @@
<touch:TouchNotificationBar
NotificationBarVisibility="{Binding NotificationProvider.NotificationsVisible,Converter={StaticResource BooleanToVisibilityConverter}}"
- HasNotifications="{Binding NotificationProvider.HasNotificationItems}"
- Notifications="{Binding NotificationProvider.NotificationItems}"
- ItemExpandedPropertyPath="IsExpanded">
+ HasNotifications="{Binding NotificationProvider.HasNotificationItems}" Notifications="{Binding NotificationProvider.NotificationItems}">
<touch:TouchNotificationBar.NotificationTemplate>
<DataTemplate>
<components:Ripple Padding="0">
@@ -259,7 +257,10 @@
<touch:TouchClickableControl Command="{Binding PressedCommand}">
<ContentControl Content="{Binding Converter={StaticResource ItemBaseConverter}}"/>
</touch:TouchClickableControl>
- <touch:TouchIconButton Visibility="{Binding CanClose,Converter={StaticResource BooleanToVisibilityConverter}}" DockPanel.Dock="Right" Background="Transparent" Padding="35" Style="{StaticResource TangoRoundTouchIconButton}" Command="{Binding CloseCommand}" CommandParameter="{Binding}" HorizontalAlignment="Right" MaxHeight="90" Width="{Binding RelativeSource={RelativeSource Self},Path=ActualHeight}" Icon="Close" Foreground="{StaticResource TangoDarkForegroundBrush}" />
+ <Grid Margin="0 7 7 0" HorizontalAlignment="Right" VerticalAlignment="Top">
+ <Ellipse Fill="White" StrokeThickness="1" Stroke="{StaticResource TangoDarkForegroundBrush}" />
+ <touch:TouchIconButton Visibility="{Binding CanClose,Converter={StaticResource BooleanToVisibilityConverter}}" DockPanel.Dock="Right" Background="Transparent" Style="{StaticResource TangoRoundTouchIconButton}" Command="{Binding CloseCommand}" CommandParameter="{Binding}" HorizontalAlignment="Right" Width="20" Icon="Close" Foreground="{StaticResource TangoDarkForegroundBrush}" Padding="5" />
+ </Grid>
</Grid>
</components:Ripple>
</DataTemplate>
@@ -268,9 +269,8 @@
<Border BorderThickness="0 0 0 1" BorderBrush="{StaticResource TangoDividerBrush}" DockPanel.Dock="Top">
<DockPanel>
<Border BorderThickness="0 0 1 0" BorderBrush="{StaticResource TangoDividerBrush}">
- <touch:TouchHamburgerButton IsHitTestVisible="{Binding NavigationManager.IsNavigating,Converter={StaticResource BooleanInverseConverter}}" IsEnabled="{Binding NavigationManager.IsBackEnabled}" Width="100" Height="100" Padding="15" Command="{Binding MenuOrBackCommand}" EnableDropShadow="False" Foreground="{StaticResource TangoPrimaryAccentBrush}" IsBack="{Binding NavigationManager.CanNavigateBack}">
-
- </touch:TouchHamburgerButton>
+ <touch:TouchHamburgerButton IsHitTestVisible="{Binding NavigationManager.IsNavigating,Converter={StaticResource BooleanInverseConverter}}" IsEnabled="{Binding NavigationManager.IsBackEnabled}" Width="100" Height="100" Padding="15" Command="{Binding MenuOrBackCommand}" EnableDropShadow="False" Foreground="{StaticResource TangoPrimaryAccentBrush}" IsBack="{Binding NavigationManager.CanNavigateBack}"/>
+
</Border>
<Grid DockPanel.Dock="Right" Margin="0 0 20 0">
<StackPanel Orientation="Horizontal">
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs
index d7f79cb8d..8ed4ead69 100644
--- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.cs
@@ -27,6 +27,7 @@ namespace Tango.Touch.Controls
public class TouchNotificationBar : ContentControl
{
private const double HEIGHT_RATIO = 0.75;
+ private const double DRAGPATH_HEIGH = 20.0;
private bool _isMouseDown;
private Point _mouseDownLocation;
@@ -47,18 +48,9 @@ namespace Tango.Touch.Controls
private Grid _notification_counter_grid;
private LightTouchScrollViewer _scrollViewer;
- static TouchNotificationBar()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchNotificationBar), new FrameworkPropertyMetadata(typeof(TouchNotificationBar)));
- }
- public String ItemExpandedPropertyPath
- {
- get { return (String)GetValue(ItemExpandedPropertyPathProperty); }
- set { SetValue(ItemExpandedPropertyPathProperty, value); }
- }
- public static readonly DependencyProperty ItemExpandedPropertyPathProperty =
- DependencyProperty.Register("ItemExpandedPropertyPath", typeof(String), typeof(TouchNotificationBar), new PropertyMetadata(null));
+
+ #region Dep_Properties
public bool HasNotifications
{
@@ -115,8 +107,18 @@ namespace Tango.Touch.Controls
}
public static readonly DependencyProperty NotificationBarVisibilityProperty =
DependencyProperty.Register("NotificationBarVisibility", typeof(Visibility), typeof(TouchNotificationBar), new PropertyMetadata(Visibility.Visible));
+
+ #endregion
+
+ #region constructors
+
+ static TouchNotificationBar()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(TouchNotificationBar), new FrameworkPropertyMetadata(typeof(TouchNotificationBar)));
+ }
public TouchNotificationBar()
{
+ IsExpanded = false;
Loaded += TouchNotificationBar_Loaded;
NotificationPressedCommand = new RelayCommand(() =>
@@ -128,10 +130,10 @@ namespace Tango.Touch.Controls
});
}
- private void TouchNotificationBar_Loaded(object sender, RoutedEventArgs e)
- {
- _border_drag.MaxHeight = ActualHeight;
- }
+ #endregion
+
+
+ #region Override_Base
public override void OnApplyTemplate()
{
@@ -143,188 +145,121 @@ namespace Tango.Touch.Controls
_items_control = GetTemplateChild("PART_ItemsControl") as ItemsControl;
_notification_counter_grid = GetTemplateChild("PART_NotificationCounterGrid") as Grid;
_scrollViewer = GetTemplateChild("PART_ScrollViewer") as LightTouchScrollViewer;
-
- //border_notifications.IsManipulationEnabled = true;
+
_border_drag.RegisterForPreviewMouseOrTouchDown(GridNotificationMouseDown);
_border_drag.RegisterForMouseOrTouchMove(GridNotificationMouseMove);
_border_drag.RegisterForPreviewMouseOrTouchUp(GridNotificationMouseUp);
-
_border_drag.SizeChanged += Drag_Border_SizeChanged;
- _items_control.ItemContainerGenerator.StatusChanged += ItemContainerGenerator_StatusChanged;
+
}
- private void ItemContainerGenerator_StatusChanged(object sender, EventArgs e)
- {
- if (_items_control.ItemContainerGenerator.Status == System.Windows.Controls.Primitives.GeneratorStatus.ContainersGenerated)
- {
- if (_items_control.Items.Count > 0)
- {
- var element = _items_control.ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement;
+ #endregion
- if (element != null)
- {
- element.RegisterForLoadedOrNow((x, y) =>
- {
- var userControl = element.FindChild<UserControl>();
-
- if (userControl != null)
- {
- CurrentMinHeight = userControl.MinHeight;
- }
- });
- }
- }
- else
- {
- CurrentMinHeight = 0;
- }
- }
- }
private FrameworkElement GetLastNotification()
{
return _items_control.ItemContainerGenerator.ContainerFromIndex(0) as FrameworkElement;
}
+ private void TouchNotificationBar_Loaded(object sender, RoutedEventArgs e)
+ {
+ _border_drag.MaxHeight = ActualHeight;
+ }
private void Drag_Border_SizeChanged(object sender, SizeChangedEventArgs e)
{
_grid_mask.Opacity = _border_drag.ActualHeight / ActualHeight;
- ResizeNotifications();
-
- if (e.NewSize.Height > CurrentMinHeight && CurrentMinHeight > 0)
+ if (e.NewSize.Height > CurrentMinHeight && CurrentMinHeight > 0 )
{
_notification_counter_grid.Visibility = Visibility.Hidden;
}
- else
+ else if(Notifications.Count > 1 && CurrentMinHeight > 0)
{
_notification_counter_grid.Visibility = Visibility.Visible;
}
}
- private void ResizeNotifications()
+ /// <summary>
+ /// Called when has notifications items or all items removed
+ /// </summary>
+ private void OnHasNotificationsChanged()
{
- for (int i = 0; i < _items_control.Items.Count; i++)
+ if (HasNotifications)
{
- FrameworkElement element = _items_control.ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement;
- ResizeNotification(element);
+ UpdateMinHeightByDispalyedItem();
}
- }
-
- private void ResizeNotification(FrameworkElement element)
- {
- var control = element.FindChild<UserControl>();
-
- if (control != null && !double.IsNaN(_border_drag.Height))
+ else
{
- control.Height = ((_border_drag.Height - CurrentMinHeight) / ActualHeight) * (control.MaxHeight - control.MinHeight) + control.MinHeight;
+ CurrentMinHeight = 0;
+ if (IsExpanded)
+ {
+ CloseNotifications();
+ }
+ _border_notifications.Height = CurrentMinHeight;
+ _grid_container.MinHeight = 0;
+ _grid_container.Height = 0;
}
}
- private void OnHasNotificationsChanged()
+ private void UpdateMinHeightByDispalyedItem()
{
- DoubleAnimation ani = new DoubleAnimation();
- ani.Duration = TimeSpan.FromSeconds(0.2);
-
- _grid_container.EnsureHeight();
-
- if (HasNotifications)
+ var last = GetLastNotification();
+ if(last != null)
{
- var last = GetLastNotification();
-
- last.RegisterForLoadedOrNow((x, e) =>
+ last.RegisterForLoadedOrNow((x, y) =>
{
- ani.To = last.ActualHeight;
- _grid_container.BeginAnimation(Grid.HeightProperty, ani);
+ CurrentMinHeight = last.ActualHeight;
_border_notifications.Height = last.ActualHeight;
+ _grid_container.MinHeight = last.ActualHeight;
+ _grid_container.Height = CurrentMinHeight;
});
}
- else
- {
- CurrentMinHeight = 0;
- ani.To = 0;
- CloseNotifications();
- _grid_container.BeginAnimation(Grid.HeightProperty, ani);
- }
}
-
- private void OnNotificationsChanged()
+ /// <summary>
+ /// Callback function on Notifications property
+ /// </summary>
+ private void OnNotificationsChanged()
{
- UpdateExpanded(IsExpanded);
-
if (Notifications is INotifyCollectionChanged)
{
(Notifications as INotifyCollectionChanged).CollectionChanged += (_, e) =>
{
this.BeginInvoke(() =>
{
- if (e.NewItems != null && e.NewItems.Count > 0)
+ if(Notifications.Count > 0)
{
- foreach (var item in e.NewItems.Cast<Object>().ToList())
- {
- var element = _items_control.ItemContainerGenerator.ContainerFromItem(item) as FrameworkElement;
- if (element != null)
- {
- element.RegisterForLoadedOrNow((___, ____) =>
- {
- ResizeNotification(element);
- });
- }
- }
+ UpdateMinHeightByDispalyedItem();
+ }
+ if (IsExpanded == false && Notifications.Count > 1)
+ {
+ _notification_counter_grid.Visibility = Visibility.Visible;
+ }
+ else
+ {
+ _notification_counter_grid.Visibility = Visibility.Hidden;
}
-
- UpdateExpanded(IsExpanded);
});
- };
+ };
+
}
}
-
- private void UpdateExpanded(bool expanded)
- {
- if (ItemExpandedPropertyPath != null)
- {
- foreach (var item in Notifications.Cast<Object>().ToList())
- {
- item.SetPropertyValueByPath(ItemExpandedPropertyPath, expanded);
- }
- }
- }
-
+
+ #region Mouse handlers
private void OpenNotifications()
{
- _border_drag.EnsureHeight();
- _border_notifications.EnsureHeight();
-
_border_drag.StartDoubleAnimation(Border.HeightProperty, TimeSpan.FromSeconds(0.2), _border_drag.MaxHeight, null, null, 1, () =>
- {
- IsExpanded = true;
- });
+ {
+ IsExpanded = true;
+ });
_border_notifications.StartDoubleAnimation(Border.HeightProperty, TimeSpan.FromSeconds(0.2), ActualHeight * HEIGHT_RATIO, null, null, 1);
-
- UpdateExpanded(true);
}
private void CloseNotifications()
{
- _border_drag.EnsureHeight();
- _border_notifications.EnsureHeight();
-
_border_notifications.StartDoubleAnimation(Border.HeightProperty, TimeSpan.FromSeconds(0.2), CurrentMinHeight, null, 1, null, () =>
{
_border_notifications.BeginAnimation(Border.HeightProperty, null);
_border_notifications.Height = CurrentMinHeight;
-
- for (int i = 0; i < _items_control.Items.Count; i++)
- {
- FrameworkElement element = _items_control.ItemContainerGenerator.ContainerFromIndex(i) as FrameworkElement;
-
- var control = element.FindChild<UserControl>();
-
- if (control != null)
- {
- control.Height = control.MinHeight;
- }
- }
});
_border_drag.StartDoubleAnimation(Border.HeightProperty, TimeSpan.FromSeconds(0.2), CurrentMinHeight, null, 1, null, () =>
@@ -337,9 +272,7 @@ namespace Tango.Touch.Controls
tAni.Duration = TimeSpan.FromSeconds(0.3);
tAni.To = new Thickness(0);
_border_notifications.BeginAnimation(Border.BorderThicknessProperty, tAni);
-
- UpdateExpanded(false);
-
+
IsExpanded = false;
Task.Delay(400).ContinueWith((x) =>
@@ -432,7 +365,7 @@ namespace Tango.Touch.Controls
if (_border_notifications.ActualHeight > CurrentMinHeight)
{
- _border_notifications.BorderThickness = new Thickness(0, 0, 0, 20);
+ _border_notifications.BorderThickness = new Thickness(0, 0, 0, DRAGPATH_HEIGH);
}
else
{
@@ -455,5 +388,7 @@ namespace Tango.Touch.Controls
_isMouseDown = true;
}
}
+
+ #endregion
}
}
diff --git a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml
index d097aa2bb..689981de6 100644
--- a/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml
+++ b/Software/Visual_Studio/Tango.Touch/Controls/TouchNotificationBar.xaml
@@ -8,7 +8,6 @@
<ResourceDictionary Source="../Resources/Colors.xaml" />
</ResourceDictionary.MergedDictionaries>
- <converters:GreaterThanToBooleanConverter x:Key="GreaterThanToBooleanConverter" />
<Style TargetType="{x:Type local:TouchNotificationBar}">
<Setter Property="Template">
@@ -27,7 +26,6 @@
<ContentPresenter Grid.Row="1" Content="{TemplateBinding Content}" />
<Grid x:Name="PART_GridMask" Grid.RowSpan="2" Background="{StaticResource TangoNotificationBarMaskBrush}" Opacity="0" IsHitTestVisible="False">
-
</Grid>
<Grid x:Name="PART_Grid_Container" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent},Path=NotificationBarVisibility}" VerticalAlignment="Top" Background="Transparent" ClipToBounds="False">
@@ -36,6 +34,7 @@
<Border x:Name="PART_BorderNotifications" VerticalAlignment="Top" BorderBrush="{StaticResource TangoNotificationBarBottomBorderBrush}" Background="{StaticResource TangoNotificationBarBackgroundBrush}">
<local:LightTouchScrollViewer x:Name="PART_ScrollViewer">
<ItemsControl x:Name="PART_ItemsControl" ItemsSource="{Binding RelativeSource={RelativeSource TemplatedParent},Path=Notifications}">
+
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border Background="{StaticResource TangoNotificationBackgroundBrush}" BorderBrush="{StaticResource TangoNotificationBorderBrush}" BorderThickness="0 0 0 0">
@@ -53,20 +52,9 @@
</Border>
</Border>
- <Grid x:Name="PART_NotificationCounterGrid" Canvas.Left="41" Canvas.Top="19" Width="24" Height="24" HorizontalAlignment="Left" VerticalAlignment="Bottom" IsHitTestVisible="False">
+ <Grid x:Name="PART_NotificationCounterGrid" Canvas.Left="41" Canvas.Top="19" Width="24" Height="24" HorizontalAlignment="Left" VerticalAlignment="Bottom" IsHitTestVisible="False" Visibility="Collapsed">
<Grid>
- <Grid.Style>
- <Style TargetType="Grid">
- <Setter Property="Visibility" Value="Collapsed"></Setter>
- <Style.Triggers>
- <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=Notifications.Count,Converter={StaticResource GreaterThanToBooleanConverter},ConverterParameter=1}" Value="True">
- <Setter Property="Visibility" Value="Visible"></Setter>
- </DataTrigger>
- </Style.Triggers>
- </Style>
- </Grid.Style>
- <Ellipse Fill="White" StrokeThickness="1" Stroke="{StaticResource TangoPrimaryAccentBrush}">
- </Ellipse>
+ <Ellipse Fill="White" StrokeThickness="1" Stroke="{StaticResource TangoPrimaryAccentBrush}"/>
<TextBlock HorizontalAlignment="Center" FontSize="12" VerticalAlignment="Center" Text="{Binding RelativeSource={RelativeSource AncestorType=local:TouchNotificationBar},Path=Notifications.Count}"></TextBlock>
</Grid>
</Grid>