|
using System.ComponentModel;
using System.Windows;
using TaskList.DataModel;
using TaskList.ViewModel;
namespace TaskList
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application, ITaskListApplication
{
TaskCollection tasks = new TaskCollection();
public App()
{
string fileName = FileName;
if (!string.IsNullOrEmpty(fileName))
LoadTasks(fileName);
}
#region ITaskListApplication Members
public string FileName
{
get
{
return TaskList.Properties.Settings.Default.LastOpenedFile;
}
}
public TaskList.DataModel.TaskCollection Tasks
{
get
{
return tasks;
}
}
public void LoadTasks(string fileName)
{
tasks = TaskCollection.Load(fileName);
OnPropertyChanged("Tasks");
TaskList.Properties.Settings.Default.LastOpenedFile = fileName;
TaskList.Properties.Settings.Default.Save();
OnPropertyChanged("FileName");
}
public void SaveTasks(string fileName)
{
tasks.Save(fileName);
TaskList.Properties.Settings.Default.LastOpenedFile = fileName;
TaskList.Properties.Settings.Default.Save();
OnPropertyChanged("FileName");
}
public void NewTasks()
{
tasks = new TaskCollection();
OnPropertyChanged("Tasks");
TaskList.Properties.Settings.Default.LastOpenedFile = string.Empty;
TaskList.Properties.Settings.Default.Save();
OnPropertyChanged("FileName");
}
public void ExitApplication()
{
MainWindow.Close();
}
#endregion
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
}
protected void OnPropertyChanged(PropertyChangedEventArgs e)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
handler(this, e);
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Windows developer with 10+ years experience working in the banking industry.