Пример #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();
        }
Пример #2
0
        public void Initialise(string document, string fileName)
        {
            DispatchService.AssertGuiThread();

            System.Diagnostics.Trace.WriteLine("Loading document into DesignerHost");
            if (document != null)
            {
                host.Load(document, fileName);
            }
            else
            {
                host.NewFile();
            }
            System.Diagnostics.Trace.WriteLine("Loaded document into DesignerHost");

            host.Activate();
            System.Diagnostics.Trace.WriteLine("DesignerHost activated; getting designer view");

            IRootDesigner rootDesigner = (IRootDesigner)host.GetDesigner(host.RootComponent);

            designerView           = (RootDesignerView)rootDesigner.GetView(ViewTechnology.Passthrough);
            designerView.Realized += delegate { System.Diagnostics.Trace.WriteLine("Designer view realized"); };
        }