// customized drawing process
        protected override void OnDrawItem(DrawItemEventArgs e)
        {
            try
            {
                // draw background & focus rect
                e.DrawBackground();
                e.DrawFocusRectangle();

                // check if it is an item from the Items collection
                if (e.Index < 0)
                {
                    // not an item, draw the text (indented)
                    e.Graphics.DrawString(this.Text, e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left + imgs.ImageSize.Width, e.Bounds.Top);
                }

                else
                {
                    // check if item is an ImageComboItem
                    if (this.Items[e.Index].GetType() == typeof(ImageComboItem))
                    {
                        // get item to draw
                        ImageComboItem item = (ImageComboItem)this.Items[e.Index];

                        // get forecolor & font
                        Color forecolor = (item.ForeColor != Color.FromKnownColor(KnownColor.Transparent)) ? item.ForeColor : e.ForeColor;
                        Font  font      = item.Mark ? new Font(e.Font, FontStyle.Bold) : e.Font;

                        // -1: no image
                        if (item.ImageIndex != -1)
                        {
                            // draw image, then draw text next to it
                            this.ImageList.Draw(e.Graphics, e.Bounds.Left, e.Bounds.Top, item.ImageIndex);
                            e.Graphics.DrawString(item.Text, font, new SolidBrush(forecolor), e.Bounds.Left + imgs.ImageSize.Width, e.Bounds.Top);
                        }
                        else
                        {
                            // draw text (indented)
                            e.Graphics.DrawString(item.Text, font, new SolidBrush(forecolor), e.Bounds.Left + imgs.ImageSize.Width, e.Bounds.Top);
                        }
                    }
                    else
                    {
                        // it is not an ImageComboItem, draw it
                        e.Graphics.DrawString(this.Items[e.Index].ToString(), e.Font, new SolidBrush(e.ForeColor), e.Bounds.Left + imgs.ImageSize.Width, e.Bounds.Top);
                    }
                }

                base.OnDrawItem(e);
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
예제 #2
0
		public LapiImageComboBox()
			: base() {

			if( Lapis == null ) {
				Lapis = new LapiCollection();
				BuildLapiList();
			}

			// empty_slot
			Items.Add( new ImageComboItem( "", Font, System.Drawing.Color.Black, 0, EImageComboItemTextAlign.Right ) );
			// fill Combolist with Lapi Images
			foreach( Lapi lapi in Lapis ) {
				ImageComboItem i = new ImageComboItem( "", Font, System.Drawing.Color.Black, lapi.ToImageIndex() + 1, EImageComboItemTextAlign.Right );
				i.Tag = lapi;
				Items.Add( i );
			}
		}
예제 #3
0
        public void RePopulate()
        {
            System.Windows.Forms.ImageList createlist = new ImageList();
            this.ImageList=createlist;
            blockdatacache=new Dictionary<ImageComboItem, BlockData>();

            foreach (BlockData loopdata in BCBlockGameState.BlockDataMan.BlockInfo)
            {
                createlist.Images.Add(loopdata.BlockType.Name, loopdata.useBlockImage);
                //add the item itself.
                ImageComboItem createditem = new ImageComboItem(loopdata.Usename, createlist.Images.IndexOfKey(loopdata.BlockType.Name));
                blockdatacache.Add(createditem,loopdata);
                createditem.Tag = loopdata;
                int addedindex=this.Items.Add(createditem);

            }
        }
예제 #4
0
		public LapiComboBox()
			: base() {

			if( Lapis == null ) {
				Lapis = new LapiCollection();
				BuildLapiList();
			}

			//Items.Add( new ImageComboItem( "freier Sockel", Font, System.Drawing.Color.Black, 0, EImageComboItemTextAlign.Right ) );
			// fill Combolist with Lapis
			foreach( Lapi lapi in Lapis ) {
				ImageComboItem i = new ImageComboItem( lapi.ToName(), Font, System.Drawing.Color.Black, lapi.ToImageIndex() + 1, EImageComboItemTextAlign.Right );
				i.Tag = lapi;
				Items.Add( i );
			}

			SelectedIndexChanged += new EventHandler( LapiComboBox_SelectedIndexChanged );
		}
예제 #5
0
        private void LoadLanguageDirectory(string path)
        {
            int i;
            cbLanguage.Items.Clear();

            if (!Directory.Exists(path)) return;

            string[] langFiles = Directory.GetFiles(path, "*.resources");
            if (langFiles.Length <= 0)
                return;

            for (i = 0; i < langFiles.Length; i++)
            {
                FileInfo finfo = new FileInfo(langFiles[i]);
                string args = finfo.Name.Replace(finfo.Extension, "");
                args = args.Replace("lang.", "");

                string locale_name = (string)locales[args];
                LocaleItem itm = new LocaleItem(locale_name, args);
                ImageComboItem cbitm = new ImageComboItem(itm.LocaleName, LocaleImageIndex(args));
                cbitm.Tag = itm;
                int pos = cbLanguage.Items.Add(cbitm);

            }

            for (i = 0; i < cbLanguage.Items.Count; i++)
            {
                ImageComboItem itm =(ImageComboItem)cbLanguage.Items[i];
                LocaleItem litm = (LocaleItem)itm.Tag;
                if ( litm.LocaleValue == optset.Language)
                {
                    cbLanguage.SelectedIndex = i;
                    startupLanguageIdx = i;
                    break;
                }

            }
        }
예제 #6
0
파일: func.cs 프로젝트: maysam/ParsLogPlot
     Return GetType(ImageComboItem)
 End Function