Skip to content

Commit

Permalink
Altha 0.0.5
Browse files Browse the repository at this point in the history
Added shell. Used MVVM pattern for  the main window
  • Loading branch information
Cootz committed Jul 21, 2021
1 parent d7073b3 commit 913f9d6
Show file tree
Hide file tree
Showing 28 changed files with 450 additions and 74 deletions.
Binary file modified .vs/Passwords/DesignTimeBuild/.dtbcache.v2
Binary file not shown.
Binary file modified .vs/Passwords/v16/.suo
Binary file not shown.
34 changes: 3 additions & 31 deletions Passwords/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,9 @@
xmlns:local="clr-namespace:Passwords"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<DockPanel>
<Grid DockPanel.Dock="Top" Margin="140,5,140,0" Background="#dddddd">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15*"/>
<ColumnDefinition Width="1.5*"/>
</Grid.ColumnDefinitions>

<TextBlock Text="Search" TextAlignment="Center" FontSize="24" FontFamily="Times New Roman" Grid.Column="0" />
<Button Grid.Column="1" BorderThickness="0">
<Button.Background>
<SolidColorBrush Opacity="0"/>
</Button.Background>
</Button>
</Grid>
<Frame x:Name ="MainFrame" Content="{Binding Model.CurrentPage}">

<Grid DockPanel.Dock="Bottom">
<Button Content="Add" FontSize="24" Margin="500,0,50,15" BorderThickness="0">
<Button.Background>
<SolidColorBrush Opacity="0"/>
</Button.Background>
</Button>
</Grid>

<DockPanel Margin="10,0,10,0">
<TextBlock DockPanel.Dock="Top" Text="Recent" FontSize="20" FontFamily="Areal"/>

<Grid DockPanel.Dock="Right">
<ListBox BorderThickness="0"/>
</Grid>
</DockPanel>


</DockPanel>
</Frame>

</Window>
39 changes: 6 additions & 33 deletions Passwords/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Passwords.PasData;
using Passwords;
using Passwords.ViewModer;

namespace Passwords
{
Expand All @@ -24,30 +12,15 @@ public partial class MainWindow : Window
{
public MainWindow()
{
Task t = PasswordController.Initialize();//Async initializetion
Task initializeTask = PasswordController.Initialize();//Async initializetion

InitializeComponent();

Task.WhenAll(t);
//PasswordController.SavePasswords(new Profile[] {
// new Profile()
// {
// Service = "steam",
// Email = new EMail()
// {
// Adress = "[email protected]"
// },
// Password = "psw",
// Username = null
// }
//});
DataContext = new MainWindowViewModel();

List<Profile> profiles = PasswordController.SearhProfiles("Service=\'steam\'").Result;
Task.WhenAll(initializeTask);

foreach (var prof in profiles)
{

}
Shell.GoTo(nameof(Recent));
}
}
}
52 changes: 52 additions & 0 deletions Passwords/Model/MainWindowModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;
using System.Windows.Controls;

namespace Passwords.Model
{
public class MainWindowModel : INotifyPropertyChanged
{
private Shell _shell;

public Page CurrentPage
{
get
{
return _currentPage;
}
set
{
_currentPage = value;
OnPorpertyChanged();
}
}
private Page _currentPage = new Page();

public event PropertyChangedEventHandler PropertyChanged;

public MainWindowModel()
{
_shell = new Shell();
_shell.SubscribeOnEvent(OnPageChange);
_shell.RegisterPage(nameof(Recent), new Recent());
}

private void OnPageChange()
{
_currentPage = Shell.CurrentPage;
}

private void OnPorpertyChanged([CallerMemberName] string property = "")
{
if (property != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}


}
}
8 changes: 8 additions & 0 deletions Passwords/Passwords.csproj.user
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Compile Update="Recent.xaml.cs">
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<SubType>Designer</SubType>
</Page>
<Page Update="Recent.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>
47 changes: 47 additions & 0 deletions Passwords/Recent.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<Page x:Class="Passwords.Recent"
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:Passwords"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800"
Title="Recent" Background="White">

<DockPanel>
<Grid DockPanel.Dock="Top" Margin="140,5,140,0" Background="#dddddd">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="15*"/>
<ColumnDefinition Width="1.5*"/>
</Grid.ColumnDefinitions>

<TextBlock Text="Search" TextAlignment="Center" FontSize="24" FontFamily="Times New Roman" Grid.Column="0" />
<Button Grid.Column="1" BorderThickness="0">
<Button.Background>
<SolidColorBrush Opacity="0"/>
</Button.Background>
</Button>
</Grid>

<Grid DockPanel.Dock="Bottom">
<Button Content="Add" FontSize="24" Margin="500,0,50,15" BorderThickness="0">
<Button.Background>
<SolidColorBrush Opacity="0"/>
</Button.Background>
</Button>
</Grid>


<DockPanel Margin="10,0,10,0">
<TextBlock DockPanel.Dock="Top" Text="Recent" FontSize="20" FontFamily="Areal"/>

<Grid DockPanel.Dock="Right">
<ListBox BorderThickness="0"/>
</Grid>
</DockPanel>


</DockPanel>


</Page>
37 changes: 37 additions & 0 deletions Passwords/Recent.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
using Passwords.PasData;
using System.Collections.Generic;
using System.Windows.Controls;

namespace Passwords
{
/// <summary>
/// Interaction logic for Recent.xaml
/// </summary>
public partial class Recent : Page
{
public Recent()
{
InitializeComponent();

//PasswordController.SavePasswords(new Profile[] {
// new Profile()
// {
// Service = "steam",
// Email = new EMail()
// {
// Adress = "[email protected]"
// },
// Password = "psw",
// Username = null
// }
//});

List<Profile> profiles = PasswordController.SearhProfiles("Service=\'steam\'").Result;

foreach (var prof in profiles)
{

}
}
}
}
57 changes: 57 additions & 0 deletions Passwords/Shell.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Controls;

namespace Passwords
{
public class Shell
{
private static Dictionary<string, Page> _pages = new Dictionary<string, Page>();

public static Page CurrentPage
{
get
{
return _currentPage;
}

set
{
_currentPage = value;
_pageChanged();
}
}
private static Page _currentPage = null;

public delegate void PageChangeEventHandler();
private static event PageChangeEventHandler _pageChanged;

public void RegisterPage(string nameOfPage, Page page)
{
_pages.Add(nameOfPage, page);
}

public void SubscribeOnEvent(PageChangeEventHandler onPageChange)
{
_pageChanged += onPageChange;
}

public static void GoTo(string pageName)
{
if (pageName == "..")
{
//Go to previos page in stack. Make using stack
}
else
{
ChangePage(_pages[pageName]);
}
}

private static void ChangePage(Page destinantionPage)
{
CurrentPage = destinantionPage;
}
}
}
43 changes: 43 additions & 0 deletions Passwords/ViewModer/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Passwords.Model;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;
using System.Text;

namespace Passwords.ViewModer
{
public class MainWindowViewModel : INotifyPropertyChanged
{
public MainWindowModel Model
{
get
{
return _model;
}
set
{
_model = value;
OnPorpertyChanged();
}
}
private MainWindowModel _model;

public event PropertyChangedEventHandler PropertyChanged;

public MainWindowViewModel()
{
_model = new MainWindowModel();
}

private void OnPorpertyChanged([CallerMemberName] string property = "")
{
if (property != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(property));
}
}


}
}
Binary file modified Passwords/bin/Debug/netcoreapp3.1/Passwords.dll
Binary file not shown.
Binary file modified Passwords/bin/Debug/netcoreapp3.1/Passwords.pdb
Binary file not shown.
Binary file modified Passwords/obj/Debug/netcoreapp3.1/MainWindow.baml
Binary file not shown.
16 changes: 15 additions & 1 deletion Passwords/obj/Debug/netcoreapp3.1/MainWindow.g.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "A9222762EEBAC42C1508384BFDBBC889B0DEB288"
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "7AC55CBAEA450F676279A5AFE9D93E2092285FF6"
//------------------------------------------------------------------------------
// <auto-generated>
// Этот код создан программой.
Expand Down Expand Up @@ -41,6 +41,14 @@ namespace Passwords {
/// </summary>
public partial class MainWindow : System.Windows.Window, System.Windows.Markup.IComponentConnector {


#line 10 "..\..\..\MainWindow.xaml"
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1823:AvoidUnusedPrivateFields")]
internal System.Windows.Controls.Frame MainFrame;

#line default
#line hidden

private bool _contentLoaded;

/// <summary>
Expand Down Expand Up @@ -69,6 +77,12 @@ public void InitializeComponent() {
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Maintainability", "CA1502:AvoidExcessiveComplexity")]
[System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1800:DoNotCastUnnecessarily")]
void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
switch (connectionId)
{
case 1:
this.MainFrame = ((System.Windows.Controls.Frame)(target));
return;
}
this._contentLoaded = true;
}
}
Expand Down
Loading

0 comments on commit 913f9d6

Please sign in to comment.