From d651fecf4f213cc7eda5dff58081b10bf9bf7376 Mon Sep 17 00:00:00 2001 From: "Victor D. Sandiego" Date: Thu, 20 Aug 2020 15:35:20 -0500 Subject: [PATCH] Implement ability to specify banner pieces Implement the ability to specify which banner pieces are displayed in the video banner. Camera name, date/time, frame count. --- src/Camera.App/Core/CameraControl.cs | 83 ++++++++++++++++-- src/Camera.App/Core/CameraWallControl.cs | 2 +- .../Themes/Generic/CameraControl.xaml | 32 +++++-- src/Camera.App/View/CameraManageWindow.xaml | 29 ++++--- .../ViewModel/CameraManageViewModel.cs | 87 +++++++++++++++---- src/Restless.App.Database/Core/CameraFlags.cs | 22 +++-- src/Restless.App.Database/Tables/CameraRow.cs | 56 +++--------- .../Tables/CameraTable.cs | 4 +- 8 files changed, 220 insertions(+), 95 deletions(-) diff --git a/src/Camera.App/Core/CameraControl.cs b/src/Camera.App/Core/CameraControl.cs index ca565f0..2b6114b 100644 --- a/src/Camera.App/Core/CameraControl.cs +++ b/src/Camera.App/Core/CameraControl.cs @@ -495,7 +495,6 @@ public double StatusWidth /// public static readonly DependencyProperty StatusWidthProperty = StatusWidthPropertyKey.DependencyProperty; - /// /// Gets the height of the status banner. /// @@ -537,6 +536,63 @@ private static void OnStatusPlacementChanged(DependencyObject d, DependencyPrope (d as CameraControl)?.SyncStatusBannerToSize(); } + /// + /// Gets a boolean value that determines if the camera name displays in the status banner. + /// + public bool IsStatusCameraName + { + get => (bool)GetValue(IsStatusCameraNameProperty); + private set => SetValue(IsStatusCameraNamePropertyKey, value); + } + + private static readonly DependencyPropertyKey IsStatusCameraNamePropertyKey = DependencyProperty.RegisterReadOnly + ( + nameof(IsStatusCameraName), typeof(bool), typeof(CameraControl), new PropertyMetadata(true) + ); + + /// + /// Identifies the dependency property. + /// + public static readonly DependencyProperty IsStatusCameraNameProperty = IsStatusCameraNamePropertyKey.DependencyProperty; + + /// + /// Gets a boolean value that determines if the current date/time displays in the status banner. + /// + public bool IsStatusDateTime + { + get => (bool)GetValue(IsStatusDateTimeProperty); + private set => SetValue(IsStatusDateTimePropertyKey, value); + } + + private static readonly DependencyPropertyKey IsStatusDateTimePropertyKey = DependencyProperty.RegisterReadOnly + ( + nameof(IsStatusDateTime), typeof(bool), typeof(CameraControl), new PropertyMetadata(true) + ); + + /// + /// Identifies the dependency property. + /// + public static readonly DependencyProperty IsStatusDateTimeProperty = IsStatusDateTimePropertyKey.DependencyProperty; + + /// + /// Gets a boolean value that determines if the frame count displays in the status banner. + /// + public bool IsStatusFrameCount + { + get => (bool)GetValue(IsStatusFrameCountProperty); + private set => SetValue(IsStatusFrameCountPropertyKey, value); + } + + private static readonly DependencyPropertyKey IsStatusFrameCountPropertyKey = DependencyProperty.RegisterReadOnly + ( + nameof(IsStatusFrameCount), typeof(bool), typeof(CameraControl), new PropertyMetadata(true) + ); + + /// + /// Identifies the dependency property. + /// + public static readonly DependencyProperty IsStatusFrameCountProperty = IsStatusFrameCountPropertyKey.DependencyProperty; + /// /// Gets or sets the date/time format to use on the status banner. Default is "yyyy-MMM-dd hh:mm:ss tt". /// @@ -761,24 +817,35 @@ public override void OnApplyTemplate() } /// - /// Updates according to the current flags of . + /// Updates the status control according to the current flags of . /// - public void UpdateStatusPlacement() + public void UpdateStatusControl() { if (Camera != null) { if (Camera.Flags.HasFlag(CameraFlags.StatusTop)) { StatusPlacement = StatusPlacement.Top; - return; } - if (Camera.Flags.HasFlag(CameraFlags.StatusBottom)) + else if (Camera.Flags.HasFlag(CameraFlags.StatusBottom)) { StatusPlacement = StatusPlacement.Bottom; - return; + } + else + { + StatusPlacement = StatusPlacement.None; + } + + IsStatusCameraName = Camera.Flags.HasFlag(CameraFlags.StatusCameraName); + IsStatusDateTime = Camera.Flags.HasFlag(CameraFlags.StatusDateTime); + IsStatusFrameCount = Camera.Flags.HasFlag(CameraFlags.StatusFrameCount); + + /* if none of the flags are present, turn off the banner */ + if (!IsStatusCameraName && !IsStatusDateTime && !IsStatusFrameCount) + { + StatusPlacement = StatusPlacement.None; } } - StatusPlacement = StatusPlacement.None; } #endregion @@ -1015,7 +1082,7 @@ private void InitializeCamera() IsFlipped = Camera.Flags.HasFlag(CameraFlags.Flip); IsMirrored = Camera.Flags.HasFlag(CameraFlags.Mirror); - UpdateStatusPlacement(); + UpdateStatusControl(); FullScreenCommand = RelayCommand.Create(RunFullScreenCommand); diff --git a/src/Camera.App/Core/CameraWallControl.cs b/src/Camera.App/Core/CameraWallControl.cs index a0864dd..8bc9e25 100644 --- a/src/Camera.App/Core/CameraWallControl.cs +++ b/src/Camera.App/Core/CameraWallControl.cs @@ -322,7 +322,7 @@ private void UpdateStatusBanner(long id) { if (GetCameraHost(id) is CameraHostBorder host) { - host.CameraControl.UpdateStatusPlacement(); + host.CameraControl.UpdateStatusControl(); } } diff --git a/src/Camera.App/Themes/Generic/CameraControl.xaml b/src/Camera.App/Themes/Generic/CameraControl.xaml index c824e0b..29615d9 100644 --- a/src/Camera.App/Themes/Generic/CameraControl.xaml +++ b/src/Camera.App/Themes/Generic/CameraControl.xaml @@ -175,17 +175,22 @@ Style="{StaticResource BorderStreamStatus}" Height="{TemplateBinding StatusHeight}" Width="{TemplateBinding StatusWidth}"> - + - + - + - - - - - + + + + + @@ -321,6 +326,17 @@ + + + + + + + + + + + diff --git a/src/Camera.App/View/CameraManageWindow.xaml b/src/Camera.App/View/CameraManageWindow.xaml index 12d4dfe..5741c4b 100644 --- a/src/Camera.App/View/CameraManageWindow.xaml +++ b/src/Camera.App/View/CameraManageWindow.xaml @@ -41,21 +41,30 @@ + + + + + + + + + - - - -