//Used if ToolboxItemFilterAttribute demands ToolboxItemFilterType.Custom //If not expecting it, should just return false bool IToolboxConsumer.CustomFilterSupports(ItemToolboxNode item) { ComponentToolboxNode cnode = item as ComponentToolboxNode; if (cnode != null && gproject.SteticProject != null) { if (cnode.GtkVersion == null || Mono.Addins.Addin.CompareVersions(gproject.SteticProject.TargetGtkVersion, cnode.GtkVersion) <= 0) { return(true); } } return(false); }
void IToolboxConsumer.DragItem(ItemToolboxNode item, Gtk.Widget source, Gdk.DragContext ctx) { if (Designer != null) { /*ComponentToolboxNode node = item as ComponentToolboxNode; * if (node != null) { * if (node.Reference == null) * Designer.BeginComponentDrag (node.ComponentType, source, ctx); * else * Designer.BeginComponentDrag (node.Name, node.ClassName, source, ctx, delegate {CheckReference (node); }); * }*/ } }
private void handleToolboxNode(ItemToolboxNode node) { ToolboxItemToolboxNode tiNode = node as ToolboxItemToolboxNode; if (tiNode != null) { //load the type into this process and get the ToolboxItem tiNode.Type.Load(); System.Drawing.Design.ToolboxItem ti = tiNode.GetToolboxItem(); //web controls have sample HTML that need to be deserialised, in a ToolboxDataAttribute //TODO: Fix WebControlToolboxItem and (mono classlib's use of it) so we don't have to mess around with type lookups and attributes here if (ti.AssemblyName != null && ti.TypeName != null) { //look up and register the type ITypeResolutionService typeRes = (ITypeResolutionService)designerHost.GetService(typeof(ITypeResolutionService)); typeRes.ReferenceAssembly(ti.AssemblyName); Type controlType = typeRes.GetType(ti.TypeName, true); //read the WebControlToolboxItem data from the attribute AttributeCollection atts = TypeDescriptor.GetAttributes(controlType); System.Web.UI.ToolboxDataAttribute tda = (System.Web.UI.ToolboxDataAttribute)atts [typeof(System.Web.UI.ToolboxDataAttribute)]; //if it's present if (tda != null && tda.Data.Length > 0) { //look up the tag's prefix and insert it into the data WebFormReferenceManager webRef = designerHost.GetService(typeof(WebFormReferenceManager)) as WebFormReferenceManager; if (webRef == null) { throw new Exception("Host does not provide an IWebFormReferenceManager"); } string aspText = String.Format(tda.Data, webRef.GetTagPrefix(controlType)); System.Diagnostics.Trace.WriteLine("Toolbox processing ASP.NET item data: " + aspText); //and add it to the document designerHost.RootDocument.InsertFragment(aspText); return; } } //No ToolboxDataAttribute? Get the ToolboxItem to create the components itself ti.CreateComponents(designerHost); } }
internal bool CanRemoveUserItem(ItemToolboxNode node) { if (Configuration.ItemList.Contains(node)) { return(true); } else { //we need check in the dynamic providers foreach (var prov in dynamicProviders) { if (prov is IToolboxDynamicProviderDeleteSupport provDelSupport && provDelSupport.CanDeleteDynamicItem(node)) { return(true); } } } return(false); }
public void RemoveUserItem(ItemToolboxNode node) { if (Configuration.ItemList.Remove(node)) { SaveConfiguration(); } else { //we need check in the dynamic providers foreach (var prov in dynamicProviders) { if (prov is IToolboxDynamicProviderDeleteSupport provDelSupport && provDelSupport.DeleteDynamicItem(node)) { break; } } } OnToolboxContentsChanged(); }
//evaluate a filter attribute against a list, and check whether permitted private bool FilterPermitted(ItemToolboxNode node, ToolboxItemFilterAttribute desFa, ICollection <ToolboxItemFilterAttribute> filterAgainst, IToolboxConsumer consumer) { switch (desFa.FilterType) { case ToolboxItemFilterType.Allow: //this is really for matching some other filter string against return(true); case ToolboxItemFilterType.Custom: return(consumer.CustomFilterSupports(node)); case ToolboxItemFilterType.Prevent: //if host and toolboxitem have same filterstring, then not permitted foreach (ToolboxItemFilterAttribute itemFa in filterAgainst) { if (desFa.Match(itemFa)) { return(false); } } return(true); case ToolboxItemFilterType.Require: //if host and toolboxitem have same filterstring, then permitted, unless one is prevented foreach (ToolboxItemFilterAttribute itemFa in filterAgainst) { if (desFa.Match(itemFa) && (desFa.FilterType != ToolboxItemFilterType.Prevent)) { return(true); } } return(false); } throw new InvalidOperationException("Unexpected ToolboxItemFilterType value."); }
void IToolboxConsumer.ConsumeItem (ItemToolboxNode item) { }
public void ConsumeItem (ItemToolboxNode node) { if (node is ToolboxItemToolboxNode) editorProcess.Editor.UseToolboxNode (node); }
public bool IsSupported (ItemToolboxNode node, IToolboxConsumer consumer) { if (consumer is ICustomFilteringToolboxConsumer) return ((ICustomFilteringToolboxConsumer)consumer).SupportsItem (node); //if something has no filters it is more useful and efficient //to show it for everything than to show it for nothing if (node.ItemFilters == null || node.ItemFilters.Count == 0) return true; //check all of host's filters foreach (ToolboxItemFilterAttribute desFa in consumer.ToolboxFilterAttributes) { if (!FilterPermitted (node, desFa, node.ItemFilters, consumer)) return false; } //check all of item's filters foreach (ToolboxItemFilterAttribute itemFa in node.ItemFilters) { if (!FilterPermitted (node, itemFa, consumer.ToolboxFilterAttributes, consumer)) return false; } //we assume permitted, so only return false when blocked by a filter return true; }
public ToolboxSelectionChangedEventArgs (ItemToolboxNode item) { this.item = item; }
public void RemoveUserItem (ItemToolboxNode node) { Configuration.ItemList.Remove (node); SaveConfiguration (); OnToolboxContentsChanged (); }
protected virtual void OnToolboxSelectionChanged (ItemToolboxNode item) { if (ToolboxSelectionChanged != null) ToolboxSelectionChanged (this, new ToolboxSelectionChangedEventArgs (item)); }
public bool CustomFilterSupports(ItemToolboxNode item) { return false; }
internal static bool DeleteItem(ItemToolboxNode node) => clipboardRing.Remove(node as ClipboardToolboxNode);
public void DragItem (ItemToolboxNode item, Widget source, Gdk.DragContext ctx) { }
public abstract void ConsumeItem(ItemToolboxNode item);
public void ConsumeItem (ItemToolboxNode node) { if (node is ToolboxItemToolboxNode) host.UseToolboxNode (node); }
private void handleToolboxNode (ItemToolboxNode node) { ToolboxItemToolboxNode tiNode = node as ToolboxItemToolboxNode; if (tiNode != null) { //load the type into this process and get the ToolboxItem tiNode.Type.Load (); System.Drawing.Design.ToolboxItem ti = tiNode.GetToolboxItem (); //web controls have sample HTML that need to be deserialised, in a ToolboxDataAttribute //TODO: Fix WebControlToolboxItem and (mono classlib's use of it) so we don't have to mess around with type lookups and attributes here if (ti.AssemblyName != null && ti.TypeName != null) { //look up and register the type ITypeResolutionService typeRes = (ITypeResolutionService)designerHost.GetService (typeof(ITypeResolutionService)); typeRes.ReferenceAssembly (ti.AssemblyName); Type controlType = typeRes.GetType (ti.TypeName, true); //read the WebControlToolboxItem data from the attribute AttributeCollection atts = TypeDescriptor.GetAttributes (controlType); System.Web.UI.ToolboxDataAttribute tda = (System.Web.UI.ToolboxDataAttribute)atts [typeof(System.Web.UI.ToolboxDataAttribute)]; //if it's present if (tda != null && tda.Data.Length > 0) { //look up the tag's prefix and insert it into the data WebFormReferenceManager webRef = designerHost.GetService (typeof(WebFormReferenceManager)) as WebFormReferenceManager; if (webRef == null) throw new Exception("Host does not provide an IWebFormReferenceManager"); string aspText = String.Format (tda.Data, webRef.GetTagPrefix (controlType)); System.Diagnostics.Trace.WriteLine ("Toolbox processing ASP.NET item data: " + aspText); //and add it to the document designerHost.RootDocument.InsertFragment (aspText); return; } } //No ToolboxDataAttribute? Get the ToolboxItem to create the components itself ti.CreateComponents (designerHost); } }
public void UseToolboxNode (ItemToolboxNode node) { //invoke in GUI thread as it catches and displays exceptions nicely Gtk.Application.Invoke ( delegate { handleToolboxNode (node); }); }
void HandleDragDataGet (object o, DragDataGetArgs args) { if (dragItem != null) { TextEditor.CaretToDragCaretPosition (); ((IToolboxConsumer)this).ConsumeItem (dragItem); dragItem = null; } }
public void DragItem(ItemToolboxNode item, Widget source, Gdk.DragContext ctx) { drag_item = item; _source = source; _source.DragDataGet += OnDragDataGet; _source.DragEnd += OnDragEnd; }
bool ICustomFilteringToolboxConsumer.SupportsItem (ItemToolboxNode item) { ITextToolboxNode textNode = item as ITextToolboxNode; if (textNode == null) return false; //string filename = this.IsUntitled ? UntitledName : ContentName; //int i = filename.LastIndexOf ('.'); //string ext = i < 0? null : filename.Substring (i + 1); return textNode.IsCompatibleWith (base.WorkbenchWindow.Document); }
void OnDragDataGet(object sender, DragDataGetArgs args) { if (drag_item == null) return; ConsumeItem (drag_item); drag_item = null; }
public ToolboxUsedEventArgs(IToolboxConsumer consumer, ItemToolboxNode item) { this.item = item; this.consumer = consumer; }
public void UseToolboxNode(ItemToolboxNode node) { //invoke in GUI thread as it catches and displays exceptions nicely Gtk.Application.Invoke(delegate { handleToolboxNode(node); }); }
public void SelectItem (ItemToolboxNode item) { selectedItem = item; OnToolboxSelectionChanged (item); }
void IToolboxConsumer.DragItem (ItemToolboxNode item, Gtk.Widget source, Gdk.DragContext ctx) { if (Designer != null) { ComponentToolboxNode node = item as ComponentToolboxNode; if (node != null) { if (node.Reference == null) Designer.BeginComponentDrag (node.ComponentType, source, ctx); else Designer.BeginComponentDrag (node.Name, node.ClassName, source, ctx, delegate { CheckReference (node); }); } } }
protected virtual void OnToolboxUsed (IToolboxConsumer consumer, ItemToolboxNode item) { if (ToolboxUsed != null) ToolboxUsed (this, new ToolboxUsedEventArgs (consumer, item)); }
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 (); }
//evaluate a filter attribute against a list, and check whether permitted private bool FilterPermitted (ItemToolboxNode node, ToolboxItemFilterAttribute desFa, ICollection<ToolboxItemFilterAttribute> filterAgainst, IToolboxConsumer consumer) { switch (desFa.FilterType) { case ToolboxItemFilterType.Allow: //this is really for matching some other filter string against return true; case ToolboxItemFilterType.Custom: return consumer.CustomFilterSupports (node); case ToolboxItemFilterType.Prevent: //if host and toolboxitem have same filterstring, then not permitted foreach (ToolboxItemFilterAttribute itemFa in filterAgainst) if (desFa.Match (itemFa)) return false; return true; case ToolboxItemFilterType.Require: //if host and toolboxitem have same filterstring, then permitted, unless one is prevented foreach (ToolboxItemFilterAttribute itemFa in filterAgainst) if (desFa.Match (itemFa) && (desFa.FilterType != ToolboxItemFilterType.Prevent)) return true; return false; } throw new InvalidOperationException ("Unexpected ToolboxItemFilterType value."); }
public void DragItem(ItemToolboxNode item, Widget source, Gdk.DragContext ctx) { }
public ToolboxUsedEventArgs (IToolboxConsumer consumer, ItemToolboxNode item) { this.item = item; this.consumer = consumer; }
void IToolboxConsumer.ConsumeItem (ItemToolboxNode item) { var tn = item as ITextToolboxNode; if (tn != null) { tn.InsertAtCaret (base.WorkbenchWindow.Document); TextEditor.GrabFocus (); } }
//Used if ToolboxItemFilterAttribute demands ToolboxItemFilterType.Custom //If not expecting it, should just return false bool IToolboxConsumer.CustomFilterSupports (ItemToolboxNode item) { ComponentToolboxNode cnode = item as ComponentToolboxNode; if (cnode != null && gproject.SteticProject != null) { if (cnode.GtkVersion == null || Mono.Addins.Addin.CompareVersions (gproject.SteticProject.TargetGtkVersion, cnode.GtkVersion) <= 0) return true; } return false; }
public override void ConsumeItem(ItemToolboxNode item) { var figureItem = item as IToolboxFigure; var connectorItem = item as IToolboxConnector; if (connectorItem == null && figureItem == null) return; if (connectorItem != null) { // AbstractConnectionFigure connector; // // if (connectorItem.ConnectorType == ConnectionType.Inheritance) // connector = new InheritanceConnectionFigure (); // else // connector = new AssociationConnectionFigure (connectorItem.ConnectorType); // // Tool = new ConnectionCreationTool (this, connector.ConnectionLine); return; } int x, y; Control.GetPointer (out x, out y); var point = View.ViewToDrawing (x, y); if (figureItem.ClassType == ClassType.Unknown) { var comment = new CommentFigure (String.Empty); comment.MoveTo (point.X, point.Y); View.Add (comment); return; } var dialog = new AddFigureDialog (figureItem.Name, figureItem.ClassType, point, this); dialog.ShowAll (); }
void IToolboxConsumer.ConsumeItem(ItemToolboxNode item) { }
bool IToolboxConsumer.CustomFilterSupports(ItemToolboxNode item) { return(false); }
//Used if ToolboxItemFilterAttribute demands ToolboxItemFilterType.Custom //If not expecting it, should just return false public bool CustomFilterSupports(ItemToolboxNode item) { return(false); }
void IToolboxConsumer.DragItem(ItemToolboxNode item, Widget source, DragContext ctx) { }
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); }
public void RemoveUserItem(ItemToolboxNode node) { Configuration.ItemList.Remove(node); SaveConfiguration(); OnToolboxContentsChanged(); }
void IToolboxConsumer.DragItem (ItemToolboxNode item, Gtk.Widget source, Gdk.DragContext ctx) { //FIXME: use the preview text string text = GetDragPreviewText (item); if (string.IsNullOrEmpty (text)) return; dragItem = item; customSource = source; customSource.DragDataGet += HandleDragDataGet; customSource.DragEnd += HandleDragEnd; }
public void SelectItem(ItemToolboxNode item) { selectedItem = item; OnToolboxSelectionChanged(item); }
string GetDragPreviewText (ItemToolboxNode item) { ITextToolboxNode tn = item as ITextToolboxNode; if (tn == null) { LoggingService.LogWarning ("Cannot use non-ITextToolboxNode toolbox items in the text editor."); return null; } return tn.GetDragPreview (base.WorkbenchWindow.Document); }
public ToolboxSelectionChangedEventArgs(ItemToolboxNode item) { this.item = item; }
bool IToolboxConsumer.CustomFilterSupports (ItemToolboxNode item) { return false; }
public virtual bool CanDeleteDynamicItem(ItemToolboxNode node) => false;