void OnToggleItem(object ob, Gtk.ToggledArgs args)
 {
     Gtk.TreeIter it;
     if (store.GetIterFromString(out it, args.Path))
     {
         bool            b    = (bool)store.GetValue(it, ColChecked);
         ItemToolboxNode item = (ItemToolboxNode)store.GetValue(it, ColItem);
         if (!b)
         {
             currentItems.Add(item, item);
         }
         else
         {
             currentItems.Remove(item);
         }
         store.SetValue(it, ColChecked, !b);
     }
 }
		void AddItem (ComponentIndexFile ifile, ItemToolboxNode co)
		{
			Gdk.Pixbuf img = co.Icon != null ? co.Icon.ScaleSimple (16, 16, Gdk.InterpType.Bilinear) : null;
			if (showCategories) {
				TreeIter it;
				bool found = false;
				if (store.GetIterFirst (out it)) {
					do {
						if (co.Category == (string) store.GetValue (it, ColName)) {
							found = true;
							break;
						}
					}
					while (store.IterNext (ref it));
				}
				if (!found)
					it = store.AppendValues (false, co.Category, string.Empty, string.Empty, string.Empty, null, null, false, (int)Pango.Weight.Bold);
				store.AppendValues (it, currentItems.ContainsKey (co), co.Name, string.Empty, ifile.Name, ifile.Location, img, co, true, (int)Pango.Weight.Normal);
			}
			else
				store.AppendValues (currentItems.ContainsKey (co), co.Name, string.Empty, ifile.Name, ifile.Location, img, co, true, (int)Pango.Weight.Normal);
		}
示例#3
0
 public ToolboxWidgetItem(ItemToolboxNode node)
 {
     Node = node;
 }
示例#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();
        }
示例#5
0
 public Item(ItemToolboxNode node)
 {
     this.node = node;
 }
示例#6
0
        IList <ItemToolboxNode> IExternalToolboxLoader.Load(string filename)
        {
            TargetRuntime          runtime = Runtime.SystemAssemblyService.CurrentRuntime;
            List <ItemToolboxNode> list    = new List <ItemToolboxNode> ();

            System.Reflection.Assembly scanAssem;
            try
            {
                if (runtime is MsNetTargetRuntime)
                {
                    scanAssem = System.Reflection.Assembly.ReflectionOnlyLoadFrom(filename);
                }
                else
                {
                    scanAssem = System.Reflection.Assembly.LoadFile(filename);
                }
            }
            catch (Exception ex)
            {
                MonoDevelop.Core.LoggingService.LogError("ToolboxItemToolboxLoader: Could not load assembly '"
                                                         + filename + "'", ex);
                return(list);
            }

            SystemPackage package = runtime.AssemblyContext.GetPackageFromPath(filename);

            //need to initialise if this if out of the main process
            //in order to be able to load icons etc.
            if (!initialized)
            {
                Gtk.Application.Init();
                initialized = true;
            }

            //detect the runtime version
            MonoDevelop.Core.ClrVersion clrVersion = MonoDevelop.Core.ClrVersion.Default;
            byte[] corlibKey = new byte[] { 0xb7, 0x7a, 0x5c, 0x56, 0x19, 0x34, 0xe0, 0x89 };
            //the other system.{...} key:
            //{ 0xb0, 0x3f, 0x5f, 0x7f, 0x11, 0xd5, 0x0a, 0x3a };
            foreach (System.Reflection.AssemblyName an in scanAssem.GetReferencedAssemblies())
            {
                if (an.Name == "mscorlib" && byteArraysEqual(corlibKey, an.GetPublicKeyToken()))
                {
                    if (an.Version == new Version(2, 0, 0, 0))
                    {
                        clrVersion = MonoDevelop.Core.ClrVersion.Net_2_0;
                        break;
                    }
                    else if (an.Version == new Version(1, 0, 5000, 0))
                    {
                        clrVersion = MonoDevelop.Core.ClrVersion.Net_1_1;
                        break;
                    }
                }
            }

            if (clrVersion == MonoDevelop.Core.ClrVersion.Default)
            {
                MonoDevelop.Core.LoggingService.LogError("ToolboxItemToolboxLoader: assembly '"
                                                         + filename + "' references unknown runtime version.");
                return(list);
            }

            Type[] types = scanAssem.GetTypes();

            foreach (Type t in types)
            {
                //skip inaccessible types
                if (t.IsAbstract || !t.IsPublic || !t.IsClass)
                {
                    continue;
                }

                //get the ToolboxItemAttribute if present
                object[] atts = t.GetCustomAttributes(typeof(ToolboxItemAttribute), true);
                if (atts == null || atts.Length == 0)
                {
                    continue;
                }

                ToolboxItemAttribute tba = (ToolboxItemAttribute)atts[0];
                if (tba.Equals(ToolboxItemAttribute.None) || tba.ToolboxItemType == null)
                {
                    continue;
                }

                // Technically CategoryAttribute shouldn't be used for this purpose (intended for properties in
                // the PropertyGrid) but I can see no harm in doing this.
                string cat = null;
                atts = t.GetCustomAttributes(typeof(CategoryAttribute), true);
                if (atts != null && atts.Length > 0)
                {
                    cat = ((CategoryAttribute)atts[0]).Category;
                }

                try
                {
                    ItemToolboxNode node = GetNode(t, tba, cat, package != null? filename : null, clrVersion);
                    if (node != null)
                    {
                        // Make sure this item is only shown for the correct runtime
                        node.ItemFilters.Add(new ToolboxItemFilterAttribute("TargetRuntime." + runtime.Id, ToolboxItemFilterType.Require));
                        list.Add(node);
                    }
                }
                catch (Exception ex)
                {
                    MonoDevelop.Core.LoggingService.LogError(
                        "Unhandled error in toolbox node loader '" + GetType().FullName
                        + "' with type '" + t.FullName
                        + "' in assembly '" + scanAssem.FullName + "'",
                        ex);
                }
            }

            return(list);// Load (scanAssem);
        }
示例#7
0
 void ToolboxWidget_SelectedItemChanged(object sender, EventArgs e)
 {
     selectedNode = this.toolboxWidget.SelectedItem != null ? this.toolboxWidget.SelectedItem.Tag as ItemToolboxNode : null;
     toolboxService.SelectItem(selectedNode);
 }