From 8bb2ca4263bccb69f98f7984ca45dbdff8e001fd Mon Sep 17 00:00:00 2001 From: Fabian Sauter Date: Wed, 17 Mar 2021 17:41:07 +0100 Subject: [PATCH] Updated the account omemo info with label support --- .../Controls/OMEMO/OmemoDeviceControl.xaml | 33 +++++++ .../Controls/OMEMO/OmemoDeviceControl.xaml.cs | 64 +++++++++++++ .../OMEMO/OmemoDeviceListControl.xaml | 25 ++--- .../OMEMO/OmemoDeviceListControl.xaml.cs | 18 +--- .../Settings/AccountOmemoInfoControl.xaml | 96 ++++++++++++++++--- .../Settings/AccountOmemoInfoControl.xaml.cs | 48 ++++++++++ UWPX_UI/UWPX_UI.csproj | 7 ++ .../AccountOmemoInfoControlContext.cs | 44 ++++++++- .../OMEMO/OmemoDeviceControlContext.cs | 72 ++++++++++++++ .../Controls/OmemoDeviceListControlContext.cs | 26 +---- .../AccountOmemoInfoControlDataTemplate.cs | 29 +----- .../OMEMO/OmemoDeviceControlDataTemplate.cs} | 12 +-- .../OmemoDeviceListControlDataTemplate.cs | 15 +-- UWPX_UI_Context/UWPX_UI_Context.csproj | 3 +- 14 files changed, 372 insertions(+), 120 deletions(-) create mode 100644 UWPX_UI/Controls/OMEMO/OmemoDeviceControl.xaml create mode 100644 UWPX_UI/Controls/OMEMO/OmemoDeviceControl.xaml.cs create mode 100644 UWPX_UI_Context/Classes/DataContext/Controls/OMEMO/OmemoDeviceControlContext.cs rename UWPX_UI_Context/Classes/DataTemplates/{UintDataTemplate.cs => Controls/OMEMO/OmemoDeviceControlDataTemplate.cs} (81%) diff --git a/UWPX_UI/Controls/OMEMO/OmemoDeviceControl.xaml b/UWPX_UI/Controls/OMEMO/OmemoDeviceControl.xaml new file mode 100644 index 000000000..93cc17b17 --- /dev/null +++ b/UWPX_UI/Controls/OMEMO/OmemoDeviceControl.xaml @@ -0,0 +1,33 @@ + + + + + + + + + + + + + + + diff --git a/UWPX_UI/Controls/OMEMO/OmemoDeviceControl.xaml.cs b/UWPX_UI/Controls/OMEMO/OmemoDeviceControl.xaml.cs new file mode 100644 index 000000000..10b12c2c0 --- /dev/null +++ b/UWPX_UI/Controls/OMEMO/OmemoDeviceControl.xaml.cs @@ -0,0 +1,64 @@ +using Storage.Classes.Models.Omemo; +using UWPX_UI_Context.Classes.DataContext.Controls.OMEMO; +using Windows.UI.Xaml; +using Windows.UI.Xaml.Controls; + +namespace UWPX_UI.Controls.OMEMO +{ + public sealed partial class OmemoDeviceControl: UserControl + { + //--------------------------------------------------------Attributes:-----------------------------------------------------------------\\ + #region --Attributes-- + public OmemoDeviceModel Device + { + get => (OmemoDeviceModel)GetValue(DeviceProperty); + set => SetValue(DeviceProperty, value); + } + public static readonly DependencyProperty DeviceProperty = DependencyProperty.Register(nameof(Device), typeof(OmemoDeviceModel), typeof(OmemoDeviceControl), new PropertyMetadata(null, OnDeviceChanged)); + + public readonly OmemoDeviceControlContext VIEW_MODEL = new OmemoDeviceControlContext(); + #endregion + //--------------------------------------------------------Constructor:----------------------------------------------------------------\\ + #region --Constructors-- + public OmemoDeviceControl() + { + InitializeComponent(); + } + + #endregion + //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\ + #region --Set-, Get- Methods-- + + + #endregion + //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\ + #region --Misc Methods (Public)-- + private void UpdateView(DependencyPropertyChangedEventArgs e) + { + VIEW_MODEL.UpdateView(e); + } + + #endregion + + #region --Misc Methods (Private)-- + + + #endregion + + #region --Misc Methods (Protected)-- + + + #endregion + //--------------------------------------------------------Events:---------------------------------------------------------------------\\ + #region --Events-- + private static void OnDeviceChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is OmemoDeviceControl control) + { + control.UpdateView(e); + } + } + + #endregion + } +} diff --git a/UWPX_UI/Controls/OMEMO/OmemoDeviceListControl.xaml b/UWPX_UI/Controls/OMEMO/OmemoDeviceListControl.xaml index c4ace63d2..505ab4a38 100644 --- a/UWPX_UI/Controls/OMEMO/OmemoDeviceListControl.xaml +++ b/UWPX_UI/Controls/OMEMO/OmemoDeviceListControl.xaml @@ -2,30 +2,17 @@ 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:datatemplates="using:UWPX_UI_Context.Classes.DataTemplates" xmlns:extensions="using:Microsoft.Toolkit.Uwp.UI.Extensions" xmlns:local="using:UWPX_UI.Controls" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:omemo="using:Storage.Classes.Models.Omemo" + xmlns:omemoControls="using:UWPX_UI.Controls.OMEMO" mc:Ignorable="d"> - - - - - - - - + x:DataType="omemo:OmemoDeviceModel"> + @@ -52,12 +39,12 @@ extensions:ListViewExtensions.StretchItemContainerDirection="Both" Background="{ThemeResource SystemControlBackgroundAltMediumBrush}" ItemTemplate="{StaticResource DeviceTemplate}" - ItemsSource="{x:Bind VIEW_MODEL.MODEL.DEVICES}" + ItemsSource="{x:Bind Account.Client.dbAccount.omemoInfo.devices}" SelectionMode="None"/> - + diff --git a/UWPX_UI/Controls/OMEMO/OmemoDeviceListControl.xaml.cs b/UWPX_UI/Controls/OMEMO/OmemoDeviceListControl.xaml.cs index 49853efbd..d4ff94e8f 100644 --- a/UWPX_UI/Controls/OMEMO/OmemoDeviceListControl.xaml.cs +++ b/UWPX_UI/Controls/OMEMO/OmemoDeviceListControl.xaml.cs @@ -14,7 +14,7 @@ public AccountDataTemplate Account get => (AccountDataTemplate)GetValue(AccountProperty); set => SetValue(AccountProperty, value); } - public static readonly DependencyProperty AccountProperty = DependencyProperty.Register(nameof(Account), typeof(AccountDataTemplate), typeof(OmemoDeviceListControl), new PropertyMetadata(null, OnAccountChanged)); + public static readonly DependencyProperty AccountProperty = DependencyProperty.Register(nameof(Account), typeof(AccountDataTemplate), typeof(OmemoDeviceListControl), new PropertyMetadata(null)); public readonly OmemoDeviceListControlContext VIEW_MODEL = new OmemoDeviceListControlContext(); @@ -39,10 +39,6 @@ public OmemoDeviceListControl() #endregion #region --Misc Methods (Private)-- - private void UpdateView(DependencyPropertyChangedEventArgs e) - { - VIEW_MODEL.UpdateView(e); - } #endregion @@ -52,24 +48,16 @@ private void UpdateView(DependencyPropertyChangedEventArgs e) #endregion //--------------------------------------------------------Events:---------------------------------------------------------------------\\ #region --Events-- - private async void Reset_ibtn_Click(object sender, RoutedEventArgs args) + private async void Reset_ibtn_Click(IconProgressButtonControl sender, RoutedEventArgs args) { await VIEW_MODEL.ResetOmemoDevicesAsync(Account.Client); } - private async void Refresh_ibtn_Click(object sender, RoutedEventArgs args) + private async void Refresh_ibtn_Click(IconProgressButtonControl sender, RoutedEventArgs args) { await VIEW_MODEL.RefreshOmemoDevicesAsync(Account.Client); } - private static void OnAccountChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if (d is OmemoDeviceListControl omemoDeviceListControl) - { - omemoDeviceListControl.UpdateView(e); - } - } - #endregion } } diff --git a/UWPX_UI/Controls/Settings/AccountOmemoInfoControl.xaml b/UWPX_UI/Controls/Settings/AccountOmemoInfoControl.xaml index df0751e79..a16a86089 100644 --- a/UWPX_UI/Controls/Settings/AccountOmemoInfoControl.xaml +++ b/UWPX_UI/Controls/Settings/AccountOmemoInfoControl.xaml @@ -1,17 +1,24 @@  - - - + + + + + + + + - - - - - + + + + + + + + + +