//******************************************************************************************************
// ViewModelBase.cs - Gbtc
//
// Copyright © 2012, Grid Protection Alliance. All Rights Reserved.
//
// Licensed to the Grid Protection Alliance (GPA) under one or more contributor license agreements. See
// the NOTICE file distributed with this work for additional information regarding copyright ownership.
// The GPA licenses this file to you under the MIT License (MIT), the "License"; you may
// not use this file except in compliance with the License. You may obtain a copy of the License at:
//
// http://www.opensource.org/licenses/MIT
//
// Unless agreed to in writing, the subject software distributed under the License is distributed on an
// "AS-IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. Refer to the
// License for the specific language governing permissions and limitations.
//
// Code Modification History:
// ----------------------------------------------------------------------------------------------------
// 03/25/2011 - Mehulbhai P Thakkar
// Generated original version of source code.
// 12/20/2012 - Starlynn Danyelle Gilliam
// Modified Header.
//
//******************************************************************************************************
using System;
using System.ComponentModel;
using System.Windows;
namespace GSF.TimeSeries.UI
{
///
/// Represents an abstract class from which all ViewModel objects will derive.
///
public abstract class ViewModelBase : INotifyPropertyChanged
{
#region [ Members ]
//Events
///
/// Raised when a property on this object has a new value.
///
public event PropertyChangedEventHandler PropertyChanged;
#endregion
#region [ Properties ]
///
/// Gets a to display information to UI user.
///
public Action Popup
{
get
{
return (Action)((message, caption, messageBoxImage) => MessageBox.Show(Application.Current.MainWindow, message, caption, MessageBoxButton.OK, messageBoxImage));
}
}
///
/// Gets a to request confirmation from UI user.
///
public Func Confirm
{
get
{
return (Func)((message, caption) => MessageBox.Show(Application.Current.MainWindow, message, caption, MessageBoxButton.YesNo) == MessageBoxResult.Yes);
}
}
#endregion
#region [ Methods ]
///
/// Raises the event.
///
/// The property that has a new value.
protected void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
#endregion
}
}