-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9825c05
commit 1f56a9c
Showing
15 changed files
with
312 additions
and
18 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,15 @@ | ||
namespace MagpieUpdater.Models | ||
{ | ||
public class Enrollment | ||
{ | ||
public Channel Channel { get; private set; } | ||
public bool IsRequired { get; internal set; } | ||
public bool IsEnrolled { get; internal set; } | ||
public string Email { get; internal set; } | ||
|
||
public Enrollment(Channel channel) | ||
{ | ||
Channel = channel; | ||
} | ||
} | ||
} |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,9 @@ | ||
namespace MagpieUpdater.Services | ||
{ | ||
internal enum CheckState | ||
{ | ||
InBackground, | ||
Force, | ||
ChannelSwitch | ||
} | ||
} |
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,90 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Net.Mail; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Windows.Input; | ||
using MagpieUpdater.Models; | ||
using MagpieUpdater.Properties; | ||
using MagpieUpdater.Services; | ||
|
||
namespace MagpieUpdater.ViewModels | ||
{ | ||
internal class EnrollmentViewModel : BindableBase | ||
{ | ||
private string _emailAddress; | ||
private readonly Enrollment _enrollment; | ||
private string _channelName; | ||
private string _appIconPath; | ||
|
||
public string AppIconPath | ||
{ | ||
get { return _appIconPath; } | ||
set { SetProperty(ref _appIconPath, value); } | ||
} | ||
|
||
public string EmailAddress | ||
{ | ||
get { return _emailAddress; } | ||
set | ||
{ | ||
_emailAddress = value; | ||
SetProperty(ref _emailAddress, value); | ||
EnrollCommand.RaiseCanExecuteChanged(); | ||
} | ||
} | ||
|
||
public string ChannelName | ||
{ | ||
get { return _channelName; } | ||
set | ||
{ | ||
_channelName = value; | ||
SetProperty(ref _channelName, value); | ||
|
||
} | ||
} | ||
|
||
public DelegateCommand EnrollCommand { get; set; } | ||
|
||
public EnrollmentViewModel(Enrollment enrollment, AppInfo appInfo) | ||
{ | ||
_enrollment = enrollment; | ||
AppIconPath = appInfo.AppIconPath; | ||
ChannelName = _enrollment.Channel.Build; | ||
EnrollCommand = new DelegateCommand(EnrollCommandHandler, CanEnroll); | ||
} | ||
|
||
private bool CanEnroll(object obj) | ||
{ | ||
return ValidateEmailFormat(); | ||
} | ||
|
||
private void EnrollCommandHandler(object obj) | ||
{ | ||
_enrollment.IsEnrolled = true; | ||
_enrollment.Email = EmailAddress; | ||
} | ||
|
||
private bool ValidateEmailFormat() | ||
{ | ||
if (string.IsNullOrWhiteSpace(EmailAddress)) | ||
{ | ||
return false; | ||
} | ||
try | ||
{ | ||
#pragma warning disable 168 | ||
var m = new MailAddress(EmailAddress); | ||
#pragma warning restore 168 | ||
return true; | ||
} | ||
catch (FormatException) | ||
{ | ||
return false; | ||
} | ||
} | ||
|
||
} | ||
} |
Oops, something went wrong.