Skip to content
Permalink
Browse files

Added functionality to the ContactInfoControl

  • Loading branch information...
COM8 committed Jul 28, 2019
1 parent 4d3adf6 commit 5ab61f12ac3bbe23382c1e5ccd098746cc79caaa
@@ -0,0 +1,51 @@
using System.Runtime.CompilerServices;
using System.Threading.Tasks;

namespace Shared.Classes
{
public static class TaskExtensions
{
//--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
#region --Attributes--


#endregion
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\
#region --Constructors--


#endregion
//--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
#region --Set-, Get- Methods--


#endregion
//--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
#region --Misc Methods (Public)--
/// <summary>
/// Configures await to false.
/// Same as: .ConfigureAwait(false)
/// </summary>
public static ConfiguredTaskAwaitable ConfAwaitFalse(this Task task)
{
return task.ConfigureAwait(false);
}

#endregion

#region --Misc Methods (Private)--


#endregion

#region --Misc Methods (Protected)--


#endregion
//--------------------------------------------------------Events:---------------------------------------------------------------------\\
#region --Events--


#endregion
}
}
@@ -143,6 +143,7 @@
<Compile Include="Classes\SharedUtils.cs" />
<Compile Include="Classes\SQLite\AbstractDBManager.cs" />
<Compile Include="Classes\SQLite\TSSQLiteConnection.cs" />
<Compile Include="Classes\TaskExtensions.cs" />
<Compile Include="Classes\Threading\MySemaphoreSlim.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Shared.rd.xml" />
@@ -4,6 +4,7 @@
using UWPX_UI_Context.Classes;
using UWPX_UI_Context.Classes.DataContext.Controls;
using UWPX_UI_Context.Classes.DataTemplates;
using UWPX_UI_Context.Classes.Events;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;

@@ -125,7 +126,7 @@ private void Info_mfo_Click(object sender, RoutedEventArgs e)
}
else
{
UiUtils.NavigateToPage(typeof(ContactInfoPage), new NavigatedToUserProfileEventArgs(Chat.Chat, Chat.Client));
UiUtils.NavigateToPage(typeof(ContactInfoPage), new NavigatedToContactInfoPageEventArgs(Chat.Client, Chat.Chat));
}
}
}
@@ -8,6 +8,7 @@
using UWPX_UI_Context.Classes;
using UWPX_UI_Context.Classes.DataContext.Controls;
using UWPX_UI_Context.Classes.DataTemplates;
using UWPX_UI_Context.Classes.Events;
using Windows.UI;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
@@ -185,7 +186,7 @@ private void ShowProfile_mfo_Click(object sender, RoutedEventArgs e)
}
else
{
UiUtils.NavigateToPage(typeof(ContactInfoPage), new NavigatedToUserProfileEventArgs(Chat.Chat, Chat.Client));
UiUtils.NavigateToPage(typeof(ContactInfoPage), new NavigatedToContactInfoPageEventArgs(Chat.Client, Chat.Chat));
}
}

@@ -197,7 +198,7 @@ private static void ChatPropertyChanged(DependencyObject d, DependencyPropertyCh
}
}

private void VIEW_MODEL_OnError(ChatMasterControlContext sender, UWPX_UI_Context.Classes.Events.OnErrorEventArgs args)
private void VIEW_MODEL_OnError(ChatMasterControlContext sender, OnErrorEventArgs args)
{
InfoDialog dialog = new InfoDialog(args.TITLE, args.MESSAGE)
{
@@ -6,6 +6,7 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:omemoControls="using:UWPX_UI.Controls.OMEMO"
xmlns:valueConverter="using:UWPX_UI_Context.Classes.ValueConverter"
HorizontalAlignment="Center"
mc:Ignorable="d">

@@ -24,6 +25,7 @@
<Setter Property="Foreground" Value="{ThemeResource SystemAccentColor}"/>
<Setter Property="Height" Value="35"/>
</Style>
<valueConverter:PresenceStringValueConverter x:Key="PresenceStringValueConverter"/>
</UserControl.Resources>

<controls:DropShadowPanel x:Name="mainShadow"
@@ -44,26 +46,27 @@
<controls1:AccountImagePresenceControl Grid.Row="0"
Width="150"
Height="150"
BareJid="someone@xmpp.uwpx.org"
BareJid="{x:Bind VIEW_MODEL.MODEL.ChatBareJid, Mode=OneWay}"
PresenceVisibility="Collapsed"/>
<controls:DropShadowPanel Grid.Row="1"
Margin="0,10,0,0"
HorizontalAlignment="Center">
<Border Background="{StaticResource PresenceOnlineBrush}"
<Border Background="{x:Bind VIEW_MODEL.MODEL.Presence, Mode=OneWay, Converter={StaticResource PresenceBrushValueConverter}}"
CornerRadius="2">
<TextBlock Margin="5,0,5,0"
Foreground="White"
IsTextSelectionEnabled="True"
Text="Online"/>
Text="{x:Bind VIEW_MODEL.MODEL.Presence, Mode=OneWay, Converter={StaticResource PresenceStringValueConverter}}"/>
</Border>
</controls:DropShadowPanel>

<TextBlock Grid.Row="2"
Margin="0,10,0,0"
IsTextSelectionEnabled="True"
MaxLines="1"
Text="com8@xmpp.uwpx.org"
TextTrimming="CharacterEllipsis"/>
Text="{x:Bind VIEW_MODEL.MODEL.ChatState, Mode=OneWay}"
TextTrimming="CharacterEllipsis"
Visibility="{x:Bind VIEW_MODEL.MODEL.ChatState, Mode=OneWay, Converter={StaticResource StringEmptyVisibilityValueConverter}}"/>
</Grid>
<Grid Grid.Column="1"
Margin="30,0,0,0">
@@ -83,22 +86,24 @@
<TextBlock Grid.Column="0"
IsTextSelectionEnabled="True"
Style="{StaticResource SubtitleTextBlockStyle}"
Text="Some Name"/>
Text="{x:Bind VIEW_MODEL.MODEL.Nickname, Mode=OneWay}"/>
<Button Grid.Column="1"
Margin="5,0,0,0"
VerticalAlignment="Center"
Content="&#xE70F;"
IsEnabled="False"
Style="{ThemeResource TransparentButtonStlye}"
ToolTipService.ToolTip="Change Nickname"/>
</Grid>
<TextBlock Grid.Row="1"
Margin="0,10,0,0"
Text="someone@xmpp.uwpx.org"/>
Text="{x:Bind VIEW_MODEL.MODEL.ChatBareJid, Mode=OneWay}"
Visibility="{x:Bind VIEW_MODEL.MODEL.DifferentNickname, Mode=OneWay, Converter={StaticResource BoolVisibilityValueConverter}}"/>
<controls1:SeperatorControl Grid.Row="2"
Margin="0,10,0,0"/>
<TextBlock Grid.Row="3"
Margin="0,10,0,0"
Text="This is some status Text."/>
Text="{x:Bind VIEW_MODEL.MODEL.ChatStatus, Mode=OneWay}"/>
<Grid Grid.Row="4"
HorizontalAlignment="Center"
VerticalAlignment="Bottom">
@@ -109,16 +114,71 @@
</Grid.ColumnDefinitions>
<omemoControls:OmemoButtonControl Grid.Column="0"
Margin="0,10,0,0"/>
<Button Grid.Column="1"
<Button x:Name="mute_btn"
Grid.Column="1"
Margin="10,10,0,0"
Content="&#xE74F;"
Click="Mute_btn_Click"
Content="{x:Bind VIEW_MODEL.MODEL.MuteGlyph, Mode=OneWay}"
Style="{ThemeResource TransparentButtonStlye}"
ToolTipService.ToolTip="Mute"/>
ToolTipService.ToolTip="{x:Bind VIEW_MODEL.MODEL.MuteTooltip, Mode=OneWay}"/>
<Button Grid.Column="2"
Margin="10,10,0,0"
Content="&#xF138;"
Content="&#xE712;"
Style="{ThemeResource TransparentButtonStlye}"
ToolTipService.ToolTip="Presence"/>
ToolTipService.ToolTip="More">
<Button.Flyout>
<MenuFlyout>
<MenuFlyoutSubItem x:Name="presenceSubscription_mfo"
IsEnabled="{x:Bind VIEW_MODEL.MODEL.PresenceFlyoutEnabled, Mode=OneWay}"
Text="Presence subscription">
<MenuFlyoutItem x:Name="requestPresenceSubscription_mfo"
Click="RequestPresenceSubscription_mfo_Click"
Text="Request subscription"
Visibility="{x:Bind VIEW_MODEL.MODEL.RequestPresenceSubscriptionVisibility, Mode=OneWay}">
<MenuFlyoutItem.Icon>
<FontIcon Foreground="Green"
Glyph="&#xE109;"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem x:Name="cancelPresenceSubscription_mfo"
Click="CancelPresenceSubscription_mfo_Click"
Text="Cancel subscription"
Visibility="{x:Bind VIEW_MODEL.MODEL.CancelPresenceSubscriptionVisibility, Mode=OneWay}">
<MenuFlyoutItem.Icon>
<FontIcon Foreground="Red"
Glyph="&#xE738;"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem x:Name="rejectPresenceSubscription_mfo"
Click="RejectPresenceSubscription_mfo_Click"
Text="Reject subscription"
Visibility="{x:Bind VIEW_MODEL.MODEL.RejectPresenceSubscriptionVisibility, Mode=OneWay}">
<MenuFlyoutItem.Icon>
<FontIcon Foreground="Red"
Glyph="&#xE711;"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
<MenuFlyoutItem x:Name="probePresence_mfo"
Click="ProbePresence_mfo_Click"
Text="Probe presence"
Visibility="{x:Bind VIEW_MODEL.MODEL.ProbePresenceVisibility, Mode=OneWay}">
<MenuFlyoutItem.Icon>
<FontIcon Glyph="&#xEA62;"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
</MenuFlyoutSubItem>
<MenuFlyoutSeparator/>
<MenuFlyoutItem x:Name="removeFromRoster_mfo"
Click="RemoveFromRoster_mfo_Click"
Text="{x:Bind VIEW_MODEL.MODEL.RemoveFromRosterText, Mode=OneWay}">
<MenuFlyoutItem.Icon>
<FontIcon Foreground="{ThemeResource GoldBrush}"
Glyph="&#xE734;"/>
</MenuFlyoutItem.Icon>
</MenuFlyoutItem>
</MenuFlyout>
</Button.Flyout>
</Button>
</Grid>
</Grid>
</Grid>
@@ -1,12 +1,31 @@
using Windows.UI.Xaml.Controls;
using Data_Manager2.Classes.DBTables;
using Shared.Classes;
using UWPX_UI_Context.Classes.DataContext.Controls;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
using XMPP_API.Classes;

namespace UWPX_UI.Controls.Chat
{
public sealed partial class ContactInfoControl: UserControl
{
//--------------------------------------------------------Attributes:-----------------------------------------------------------------\\
#region --Attributes--
public readonly ContactInfoControlContext VIEW_MODEL = new ContactInfoControlContext();

public ChatTable Chat
{
get { return (ChatTable)GetValue(ChatProperty); }
set { SetValue(ChatProperty, value); }
}
public static readonly DependencyProperty ChatProperty = DependencyProperty.Register(nameof(Chat), typeof(ChatTable), typeof(ContactInfoControl), new PropertyMetadata(null, OnChatChanged));

public XMPPClient Client
{
get { return (XMPPClient)GetValue(ClientProperty); }
set { SetValue(ClientProperty, value); }
}
public static readonly DependencyProperty ClientProperty = DependencyProperty.Register(nameof(Client), typeof(XMPPClient), typeof(ContactInfoControl), new PropertyMetadata(null, OnClientChanged));

#endregion
//--------------------------------------------------------Constructor:----------------------------------------------------------------\\
@@ -29,7 +48,10 @@ public ContactInfoControl()
#endregion

#region --Misc Methods (Private)--

private void UpdateView(DependencyPropertyChangedEventArgs e)
{
VIEW_MODEL.UpdateView(e);
}

#endregion

@@ -39,7 +61,51 @@ public ContactInfoControl()
#endregion
//--------------------------------------------------------Events:---------------------------------------------------------------------\\
#region --Events--
private static void OnChatChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ContactInfoControl contactInfoControl)
{
contactInfoControl.UpdateView(e);
}
}

private static void OnClientChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
if (d is ContactInfoControl contactInfoControl)
{
contactInfoControl.UpdateView(e);
}
}

private async void ProbePresence_mfo_Click(object sender, RoutedEventArgs e)
{
await VIEW_MODEL.SendPresenceProbeAsync(Client, Chat).ConfAwaitFalse();
}

private async void RejectPresenceSubscription_mfo_Click(object sender, RoutedEventArgs e)
{
await VIEW_MODEL.RejectPresenceSubscriptionAsync(Client, Chat).ConfAwaitFalse();
}

private async void RemoveFromRoster_mfo_Click(object sender, RoutedEventArgs e)
{
await VIEW_MODEL.SwitchChatInRosterAsync(Client, Chat).ConfAwaitFalse();
}

private async void CancelPresenceSubscription_mfo_Click(object sender, RoutedEventArgs e)
{
await VIEW_MODEL.CancelPresenceSubscriptionAsync(Client, Chat).ConfAwaitFalse();
}

private async void RequestPresenceSubscription_mfo_Click(object sender, RoutedEventArgs e)
{
await VIEW_MODEL.RequestPresenceSubscriptionAsync(Client, Chat).ConfAwaitFalse();
}

private async void Mute_btn_Click(object sender, RoutedEventArgs e)
{
await VIEW_MODEL.ToggleChatMutedAsync(Chat).ConfAwaitFalse();
}

#endregion
}
@@ -20,7 +20,8 @@
FontSize="20"
FontWeight="Bold"
Foreground="{x:Bind OmemoEnabled, Mode=OneWay, Converter={StaticResource OmemoBoolBrushValueConverter}}"
Style="{ThemeResource ButtonRevealStyle}">
Style="{ThemeResource ButtonRevealStyle}"
ToolTipService.ToolTip="Enable/Disable Encryption">
<Button.Flyout>
<Flyout>
<StackPanel>
@@ -30,15 +30,19 @@
</Grid.RowDefinitions>

<!-- Info: -->
<chat:ContactInfoControl Grid.Row="0"/>
<chat:ContactInfoControl Grid.Row="0"
Chat="{x:Bind Chat, Mode=OneWay}"
Client="{x:Bind Client, Mode=OneWay}"/>

<!-- Media: -->
<chat:ContactMediaControl Grid.Row="1"
Margin="0,10,0,0"/>
Margin="0,10,0,0"
Visibility="Collapsed"/>

<!-- OMEMO: -->
<chat:ContactOmemoControl Grid.Row="2"
Margin="0,10,0,0"/>
Margin="0,10,0,0"
Visibility="Collapsed"/>
</Grid>
</ScrollViewer>
</Grid>

0 comments on commit 5ab61f1

Please sign in to comment.
You can’t perform that action at this time.