Exemple #1
0
		protected override void HandleError (Exception e)
		{
			//remove the grid in case it was the source of the exception, as GTK# expose exceptions can fire repeatedly
			//also user should not be able to edit things when showing exceptions
			if (propertyGrid != null) {
				Gtk.Container parent = propertyGrid.Parent as Gtk.Container;
				if (parent != null)
					parent.Remove (propertyGrid);
				
				propertyGrid.Destroy ();
				propertyGrid = null;
			}
			
			//show the error message
			base.HandleError (e);
		}
Exemple #2
0
        static void Main()
        {
            #if TRACE
                System.Diagnostics.TextWriterTraceListener listener
                    = new System.Diagnostics.TextWriterTraceListener (System.Console.Out);
                System.Diagnostics.Trace.Listeners.Add (listener);
            #endif

            Application.Init ();

            #region Packing and layout

            Window window = new Window ("AspNetEdit Host Sample");
            window.SetDefaultSize (1000, 700);
            window.DeleteEvent += new DeleteEventHandler (window_DeleteEvent);

            VBox outerBox = new VBox ();
            window.Add (outerBox);

            HPaned leftBox = new HPaned ();
            outerBox.PackEnd (leftBox, true, true, 0);
            HPaned rightBox = new HPaned ();
            leftBox.Add2 (rightBox);

            geckoFrame = new Frame ();
            geckoFrame.Shadow = ShadowType.In;
            rightBox.Pack1 (geckoFrame, true, false);

            #endregion

            #region Toolbar

            // * Save/Open

            Toolbar buttons = new Toolbar ();
            outerBox.PackStart (buttons, false, false, 0);

            ToolButton saveButton = new ToolButton (Stock.Save);
            buttons.Add (saveButton);
            saveButton.Clicked += new EventHandler (saveButton_Clicked);

            ToolButton openButton = new ToolButton(Stock.Open);
            buttons.Add(openButton);
            openButton.Clicked += new EventHandler(openButton_Clicked);

            buttons.Add (new SeparatorToolItem());

            // * Clipboard

            ToolButton undoButton = new ToolButton (Stock.Undo);
            buttons.Add (undoButton);
            undoButton.Clicked +=new EventHandler (undoButton_Clicked);

            ToolButton redoButton = new ToolButton (Stock.Redo);
            buttons.Add (redoButton);
            redoButton.Clicked += new EventHandler (redoButton_Clicked);

            ToolButton cutButton = new ToolButton (Stock.Cut);
            buttons.Add (cutButton);
            cutButton.Clicked += new EventHandler (cutButton_Clicked);

            ToolButton copyButton = new ToolButton (Stock.Copy);
            buttons.Add (copyButton);
            copyButton.Clicked += new EventHandler (copyButton_Clicked);

            ToolButton pasteButton = new ToolButton (Stock.Paste);
            buttons.Add (pasteButton);
            pasteButton.Clicked += new EventHandler (pasteButton_Clicked);

            buttons.Add (new SeparatorToolItem());

            // * Text style

            ToolButton boldButton = new ToolButton (Stock.Bold);
            buttons.Add (boldButton);
            boldButton.Clicked += new EventHandler (boldButton_Clicked);

            ToolButton italicButton = new ToolButton (Stock.Italic);
            buttons.Add (italicButton);
            italicButton.Clicked += new EventHandler (italicButton_Clicked);

            ToolButton underlineButton = new ToolButton (Stock.Underline);
            buttons.Add (underlineButton);
            underlineButton.Clicked += new EventHandler (underlineButton_Clicked);

            ToolButton indentButton = new ToolButton (Stock.Indent);
            buttons.Add (indentButton);
            indentButton.Clicked += new EventHandler (indentButton_Clicked);

            ToolButton unindentButton = new ToolButton (Stock.Unindent);
            buttons.Add (unindentButton);
            unindentButton.Clicked += new EventHandler (unindentButton_Clicked);

            buttons.Add (new SeparatorToolItem());

            // * Toolbox

            ToolButton toolboxAddButton = new ToolButton (Stock.Add);
            buttons.Add (toolboxAddButton);
            toolboxAddButton.Clicked += new EventHandler (toolboxAddButton_Clicked);

            #endregion

            #region Designer services and host

            //set up the services
            ServiceContainer services = new ServiceContainer ();
            services.AddService (typeof (INameCreationService), new NameCreationService ());
            services.AddService (typeof (ISelectionService), new SelectionService ());
            services.AddService (typeof (IEventBindingService), new EventBindingService (window));
            services.AddService (typeof (ITypeResolutionService), new TypeResolutionService ());
            ExtenderListService extListServ = new AspNetEdit.Editor.ComponentModel.ExtenderListService ();
            services.AddService (typeof (IExtenderListService), extListServ);
            services.AddService (typeof (IExtenderProviderService), extListServ);
            services.AddService (typeof (ITypeDescriptorFilterService), new TypeDescriptorFilterService ());
            toolboxService = new ToolboxService ();
            services.AddService (typeof (IToolboxService), toolboxService);

            //create our host
            host = new DesignerHost(services);
            host.NewFile();
            host.Activate();

            #endregion

            #region Designer UI and panels

            IRootDesigner rootDesigner = (IRootDesigner) host.GetDesigner (host.RootComponent);
            RootDesignerView designerView = (RootDesignerView) rootDesigner.GetView (ViewTechnology.Passthrough);
            geckoFrame.Add (designerView);

            PropertyGrid p = new PropertyGrid (services);
            p.WidthRequest = 200;
            rightBox.Pack2 (p, false, false);

            Toolbox toolbox = new Toolbox (services);
            leftBox.Pack1 (toolbox, false, false);
            toolboxService.PopulateFromAssembly (System.Reflection.Assembly.GetAssembly (typeof (System.Web.UI.Control)));
            toolboxService.AddToolboxItem (new TextToolboxItem ("<table><tr><td></td><td></td></tr><tr><td></td><td></td></tr></table>", "Table"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<div style=\"width: 100px; height: 100px;\"></div>", "Div"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<hr />", "Horizontal Rule"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<select><option></option></select>", "Select"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<img src=\"\" />", "Image"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<textarea cols=\"20\" rows=\"2\"></textarea>", "Textarea"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"hidden\" />", "Input [Hidden]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"radio\" />", "Input [Radio]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"checkbox\" />", "Input [Checkbox]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"password\" />", "Input [Password]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"file\" />", "Input [File]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"text\" />", "Input [Text]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"submit\" value=\"submit\" />", "Input [Submit]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"reset\" value=\"reset\" />", "Input [Reset]"), "Html");
            toolboxService.AddToolboxItem (new TextToolboxItem ("<input type=\"button\" value=\"button\" />", "Input [Button]"), "Html");
            toolbox.Refresh ();

            #endregion

            window.ShowAll ();
            Application.Run ();
        }
Exemple #3
0
		void LoadGui (MonoDevelopProxy proxy, string document, string fileName)
		{
			System.Diagnostics.Trace.WriteLine ("Creating AspNetEdit EditorHost");
			host = new EditorHost (proxy);
			host.Initialise (document, fileName);
			System.Diagnostics.Trace.WriteLine ("Created AspNetEdit EditorHost");
			
			System.Diagnostics.Trace.WriteLine ("Building AspNetEdit GUI");
			Gtk.VBox outerBox = new Gtk.VBox ();
			
			geckoFrame = new Frame ();
			geckoFrame.Shadow = ShadowType.In;
			geckoFrame.Add (host.DesignerView);
			outerBox.PackEnd (geckoFrame, true, true, 0);
			
			Toolbar tb = BuildToolbar ();
			outerBox.PackStart (tb, false, false, 0);
			
			outerBox.ShowAll ();
			base.DesignerWidget = outerBox;
			
			//grid picks up some services from the designer host
			propertyGrid = new PropertyGrid (host.Services);
			propertyGrid.ShowAll ();
			base.PropertyGridWidget = propertyGrid;
			System.Diagnostics.Trace.WriteLine ("Built AspNetEdit GUI");
		}