コード例 #1
0
        // 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
ファイル: LapiImageComboBox.cs プロジェクト: GodLesZ/svn-dump
		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
ファイル: BlockCombo.cs プロジェクト: BCProgramming/BASeBlock
        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
ファイル: LapiComboBox.cs プロジェクト: GodLesZ/svn-dump
		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