Пример #1
0
        public override bool OnMouseDown(Glyph g, MouseButtons button, Point mouseLoc)
        {
            if (button == MouseButtons.Left)
            {
                ISelectionService service = (ISelectionService)this.serviceProvider.GetService(typeof(ISelectionService));
                if ((service != null) && !this.containerControl.Equals(service.PrimarySelection as Control))
                {
                    service.SetSelectedComponents(new object[] { this.containerControl }, SelectionTypes.Toggle | SelectionTypes.Click);
                    ContainerSelectorGlyph glyph = g as ContainerSelectorGlyph;
                    if (glyph == null)
                    {
                        return(false);
                    }
                    using (BehaviorServiceAdornerCollectionEnumerator enumerator = this.behaviorService.Adorners.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            foreach (Glyph glyph2 in enumerator.Current.Glyphs)
                            {
                                ContainerSelectorGlyph glyph3 = glyph2 as ContainerSelectorGlyph;
                                if ((glyph3 != null) && !glyph3.Equals(glyph))
                                {
                                    ContainerSelectorBehavior relatedBehavior = glyph3.RelatedBehavior as ContainerSelectorBehavior;
                                    ContainerSelectorBehavior behavior2       = glyph.RelatedBehavior as ContainerSelectorBehavior;
                                    if (((relatedBehavior != null) && (behavior2 != null)) && behavior2.ContainerControl.Equals(relatedBehavior.ContainerControl))
                                    {
                                        relatedBehavior.OkToMove         = true;
                                        relatedBehavior.InitialDragPoint = this.DetermineInitialDragPoint(mouseLoc);
                                        continue;
                                    }
                                }
                            }
                        }
                        goto Label_0167;
                    }
                }
                this.InitialDragPoint = this.DetermineInitialDragPoint(mouseLoc);
                this.OkToMove         = true;
            }
Label_0167:
            return(false);
        }
Пример #2
0
 /// <summary>
 ///  ContainerSelectorGlyph constructor.
 /// </summary>
 internal ContainerSelectorGlyph(Rectangle containerBounds, int glyphSize, int glyphOffset, ContainerSelectorBehavior behavior) : base(behavior)
 {
     _relatedBehavior = (ContainerSelectorBehavior)behavior;
     _glyphBounds     = new Rectangle(containerBounds.X + glyphOffset, containerBounds.Y - (int)(glyphSize * .5), glyphSize, glyphSize);
 }
 public override GlyphCollection GetGlyphs(GlyphSelectionType selType)
 {
     GlyphCollection glyphs = new GlyphCollection();
     foreach (object obj2 in this.SelectionService.GetSelectedComponents())
     {
         if (obj2 is System.Windows.Forms.ToolStrip)
         {
             GlyphCollection glyphs2 = base.GetGlyphs(selType);
             glyphs.AddRange(glyphs2);
         }
         else
         {
             ToolStripItem component = obj2 as ToolStripItem;
             if ((component != null) && component.Visible)
             {
                 ToolStripItemDesigner designer = (ToolStripItemDesigner) this.host.GetDesigner(component);
                 if (designer != null)
                 {
                     designer.GetGlyphs(ref glyphs, this.StandardBehavior);
                 }
             }
         }
     }
     if ((((this.SelectionRules & SelectionRules.Moveable) != SelectionRules.None) && (this.InheritanceAttribute != System.ComponentModel.InheritanceAttribute.InheritedReadOnly)) && (selType != GlyphSelectionType.NotSelected))
     {
         Point location = base.BehaviorService.ControlToAdornerWindow((Control) base.Component);
         Rectangle containerBounds = new Rectangle(location, ((Control) base.Component).Size);
         int glyphOffset = (int) (DesignerUtils.CONTAINERGRABHANDLESIZE * 0.5);
         if (containerBounds.Width < (2 * DesignerUtils.CONTAINERGRABHANDLESIZE))
         {
             glyphOffset = -1 * glyphOffset;
         }
         ContainerSelectorBehavior behavior = new ContainerSelectorBehavior(this.ToolStrip, base.Component.Site, true);
         ContainerSelectorGlyph glyph = new ContainerSelectorGlyph(containerBounds, DesignerUtils.CONTAINERGRABHANDLESIZE, glyphOffset, behavior);
         glyphs.Insert(0, glyph);
     }
     return glyphs;
 }
 public override GlyphCollection GetGlyphs(GlyphSelectionType selectionType)
 {
     GlyphCollection glyphs = base.GetGlyphs(selectionType);
     if ((((this.SelectionRules & SelectionRules.Moveable) != SelectionRules.None) && (this.InheritanceAttribute != InheritanceAttribute.InheritedReadOnly)) && (selectionType != GlyphSelectionType.NotSelected))
     {
         Point location = base.BehaviorService.ControlToAdornerWindow((Control) base.Component);
         Rectangle containerBounds = new Rectangle(location, ((Control) base.Component).Size);
         int glyphOffset = (int) (DesignerUtils.CONTAINERGRABHANDLESIZE * 0.5);
         if (containerBounds.Width < (2 * DesignerUtils.CONTAINERGRABHANDLESIZE))
         {
             glyphOffset = -1 * glyphOffset;
         }
         ContainerSelectorBehavior behavior = new ContainerSelectorBehavior((Control) base.Component, base.Component.Site, true);
         ContainerSelectorGlyph glyph = new ContainerSelectorGlyph(containerBounds, DesignerUtils.CONTAINERGRABHANDLESIZE, glyphOffset, behavior);
         glyphs.Insert(0, glyph);
     }
     return glyphs;
 }
 internal ContainerSelectorGlyph(Rectangle containerBounds, int glyphSize, int glyphOffset, ContainerSelectorBehavior behavior)
     : base(behavior)
 {
     this.relatedBehavior = behavior;
     this.glyphBounds = new Rectangle(containerBounds.X + glyphOffset, containerBounds.Y - ((int) (glyphSize * 0.5)), glyphSize, glyphSize);
 }
Пример #6
0
 internal ContainerSelectorGlyph(Rectangle containerBounds, int glyphSize, int glyphOffset, ContainerSelectorBehavior behavior) : base(behavior)
 {
     this.relatedBehavior = behavior;
     this.glyphBounds     = new Rectangle(containerBounds.X + glyphOffset, containerBounds.Y - ((int)(glyphSize * 0.5)), glyphSize, glyphSize);
 }