mirror of
https://github.com/DevExpress/netcore-winforms-demos.git
synced 2025-12-25 10:57:30 +00:00
81 lines
3.1 KiB
C#
81 lines
3.1 KiB
C#
using System.Diagnostics;
|
|
using DevExpress.DevAV.Common.ViewModel;
|
|
using DevExpress.Mvvm;
|
|
using DevExpress.Mvvm.DataAnnotations;
|
|
using DevExpress.Mvvm.POCO;
|
|
|
|
namespace DevExpress.DevAV.ViewModels {
|
|
public class EmployeeContactsViewModel : SingleObjectChildViewModel<Employee> {
|
|
public new static EmployeeContactsViewModel Create() {
|
|
return ViewModelSource.Create(() => new EmployeeContactsViewModel());
|
|
}
|
|
|
|
public EmployeeContactsViewModel() { }
|
|
|
|
protected IMessageBoxService MessageBoxService { get { return this.GetRequiredService<IMessageBoxService>(); } }
|
|
|
|
[Command]
|
|
public void Message() {
|
|
MessageBoxService.Show("Send an IM to: " + Entity.Skype);
|
|
}
|
|
public bool CanMessage() {
|
|
return Entity != null && !string.IsNullOrEmpty(Entity.Skype);
|
|
}
|
|
[Command]
|
|
public void Phone() {
|
|
MessageBoxService.Show("Phone Call: " + Entity.MobilePhone);
|
|
}
|
|
public bool CanPhone() {
|
|
return Entity != null && !string.IsNullOrEmpty(Entity.MobilePhone);
|
|
}
|
|
[Command]
|
|
public void HomeCall() {
|
|
MessageBoxService.Show("Home Call: " + Entity.HomePhone);
|
|
}
|
|
public bool CanHomeCall() {
|
|
return Entity != null && !string.IsNullOrEmpty(Entity.HomePhone);
|
|
}
|
|
[Command]
|
|
public void MobileCall() {
|
|
MessageBoxService.Show("Mobile Call: " + Entity.MobilePhone);
|
|
}
|
|
public bool CanMobileCall() {
|
|
return Entity != null && !string.IsNullOrEmpty(Entity.MobilePhone);
|
|
}
|
|
[Command]
|
|
public void Call() {
|
|
MessageBoxService.Show("Call: " + Entity.Skype);
|
|
}
|
|
public bool CanCall() {
|
|
return Entity != null && !string.IsNullOrEmpty(Entity.Skype);
|
|
}
|
|
[Command]
|
|
public void VideoCall() {
|
|
MessageBoxService.Show("Video Call: " + Entity.Skype);
|
|
}
|
|
public bool CanVideoCall() {
|
|
return Entity != null && !string.IsNullOrEmpty(Entity.Skype);
|
|
}
|
|
[Command]
|
|
public void MailTo() {
|
|
ExecuteMailTo(MessageBoxService, Entity.Email);
|
|
}
|
|
public bool CanMailTo() {
|
|
return Entity != null && !string.IsNullOrEmpty(Entity.Email);
|
|
}
|
|
protected override void OnEntityChanged() {
|
|
base.OnEntityChanged();
|
|
this.RaiseCanExecuteChanged(x => x.Message());
|
|
this.RaiseCanExecuteChanged(x => x.Phone());
|
|
this.RaiseCanExecuteChanged(x => x.MobileCall());
|
|
this.RaiseCanExecuteChanged(x => x.HomeCall());
|
|
this.RaiseCanExecuteChanged(x => x.Call());
|
|
this.RaiseCanExecuteChanged(x => x.VideoCall());
|
|
this.RaiseCanExecuteChanged(x => x.MailTo());
|
|
}
|
|
public static void ExecuteMailTo(IMessageBoxService messageBoxService, string email) {
|
|
if(Data.Utils.SafeProcess.Start("mailto://" + email) == null && messageBoxService != null)
|
|
messageBoxService.Show("Mail To: " + email);
|
|
}
|
|
}
|
|
} |