Exemplo n.º 1
0
        static void Start(string loadxaml, IEnumerable<Assembly> libs)
        {
            Gtk.Application.Init ();
            MoonBase.Init ();

            foreach (var lib in libs)
                MoonBase.Assemblies.Add (lib);

            var mw = new MoonArea ();
            mw.Content = new System.Windows.Controls.TextBlock (){ Text = "Loading..." };

            MainWindow win = new MainWindow ();
            win.Title = "Xaml Source";
            win.Show ();
            win.Resize (750, 600);

            win.MoonAreaContainer.Add (mw);

            var loader = new ViewLoader (mw);
            var xp = loader.LoadViewViewModel<XamlPanelViewModel> ("Views;component/Views/XamlPanel.xaml");
            mw.Content = xp.View;
            win.XpVM = (XamlPanelViewModel)xp.ViewModel;

            if (loadxaml != null) {
                try {
                    win.LoadFile (loadxaml);
                } catch (Exception e) {
                    ((XamlPanelViewModel)xp.ViewModel).UserContent
                        = new System.Windows.Controls.TextBlock ()
                {
                    Text = String.Format("Error\n\n{0}", e.Message ),
                    Padding = new System.Windows.Thickness(10.0),
                    FontStyle = System.Windows.FontStyles.Italic };
                }
            }
            Gtk.Application.Run ();
        }