Exemplo n.º 1
0
 /// <summary>
 /// Raises the GalleryDropMenu event.
 /// </summary>
 /// <param name="e">An GalleryDropMenuEventArgs containing the event data.</param>
 protected virtual void OnGalleryDropMenu(GalleryDropMenuEventArgs e)
 {
     if (GalleryDropMenu != null)
     {
         GalleryDropMenu(this, e);
     }
 }
Exemplo n.º 2
0
        internal void ShownGalleryDropDown(Rectangle screenRect,
                                           KryptonContextMenuPositionH hPosition,
                                           KryptonContextMenuPositionV vPosition,
                                           EventHandler finishDelegate,
                                           int actualLineItems)
        {
            // First time around create the context menu, otherwise just clear it down
            if (_dropMenu == null)
            {
                _dropMenu = new KryptonContextMenu();
            }

            // Number of line items equals the number actually used
            int lineItems = Math.Max(DropMinItemWidth, Math.Min(DropMaxItemWidth, actualLineItems));

            // If there are no ranges defined, just add a single entry showing all enties
            if (_dropButtonRanges.Count == 0)
            {
                KryptonContextMenuImageSelect imageSelect = new KryptonContextMenuImageSelect();
                imageSelect.ImageList       = ImageList;
                imageSelect.ImageIndexStart = 0;
                imageSelect.ImageIndexEnd   = (ImageList == null ? 0 : ImageList.Images.Count - 1);
                imageSelect.SelectedIndex   = SelectedIndex;
                imageSelect.LineItems       = lineItems;
                _dropMenu.Items.Add(imageSelect);
            }
            else
            {
                foreach (KryptonGalleryRange range in _dropButtonRanges)
                {
                    // If not the first item in the menu, add a separator
                    if (_dropMenu.Items.Count > 0)
                    {
                        _dropMenu.Items.Add(new KryptonContextMenuSeparator());
                    }

                    // Only add a heading if the heading text is not empty
                    if (!string.IsNullOrEmpty(range.Heading))
                    {
                        KryptonContextMenuHeading heading = new KryptonContextMenuHeading();
                        heading.Text = range.Heading;
                        _dropMenu.Items.Add(heading);
                    }

                    // Add the image select for the range
                    KryptonContextMenuImageSelect imageSelect = new KryptonContextMenuImageSelect();
                    imageSelect.ImageList       = ImageList;
                    imageSelect.ImageIndexStart = Math.Max(0, range.ImageIndexStart);
                    imageSelect.ImageIndexEnd   = Math.Min(range.ImageIndexEnd, (ImageList == null ? 0 : ImageList.Images.Count - 1));
                    imageSelect.SelectedIndex   = SelectedIndex;
                    imageSelect.LineItems       = lineItems;
                    _dropMenu.Items.Add(imageSelect);
                }
            }

            // Give event handler a change to modify the menu
            GalleryDropMenuEventArgs args = new GalleryDropMenuEventArgs(_dropMenu);

            OnGalleryDropMenu(args);

            if (!args.Cancel && CommonHelper.ValidKryptonContextMenu(args.KryptonContextMenu))
            {
                // Hook into relevant events of the image select areas
                foreach (KryptonContextMenuItemBase item in _dropMenu.Items)
                {
                    if (item is KryptonContextMenuImageSelect)
                    {
                        KryptonContextMenuImageSelect itemSelect = (KryptonContextMenuImageSelect)item;
                        itemSelect.SelectedIndexChanged += new EventHandler(OnDropImageSelect);
                        itemSelect.TrackingImage        += new EventHandler <ImageSelectEventArgs>(OnDropImageTracking);
                    }
                }

                // Need to know when the menu is dismissed
                args.KryptonContextMenu.Closed += new ToolStripDropDownClosedEventHandler(OnDropMenuClosed);

                // Remember the delegate we need to fire when the menu is dismissed
                _finishDelegate = finishDelegate;

                // Show the menu to the user
                args.KryptonContextMenu.Show(this, screenRect, hPosition, vPosition);
            }
            else
            {
                // Nothing to show, but still need to call the finished delegate?
                if (finishDelegate != null)
                {
                    finishDelegate(this, EventArgs.Empty);
                }
            }
        }
Exemplo n.º 3
0
 private void OnGalleryGalleryDropMenu(object sender, GalleryDropMenuEventArgs e)
 {
     OnGalleryDropMenu(e);
 }