Esempio n. 1
0
        public void OnItemClicked(object sender, ImageListPanelEventArgs e)
        {
            m_selectedIndex = ((ImageListPanelEventArgs)e).SelectedItem;

            //remove listner
            m_imagePanel.ItemClick -= new ImageListPanelEventHandler(OnItemClicked);

            // close the drop-dwon, we are done
            wfes.CloseDropDown();

            m_imagePanel.Dispose();
            m_imagePanel = null;
        }
Esempio n. 2
0
        public override object EditValue(System.ComponentModel.ITypeDescriptorContext context, IServiceProvider provider, object value)
        {
            wfes = (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService));
            if ((wfes == null) || (context == null))
            {
                return(null);
            }

            ImageList imageList = GetImageList(context.Instance);

            if ((imageList == null) || (imageList.Images.Count == 0))
            {
                return(-1);
            }

            m_imagePanel = new ImageListPanel();

            m_imagePanel.BackgroundColor     = Color.FromArgb(241, 241, 241);
            m_imagePanel.BackgroundOverColor = Color.FromArgb(102, 154, 204);
            m_imagePanel.HLinesColor         = Color.FromArgb(182, 189, 210);
            m_imagePanel.VLinesColor         = Color.FromArgb(182, 189, 210);
            m_imagePanel.BorderColor         = Color.FromArgb(0, 0, 0);
            m_imagePanel.EnableDragDrop      = true;
            m_imagePanel.Init(imageList, 12, 12, 6, (int)value);

            // add listner for event
            m_imagePanel.ItemClick += new ImageListPanelEventHandler(OnItemClicked);

            // set m_selectedIndex to -1 in case the dropdown is closed without selection
            m_selectedIndex = -1;
            // show the popup as a drop-down
            wfes.DropDownControl(m_imagePanel);

            // return the selection (or the original value if none selected)
            return((m_selectedIndex != -1) ? m_selectedIndex : (int)value);
        }