private void PopulateColumnTypesCombo()
        {
            this.columnTypesCombo.Items.Clear();
            IDesignerHost host = (IDesignerHost)this.liveDataGridView.Site.GetService(iDesignerHostType);

            if (host != null)
            {
                ITypeDiscoveryService service = (ITypeDiscoveryService)host.GetService(iTypeDiscoveryServiceType);
                if (service != null)
                {
                    foreach (System.Type type in DesignerUtils.FilterGenericTypes(service.GetTypes(dataGridViewColumnType, false)))
                    {
                        if (((type != dataGridViewColumnType) && !type.IsAbstract) && (type.IsPublic || type.IsNestedPublic))
                        {
                            DataGridViewColumnDesignTimeVisibleAttribute attribute = TypeDescriptor.GetAttributes(type)[dataGridViewColumnDesignTimeVisibleAttributeType] as DataGridViewColumnDesignTimeVisibleAttribute;
                            if ((attribute == null) || attribute.Visible)
                            {
                                this.columnTypesCombo.Items.Add(new ComboBoxItem(type));
                            }
                        }
                    }
                    this.columnTypesCombo.SelectedIndex = this.TypeToSelectedIndex(typeof(DataGridViewTextBoxColumn));
                }
            }
        }
예제 #2
0
        /// <summary>
        ///  Retrieves the next parent control that would be usable
        ///  by the tab order UI.  We only want parents that are
        ///  sited by the designer host.
        /// </summary>
        private Control GetSitedParent(Control child)
        {
            Control parent = child.Parent;

            while (parent != null)
            {
                ISite      site      = parent.Site;
                IContainer container = null;

                if (site != null)
                {
                    container = site.Container;
                }

                container = DesignerUtils.CheckForNestedContainer(container); // ...necessary to support SplitterPanel components

                if (site != null && container == host)
                {
                    break;
                }

                parent = parent.Parent;
            }

            return(parent);
        }
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            string strA = (string)value;

            if (((strA == null) || (strA.Length == 0)) || (string.Compare(strA, System.Design.SR.GetString("DataGridNoneString"), true, CultureInfo.CurrentCulture) == 0))
            {
                return(DesignBinding.Null);
            }
            int index = strA.IndexOf("-");

            if (index == -1)
            {
                throw new ArgumentException(System.Design.SR.GetString("DesignBindingBadParseString", new object[] { strA }));
            }
            string a          = strA.Substring(0, index - 1).Trim();
            string dataMember = strA.Substring(index + 1).Trim();

            if ((context == null) || (context.Container == null))
            {
                throw new ArgumentException(System.Design.SR.GetString("DesignBindingContextRequiredWhenParsing", new object[] { strA }));
            }
            IComponent dataSource = DesignerUtils.CheckForNestedContainer(context.Container).Components[a];

            if (dataSource != null)
            {
                return(new DesignBinding(dataSource, dataMember));
            }
            if (!string.Equals(a, "(List)", StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException(System.Design.SR.GetString("DesignBindingComponentNotFound", new object[] { a }));
            }
            return(null);
        }
예제 #4
0
        /// <summary>
        /// Uses the specified ITypeDiscoveryService service provider to discover MaskDescriptor objects from
        /// the referenced assemblies.
        /// </summary>
        public void DiscoverMaskDescriptors(ITypeDiscoveryService discoveryService)
        {
            if (discoveryService is null)
            {
                return;
            }

            ICollection descriptors = DesignerUtils.FilterGenericTypes(discoveryService.GetTypes(typeof(MaskDescriptor), false /* excludeGlobalTypes */));

            // Note: This code assumes DesignerUtils.FilterGenericTypes return a valid ICollection (collection of MaskDescriptor types).
            foreach (Type t in descriptors)
            {
                if (t.IsAbstract || !t.IsPublic)
                {
                    continue;
                }

                // Since mask descriptors can be provided from external sources, we need to guard against
                // possible exceptions when accessing an external descriptor.
                try
                {
                    MaskDescriptor maskDescriptor = (MaskDescriptor)Activator.CreateInstance(t);
                    InsertMaskDescriptor(0, maskDescriptor);
                }
                catch (Exception ex)
                {
                    if (ClientUtils.IsCriticalException(ex))
                    {
                        throw;
                    }
                }
            }
        }
예제 #5
0
 public MaskDesignerDialog(MaskedTextBox instance, IHelpService helpService)
 {
     if (instance == null)
     {
         this.maskedTextBox = new MaskedTextBox();
     }
     else
     {
         this.maskedTextBox = MaskedTextBoxDesigner.GetDesignMaskedTextBox(instance);
     }
     this.helpService = helpService;
     this.InitializeComponent();
     DesignerUtils.ApplyListViewThemeStyles(this.listViewCannedMasks);
     base.SuspendLayout();
     this.txtBoxMask.Text = this.maskedTextBox.Mask;
     this.AddDefaultMaskDescriptors(this.maskedTextBox.Culture);
     this.maskDescriptionHeader.Text  = System.Design.SR.GetString("MaskDesignerDialogMaskDescription");
     this.maskDescriptionHeader.Width = this.listViewCannedMasks.Width / 3;
     this.dataFormatHeader.Text       = System.Design.SR.GetString("MaskDesignerDialogDataFormat");
     this.dataFormatHeader.Width      = this.listViewCannedMasks.Width / 3;
     this.validatingTypeHeader.Text   = System.Design.SR.GetString("MaskDesignerDialogValidatingType");
     this.validatingTypeHeader.Width  = ((this.listViewCannedMasks.Width / 3) - SystemInformation.VerticalScrollBarWidth) - 4;
     base.ResumeLayout(false);
     this.HookEvents();
 }
 public TreeNodeCollectionForm(CollectionEditor editor) : base(editor)
 {
     this.editor = (TreeNodeCollectionEditor)editor;
     this.InitializeComponent();
     this.HookEvents();
     this.intialNextNode = this.NextNode;
     this.SetButtonsState();
     DesignerUtils.ApplyTreeViewThemeStyles(this.treeView1);
 }
        private void SyncDesignerUI()
        {
            Size adornmentDimensions = DesignerUtils.GetAdornmentDimensions(AdornmentType.Maximum);

            this.designerRegion.AutoScrollMargin = adornmentDimensions;
            this.designer.Location = new Point(adornmentDimensions.Width, adornmentDimensions.Height);
            if (this.BehaviorService != null)
            {
                this.BehaviorService.SyncSelection();
            }
        }
 private void SiteItem(IDesignerHost host, ToolStripItem item)
 {
     if (!(item is DesignerToolStripControlHost))
     {
         host.Container.Add(item, DesignerUtils.GetUniqueSiteName(host, item.Name));
         item.Name = item.Site.Name;
         ToolStripDropDownItem item2 = item as ToolStripDropDownItem;
         if ((item2 != null) && item2.HasDropDownItems)
         {
             this.SiteItems(host, item2.DropDownItems);
         }
     }
 }
예제 #9
0
        /// <summary>
        /// Constructor receiving a clone of the MaskedTextBox control under design.
        /// </summary>
        public MaskDesignerDialog(MaskedTextBox instance, IHelpService helpService)
        {
            if (instance is null)
            {
                Debug.Fail("Null masked text box, creating default.");
                _maskedTextBox = new MaskedTextBox();
            }
            else
            {
                _maskedTextBox = MaskedTextBoxDesigner.GetDesignMaskedTextBox(instance);
            }

            _helpService = helpService;

            InitializeComponent();

            // Enable Vista Explorer listview style
            DesignerUtils.ApplyListViewThemeStyles(_listViewCannedMasks);

            // Non-designer-handled stuff.
            SuspendLayout();

            _txtBoxMask.Text = _maskedTextBox.Mask;

            // Add default mask descriptors to the mask description list.
            AddDefaultMaskDescriptors(_maskedTextBox.Culture);

            //
            // maskDescriptionHeader
            //
            _maskDescriptionHeader.Text  = SR.MaskDesignerDialogMaskDescription;
            _maskDescriptionHeader.Width = _listViewCannedMasks.Width / 3;
            //
            // dataFormatHeader
            //
            _dataFormatHeader.Text  = SR.MaskDesignerDialogDataFormat;
            _dataFormatHeader.Width = _listViewCannedMasks.Width / 3;
            //
            // validatingTypeHeader
            //
            _validatingTypeHeader.Text  = SR.MaskDesignerDialogValidatingType;
            _validatingTypeHeader.Width = (_listViewCannedMasks.Width / 3) - SystemInformation.VerticalScrollBarWidth - 4;  // so no h-scrollbar.
            ResumeLayout(false);

            HookEvents();
        }
 public void Start(IWindowsFormsEditorService edSvc, ITypeDiscoveryService discoveryService, System.Type defaultType)
 {
     this.edSvc = edSvc;
     this.typesListBox.Items.Clear();
     foreach (System.Type type in DesignerUtils.FilterGenericTypes(discoveryService.GetTypes(dataGridViewColumnType, false)))
     {
         if (((type != dataGridViewColumnType) && !type.IsAbstract) && (type.IsPublic || type.IsNestedPublic))
         {
             DataGridViewColumnDesignTimeVisibleAttribute attribute = TypeDescriptor.GetAttributes(type)[typeof(DataGridViewColumnDesignTimeVisibleAttribute)] as DataGridViewColumnDesignTimeVisibleAttribute;
             if ((attribute == null) || attribute.Visible)
             {
                 this.typesListBox.Items.Add(new ListBoxItem(type));
             }
         }
     }
     this.typesListBox.SelectedIndex = this.TypeToSelectedIndex(defaultType);
     this.selectedType = null;
     base.Width        = Math.Max(base.Width, this.PreferredWidth + (SystemInformation.VerticalScrollBarWidth * 2));
 }
        private Control GetSitedParent(Control child)
        {
            Control parent = child.Parent;

            while (parent != null)
            {
                ISite      site      = parent.Site;
                IContainer container = null;
                if (site != null)
                {
                    container = site.Container;
                }
                container = DesignerUtils.CheckForNestedContainer(container);
                if ((site != null) && (container == this.host))
                {
                    return(parent);
                }
                parent = parent.Parent;
            }
            return(parent);
        }
예제 #12
0
            internal StyleEditorForm(CollectionEditor editor, bool isRowCollection) : base(editor)
            {
                this.editor          = (StyleCollectionEditor)editor;
                this.isRowCollection = isRowCollection;
                this.InitializeComponent();
                this.HookEvents();
                DesignerUtils.ApplyListViewThemeStyles(this.columnsAndRowsListView);
                base.ActiveControl = this.columnsAndRowsListView;
                this.tlp           = base.Context.Instance as TableLayoutPanel;
                this.tlp.SuspendLayout();
                this.deleteList = new ArrayList();
                IDesignerHost service = this.tlp.Site.GetService(typeof(IDesignerHost)) as IDesignerHost;

                if (service != null)
                {
                    this.tlpDesigner = service.GetDesigner(this.tlp) as TableLayoutPanelDesigner;
                    this.compSvc     = service.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
                }
                this.rowStyleProp = TypeDescriptor.GetProperties(this.tlp)["RowStyles"];
                this.colStyleProp = TypeDescriptor.GetProperties(this.tlp)["ColumnStyles"];
                this.tlpDesigner.SuspendEnsureAvailableStyles();
            }
예제 #13
0
 public void DiscoverMaskDescriptors(ITypeDiscoveryService discoveryService)
 {
     if (discoveryService != null)
     {
         foreach (System.Type type in DesignerUtils.FilterGenericTypes(discoveryService.GetTypes(typeof(MaskDescriptor), false)))
         {
             if (!type.IsAbstract && type.IsPublic)
             {
                 try
                 {
                     MaskDescriptor maskDescriptor = (MaskDescriptor)Activator.CreateInstance(type);
                     this.InsertMaskDescriptor(0, maskDescriptor);
                 }
                 catch (Exception exception)
                 {
                     if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
                     {
                         throw;
                     }
                 }
             }
         }
     }
 }
        //  OLE DragDrop virtual methods
        /// <summary>
        ///  OnDragDrop can be overridden so that a Behavior can specify its own Drag/Drop rules.
        /// </summary>
        public override void OnDragDrop(Glyph g, DragEventArgs e)
        {
            ToolStripItem currentDropItem = ToolStripDesigner.s_dragItem;

            // Ensure that the list item index is contained in the data.
            if (e.Data is ToolStripItemDataObject && currentDropItem != null)
            {
                ToolStripItemDataObject data = (ToolStripItemDataObject)e.Data;
                // Get the PrimarySelection before the Drag operation...
                ToolStripItem selectedItem = data.PrimarySelection;
                IDesignerHost designerHost = (IDesignerHost)currentDropItem.Site.GetService(typeof(IDesignerHost));
                Debug.Assert(designerHost != null, "Invalid DesignerHost");
                //Do DragDrop only if currentDropItem has changed.
                if (currentDropItem != selectedItem && designerHost != null)
                {
                    ArrayList components      = data.DragComponents;
                    ToolStrip parentToolStrip = currentDropItem.GetCurrentParent() as ToolStrip;
                    int       primaryIndex    = -1;
                    string    transDesc;
                    bool      copy = (e.Effect == DragDropEffects.Copy);
                    if (components.Count == 1)
                    {
                        string name = TypeDescriptor.GetComponentName(components[0]);
                        if (name == null || name.Length == 0)
                        {
                            name = components[0].GetType().Name;
                        }
                        transDesc = string.Format(copy ? SR.BehaviorServiceCopyControl : SR.BehaviorServiceMoveControl, name);
                    }
                    else
                    {
                        transDesc = string.Format(copy ? SR.BehaviorServiceCopyControls : SR.BehaviorServiceMoveControls, components.Count);
                    }

                    DesignerTransaction designerTransaction = designerHost.CreateTransaction(transDesc);
                    try
                    {
                        IComponentChangeService changeSvc = (IComponentChangeService)currentDropItem.Site.GetService(typeof(IComponentChangeService));
                        if (changeSvc != null)
                        {
                            if (parentToolStrip is ToolStripDropDown dropDown)
                            {
                                ToolStripItem ownerItem = dropDown.OwnerItem;
                                changeSvc.OnComponentChanging(ownerItem, TypeDescriptor.GetProperties(ownerItem)["DropDownItems"]);
                            }
                            else
                            {
                                changeSvc.OnComponentChanging(parentToolStrip, TypeDescriptor.GetProperties(parentToolStrip)["Items"]);
                            }
                        }

                        // If we are copying, then we want to make a copy of the components we are dragging
                        if (copy)
                        {
                            // Remember the primary selection if we had one
                            if (selectedItem != null)
                            {
                                primaryIndex = components.IndexOf(selectedItem);
                            }
                            ToolStripKeyboardHandlingService keyboardHandlingService = GetKeyBoardHandlingService(selectedItem);
                            if (keyboardHandlingService != null)
                            {
                                keyboardHandlingService.CopyInProgress = true;
                            }
                            components = DesignerUtils.CopyDragObjects(components, currentDropItem.Site) as ArrayList;
                            if (keyboardHandlingService != null)
                            {
                                keyboardHandlingService.CopyInProgress = false;
                            }
                            if (primaryIndex != -1)
                            {
                                selectedItem = components[primaryIndex] as ToolStripItem;
                            }
                        }

                        if (e.Effect == DragDropEffects.Move || copy)
                        {
                            ISelectionService selSvc = GetSelectionService(currentDropItem);
                            if (selSvc != null)
                            {
                                // Insert the item.
                                if (parentToolStrip is ToolStripOverflow)
                                {
                                    parentToolStrip = (((ToolStripOverflow)parentToolStrip).OwnerItem).Owner;
                                }

                                int indexOfItemUnderMouseToDrop = parentToolStrip.Items.IndexOf(ToolStripDesigner.s_dragItem);
                                if (indexOfItemUnderMouseToDrop != -1)
                                {
                                    int indexOfPrimarySelection = 0;
                                    if (selectedItem != null)
                                    {
                                        indexOfPrimarySelection = parentToolStrip.Items.IndexOf(selectedItem);
                                    }

                                    if (indexOfPrimarySelection != -1 && indexOfItemUnderMouseToDrop > indexOfPrimarySelection)
                                    {
                                        indexOfItemUnderMouseToDrop--;
                                    }
                                    foreach (ToolStripItem item in components)
                                    {
                                        parentToolStrip.Items.Insert(indexOfItemUnderMouseToDrop, item);
                                    }
                                }
                                selSvc.SetSelectedComponents(new IComponent[] { selectedItem }, SelectionTypes.Primary | SelectionTypes.Replace);
                            }
                        }
                        if (changeSvc != null)
                        {
                            ToolStripDropDown dropDown = parentToolStrip as ToolStripDropDown;
                            if (dropDown != null)
                            {
                                ToolStripItem ownerItem = dropDown.OwnerItem;
                                changeSvc.OnComponentChanged(ownerItem, TypeDescriptor.GetProperties(ownerItem)["DropDownItems"], null, null);
                            }
                            else
                            {
                                changeSvc.OnComponentChanged(parentToolStrip, TypeDescriptor.GetProperties(parentToolStrip)["Items"], null, null);
                            }

                            //fire extra changing/changed events.
                            if (copy)
                            {
                                if (dropDown != null)
                                {
                                    ToolStripItem ownerItem = dropDown.OwnerItem;
                                    changeSvc.OnComponentChanging(ownerItem, TypeDescriptor.GetProperties(ownerItem)["DropDownItems"]);
                                    changeSvc.OnComponentChanged(ownerItem, TypeDescriptor.GetProperties(ownerItem)["DropDownItems"], null, null);
                                }
                                else
                                {
                                    changeSvc.OnComponentChanging(parentToolStrip, TypeDescriptor.GetProperties(parentToolStrip)["Items"]);
                                    changeSvc.OnComponentChanged(parentToolStrip, TypeDescriptor.GetProperties(parentToolStrip)["Items"], null, null);
                                }
                            }
                        }

                        //If Parent is DropDown... we have to manage the Glyphs ....
                        foreach (ToolStripItem item in components)
                        {
                            if (item is ToolStripDropDownItem)
                            {
                                if (designerHost.GetDesigner(item) is ToolStripMenuItemDesigner itemDesigner)
                                {
                                    itemDesigner.InitializeDropDown();
                                }
                            }
                            if (item.GetCurrentParent() is ToolStripDropDown dropDown && !(dropDown is ToolStripOverflow))
                            {
                                if (dropDown.OwnerItem is ToolStripDropDownItem ownerItem)
                                {
                                    if (designerHost.GetDesigner(ownerItem) is ToolStripMenuItemDesigner ownerDesigner)
                                    {
                                        ownerDesigner.InitializeBodyGlyphsForItems(false, ownerItem);
                                        ownerDesigner.InitializeBodyGlyphsForItems(true, ownerItem);
                                    }
                                }
                            }
                        }
                        // Refresh on SelectionManager...
                        BehaviorService bSvc = GetBehaviorService(currentDropItem);
                        if (bSvc != null)
                        {
                            bSvc.SyncSelection();
                        }
                    }
                    catch (Exception ex)
                    {
                        if (designerTransaction != null)
                        {
                            designerTransaction.Cancel();
                            designerTransaction = null;
                        }
                        if (ClientUtils.IsCriticalException(ex))
                        {
                            throw;
                        }
                    }
                    finally
                    {
                        if (designerTransaction != null)
                        {
                            designerTransaction.Commit();
                            designerTransaction = null;
                        }
                    }
                }
            }
        }
예제 #15
0
        /// <summary>
        ///  Creates a new tab order control that displays the tab order
        ///  UI for a form.
        /// </summary>
        public TabOrder(IDesignerHost host)
        {
            this.host = host;

            // Determine a font for us to use.
            //
            IUIService uisvc = (IUIService)host.GetService(typeof(IUIService));

            if (uisvc != null)
            {
                tabFont = (Font)uisvc.Styles["DialogFont"];
            }
            else
            {
                tabFont = DefaultFont;
            }

            tabFont = new Font(tabFont, FontStyle.Bold);

            // And compute the proper highlight dimensions.
            //
            selSize = DesignerUtils.GetAdornmentDimensions(AdornmentType.GrabHandle).Width;

            // Colors and brushes...
            //
            drawString         = new StringBuilder(12);
            highlightTextBrush = new SolidBrush(SystemColors.HighlightText);
            highlightPen       = new Pen(SystemColors.Highlight);

            // The decimal separator
            //
            NumberFormatInfo formatInfo = (NumberFormatInfo)CultureInfo.CurrentCulture.GetFormat(typeof(NumberFormatInfo));

            if (formatInfo != null)
            {
                decimalSep = formatInfo.NumberDecimalSeparator;
            }
            else
            {
                decimalSep = ".";
            }

            tabProperties = new Hashtable();

            // Set up a NULL brush so we never try to invalidate the control.  This is
            // more efficient for what we're doing
            //
            SetStyle(ControlStyles.Opaque, true);

            // We're an overlay on top of the form
            //
            IOverlayService os = (IOverlayService)host.GetService(typeof(IOverlayService));

            Debug.Assert(os != null, "No overlay service -- tab order UI cannot be shown");
            if (os != null)
            {
                os.PushOverlay(this);
            }

            // Push a help keyword so the help system knows we're in place.
            //
            IHelpService hs = (IHelpService)host.GetService(typeof(IHelpService));

            if (hs != null)
            {
                hs.AddContextAttribute("Keyword", "TabOrderView", HelpKeywordType.FilterKeyword);
            }

            commands = new MenuCommand[]
            {
                new MenuCommand(new EventHandler(OnKeyCancel),
                                MenuCommands.KeyCancel),

                new MenuCommand(new EventHandler(OnKeyDefault),
                                MenuCommands.KeyDefaultAction),

                new MenuCommand(new EventHandler(OnKeyPrevious),
                                MenuCommands.KeyMoveUp),

                new MenuCommand(new EventHandler(OnKeyNext),
                                MenuCommands.KeyMoveDown),

                new MenuCommand(new EventHandler(OnKeyPrevious),
                                MenuCommands.KeyMoveLeft),

                new MenuCommand(new EventHandler(OnKeyNext),
                                MenuCommands.KeyMoveRight),

                new MenuCommand(new EventHandler(OnKeyNext),
                                MenuCommands.KeySelectNext),

                new MenuCommand(new EventHandler(OnKeyPrevious),
                                MenuCommands.KeySelectPrevious),
            };

            newCommands = new MenuCommand[]
            {
                new MenuCommand(new EventHandler(OnKeyDefault),
                                MenuCommands.KeyTabOrderSelect),
            };

            IMenuCommandService mcs = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));

            if (mcs != null)
            {
                foreach (MenuCommand mc in newCommands)
                {
                    mcs.AddCommand(mc);
                }
            }

            // We also override keyboard, menu and mouse handlers.  Our override relies on the
            // above array of menu commands, so this must come after we initialize the array.
            //
            IEventHandlerService ehs = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));

            if (ehs != null)
            {
                ehs.PushHandler(this);
            }

            // We sync add, remove and change events so we remain in sync with any nastiness that the
            // form may pull on us.
            //
            IComponentChangeService cs = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            if (cs != null)
            {
                cs.ComponentAdded   += new ComponentEventHandler(OnComponentAddRemove);
                cs.ComponentRemoved += new ComponentEventHandler(OnComponentAddRemove);
                cs.ComponentChanged += new ComponentChangedEventHandler(OnComponentChanged);
            }
        }
예제 #16
0
 private void BindingFormattingDialog_Load(object sender, EventArgs e)
 {
     this.inLoad = true;
     try
     {
         BindingTreeNode node6;
         this.dirty = false;
         Font       defaultFont = Control.DefaultFont;
         IUIService service     = null;
         if (this.bindings.BindableComponent.Site != null)
         {
             service = (IUIService)this.bindings.BindableComponent.Site.GetService(typeof(IUIService));
         }
         if (service != null)
         {
             defaultFont = (Font)service.Styles["DialogFont"];
         }
         this.Font = defaultFont;
         DesignerUtils.ApplyTreeViewThemeStyles(this.propertiesTreeView);
         if (this.propertiesTreeView.ImageList == null)
         {
             ImageList list = new ImageList();
             list.Images.Add(BoundBitmap);
             list.Images.Add(UnboundBitmap);
             this.propertiesTreeView.ImageList = list;
         }
         BindingTreeNode node  = null;
         BindingTreeNode node2 = null;
         string          name  = null;
         string          str2  = null;
         foreach (Attribute attribute in TypeDescriptor.GetAttributes(this.bindings.BindableComponent))
         {
             if (attribute is DefaultBindingPropertyAttribute)
             {
                 name = ((DefaultBindingPropertyAttribute)attribute).Name;
                 break;
             }
             if (attribute is DefaultPropertyAttribute)
             {
                 str2 = ((DefaultPropertyAttribute)attribute).Name;
             }
         }
         this.propertiesTreeView.Nodes.Clear();
         TreeNode node3 = new TreeNode(System.Design.SR.GetString("BindingFormattingDialogCommonTreeNode"));
         TreeNode node4 = new TreeNode(System.Design.SR.GetString("BindingFormattingDialogAllTreeNode"));
         this.propertiesTreeView.Nodes.Add(node3);
         this.propertiesTreeView.Nodes.Add(node4);
         PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(this.bindings.BindableComponent);
         for (int i = 0; i < properties.Count; i++)
         {
             if (!properties[i].IsReadOnly)
             {
                 BindableAttribute  attribute2 = (BindableAttribute)properties[i].Attributes[typeof(BindableAttribute)];
                 BrowsableAttribute attribute3 = (BrowsableAttribute)properties[i].Attributes[typeof(BrowsableAttribute)];
                 if (((attribute3 == null) || attribute3.Browsable) || ((attribute2 != null) && attribute2.Bindable))
                 {
                     BindingTreeNode node5 = new BindingTreeNode(properties[i].Name)
                     {
                         Binding = this.FindBinding(properties[i].Name)
                     };
                     if (node5.Binding != null)
                     {
                         node5.FormatType = FormatControl.FormatTypeStringFromFormatString(node5.Binding.FormatString);
                     }
                     else
                     {
                         node5.FormatType = System.Design.SR.GetString("BindingFormattingDialogFormatTypeNoFormatting");
                     }
                     if ((attribute2 != null) && attribute2.Bindable)
                     {
                         node3.Nodes.Add(node5);
                     }
                     else
                     {
                         node4.Nodes.Add(node5);
                     }
                     if (((node == null) && !string.IsNullOrEmpty(name)) && (string.Compare(properties[i].Name, name, false, CultureInfo.CurrentCulture) == 0))
                     {
                         node = node5;
                     }
                     else if (((node2 == null) && !string.IsNullOrEmpty(str2)) && (string.Compare(properties[i].Name, str2, false, CultureInfo.CurrentCulture) == 0))
                     {
                         node2 = node5;
                     }
                 }
             }
         }
         node3.Expand();
         node4.Expand();
         this.propertiesTreeView.Sort();
         if (node != null)
         {
             node6 = node;
         }
         else if (node2 != null)
         {
             node6 = node2;
         }
         else if (node3.Nodes.Count > 0)
         {
             node6 = FirstNodeInAlphabeticalOrder(node3.Nodes) as BindingTreeNode;
         }
         else if (node4.Nodes.Count > 0)
         {
             node6 = FirstNodeInAlphabeticalOrder(node4.Nodes) as BindingTreeNode;
         }
         else
         {
             node6 = null;
         }
         this.propertiesTreeView.SelectedNode = node6;
         if (node6 != null)
         {
             node6.EnsureVisible();
         }
         this.dataSourcePicker.PropertyName   = node6.Text;
         this.dataSourcePicker.Binding        = (node6 != null) ? node6.Binding : null;
         this.dataSourcePicker.Enabled        = true;
         this.dataSourcePicker.OwnerComponent = this.bindings.BindableComponent;
         this.dataSourcePicker.DefaultDataSourceUpdateMode = this.bindings.DefaultDataSourceUpdateMode;
         if ((node6 != null) && (node6.Binding != null))
         {
             this.bindingUpdateDropDown.Enabled      = true;
             this.bindingUpdateDropDown.SelectedItem = node6.Binding.DataSourceUpdateMode;
             this.updateModeLabel.Enabled            = true;
             this.formatControl1.Enabled             = true;
             this.formatControl1.FormatType          = node6.FormatType;
             this.formatControl1.FormatTypeItem.PushFormatStringIntoFormatType(node6.Binding.FormatString);
             if (node6.Binding.NullValue != null)
             {
                 this.formatControl1.NullValue = node6.Binding.NullValue.ToString();
             }
             else
             {
                 this.formatControl1.NullValue = string.Empty;
             }
         }
         else
         {
             this.bindingUpdateDropDown.Enabled      = false;
             this.bindingUpdateDropDown.SelectedItem = this.bindings.DefaultDataSourceUpdateMode;
             this.updateModeLabel.Enabled            = false;
             this.formatControl1.Enabled             = false;
             this.formatControl1.FormatType          = string.Empty;
         }
         this.formatControl1.Dirty   = false;
         this.currentBindingTreeNode = this.propertiesTreeView.SelectedNode as BindingTreeNode;
     }
     finally
     {
         this.inLoad = false;
     }
 }
        public override void OnDragDrop(Glyph g, DragEventArgs e)
        {
            ToolStripItem dragItem = ToolStripDesigner.dragItem;

            if ((e.Data is ToolStripItemDataObject) && (dragItem != null))
            {
                ToolStripItemDataObject data             = (ToolStripItemDataObject)e.Data;
                ToolStripItem           primarySelection = data.PrimarySelection;
                IDesignerHost           host             = (IDesignerHost)dragItem.Site.GetService(typeof(IDesignerHost));
                if ((dragItem != primarySelection) && (host != null))
                {
                    string    str;
                    ArrayList dragComponents = data.DragComponents;
                    ToolStrip currentParent  = dragItem.GetCurrentParent();
                    int       index          = -1;
                    bool      flag           = e.Effect == DragDropEffects.Copy;
                    if (dragComponents.Count == 1)
                    {
                        string componentName = TypeDescriptor.GetComponentName(dragComponents[0]);
                        if ((componentName == null) || (componentName.Length == 0))
                        {
                            componentName = dragComponents[0].GetType().Name;
                        }
                        str = System.Design.SR.GetString(flag ? "BehaviorServiceCopyControl" : "BehaviorServiceMoveControl", new object[] { componentName });
                    }
                    else
                    {
                        str = System.Design.SR.GetString(flag ? "BehaviorServiceCopyControls" : "BehaviorServiceMoveControls", new object[] { dragComponents.Count });
                    }
                    DesignerTransaction transaction = host.CreateTransaction(str);
                    try
                    {
                        IComponentChangeService service = (IComponentChangeService)dragItem.Site.GetService(typeof(IComponentChangeService));
                        if (service != null)
                        {
                            ToolStripDropDown down = currentParent as ToolStripDropDown;
                            if (down != null)
                            {
                                ToolStripItem ownerItem = down.OwnerItem;
                                service.OnComponentChanging(ownerItem, TypeDescriptor.GetProperties(ownerItem)["DropDownItems"]);
                            }
                            else
                            {
                                service.OnComponentChanging(currentParent, TypeDescriptor.GetProperties(currentParent)["Items"]);
                            }
                        }
                        if (flag)
                        {
                            if (primarySelection != null)
                            {
                                index = dragComponents.IndexOf(primarySelection);
                            }
                            ToolStripKeyboardHandlingService keyBoardHandlingService = this.GetKeyBoardHandlingService(primarySelection);
                            if (keyBoardHandlingService != null)
                            {
                                keyBoardHandlingService.CopyInProgress = true;
                            }
                            dragComponents = DesignerUtils.CopyDragObjects(dragComponents, dragItem.Site) as ArrayList;
                            if (keyBoardHandlingService != null)
                            {
                                keyBoardHandlingService.CopyInProgress = false;
                            }
                            if (index != -1)
                            {
                                primarySelection = dragComponents[index] as ToolStripItem;
                            }
                        }
                        if ((e.Effect == DragDropEffects.Move) || flag)
                        {
                            ISelectionService selectionService = this.GetSelectionService(dragItem);
                            if (selectionService != null)
                            {
                                if (currentParent is ToolStripOverflow)
                                {
                                    currentParent = ((ToolStripOverflow)currentParent).OwnerItem.Owner;
                                }
                                int num2 = currentParent.Items.IndexOf(ToolStripDesigner.dragItem);
                                if (num2 != -1)
                                {
                                    int num3 = 0;
                                    if (primarySelection != null)
                                    {
                                        num3 = currentParent.Items.IndexOf(primarySelection);
                                    }
                                    if ((num3 != -1) && (num2 > num3))
                                    {
                                        num2--;
                                    }
                                    foreach (ToolStripItem item4 in dragComponents)
                                    {
                                        currentParent.Items.Insert(num2, item4);
                                    }
                                }
                                selectionService.SetSelectedComponents(new IComponent[] { primarySelection }, SelectionTypes.Click | SelectionTypes.Replace);
                            }
                        }
                        if (service != null)
                        {
                            ToolStripDropDown down2 = currentParent as ToolStripDropDown;
                            if (down2 != null)
                            {
                                ToolStripItem component = down2.OwnerItem;
                                service.OnComponentChanged(component, TypeDescriptor.GetProperties(component)["DropDownItems"], null, null);
                            }
                            else
                            {
                                service.OnComponentChanged(currentParent, TypeDescriptor.GetProperties(currentParent)["Items"], null, null);
                            }
                            if (flag)
                            {
                                if (down2 != null)
                                {
                                    ToolStripItem item6 = down2.OwnerItem;
                                    service.OnComponentChanging(item6, TypeDescriptor.GetProperties(item6)["DropDownItems"]);
                                    service.OnComponentChanged(item6, TypeDescriptor.GetProperties(item6)["DropDownItems"], null, null);
                                }
                                else
                                {
                                    service.OnComponentChanging(currentParent, TypeDescriptor.GetProperties(currentParent)["Items"]);
                                    service.OnComponentChanged(currentParent, TypeDescriptor.GetProperties(currentParent)["Items"], null, null);
                                }
                            }
                        }
                        foreach (ToolStripItem item7 in dragComponents)
                        {
                            if (item7 is ToolStripDropDownItem)
                            {
                                ToolStripMenuItemDesigner designer = host.GetDesigner(item7) as ToolStripMenuItemDesigner;
                                if (designer != null)
                                {
                                    designer.InitializeDropDown();
                                }
                            }
                            ToolStripDropDown down3 = item7.GetCurrentParent() as ToolStripDropDown;
                            if ((down3 != null) && !(down3 is ToolStripOverflow))
                            {
                                ToolStripDropDownItem item8 = down3.OwnerItem as ToolStripDropDownItem;
                                if (item8 != null)
                                {
                                    ToolStripMenuItemDesigner designer2 = host.GetDesigner(item8) as ToolStripMenuItemDesigner;
                                    if (designer2 != null)
                                    {
                                        designer2.InitializeBodyGlyphsForItems(false, item8);
                                        designer2.InitializeBodyGlyphsForItems(true, item8);
                                    }
                                }
                            }
                        }
                        BehaviorService behaviorService = this.GetBehaviorService(dragItem);
                        if (behaviorService != null)
                        {
                            behaviorService.SyncSelection();
                        }
                    }
                    catch (Exception exception)
                    {
                        if (transaction != null)
                        {
                            transaction.Cancel();
                            transaction = null;
                        }
                        if (System.Windows.Forms.ClientUtils.IsCriticalException(exception))
                        {
                            throw;
                        }
                    }
                    finally
                    {
                        if (transaction != null)
                        {
                            transaction.Commit();
                            transaction = null;
                        }
                    }
                }
            }
        }
        public TabOrder(IDesignerHost host)
        {
            this.host = host;
            IUIService service = (IUIService)host.GetService(typeof(IUIService));

            if (service != null)
            {
                this.tabFont = (Font)service.Styles["DialogFont"];
            }
            else
            {
                this.tabFont = Control.DefaultFont;
            }
            this.tabFont            = new Font(this.tabFont, FontStyle.Bold);
            this.selSize            = DesignerUtils.GetAdornmentDimensions(AdornmentType.GrabHandle).Width;
            this.drawString         = new StringBuilder(12);
            this.highlightTextBrush = new SolidBrush(SystemColors.HighlightText);
            this.highlightPen       = new Pen(SystemColors.Highlight);
            NumberFormatInfo format = (NumberFormatInfo)CultureInfo.CurrentCulture.GetFormat(typeof(NumberFormatInfo));

            if (format != null)
            {
                this.decimalSep = format.NumberDecimalSeparator;
            }
            else
            {
                this.decimalSep = ".";
            }
            this.tabProperties = new Hashtable();
            base.SetStyle(ControlStyles.Opaque, true);
            IOverlayService service2 = (IOverlayService)host.GetService(typeof(IOverlayService));

            if (service2 != null)
            {
                service2.PushOverlay(this);
            }
            IHelpService service3 = (IHelpService)host.GetService(typeof(IHelpService));

            if (service3 != null)
            {
                service3.AddContextAttribute("Keyword", "TabOrderView", HelpKeywordType.FilterKeyword);
            }
            this.commands    = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnKeyCancel), MenuCommands.KeyCancel), new MenuCommand(new EventHandler(this.OnKeyDefault), MenuCommands.KeyDefaultAction), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeyMoveUp), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeyMoveDown), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeyMoveLeft), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeyMoveRight), new MenuCommand(new EventHandler(this.OnKeyNext), MenuCommands.KeySelectNext), new MenuCommand(new EventHandler(this.OnKeyPrevious), MenuCommands.KeySelectPrevious) };
            this.newCommands = new MenuCommand[] { new MenuCommand(new EventHandler(this.OnKeyDefault), MenuCommands.KeyTabOrderSelect) };
            IMenuCommandService service4 = (IMenuCommandService)host.GetService(typeof(IMenuCommandService));

            if (service4 != null)
            {
                foreach (MenuCommand command in this.newCommands)
                {
                    service4.AddCommand(command);
                }
            }
            IEventHandlerService service5 = (IEventHandlerService)host.GetService(typeof(IEventHandlerService));

            if (service5 != null)
            {
                service5.PushHandler(this);
            }
            IComponentChangeService service6 = (IComponentChangeService)host.GetService(typeof(IComponentChangeService));

            if (service6 != null)
            {
                service6.ComponentAdded   += new ComponentEventHandler(this.OnComponentAddRemove);
                service6.ComponentRemoved += new ComponentEventHandler(this.OnComponentAddRemove);
                service6.ComponentChanged += new ComponentChangedEventHandler(this.OnComponentChanged);
            }
        }
예제 #19
0
        protected override void OnDragDrop(DragEventArgs de)
        {
            bool flag = false;

            if (((this.dragControls != null) && (this.primaryDragControl != null)) && this.Control.Controls.Contains(this.primaryDragControl))
            {
                flag = true;
            }
            if (!flag)
            {
                if (this.Control != null)
                {
                    this.Control.ControlAdded += new ControlEventHandler(this.OnChildControlAdded);
                }
                try
                {
                    base.OnDragDrop(de);
                }
                finally
                {
                    if (this.Control != null)
                    {
                        this.Control.ControlAdded -= new ControlEventHandler(this.OnChildControlAdded);
                    }
                }
            }
            else
            {
                IDesignerHost host = this.GetService(typeof(IDesignerHost)) as IDesignerHost;
                if (host != null)
                {
                    string str;
                    DesignerTransaction transaction = null;
                    bool              flag2         = de.Effect == DragDropEffects.Copy;
                    ArrayList         list          = null;
                    ISelectionService service       = null;
                    if (this.dragControls.Count == 1)
                    {
                        string componentName = TypeDescriptor.GetComponentName(this.dragControls[0]);
                        if ((componentName == null) || (componentName.Length == 0))
                        {
                            componentName = this.dragControls[0].GetType().Name;
                        }
                        str = System.Design.SR.GetString(flag2 ? "BehaviorServiceCopyControl" : "BehaviorServiceMoveControl", new object[] { componentName });
                    }
                    else
                    {
                        str = System.Design.SR.GetString(flag2 ? "BehaviorServiceCopyControls" : "BehaviorServiceMoveControls", new object[] { this.dragControls.Count });
                    }
                    transaction = host.CreateTransaction(str);
                    try
                    {
                        while ((this.insertIndex < (this.childInfo.Length - 1)) && this.childInfo[this.insertIndex].inSelectionColl)
                        {
                            this.insertIndex++;
                        }
                        IComponentChangeService      service2 = this.GetService(typeof(IComponentChangeService)) as IComponentChangeService;
                        PropertyDescriptor           member   = TypeDescriptor.GetProperties(this.Control)["Controls"];
                        System.Windows.Forms.Control child    = null;
                        if (this.insertIndex != this.childInfo.Length)
                        {
                            child = this.Control.Controls[this.insertIndex];
                        }
                        else
                        {
                            this.insertIndex = -1;
                        }
                        if ((service2 != null) && (member != null))
                        {
                            service2.OnComponentChanging(this.Control, member);
                        }
                        if (!flag2)
                        {
                            for (int j = 0; j < this.dragControls.Count; j++)
                            {
                                this.Control.Controls.Remove(this.dragControls[j] as System.Windows.Forms.Control);
                            }
                            if (child != null)
                            {
                                this.insertIndex = this.Control.Controls.GetChildIndex(child, false);
                            }
                        }
                        else
                        {
                            ArrayList objects = new ArrayList();
                            for (int k = 0; k < this.dragControls.Count; k++)
                            {
                                objects.Add(this.dragControls[k]);
                            }
                            objects = DesignerUtils.CopyDragObjects(objects, base.Component.Site) as ArrayList;
                            if (objects == null)
                            {
                                return;
                            }
                            list = new ArrayList();
                            for (int m = 0; m < objects.Count; m++)
                            {
                                list.Add(this.dragControls[m]);
                                if (this.primaryDragControl.Equals(this.dragControls[m] as System.Windows.Forms.Control))
                                {
                                    this.primaryDragControl = objects[m] as System.Windows.Forms.Control;
                                }
                                this.dragControls[m] = objects[m];
                            }
                            service = (ISelectionService)this.GetService(typeof(ISelectionService));
                        }
                        if (this.insertIndex == -1)
                        {
                            this.insertIndex = this.Control.Controls.Count;
                        }
                        this.Control.Controls.Add(this.primaryDragControl);
                        this.Control.Controls.SetChildIndex(this.primaryDragControl, this.insertIndex);
                        this.insertIndex++;
                        if (service != null)
                        {
                            service.SetSelectedComponents(new object[] { this.primaryDragControl }, SelectionTypes.Click | SelectionTypes.Replace);
                        }
                        for (int i = this.dragControls.Count - 1; i >= 0; i--)
                        {
                            if (!this.primaryDragControl.Equals(this.dragControls[i] as System.Windows.Forms.Control))
                            {
                                this.Control.Controls.Add(this.dragControls[i] as System.Windows.Forms.Control);
                                this.Control.Controls.SetChildIndex(this.dragControls[i] as System.Windows.Forms.Control, this.insertIndex);
                                this.insertIndex++;
                                if (service != null)
                                {
                                    service.SetSelectedComponents(new object[] { this.dragControls[i] }, SelectionTypes.Add);
                                }
                            }
                        }
                        if ((service2 != null) && (member != null))
                        {
                            service2.OnComponentChanged(this.Control, member, null, null);
                        }
                        if (list != null)
                        {
                            for (int n = 0; n < list.Count; n++)
                            {
                                this.dragControls[n] = list[n];
                            }
                        }
                        base.OnDragComplete(de);
                        if (transaction != null)
                        {
                            transaction.Commit();
                            transaction = null;
                        }
                    }
                    finally
                    {
                        if (transaction != null)
                        {
                            transaction.Cancel();
                        }
                    }
                }
            }
            this.insertIndex = InvalidIndex;
        }
예제 #20
0
 private void OnOkButtonClick(object sender, EventArgs e)
 {
     if (this.isDialogDirty)
     {
         if (this.absoluteRadioButton.Checked)
         {
             this.UpdateTypeAndValue(SizeType.Absolute, (float)this.absoluteNumericUpDown.Value);
         }
         else if (this.percentRadioButton.Checked)
         {
             this.UpdateTypeAndValue(SizeType.Percent, (float)this.percentNumericUpDown.Value);
         }
         else if (this.autoSizedRadioButton.Checked)
         {
             this.UpdateTypeAndValue(SizeType.AutoSize, 0f);
         }
         this.NormalizePercentStyles();
         if (this.deleteList.Count > 0)
         {
             PropertyDescriptor member = TypeDescriptor.GetProperties(this.tlp)["Controls"];
             if ((this.compSvc != null) && (member != null))
             {
                 this.compSvc.OnComponentChanging(this.tlp, member);
             }
             IDesignerHost service = this.tlp.Site.GetService(typeof(IDesignerHost)) as IDesignerHost;
             if (service != null)
             {
                 foreach (object obj2 in this.deleteList)
                 {
                     ArrayList list = new ArrayList();
                     DesignerUtils.GetAssociatedComponents((IComponent)obj2, service, list);
                     foreach (IComponent component in list)
                     {
                         this.compSvc.OnComponentChanging(component, null);
                     }
                     service.DestroyComponent(obj2 as Component);
                 }
             }
             if ((this.compSvc != null) && (member != null))
             {
                 this.compSvc.OnComponentChanged(this.tlp, member, null, null);
             }
         }
         if (this.compSvc != null)
         {
             if (this.rowStyleProp != null)
             {
                 this.compSvc.OnComponentChanged(this.tlp, this.rowStyleProp, null, null);
             }
             if (this.colStyleProp != null)
             {
                 this.compSvc.OnComponentChanged(this.tlp, this.colStyleProp, null, null);
             }
         }
         base.DialogResult = DialogResult.OK;
     }
     else
     {
         base.DialogResult = DialogResult.Cancel;
     }
     this.tlpDesigner.ResumeEnsureAvailableStyles(true);
     this.tlp.ResumeLayout();
 }