Finished login and enabled login menu

This commit is contained in:
WeeXnes 2023-11-23 14:15:09 +01:00
parent 55b0ff1c45
commit 30099b56d2
13 changed files with 207 additions and 6 deletions

View file

@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Windows;
using System.IO;
using System.Net;
using System.Windows.Media;
using Newtonsoft.Json.Linq;
using Nocksoft.IO.ConfigFiles;
@ -188,6 +189,9 @@ namespace WeeXnes
#if DEBUG
DebugMode = true;
HandleLaunchArguments.arg_enableConsole();
//Allow untrusted certs in Debug mode
ServicePointManager.ServerCertificateValidationCallback +=
(sender, cert, chain, sslPolicyErrors) => true;
#endif
}
}

View file

@ -8,7 +8,7 @@ namespace WeeXnes.Core
{
public class Information
{
public const string Version = "4.4.8";
public const string Version = "4.5.0";
public const string EncryptionHash = "8zf5#RdyQ]$4x4_";
public const string ApiUrl = "https://api.github.com/repos/weexnes/weexnessuite/releases/latest";
}

View file

@ -37,6 +37,7 @@ namespace WeeXnes.Core
}
catch (Exception ex)
{
WeeXnes.Core.CustomConsole.WriteLine(ex.ToString());
this.ExceptionCache.Value = ex;
}
};
@ -114,6 +115,7 @@ namespace WeeXnes.Core
// Parse the JSON data into a dynamic object
dynamic user = JsonConvert.DeserializeObject(responseData);
user = user.user;
// Now you can access the user object properties dynamically
WeeXnes.Core.CustomConsole.WriteLine("authenticated user: " + user.name);
//Console.WriteLine($"Email: {user.email}");

View file

@ -92,7 +92,6 @@
PageTag="Gen"
PageType="{x:Type passwordGenerator:PasswordGenView}"/>
<ui:NavigationItem
Visibility="Collapsed"
Content="Profile"
Icon="InprivateAccount24"
Name="ButtonProfile"

View file

@ -0,0 +1,44 @@
<Page x:Class="WeeXnes.Views.ProfileView.InboxView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WeeXnes.Views.ProfileView"
xmlns:ui="http://schemas.lepo.co/wpfui/2022/xaml"
mc:Ignorable="d"
Title="InboxView" Height="Auto" Width="Auto"
Loaded="InboxView_OnLoaded">
<Grid>
<ScrollViewer Grid.Row="1" Name="LogViewer">
<ItemsControl Grid.Row="1" x:Name="InboxItems" Loaded="InboxItemsLoaded" Margin="0,0,0,0">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<ui:CardAction Icon="Mail24" Margin="0,0,0,5"
Click="ButtonBase_OnClick"
CommandParameter="test123"
Tag="{Binding}">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
FontWeight="Medium"
Text="{Binding Author}" />
<TextBlock
FontSize="11"
Foreground="{DynamicResource TextFillColorTertiaryBrush}"
Text="{Binding Message}"
TextTrimming="CharacterEllipsis"/>
</StackPanel>
</ui:CardAction>
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</ScrollViewer>
</Grid>
</Page>

View file

@ -0,0 +1,45 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using WeeXnes.Core;
using Wpf.Ui.Controls;
namespace WeeXnes.Views.ProfileView
{
public partial class InboxView : Page
{
public InboxView()
{
InitializeComponent();
}
private void InboxView_OnLoaded(object sender, RoutedEventArgs e)
{
//header_label.Content = "Inbox of " + ProfileView.auth._currentUserCache.Value.name;
}
private void InboxItemsLoaded(object sender, RoutedEventArgs e)
{
//Reverse the message list
List<dynamic> messageList = new List<dynamic>();
foreach (var msg in ProfileView.auth._currentUserCache.Value.inbox)
{
messageList.Add(msg);
}
messageList.Reverse();
InboxItems.ItemsSource = messageList;
}
private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
{
CardAction button = (CardAction)sender;
dynamic messageObj = button.Tag;
MessageFullView.MessageToShow = messageObj;
NavigationService.Navigate(new Uri("/Views/ProfileView/MessageFullView.xaml",UriKind.Relative));
}
}
}

View file

@ -0,0 +1,15 @@
<Page x:Class="WeeXnes.Views.ProfileView.LicenseView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WeeXnes.Views.ProfileView"
mc:Ignorable="d"
Title="LicenseView" Height="Auto" Width="Auto"
Loaded="LicenseView_OnLoaded">
<Grid>
<StackPanel>
<Label Name="header_label"/>
</StackPanel>
</Grid>
</Page>

View file

@ -0,0 +1,18 @@
using System.Windows;
using System.Windows.Controls;
namespace WeeXnes.Views.ProfileView
{
public partial class LicenseView : Page
{
public LicenseView()
{
InitializeComponent();
}
private void LicenseView_OnLoaded(object sender, RoutedEventArgs e)
{
header_label.Content = "Licenses of " + ProfileView.auth._currentUserCache.Value.name;
}
}
}

View file

@ -0,0 +1,18 @@
<Page x:Class="WeeXnes.Views.ProfileView.MessageFullView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WeeXnes.Views.ProfileView"
mc:Ignorable="d"
Title="MessageFullView" Height="Auto" Width="Auto"
Loaded="MessageFullView_OnLoaded">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="50px"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label HorizontalAlignment="Center" VerticalAlignment="Center" Name="AuthorLabel" Content=""/>
<RichTextBox Grid.Row="1" Name="MessageContent" IsReadOnly="True"/>
</Grid>
</Page>

View file

@ -0,0 +1,30 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
namespace WeeXnes.Views.ProfileView
{
public partial class MessageFullView : Page
{
public static dynamic MessageToShow = null;
public MessageFullView()
{
InitializeComponent();
}
private void MessageFullView_OnLoaded(object sender, RoutedEventArgs e)
{
if(MessageToShow == null)
return;
AuthorLabel.Content = MessageToShow.Author;
MessageContent.Document.Blocks.Clear();
MessageContent.Document.Blocks.Add(
new Paragraph(
new Run(
MessageToShow.Message.ToString()
)
)
);
}
}
}

View file

@ -45,7 +45,8 @@
<!-- Options for Account -->
<ui:CardAction Icon="MailInbox24"
Name="InboxButton">
Name="InboxButton"
Click="InboxButton_OnClick">
<StackPanel>
<TextBlock
Margin="0,0,0,4"
@ -59,7 +60,9 @@
</ui:CardAction>
<ui:CardAction Icon="Key24"
Name="LicenseButton" Margin="0,5,0,0">
Click="LicenseButton_OnClick"
Name="LicenseButton" Margin="0,5,0,0"
Visibility="Collapsed">
<StackPanel>
<TextBlock
Margin="0,0,0,4"

View file

@ -62,7 +62,8 @@ namespace WeeXnes.Views.ProfileView
{
this.Dispatcher.Invoke(() =>
{
new FluentMessageBox(auth.ExceptionCache.Value.Message).ShowDialog();
new FluentMessageBox(auth.ExceptionCache.Value.ToString()).ShowDialog();
errorStringChanged();
});
}
@ -91,5 +92,15 @@ namespace WeeXnes.Views.ProfileView
NavigationService.Navigate(new Uri("/Views/ProfileView/LoginError.xaml",UriKind.Relative));
});
}
private void InboxButton_OnClick(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Views/ProfileView/InboxView.xaml",UriKind.Relative));
}
private void LicenseButton_OnClick(object sender, RoutedEventArgs e)
{
NavigationService.Navigate(new Uri("/Views/ProfileView/LicenseView.xaml",UriKind.Relative));
}
}
}

View file

@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<Version>4.4.8</Version>
<Version>4.5.0</Version>
<ProjectGuid>{4B33CEE7-C74D-43B9-B99A-8B273D5195BC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>WeeXnes</RootNamespace>
@ -106,12 +106,21 @@
<Compile Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml.cs">
<DependentUpon>SaveToKeyManagerView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProfileView\InboxView.xaml.cs">
<DependentUpon>InboxView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProfileView\LicenseView.xaml.cs">
<DependentUpon>LicenseView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProfileView\LoginError.xaml.cs">
<DependentUpon>LoginError.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProfileView\LoginView.xaml.cs">
<DependentUpon>LoginView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProfileView\MessageFullView.xaml.cs">
<DependentUpon>MessageFullView.xaml</DependentUpon>
</Compile>
<Compile Include="Views\ProfileView\ProfileView.xaml.cs">
<DependentUpon>ProfileView.xaml</DependentUpon>
</Compile>
@ -153,8 +162,11 @@
<Page Include="Views\PasswordGenerator\PasswordGenView.xaml" />
<Page Include="Views\PasswordGenerator\SavePasswordView.xaml" />
<Page Include="Views\PasswordGenerator\SaveToKeyManagerView.xaml" />
<Page Include="Views\ProfileView\InboxView.xaml" />
<Page Include="Views\ProfileView\LicenseView.xaml" />
<Page Include="Views\ProfileView\LoginError.xaml" />
<Page Include="Views\ProfileView\LoginView.xaml" />
<Page Include="Views\ProfileView\MessageFullView.xaml" />
<Page Include="Views\ProfileView\ProfileView.xaml" />
<Page Include="Views\Settings\ChangePathsView.xaml" />
<Page Include="Views\Settings\FluentMessageBox.xaml" />