Exemple #1
0
        public int ComboBoxAddItem(ImageComboBoxItem item)
        {
            item.Text = (item.Text.Length == 0)?item.GetType().Name + base.Items.Count.ToString():item.Text;
            base.Items.Add(item);

            return(base.Items.Count - 1);
        }
Exemple #2
0
        /// <summary>
        /// Helper method for drawing items .
        /// </summary>
        /// <param name="e"></param>
        private void DrawItemHelperForItems(DrawItemEventArgs e)
        {
            e.DrawFocusRectangle();
            e.DrawBackground();

            ImageComboBoxItem item = (ImageComboBoxItem)this.Items [e.Index];

            if (item.Font == null)
            {
                item.Font = this.Font;
            }

            StringFormat format = new StringFormat();

            //format.FormatFlags = StringFormatFlags.NoWrap;
            format.FormatFlags = StringFormatFlags.NoClip;
            int indent = (item.IndentLevel * this.Indent);

            if (item.ImageIndex != -1)
            {
                Image  theIcon     = this.ImageList.Images [item.ImageIndex];
                Bitmap ImageToDraw = new Bitmap(theIcon, e.Bounds.Height - 1, e.Bounds.Height - 1);
                int    IconHeight  = ImageToDraw.Height;
                int    IconWidth   = ImageToDraw.Width;
                int    offset      = 1;
                if (this.RightToLeft == RightToLeft.Yes)
                {
                    ImageToDraw.RotateFlip(RotateFlipType.RotateNoneFlipX);
                    format.Alignment = StringAlignment.Far;
                    RectangleF itemRect = new RectangleF((float)(e.Bounds.X - offset), (float)(e.Bounds.Y), (float)(e.Bounds.Width - IconWidth - indent - offset), (float)(e.Bounds.Height));
                    e.Graphics.DrawString(item.Text, item.Font, new SolidBrush(e.ForeColor), itemRect, format);
                    Rectangle imageRect = new Rectangle(e.Bounds.X + offset + (e.Bounds.Width - (IconWidth + indent)), e.Bounds.Y, IconWidth, IconHeight);
                    e.Graphics.DrawImage(ImageToDraw, imageRect);
                }
                else
                {
                    format.Alignment = StringAlignment.Near;
                    RectangleF itemRect = new RectangleF((float)(e.Bounds.X + IconWidth + indent + offset), (float)(e.Bounds.Y), (float)(e.Bounds.Width - IconWidth - indent - offset), (float)(e.Bounds.Height));
                    e.Graphics.DrawString(item.Text, item.Font, new SolidBrush(e.ForeColor), itemRect, format);
                    Rectangle imageRect = new Rectangle(e.Bounds.X + offset + indent, e.Bounds.Y, IconWidth, IconHeight);
                    e.Graphics.DrawImage(ImageToDraw, imageRect);
                }
            }
            else
            {
                if (this.RightToLeft == RightToLeft.Yes)
                {
                    format.Alignment = StringAlignment.Far;
                    e.Graphics.DrawString(item.Text, item.Font, new SolidBrush(e.ForeColor), new RectangleF((float)e.Bounds.X, (float)e.Bounds.Y, (float)(e.Bounds.Width - indent), (float)e.Bounds.Height), format);
                }
                else
                {
                    format.Alignment = StringAlignment.Near;
                    e.Graphics.DrawString(item.Text, item.Font, new SolidBrush(e.ForeColor), new RectangleF((float)(e.Bounds.X + indent), (float)e.Bounds.Y, (float)e.Bounds.Width, (float)e.Bounds.Height), format);
                }
            }
        }
 public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(System.ComponentModel.Design.Serialization.InstanceDescriptor))
     {
         Type              valueType = value.GetType();
         ConstructorInfo   ci        = valueType.GetConstructor(System.Type.EmptyTypes);
         ImageComboBoxItem item      = (ImageComboBoxItem)value;
         return(new InstanceDescriptor(ci, null, false));
     }
     else
     {
         return(base.ConvertTo(context, culture, value, destinationType));
     }
 }
Exemple #4
0
		public bool ComboBoxContains(ImageComboBoxItem item)
		{
			return base.Items.Contains (item);
		}
		public void AddRange(ImageComboBoxItem[] items)
		{
			for(IEnumerator e = items.GetEnumerator(); e.MoveNext();)
				owner.ComboBoxInsertItem(this.Count, (ImageComboBoxItem)e.Current);
		}
		public int Add(ImageComboBoxItem item)
		{
			return owner.ComboBoxInsertItem(this.Count, item);
		}
		public void Insert(int index, ImageComboBoxItem item)
		{
			owner.ComboBoxInsertItem(index, item);
		}
		public void Remove(ImageComboBoxItem item)
		{
			throw new NotSupportedException();
		}
Exemple #9
0
 public bool ComboBoxContains(ImageComboBoxItem item)
 {
     return(base.Items.Contains(item));
 }
Exemple #10
0
		public void ComboBoxRemoveItem(ImageComboBoxItem item)
		{
			base.Items.Remove (item);
		}
 public int Add(ImageComboBoxItem item)
 {
     return(owner.ComboBoxInsertItem(this.Count, item));
 }
 public void Insert(int index, ImageComboBoxItem item)
 {
     owner.ComboBoxInsertItem(index, item);
 }
 public void Remove(ImageComboBoxItem item)
 {
     throw new NotSupportedException();
 }
Exemple #14
0
 public void ComboBoxRemoveItem(ImageComboBoxItem item)
 {
     base.Items.Remove(item);
 }
Exemple #15
0
 public int ComboBoxInsertItem(int index, ImageComboBoxItem item)
 {
     item.Text = (item.Text.Length == 0)?item.GetType().Name + index.ToString():item.Text;
     base.Items.Insert(index, item);
     return(index);
 }
Exemple #16
0
		public int ComboBoxInsertItem(int index, ImageComboBoxItem item)
		{
			item.Text = (item.Text.Length == 0)?item.GetType ().Name+index.ToString ():item.Text;
			base.Items.Insert(index, item);
			return index;
		}
Exemple #17
0
		public int ComboBoxAddItem(ImageComboBoxItem item)
		{
			item.Text = (item.Text.Length == 0)?item.GetType ().Name+base.Items.Count.ToString ():item.Text;
			base.Items.Add (item);
		
			return base.Items.Count-1;
		}
        int IList.Add(object item)
        {
            ImageComboBoxItem comboItem = (ImageComboBoxItem)item;

            return(this.Add(comboItem));
        }
        private void UpdateAccountsCombobox()
        {
            m_cbAccounts.BeginUpdate();

            ImageComboBoxItem item;
            StorageDescriptor descriptor = null;

            foreach (var account in m_configService.Accounts.OrderBy(_ => _.Type).ThenBy(_ => _.Name))
            {
                if (descriptor == null || (account.Type != descriptor.Type))
                {
                    descriptor = StorageRegistry.Descriptors.Single(_ => _.Type == account.Type);

                    item = new ImageComboBoxItem()
                    {
                        Text = descriptor.FriendlyName,
                        ImageIndex = m_ilProviderIcons.Images.IndexOfKey(descriptor.Type.ToString()),
                        IndentLevel = 0,
                        Font = new Font(FontFamily.GenericSansSerif, 9, FontStyle.Bold),
                    };

                    m_cbAccounts.Items.Add(item);
                }

                item = new ImageComboBoxItem()
                {
                    Text = account.Name,
                    ImageIndex = m_ilProviderIcons.Images.IndexOfKey(account.Type.ToString()),
                    Item = account,
                    IndentLevel = 1,
                };

                m_cbAccounts.Items.Add(item);
            };

            m_cbAccounts.EndUpdate();
        }
        void IList.Insert(int index, object item)
        {
            ImageComboBoxItem comboItem = (ImageComboBoxItem)item;

            this.Insert(index, comboItem);
        }