Skip to content
This repository was archived by the owner on Jan 21, 2022. It is now read-only.

Commit aa5561f

Browse files
Merge pull request #18 from Standaard-boos/ProfileV2
Profile v2
2 parents 1fa6409 + 38c81ab commit aa5561f

17 files changed

Lines changed: 472 additions & 113 deletions

Gateway/ProfileDataAccess.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using Dapper;
2+
using System.Collections.Generic;
3+
using System.Data;
4+
5+
namespace Gateway
6+
{
7+
public class ProfileDataAccess
8+
{
9+
10+
public static List<string> GetAllInterests()
11+
{
12+
using IDbConnection connection = new System.Data.SqlClient.SqlConnection(FiddleHelper.GetConnectionStringSql("StudentMatcherDB"));
13+
return (List<string>)connection.Query<string>("SELECT HobbyName FROM HobbyType");
14+
}
15+
16+
}
17+
}

Model/Student.cs

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,33 @@ public class Student
1313
//public Account Account { get; set; }
1414
public int ID { get; set; }
1515
public string Email { get; set; }
16-
public string City { get; set; }
16+
public string City { get; set; }
1717
public DateTime DateOfBirth { get; set; }
18-
1918
public string Age { get; set; }
2019
public School School { get; set; }
2120
public HashSet<Relationships> Relationships { get; set; }
2221
public Profile Profile { get; set; }
2322
public string Name { get; set; }
23+
public string FirstName { get; set; }
24+
public string LastName { get; set; }
25+
public bool Sex { get; set; }
2426

2527
public Student(string email)
2628
{
2729
//Account = account;
2830
Email = email;
29-
City = (string)LoadObject(DataKeys.City);
30-
DateOfBirth = (DateTime)LoadObject(DataKeys.DateOfBirth);
31+
City = (string)"";
32+
DateOfBirth = (DateTime)DateTime.MaxValue;
3133
Age = CalculateAge(DateOfBirth).ToString() + " Jaar";
32-
School = (School)LoadObject(DataKeys.School);
33-
Relationships = (HashSet<Relationships>)LoadObject(DataKeys.Relationships);
34+
School = (School)new School("", "", "");
35+
Relationships = (HashSet<Relationships>)new HashSet<Relationships>();
36+
3437
Profile = new Profile(this);
3538
}
3639

3740
public Student()
3841
{
39-
}
40-
41-
private object LoadObject(DataKeys data)
42-
{
43-
44-
//this method will connect to the database and load the correct data for the object
45-
switch (data)
46-
{
47-
case DataKeys.City:
48-
break;
49-
case DataKeys.DateOfBirth:
50-
break;
51-
case DataKeys.School:
52-
break;
53-
case DataKeys.Relationships:
54-
break;
55-
default:
56-
break;
57-
}
58-
59-
return null;
42+
Profile = new Profile(this);
6043
}
6144

6245
private static int CalculateAge(DateTime birthDay)

View/App.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="clr-namespace:View"
5-
xmlns:stylingHelperTools="clr-namespace:View.StylingHelperTools"
65
StartupUri="MainWindow.xaml">
76
<Application.Resources>
87
<ResourceDictionary Source="Styling/Main.xaml"/>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Text;
5+
using System.Windows.Data;
6+
7+
namespace View.Converters
8+
{
9+
public class MultiPageEqualsConverter : IMultiValueConverter
10+
{
11+
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
12+
{
13+
bool ret = true;
14+
if (values.Length == 0) return true;
15+
if (values[0].GetType() != typeof(string)) throw new NotImplementedException();
16+
string first = (string)(values[0]);
17+
foreach (var val in values)
18+
{
19+
if (val.GetType() != typeof(string)) throw new NotImplementedException();
20+
if (!(
21+
((string)val).Equals(first) ||
22+
((string)val).Equals("View;component/" + first)
23+
))
24+
ret = false;
25+
}
26+
return ret;
27+
}
28+
29+
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
30+
{
31+
throw new NotSupportedException();
32+
}
33+
}
34+
}

View/StylingHelperTools/isLessThanConverter.cs renamed to View/Converters/isLessThanConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Text;
55
using System.Windows.Data;
66

7-
namespace View.StylingHelperTools
7+
namespace View.Converters
88
{
99
public class isLessThanConverter : IValueConverter
1010
{

View/HomePage.xaml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Page x:Class="View.HomePage"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:local="clr-namespace:View"
7+
mc:Ignorable="d"
8+
d:DesignHeight="450" d:DesignWidth="800"
9+
Title="HomePage">
10+
11+
<Grid>
12+
<StackPanel HorizontalAlignment="Center" VerticalAlignment="Center">
13+
<TextBlock Text="Welkom persoon!" Margin="5"/>
14+
<Button Click="Login_Click" Content="Login" HorizontalAlignment="Center" VerticalAlignment="Center" Padding="5,2,5,2" Margin="5"/>
15+
</StackPanel>
16+
</Grid>
17+
</Page>

View/HomePage.xaml.cs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using System.Windows;
5+
using System.Windows.Controls;
6+
using System.Windows.Data;
7+
using System.Windows.Documents;
8+
using System.Windows.Input;
9+
using System.Windows.Media;
10+
using System.Windows.Media.Imaging;
11+
using System.Windows.Navigation;
12+
using System.Windows.Shapes;
13+
using View.Authentication;
14+
15+
namespace View
16+
{
17+
/// <summary>
18+
/// Interaction logic for HomePage.xaml
19+
/// </summary>
20+
public partial class HomePage : Page
21+
{
22+
public HomePage()
23+
{
24+
InitializeComponent();
25+
}
26+
27+
private void Login_Click(object sender, RoutedEventArgs e)
28+
{
29+
AuthenticationWindow authenticationWindow = new AuthenticationWindow();
30+
authenticationWindow.Show();
31+
}
32+
}
33+
}

View/MainWindow.xaml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
xmlns:local="clr-namespace:View"
77
xmlns:vm="clr-namespace:ViewModel;assembly=ViewModel"
88
xmlns:vmc="clr-namespace:ViewModel.Commands;assembly=ViewModel"
9+
xmlns:converters="clr-namespace:View.Converters"
910
mc:Ignorable="d"
1011
Style="{StaticResource {x:Type Window}}"
1112
Title="Stugether" Height="450" Width="800">
@@ -21,16 +22,19 @@
2122
<RowDefinition Height="35"/>
2223
<RowDefinition Height="1*"/>
2324
</Grid.RowDefinitions>
24-
<Grid Height="{Binding ActualHeight, ElementName=tbContentTitle, Mode=OneWay}">
25+
<Grid Height="{Binding ActualHeight, ElementName=tbContentTitle, Mode=OneWay}" Background="{StaticResource BackgroundSecundary}">
2526
<Grid.ColumnDefinitions>
2627
<ColumnDefinition Width="1*" />
2728
<ColumnDefinition Width="1*" />
2829
</Grid.ColumnDefinitions>
29-
<Button x:Name="btPreviousButton" Content="&lt;" Margin="5,5,5,5" Click="NavigationNextPreviousButton_Click"/>
30-
<Button x:Name="btNextButton" Content="&gt;" Grid.Column="1" Margin="5" Click="NavigationNextPreviousButton_Click"/>
30+
<Button x:Name="btPreviousButton" Margin="5,5,5,5" Command="NavigationCommands.BrowseBack" CommandTarget="{Binding ElementName=frContent}">
31+
<Path Margin="0,0,2,0" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 4 0 L 0 4 L 4 8 Z" Fill="#FF444444"/>
32+
</Button>
33+
<Button x:Name="btNextButton" Grid.Column="1" Margin="5" Command="NavigationCommands.BrowseForward" CommandTarget="{Binding ElementName=frContent}">
34+
<Path Margin="0,0,2,0" HorizontalAlignment="Center" VerticalAlignment="Center" Data="M 0 0 L 4 4 L 0 8 Z" Fill="#FF444444"/>
35+
</Button>
3136
</Grid>
3237
<!-- The Stackpanel doesn't allow a binding for its children, so we use a ItemsControl instead -->
33-
<StackPanel Grid.Row="1"> <!-- TEMPORARY for login button -->
3438
<ItemsControl x:Name="icMenuItems" Grid.Row="1" ItemsSource="{Binding MainNavigationItems}">
3539
<ItemsControl.ItemsPanel>
3640
<ItemsPanelTemplate>
@@ -39,15 +43,25 @@
3943
</ItemsControl.ItemsPanel>
4044
<ItemsControl.ItemTemplate>
4145
<ItemContainerTemplate>
42-
<local:MainWindowNavigationItem Content="{Binding Title}" Page="{Binding Page}" ExtraNavigationInformation="{Binding ExtraInformation}" Command="{Binding Path=DataContext.NavigateButtonCommand, RelativeSource={RelativeSource AncestorType=Window},Mode=Default}" CommandParameter="{Binding Mode=OneWay}"/>
46+
<local:MainWindowNavigationItem
47+
Content="{Binding Title}" Page="{Binding Page}" ExtraNavigationInformation="{Binding ExtraInformation}"
48+
Command="{Binding Path=DataContext.NavigateButtonCommand, RelativeSource={RelativeSource AncestorType=Window},Mode=Default}" CommandParameter="{Binding Mode=OneWay}">
49+
<local:MainWindowNavigationItem.IsChecked>
50+
<MultiBinding Mode="OneWay">
51+
<MultiBinding.Converter>
52+
<converters:MultiPageEqualsConverter/>
53+
</MultiBinding.Converter>
54+
<Binding Path="Page" Mode="OneWay"/>
55+
<Binding Path="DataContext.CurrentVisiblePage" RelativeSource="{RelativeSource AncestorType=Window}" Mode="OneWay"/>
56+
</MultiBinding>
57+
</local:MainWindowNavigationItem.IsChecked>
58+
</local:MainWindowNavigationItem>
4359
</ItemContainerTemplate>
4460
</ItemsControl.ItemTemplate>
4561
</ItemsControl>
46-
<local:MainWindowNavigationItem Content="Login" ExtraNavigationInformation="" Click="Login_Click"/>
47-
</StackPanel>
48-
<TextBlock x:Name="tbContentTitle" Grid.Column="1" FontSize="22" FontWeight="Bold" Text="{Binding Title}"/>
62+
<TextBlock x:Name="tbContentTitle" Grid.Column="1" FontSize="22" FontWeight="Bold" Text="{Binding Content.Title, ElementName=frContent}"/>
4963
<ScrollViewer Grid.Column="1" Grid.Row="1" VerticalScrollBarVisibility="Auto" >
50-
<Frame x:Name="frContent" Grid.Column="1" Grid.Row="1" NavigationUIVisibility="Hidden" Navigated="frContent_Navigated" Source="{Binding CurrentVisiblePage}"/>
64+
<Frame x:Name="frContent" Grid.Column="1" Grid.Row="1" NavigationUIVisibility="Hidden" Source="{Binding CurrentVisiblePage, Mode=TwoWay}"/>
5165
</ScrollViewer>
5266
</Grid>
5367
</Window>

View/MainWindow.xaml.cs

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -16,49 +16,5 @@ public MainWindow()
1616
InitializeComponent();
1717
SSHConnection.InitializeSsh(); // TODO: Not MVVM, this needs to be moved somewhere soon
1818
}
19-
20-
21-
/// <summary>
22-
/// Occurs when the back/forward buttons are clicked
23-
/// </summary>
24-
/// <param name="sender">The source of the event.</param>
25-
/// <param name="e">The event data.</param>
26-
private void NavigationNextPreviousButton_Click(object sender, RoutedEventArgs e)
27-
{
28-
if ((Button)sender == btPreviousButton)
29-
{
30-
frContent.GoBack();
31-
}
32-
else if ((Button)sender == btNextButton)
33-
{
34-
frContent.GoForward();
35-
}
36-
}
37-
38-
/// <summary>
39-
/// Occurs when navigation happened in the frame
40-
/// </summary>
41-
/// <param name="sender">The source of the event.</param>
42-
/// <param name="e">The event data.</param>
43-
private void frContent_Navigated(object sender, NavigationEventArgs e)
44-
{
45-
btPreviousButton.IsEnabled = ((Frame)sender).CanGoBack;
46-
btNextButton.IsEnabled = ((Frame)sender).CanGoForward;
47-
if (((Frame)sender).Content.GetType() == typeof(Page))
48-
{
49-
tbContentTitle.Text = ((Page)((Frame)sender).Content).Title;
50-
}
51-
}
52-
53-
private void MainWindowNavigationItem_Checked(object sender, RoutedEventArgs e)
54-
{
55-
56-
}
57-
58-
private void Login_Click(object sender, RoutedEventArgs e)
59-
{
60-
AuthenticationWindow authenticationWindow = new AuthenticationWindow();
61-
authenticationWindow.Show();
62-
}
6319
}
6420
}

View/MainWindowNavigationItem.xaml.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ namespace View
2020
public partial class MainWindowNavigationItem : RadioButton
2121
{
2222
public static readonly DependencyProperty PageProperty = DependencyProperty.Register(
23-
"Page", typeof(UIElement), typeof(MainWindowNavigationItem));
23+
"Page", typeof(string), typeof(MainWindowNavigationItem));
2424
/// <summary>
2525
/// The page to be navigated to
2626
/// </summary>
27-
public UIElement Page
27+
public string Page
2828
{
29-
get { return GetValue(PageProperty) as UIElement; }
29+
get { return GetValue(PageProperty) as string; }
3030
set { SetValue(PageProperty, value); }
3131
}
3232

0 commit comments

Comments
 (0)