Event arguments for the drop down menu of a gallery.
Inheritance: CancelEventArgs
Beispiel #1
0
        private void galleryCustom_GalleryDropMenu(object sender, GalleryDropMenuEventArgs e)
        {
            KryptonContextMenuHeading h = new KryptonContextMenuHeading();
            h.Text = "Customize Drop Menu";

            KryptonContextMenuItems items1 = new KryptonContextMenuItems();
            KryptonContextMenuItem item1 = new KryptonContextMenuItem();
            item1.Text = "Custom Entry 1";
            KryptonContextMenuItem item2 = new KryptonContextMenuItem();
            item2.Text = "Custom Entry 2";
            item2.Checked = true;
            items1.Items.Add(item1);
            items1.Items.Add(item2);

            KryptonContextMenuItems items2 = new KryptonContextMenuItems();
            KryptonContextMenuItem item3 = new KryptonContextMenuItem();
            item3.Text = "Custom Entry 3";
            KryptonContextMenuItem item4 = new KryptonContextMenuItem();
            item4.Text = "Custom Entry 4";
            item4.CheckState = CheckState.Indeterminate;
            items2.Items.Add(item3);
            items2.Items.Add(item4);

            e.KryptonContextMenu.Items.Insert(0, new KryptonContextMenuSeparator());
            e.KryptonContextMenu.Items.Insert(0, items1);
            e.KryptonContextMenu.Items.Insert(0, h);
            e.KryptonContextMenu.Items.Add(new KryptonContextMenuSeparator());
            e.KryptonContextMenu.Items.Add(items2);
        }
 /// <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);
     }
 }
 private void OnGalleryGalleryDropMenu(object sender, GalleryDropMenuEventArgs e)
 {
     OnGalleryDropMenu(e);
 }
Beispiel #4
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?
                finishDelegate?.Invoke(this, EventArgs.Empty);
            }
        }
Beispiel #5
0
 /// <summary>
 /// Raises the GalleryDropMenu event.
 /// </summary>
 /// <param name="e">An GalleryDropMenuEventArgs containing the event data.</param>
 protected virtual void OnGalleryDropMenu(GalleryDropMenuEventArgs e)
 {
     GalleryDropMenu?.Invoke(this, e);
 }
 private void OnGalleryGalleryDropMenu(object sender, GalleryDropMenuEventArgs e)
 {
     OnGalleryDropMenu(e);
 }
 /// <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);
 }
Beispiel #8
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);
            }
        }