-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added shell. Used MVVM pattern for the main window
- Loading branch information
Showing
28 changed files
with
450 additions
and
74 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
|
@@ -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)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
{ | ||
|
||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.