Example #1
0
        internal void ShowUI(Glyph g)
        {
            DesignerActionGlyph glyph = g as DesignerActionGlyph;

            if (glyph != null)
            {
                DesignerActionPanel panel = this.CreateDesignerActionPanel(this.RelatedComponent);
                this.ParentUI.ShowDesignerActionPanel(this.RelatedComponent, panel, glyph);
            }
        }
 private void VerifyGlyphIsInAdorner(DesignerActionGlyph glyph)
 {
     if (glyph.IsInComponentTray)
     {
         ComponentTray service = this.serviceProvider.GetService(typeof(ComponentTray)) as ComponentTray;
         if ((service.SelectionGlyphs != null) && !service.SelectionGlyphs.Contains(glyph))
         {
             service.SelectionGlyphs.Insert(0, glyph);
         }
     }
     else if (((this.designerActionAdorner != null) && (this.designerActionAdorner.Glyphs != null)) && !this.designerActionAdorner.Glyphs.Contains(glyph))
     {
         this.designerActionAdorner.Glyphs.Insert(0, glyph);
     }
     glyph.InvalidateOwnerLocation();
 }
 private void InvalidateGlyphOnLastTransaction(object sender, DesignerTransactionCloseEventArgs e)
 {
     if (e.LastTransaction)
     {
         IDesignerHost host = (this.serviceProvider != null) ? (this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost) : null;
         if (host != null)
         {
             host.TransactionClosed -= new DesignerTransactionCloseEventHandler(this.InvalidateGlyphOnLastTransaction);
         }
         if (this.relatedGlyphTransaction != null)
         {
             this.relatedGlyphTransaction.InvalidateOwnerLocation();
         }
         this.relatedGlyphTransaction = null;
     }
 }
 internal Point UpdateDAPLocation(IComponent component, DesignerActionGlyph glyph)
 {
     DockStyle style;
     if (component == null)
     {
         component = this.lastPanelComponent;
     }
     if (this.designerActionHost == null)
     {
         return Point.Empty;
     }
     if ((component == null) || (glyph == null))
     {
         return this.designerActionHost.Location;
     }
     if ((this.behaviorService != null) && !this.behaviorService.AdornerWindowControl.DisplayRectangle.IntersectsWith(glyph.Bounds))
     {
         this.HideDesignerActionPanel();
         return this.designerActionHost.Location;
     }
     Point glyphLocationScreenCoord = this.GetGlyphLocationScreenCoord(component, glyph);
     Rectangle rectangleAnchor = new Rectangle(glyphLocationScreenCoord, glyph.Bounds.Size);
     Point point2 = DesignerActionPanel.ComputePreferredDesktopLocation(rectangleAnchor, this.designerActionHost.Size, out style);
     glyph.DockEdge = style;
     this.designerActionHost.Location = point2;
     return point2;
 }
 internal void ShowDesignerActionPanel(IComponent relatedComponent, DesignerActionPanel panel, DesignerActionGlyph glyph)
 {
     if (this.designerActionHost == null)
     {
         this.designerActionHost = new DesignerActionToolStripDropDown(this, this.mainParentWindow);
         this.designerActionHost.AutoSize = false;
         this.designerActionHost.Padding = Padding.Empty;
         this.designerActionHost.Renderer = new NoBorderRenderer();
         this.designerActionHost.Text = "DesignerActionTopLevelForm";
         this.designerActionHost.Closing += new ToolStripDropDownClosingEventHandler(this.toolStripDropDown_Closing);
     }
     this.designerActionHost.AccessibleName = System.Design.SR.GetString("DesignerActionPanel_DefaultPanelTitle", new object[] { relatedComponent.GetType().Name });
     panel.AccessibleName = System.Design.SR.GetString("DesignerActionPanel_DefaultPanelTitle", new object[] { relatedComponent.GetType().Name });
     this.designerActionHost.SetDesignerActionPanel(panel, glyph);
     Point screenLocation = this.UpdateDAPLocation(relatedComponent, glyph);
     if ((this.behaviorService != null) && this.behaviorService.AdornerWindowControl.DisplayRectangle.IntersectsWith(glyph.Bounds))
     {
         if ((this.mainParentWindow != null) && (this.mainParentWindow.Handle != IntPtr.Zero))
         {
             System.Design.UnsafeNativeMethods.SetWindowLong(new HandleRef(this.designerActionHost, this.designerActionHost.Handle), -8, new HandleRef(this.mainParentWindow, this.mainParentWindow.Handle));
         }
         this.cancelClose = true;
         this.designerActionHost.Show(screenLocation);
         this.designerActionHost.Focus();
         this.designerActionHost.BeginInvoke(new EventHandler(this.OnShowComplete));
         glyph.InvalidateOwnerLocation();
         this.lastPanelComponent = relatedComponent;
         this.dapkb = new DesignerActionKeyboardBehavior(this.designerActionHost.CurrentPanel, this.serviceProvider, this.behaviorService);
         this.behaviorService.PushBehavior(this.dapkb);
     }
 }
 internal void RemoveActionGlyph(object relatedObject)
 {
     if (relatedObject != null)
     {
         if (this.IsDesignerActionPanelVisible && (relatedObject == this.lastPanelComponent))
         {
             this.HideDesignerActionPanel();
         }
         DesignerActionGlyph glyph = (DesignerActionGlyph) this.componentToGlyph[relatedObject];
         if (glyph != null)
         {
             ComponentTray service = this.serviceProvider.GetService(typeof(ComponentTray)) as ComponentTray;
             if (((service != null) && (service.SelectionGlyphs != null)) && ((service != null) && service.SelectionGlyphs.Contains(glyph)))
             {
                 service.SelectionGlyphs.Remove(glyph);
             }
             if (this.designerActionAdorner.Glyphs.Contains(glyph))
             {
                 this.designerActionAdorner.Glyphs.Remove(glyph);
             }
             this.componentToGlyph.Remove(relatedObject);
             IDesignerHost host = this.serviceProvider.GetService(typeof(IDesignerHost)) as IDesignerHost;
             if ((host != null) && host.InTransaction)
             {
                 host.TransactionClosed += new DesignerTransactionCloseEventHandler(this.InvalidateGlyphOnLastTransaction);
                 this.relatedGlyphTransaction = glyph;
             }
         }
     }
 }
 internal DesignerActionGlyph GetDesignerActionGlyph(IComponent comp, DesignerActionListCollection dalColl)
 {
     InheritanceAttribute attribute = (InheritanceAttribute) TypeDescriptor.GetAttributes(comp)[typeof(InheritanceAttribute)];
     if (attribute != InheritanceAttribute.InheritedReadOnly)
     {
         if (dalColl == null)
         {
             dalColl = this.designerActionService.GetComponentActions(comp);
         }
         if ((dalColl != null) && (dalColl.Count > 0))
         {
             DesignerActionGlyph glyph = null;
             if (this.componentToGlyph[comp] == null)
             {
                 DesignerActionBehavior behavior = new DesignerActionBehavior(this.serviceProvider, comp, dalColl, this);
                 if (!(comp is Control) || (comp is ToolStripDropDown))
                 {
                     ComponentTray service = this.serviceProvider.GetService(typeof(ComponentTray)) as ComponentTray;
                     if (service != null)
                     {
                         ComponentTray.TrayControl trayControlFromComponent = service.GetTrayControlFromComponent(comp);
                         if (trayControlFromComponent != null)
                         {
                             Rectangle bounds = trayControlFromComponent.Bounds;
                             glyph = new DesignerActionGlyph(behavior, bounds, service);
                         }
                     }
                 }
                 if (glyph == null)
                 {
                     glyph = new DesignerActionGlyph(behavior, this.designerActionAdorner);
                 }
                 if (glyph != null)
                 {
                     this.componentToGlyph.Add(comp, glyph);
                 }
                 return glyph;
             }
             glyph = this.componentToGlyph[comp] as DesignerActionGlyph;
             if (glyph != null)
             {
                 DesignerActionBehavior behavior2 = glyph.Behavior as DesignerActionBehavior;
                 if (behavior2 != null)
                 {
                     behavior2.ActionLists = dalColl;
                 }
                 glyph.Invalidate();
             }
             return glyph;
         }
         this.RemoveActionGlyph(comp);
     }
     return null;
 }