-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEditWindowVM.cs
More file actions
134 lines (108 loc) · 3.26 KB
/
Copy pathEditWindowVM.cs
File metadata and controls
134 lines (108 loc) · 3.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using System.Windows;
using System.Data;
namespace UMS1
{
public partial class EditWindowVM:ObservableObject
{
public Person Student { get; private set; }
public Action CloseAction { get; internal set; }
[ObservableProperty]
public string firstname;
[ObservableProperty]
public string lastname;
[ObservableProperty]
public string dob;
[ObservableProperty]
public double? gpa;
[ObservableProperty]
public string email;
[ObservableProperty]
public string other;
[ObservableProperty]
public BitmapImage imgURL;
public BitmapImage _selectedImage;
public BitmapImage SelectedImage {
get { return _selectedImage; }
set { SetProperty(ref _selectedImage, value); UpdateImageDetails(); }
}
public void DefaultImage()
{
}
[RelayCommand]
public void OpenFile()
{
OpenFileDialog dialog= new OpenFileDialog();
dialog.Filter = "Image files | *.bmp; *.png; *.jpg";
dialog.FilterIndex= 1;
if (dialog.ShowDialog() == true)
{
SelectedImage = new BitmapImage(new Uri(dialog.FileName));
MessageBox.Show("Image successfuly uploded!", "successfull");
}
}
[RelayCommand]
public void Save()
{
if (gpa < 0 || gpa > 4)
{
MessageBox.Show("GPA value must be between 0 and 4.", "Error");
return;
}
if (Student == null)
{
Student = new Person()
{
FirstName = firstname,
LastName = lastname,
DOB= dob,
GPA= gpa,
Mail=email,
Other= other,
Image=SelectedImage
};
}
else
{
Student.FirstName = firstname;
Student.LastName = lastname;
Student.DOB = dob;
Student. GPA = gpa;
Student.Mail = email;
Student.Other = other;
Student.Image = SelectedImage;
}
if (Student.FirstName != null)
{
CloseAction();
}
Application.Current.MainWindow.UpdateLayout();
Application.Current.MainWindow.Show();
}
public EditWindowVM(Person p)
{
Student= p;
firstname = Student.FirstName;
lastname = Student.LastName;
dob = Student.DOB;
gpa = Student.GPA;
email = Student.Mail;
other = Student.Other;
SelectedImage = Student.Image;
}
public EditWindowVM()
{
}
private void UpdateImageDetails()
{
}
}
}