public void OpenFile(string file)
{
try {
// Open the image and add it to the layers
Pixbuf bg = new Pixbuf (file);
PintaCore.Layers.Clear ();
PintaCore.History.Clear ();
PintaCore.Layers.DestroySelectionLayer ();
PintaCore.Workspace.ImageSize = new Cairo.Point (bg.Width, bg.Height);
PintaCore.Workspace.CanvasSize = new Cairo.Point (bg.Width, bg.Height);
PintaCore.Layers.ResetSelectionPath ();
Layer layer = PintaCore.Layers.AddNewLayer (System.IO.Path.GetFileName (file));
using (Cairo.Context g = new Cairo.Context (layer.Surface)) {
CairoHelper.SetSourcePixbuf (g, bg, 0, 0);
g.Paint ();
}
bg.Dispose ();
PintaCore.Workspace.Filename = System.IO.Path.GetFileName (file);
PintaCore.History.PushNewItem (new BaseHistoryItem ("gtk-open", "Open Image"));
PintaCore.Workspace.IsDirty = false;
PintaCore.Actions.View.ZoomToWindow.Activate ();
PintaCore.Workspace.Invalidate ();
} catch {
MessageDialog md = new MessageDialog (PintaCore.Chrome.MainWindow, DialogFlags.Modal, MessageType.Error, ButtonsType.Ok, "Could not open file: {0}", file);
md.Title = "Error";
md.Run ();
md.Destroy ();
}
}