コード例 #1
0
 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;
             }
         }
     }
 }
コード例 #2
0
        private Point GetGlyphLocationScreenCoord(IComponent relatedComponent, Glyph glyph)
        {
            Point point = new Point(0, 0);

            if ((relatedComponent is Control) && !(relatedComponent is ToolStripDropDown))
            {
                return(this.behaviorService.AdornerWindowPointToScreen(glyph.Bounds.Location));
            }
            if (relatedComponent is ToolStripItem)
            {
                ToolStripItem item = relatedComponent as ToolStripItem;
                if ((item != null) && (item.Owner != null))
                {
                    point = this.behaviorService.AdornerWindowPointToScreen(glyph.Bounds.Location);
                }
                return(point);
            }
            if (relatedComponent != null)
            {
                ComponentTray service = this.serviceProvider.GetService(typeof(ComponentTray)) as ComponentTray;
                if (service != null)
                {
                    point = service.PointToScreen(glyph.Bounds.Location);
                }
            }
            return(point);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
 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();
 }
コード例 #5
0
        protected override void Dispose (bool disposing)
        {
            if (_designedControl != null)
            {
                this.DesignerPanel.Controls.Remove (_designedControl);
                _designedControl = null;
            }

            if (_componentTray != null)
            {
                this.ComponentTrayPanel.Controls.Remove (_componentTray);
                _componentTray.Dispose ();
                _componentTray = null;
            }

            base.Dispose (disposing);
        }
コード例 #6
0
ファイル: DocumentDesigner.cs プロジェクト: Profit0004/mono
			public DesignerViewFrame (Control designedControl, ComponentTray tray)
			{
				if (designedControl == null) {
					throw new ArgumentNullException ("designedControl");
				}
				if (tray == null) {
					throw new ArgumentNullException ("tray");
				}
				//
				// The InitializeComponent() call is required for Windows Forms designer support.
				//
				InitializeComponent();

 				_designedControl = designedControl;
 				this.SuspendLayout ();
 				this.DesignerPanel.Controls.Add (designedControl);
 				this.ResumeLayout ();

				this.ComponentTray = tray;
			}
コード例 #7
0
        public DesignerViewFrame (Control designedControl, ComponentTray tray)
        {
            if (designedControl == null)
            {
                throw new ArgumentNullException ("designedControl");
            }
            if (tray == null)
            {
                throw new ArgumentNullException ("tray");
            }
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            _designedControl = designedControl;
            this.SuspendLayout ();
            this.DesignerPanel.Controls.Add (designedControl);
            this.ResumeLayout ();

            this.ComponentTray = tray;
        }
コード例 #8
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
         if (host != null)
         {
             ToolStripAdornerWindowService service = (ToolStripAdornerWindowService) this.GetService(typeof(ToolStripAdornerWindowService));
             if (service != null)
             {
                 service.Dispose();
                 host.RemoveService(typeof(ToolStripAdornerWindowService));
             }
             host.Activated -= new EventHandler(this.OnDesignerActivate);
             host.Deactivated -= new EventHandler(this.OnDesignerDeactivate);
             if (this.componentTray != null)
             {
                 ISplitWindowService service2 = (ISplitWindowService) this.GetService(typeof(ISplitWindowService));
                 if (service2 != null)
                 {
                     service2.RemoveSplitWindow(this.componentTray);
                     this.componentTray.Dispose();
                     this.componentTray = null;
                 }
                 host.RemoveService(typeof(ComponentTray));
             }
             IComponentChangeService service3 = (IComponentChangeService) this.GetService(typeof(IComponentChangeService));
             if (service3 != null)
             {
                 service3.ComponentAdded -= new ComponentEventHandler(this.OnComponentAdded);
                 service3.ComponentChanged -= new ComponentChangedEventHandler(this.OnComponentChanged);
                 service3.ComponentRemoved -= new ComponentEventHandler(this.OnComponentRemoved);
             }
             if (this.undoEngine != null)
             {
                 this.undoEngine.Undoing -= new EventHandler(this.OnUndoing);
                 this.undoEngine.Undone -= new EventHandler(this.OnUndone);
             }
             if (this.toolboxCreator != null)
             {
                 IToolboxService service4 = (IToolboxService) this.GetService(typeof(IToolboxService));
                 if (service4 != null)
                 {
                     service4.RemoveCreator(axClipFormat, host);
                     service4.RemoveCreator(OleDragDropHandler.DataFormat, host);
                     service4.RemoveCreator(OleDragDropHandler.NestedToolboxItemFormat, host);
                 }
                 this.toolboxCreator = null;
             }
         }
         if (this.menuEditorService != null)
         {
             host.RemoveService(typeof(IMenuEditorService));
             this.menuEditorService = null;
         }
         ISelectionService service5 = (ISelectionService) this.GetService(typeof(ISelectionService));
         if (service5 != null)
         {
             service5.SelectionChanged -= new EventHandler(this.OnSelectionChanged);
         }
         if (this.behaviorService != null)
         {
             this.behaviorService.Dispose();
             this.behaviorService = null;
         }
         if (this.selectionManager != null)
         {
             this.selectionManager.Dispose();
             this.selectionManager = null;
         }
         if (this.componentTray != null)
         {
             if (host != null)
             {
                 ISplitWindowService service6 = (ISplitWindowService) this.GetService(typeof(ISplitWindowService));
                 if (service6 != null)
                 {
                     service6.RemoveSplitWindow(this.componentTray);
                 }
             }
             this.componentTray.Dispose();
             this.componentTray = null;
         }
         if (this.pbrsFwd != null)
         {
             this.pbrsFwd.Dispose();
             this.pbrsFwd = null;
         }
         if (this.frame != null)
         {
             this.frame.Dispose();
             this.frame = null;
         }
         if (this.commandSet != null)
         {
             this.commandSet.Dispose();
             this.commandSet = null;
         }
         if (this.inheritanceService != null)
         {
             this.inheritanceService.Dispose();
             this.inheritanceService = null;
         }
         if (this.inheritanceUI != null)
         {
             this.inheritanceUI.Dispose();
             this.inheritanceUI = null;
         }
         if (this.designBindingValueUIHandler != null)
         {
             IPropertyValueUIService service7 = (IPropertyValueUIService) this.GetService(typeof(IPropertyValueUIService));
             if (service7 != null)
             {
                 service7.RemovePropertyValueUIHandler(new PropertyValueUIHandler(this.designBindingValueUIHandler.OnGetUIValueItem));
                 service7 = null;
             }
             this.designBindingValueUIHandler.Dispose();
             this.designBindingValueUIHandler = null;
         }
         if (this.designerExtenders != null)
         {
             this.designerExtenders.Dispose();
             this.designerExtenders = null;
         }
         if (this.axTools != null)
         {
             this.axTools.Clear();
         }
         if (host != null)
         {
             host.RemoveService(typeof(BehaviorService));
             host.RemoveService(typeof(ToolStripAdornerWindowService));
             host.RemoveService(typeof(SelectionManager));
             host.RemoveService(typeof(IInheritanceService));
             host.RemoveService(typeof(IEventHandlerService));
             host.RemoveService(typeof(IOverlayService));
             host.RemoveService(typeof(ISplitWindowService));
             host.RemoveService(typeof(InheritanceUI));
         }
     }
     base.Dispose(disposing);
 }
コード例 #9
0
ファイル: DocumentDesigner.cs プロジェクト: Profit0004/mono
			protected override void Dispose (bool disposing)
			{
				if (_designedControl != null) {
					this.DesignerPanel.Controls.Remove (_designedControl);
					_designedControl = null;
				}
				
				if (_componentTray != null) {
					this.ComponentTrayPanel.Controls.Remove (_componentTray);
					_componentTray.Dispose ();
					_componentTray = null;
				}
				
				base.Dispose (disposing);
			}
コード例 #10
0
            protected override IComponent[] CreateComponentsCore(IDesignerHost host, IDictionary defaultValues)
            {
                IDesignerSerializationService ds = (IDesignerSerializationService)host.GetService(typeof(IDesignerSerializationService));

                if (ds == null)
                {
                    return(null);
                }

                // Deserialize to components collection
                //
                ICollection objects    = ds.Deserialize(_serializationData);
                ArrayList   components = new ArrayList();

                foreach (object obj in objects)
                {
                    if (obj != null && obj is IComponent)
                    {
                        components.Add(obj);
                    }
                }

                IComponent[] componentsArray = new IComponent[components.Count];
                components.CopyTo(componentsArray, 0);

                ArrayList trayComponents = null;

                // Parent and locate each Control
                //
                if (defaultValues == null)
                {
                    defaultValues = new Hashtable();
                }
                Control parentControl = defaultValues["Parent"] as Control;

                if (parentControl != null)
                {
                    ParentControlDesigner parentControlDesigner = host.GetDesigner(parentControl) as ParentControlDesigner;
                    if (parentControlDesigner != null)
                    {
                        // Determine bounds of all controls
                        //
                        Rectangle bounds = Rectangle.Empty;

                        foreach (IComponent component in componentsArray)
                        {
                            Control childControl = component as Control;

                            if (childControl != null && childControl != parentControl && childControl.Parent == null)
                            {
                                if (bounds.IsEmpty)
                                {
                                    bounds = childControl.Bounds;
                                }
                                else
                                {
                                    bounds = Rectangle.Union(bounds, childControl.Bounds);
                                }
                            }
                        }

                        defaultValues.Remove("Size");    // don't care about the drag size
                        foreach (IComponent component in componentsArray)
                        {
                            Control childControl = component as Control;
                            Form    form         = childControl as Form;
                            if (childControl != null &&
                                !(form != null && form.TopLevel) && // Don't add top-level forms
                                childControl.Parent == null)
                            {
                                defaultValues["Offset"] = new Size(childControl.Bounds.X - bounds.X, childControl.Bounds.Y - bounds.Y);
                                parentControlDesigner.AddControl(childControl, defaultValues);
                            }
                        }
                    }
                }

                // VSWhidbey 516338 - When creating an item for the tray, template items will have
                // an old location stored in them, so they may show up on top of other items.
                // So we need to call UpdatePastePositions for each one to get the tray to
                // arrange them properly.
                //
                ComponentTray tray = (ComponentTray)host.GetService(typeof(ComponentTray));

                if (tray != null)
                {
                    foreach (IComponent component in componentsArray)
                    {
                        ComponentTray.TrayControl c = tray.GetTrayControlFromComponent(component);

                        if (c != null)
                        {
                            if (trayComponents == null)
                            {
                                trayComponents = new ArrayList();
                            }

                            trayComponents.Add(c);
                        }
                    }

                    if (trayComponents != null)
                    {
                        tray.UpdatePastePositions(trayComponents);
                    }
                }

                return(componentsArray);
            }
コード例 #11
0
 public TraySelectionUIHandler(ComponentTray tray)
 {
     this.tray = tray;
     this.snapSize = new Size();
 }
コード例 #12
0
 public void UpdateLocation(ComponentTray.TrayControl trayControl)
 {
     foreach (Glyph glyph in this.traySelectionAdorner.Glyphs)
     {
         DesignerActionGlyph glyph2 = glyph as DesignerActionGlyph;
         if ((glyph2 != null) && ((DesignerActionBehavior) glyph2.Behavior).RelatedComponent.Equals(trayControl.Component))
         {
             glyph2.UpdateAlternativeBounds(trayControl.Bounds);
         }
     }
 }
コード例 #13
0
 public TrayControlAccessibleObject(ComponentTray.TrayControl owner, ComponentTray tray)
     : base(owner)
 {
     this.tray = tray;
 }
コード例 #14
0
 public TrayControl(ComponentTray tray, IComponent component)
 {
     this.tray = tray;
     this.component = component;
     base.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
     base.SetStyle(ControlStyles.Selectable, false);
     this.borderWidth = SystemInformation.BorderSize.Width;
     this.UpdateIconInfo();
     IComponentChangeService service = (IComponentChangeService) tray.GetService(typeof(IComponentChangeService));
     bool enabled = System.ComponentModel.CompModSwitches.CommonDesignerServices.Enabled;
     if (service != null)
     {
         service.ComponentRename += new ComponentRenameEventHandler(this.OnComponentRename);
     }
     ISite site = component.Site;
     string name = null;
     if (site != null)
     {
         name = site.Name;
         IDictionaryService service2 = (IDictionaryService) site.GetService(typeof(IDictionaryService));
         if (service2 != null)
         {
             service2.SetValue(base.GetType(), this);
         }
     }
     if (name == null)
     {
         name = component.GetType().Name;
     }
     this.Text = name;
     this.inheritanceAttribute = (System.ComponentModel.InheritanceAttribute) TypeDescriptor.GetAttributes(component)[typeof(System.ComponentModel.InheritanceAttribute)];
     base.TabStop = false;
 }
コード例 #15
0
 private void OnComponentAdded(object source, ComponentEventArgs ce)
 {
     IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
     if (host != null)
     {
         IComponent component = ce.Component;
         this.EnsureMenuEditorService(ce.Component);
         bool flag = true;
         if (!(host.GetDesigner(component) is ToolStripDesigner))
         {
             ControlDesigner designer = host.GetDesigner(component) as ControlDesigner;
             if (designer != null)
             {
                 Form control = designer.Control as Form;
                 if ((control == null) || !control.TopLevel)
                 {
                     flag = false;
                 }
             }
         }
         if (flag && TypeDescriptor.GetAttributes(component).Contains(DesignTimeVisibleAttribute.Yes))
         {
             if (this.componentTray == null)
             {
                 ISplitWindowService service = (ISplitWindowService) this.GetService(typeof(ISplitWindowService));
                 if (service != null)
                 {
                     this.componentTray = new ComponentTray(this, base.Component.Site);
                     service.AddSplitWindow(this.componentTray);
                     this.componentTray.Height = this.trayHeight;
                     this.componentTray.ShowLargeIcons = this.trayLargeIcon;
                     this.componentTray.AutoArrange = this.trayAutoArrange;
                     host.AddService(typeof(ComponentTray), this.componentTray);
                 }
             }
             if (this.componentTray != null)
             {
                 if (((host != null) && host.Loading) && !this.trayLayoutSuspended)
                 {
                     this.trayLayoutSuspended = true;
                     this.componentTray.SuspendLayout();
                 }
                 this.componentTray.AddComponent(component);
             }
         }
     }
 }
コード例 #16
0
 private void OnComponentRemoved(object source, ComponentEventArgs ce)
 {
     if (((!(ce.Component is Control) || (ce.Component is ToolStrip)) || ((ce.Component is Form) && ((Form) ce.Component).TopLevel)) && (this.componentTray != null))
     {
         this.componentTray.RemoveComponent(ce.Component);
         if (this.componentTray.ComponentCount == 0)
         {
             ISplitWindowService service = (ISplitWindowService) this.GetService(typeof(ISplitWindowService));
             if (service != null)
             {
                 service.RemoveSplitWindow(this.componentTray);
                 IDesignerHost host = (IDesignerHost) this.GetService(typeof(IDesignerHost));
                 if (host != null)
                 {
                     host.RemoveService(typeof(ComponentTray));
                 }
                 this.componentTray.Dispose();
                 this.componentTray = null;
             }
         }
     }
 }
コード例 #17
0
        /// <include file='doc\ControlCommandSet.uex' path='docs/doc[@for="ControlCommandSet.RotateTabSelection"]/*' />
        /// <devdoc>
        ///     Rotates the selection to the element next in the tab index.  If backwards
        ///     is set, this will rotate to the previous tab index.
        /// </devdoc>
        private void RotateTabSelection(bool backwards)
        {
            Control ctl;
            Control baseCtl;
            object  targetSelection = null;
            object  currentSelection;

            ISelectionService selSvc = SelectionService;
            IDesignerHost     host   = (IDesignerHost)GetService(typeof(IDesignerHost));

            if (selSvc == null || host == null || !(host.RootComponent is Control))
            {
                return;
            }

            IContainer container = host.Container;

            baseCtl = (Control)host.RootComponent;

            // We must handle two cases of logic here.  We are responsible for handling
            // selection within ourself, and also for components on the tray.  For our
            // own tabbing around, we want to go by tab-order.  When we get to the end
            // of the form, however, we go by selection order into the tray.  And,
            // when we're at the end of the tray we start back at the form.  We must
            // reverse this logic to go backwards.

            currentSelection = selSvc.PrimarySelection;

            if (currentSelection is Control)
            {
                // Our current selection is a control.  Select the next control in
                // the z-order.
                //
                ctl = (Control)currentSelection;

                while (null != (ctl = baseCtl.GetNextControl(ctl, !backwards)))
                {
                    if (ctl.Site != null && ctl.Site.Container == container)
                    {
                        break;
                    }
                }

                targetSelection = ctl;
            }

            if (targetSelection == null)
            {
                ComponentTray tray = (ComponentTray)GetService(typeof(ComponentTray));
                if (tray != null)
                {
                    targetSelection = tray.GetNextComponent((IComponent)currentSelection, !backwards);
                }

                if (targetSelection == null)
                {
                    targetSelection = baseCtl;
                }
            }

            selSvc.SetSelectedComponents(new object[] { targetSelection }, SelectionTypes.Replace);
        }