Ejemplo n.º 1
0
 internal DesignerToolboxInfo(ToolboxService toolboxService, IDesignerHost host)
 {
     this._toolboxService   = toolboxService;
     this._host             = host;
     this._selectionService = host.GetService(typeof(ISelectionService)) as ISelectionService;
     if (this._selectionService != null)
     {
         this._selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     if (this._host.RootComponent != null)
     {
         this._host.RootComponent.Disposed += new EventHandler(this.OnDesignerDisposed);
     }
     TypeDescriptor.Refreshed += new RefreshEventHandler(this.OnTypeDescriptorRefresh);
 }
 internal DesignerToolboxInfo(ToolboxService toolboxService, IDesignerHost host)
 {
     this._toolboxService = toolboxService;
     this._host = host;
     this._selectionService = host.GetService(typeof(ISelectionService)) as ISelectionService;
     if (this._selectionService != null)
     {
         this._selectionService.SelectionChanged += new EventHandler(this.OnSelectionChanged);
     }
     if (this._host.RootComponent != null)
     {
         this._host.RootComponent.Disposed += new EventHandler(this.OnDesignerDisposed);
     }
     TypeDescriptor.Refreshed += new RefreshEventHandler(this.OnTypeDescriptorRefresh);
 }
Ejemplo n.º 3
0
            internal byte[] GetToolboxItems(AssemblyName an, bool throwOnError)
            {
                Assembly a = null;

                try
                {
                    a = Assembly.Load(an);
                }
                catch (FileNotFoundException)
                {
                }
                catch (BadImageFormatException)
                {
                }
                catch (IOException)
                {
                }
                if ((a == null) && (an.CodeBase != null))
                {
                    a = Assembly.LoadFrom(new Uri(an.CodeBase).LocalPath);
                }
                if (a == null)
                {
                    throw new ArgumentException(System.Drawing.Design.SR.GetString("ToolboxServiceAssemblyNotFound", new object[] { an.FullName }));
                }
                ICollection graph = null;

                try
                {
                    graph = ToolboxService.GetToolboxItems(a, null, throwOnError);
                }
                catch (Exception exception)
                {
                    ReflectionTypeLoadException exception2 = exception as ReflectionTypeLoadException;
                    if (exception2 != null)
                    {
                        throw new ReflectionTypeLoadException(null, exception2.LoaderExceptions, exception2.Message);
                    }
                    throw;
                }
                BinaryFormatter formatter           = new BinaryFormatter();
                MemoryStream    serializationStream = new MemoryStream();

                formatter.Serialize(serializationStream, graph);
                serializationStream.Close();
                return(serializationStream.GetBuffer());
            }
Ejemplo n.º 4
0
		public Toolbox (ToolboxService toolboxService, IPadWindow container)
		{			
			this.toolboxService = toolboxService;
			this.container = container;
			
			#region Toolbar
			DockItemToolbar toolbar = container.GetToolbar (PositionType.Top);
		
			filterEntry = new SearchEntry();
			filterEntry.Ready = true;
			filterEntry.HasFrame = true;
			filterEntry.WidthRequest = 150;
			filterEntry.Changed += new EventHandler (filterTextChanged);
			filterEntry.Show ();

			toolbar.Add (filterEntry, true);
			
			catToggleButton = new ToggleButton ();
			catToggleButton.Image = new Image (Ide.Gui.Stock.GroupByCategory, IconSize.Menu);
			catToggleButton.Toggled += new EventHandler (toggleCategorisation);
			catToggleButton.TooltipText = GettextCatalog.GetString ("Show categories");
			toolbar.Add (catToggleButton);
			
			compactModeToggleButton = new ToggleButton ();
			compactModeToggleButton.Image = new ImageView (ImageService.GetIcon ("md-compact-display", IconSize.Menu));
			compactModeToggleButton.Toggled += new EventHandler (ToggleCompactMode);
			compactModeToggleButton.TooltipText = GettextCatalog.GetString ("Use compact display");
			toolbar.Add (compactModeToggleButton);
	
			toolboxAddButton = new Button (new Gtk.Image (Ide.Gui.Stock.Add, IconSize.Menu));
			toolbar.Add (toolboxAddButton);
			toolboxAddButton.TooltipText = GettextCatalog.GetString ("Add toolbox items");
			toolboxAddButton.Clicked += new EventHandler (toolboxAddButton_Clicked);
			toolbar.ShowAll ();

			#endregion
			
			toolboxWidget = new ToolboxWidget ();
			toolboxWidget.SelectedItemChanged += delegate {
				selectedNode = this.toolboxWidget.SelectedItem != null ? this.toolboxWidget.SelectedItem.Tag as ItemToolboxNode : null;
				toolboxService.SelectItem (selectedNode);
			};
			this.toolboxWidget.DragBegin += delegate(object sender, Gtk.DragBeginArgs e) {
				
				if (this.toolboxWidget.SelectedItem != null) {
					this.toolboxWidget.HideTooltipWindow ();
					toolboxService.DragSelectedItem (this.toolboxWidget, e.Context);
				}
			};
			this.toolboxWidget.ActivateSelectedItem += delegate {
				toolboxService.UseSelectedItem ();
			};
			
			fontChanger = new MonoDevelop.Ide.Gui.PadFontChanger (toolboxWidget, toolboxWidget.SetCustomFont, toolboxWidget.QueueResize);
			
			this.toolboxWidget.DoPopupMenu = ShowPopup;
			
			scrolledWindow = new MonoDevelop.Components.CompactScrolledWindow ();
			base.PackEnd (scrolledWindow, true, true, 0);
			base.FocusChain = new Gtk.Widget [] { scrolledWindow };
			
			//Initialise self
			scrolledWindow.ShadowType = ShadowType.None;
			scrolledWindow.VscrollbarPolicy = PolicyType.Automatic;
			scrolledWindow.HscrollbarPolicy = PolicyType.Never;
			scrolledWindow.WidthRequest = 150;
			scrolledWindow.Add (this.toolboxWidget);
			
			//update view when toolbox service updated
			toolboxService.ToolboxContentsChanged += delegate { Refresh (); };
			toolboxService.ToolboxConsumerChanged += delegate { Refresh (); };
			Refresh ();
			
			//set initial state
			this.toolboxWidget.ShowCategories = catToggleButton.Active = true;
			compactModeToggleButton.Active = MonoDevelop.Core.PropertyService.Get ("ToolboxIsInCompactMode", false);
			this.toolboxWidget.IsListMode  = !compactModeToggleButton.Active;
			this.ShowAll ();
		}