Esempio n. 1
0
        static void openButton_Clicked(object sender, EventArgs e)
        {
            FileChooserDialog fcd = new FileChooserDialog("Open page...", (Window)((Widget)sender).Toplevel, FileChooserAction.Open);

            fcd.AddButton(Stock.Cancel, ResponseType.Cancel);
            fcd.AddButton(Stock.Open, ResponseType.Ok);
            fcd.DefaultResponse = ResponseType.Ok;
            fcd.Filter          = new FileFilter();
            fcd.Filter.AddPattern("*.aspx");
            fcd.SelectMultiple = false;

            ResponseType response = (ResponseType)fcd.Run( );

            fcd.Hide();

            if (response == ResponseType.Ok && fcd.Filename != null)
            {
                using (FileStream fileStream = new FileStream(fcd.Filename, FileMode.Open))
                {
                    if (fileStream == null)
                    {
                        return;
                    }

                    host.Reset();

                    host.Load(fileStream, fcd.Filename);
                    host.Activate();
                }
            }
            fcd.Destroy();
        }
Esempio n. 2
0
        public void LoadDocument(string document, string fileName)
        {
            System.Diagnostics.Trace.WriteLine("Copying document to editor.");

            //invoke in GUI thread as it catches and displays exceptions nicely
            Gtk.Application.Invoke(delegate {
                host.Reset();
                host.Load(document, fileName);
                host.Activate();
            });
        }