コード例 #1
0
        public void SaveImage(object saveMenuItem, EventArgs args)
        {
            Gtk.FileChooserDialog fc =
                new Gtk.FileChooserDialog("Save File As",
                                          null,
                                          Gtk.FileChooserAction.Save,
                                          "Cancel", ResponseType.Cancel,
                                          "Save", ResponseType.Accept);

            if (fc.Run() == (int)Gtk.ResponseType.Accept)
            {
                if (!_model.SaveCompositeImage(fc.Filename))
                {
                    MessageDialog md =
                        new MessageDialog(this,
                                          DialogFlags.DestroyWithParent,
                                          MessageType.Error,
                                          ButtonsType.Close, "Error saving file!");

                    int result = md.Run();
                    md.Destroy();
                }
            }

            fc.Destroy();
        }
コード例 #2
0
        //requires: nothing
        //effects: opens a dialog that asks User for a filename;
        //         if User decides to save the image, triggers the
        //              SaveCompositeImage of the CompositeModel
        //         if save is not successful, displays an error message
        void OnSaveCallback()
        {
            FileChooserDialog save = new FileChooserDialog("Save As",
                                                           this, FileChooserAction.Save,
                                                           "Cancel", Gtk.ResponseType.Cancel,
                                                           "Save", Gtk.ResponseType.Ok);
            string filename;

            if (save.Run() != (int)Gtk.ResponseType.Ok)
            {
                save.Destroy();
                return;
            }
            else
            {
                filename = save.Filename;
                save.Destroy();
            }
            bool saveSuccess = _model.SaveCompositeImage(filename);

            if (saveSuccess == true)
            {
                Console.WriteLine("working");
                MessageDialog message = new MessageDialog(this,
                                                          DialogFlags.DestroyWithParent, MessageType.Info,
                                                          ButtonsType.Close, "Save As Successful!");
                message.Run();
                message.Destroy();
            }
            else
            {
                MessageDialog message = new MessageDialog(this,
                                                          DialogFlags.DestroyWithParent, MessageType.Info,
                                                          ButtonsType.Close, "Error saving file");
                message.Run();
                message.Destroy();
            }
        }