protected virtual void OnAddAttachmentButtonClicked(object sender, System.EventArgs e)
{
var task = SelectedTask;
if (task == null)
return;
var dialog = new FileChooserDialog (Catalog.GetString ("Add Attachment"),
(Gtk.Window)this.Toplevel,
FileChooserAction.Open,
Gtk.Stock.Cancel, Gtk.ResponseType.Cancel,
Gtk.Stock.Ok, Gtk.ResponseType.Ok);
int response = dialog.Run ();
List<string> filenames = new List<string> ();
if (response == (int)Gtk.ResponseType.Ok) {
if (task.Attachments != null)
filenames.AddRange (task.Attachments);
filenames.AddRange (dialog.Filenames);
var command = new EditTaskCommand () {
Storage = m_storage,
Task = task,
Property = "Attachments",
Value = filenames.ToArray ()
};
command.Done += delegate {
this.UpdateAttachments ();
};
command.Undone += delegate {
this.UpdateAttachments ();
};
var commands = ServiceManager.Get<CommandService> ().Commands;
commands.Do (command);
}
dialog.Destroy ();
}