當前位置: 首頁>>代碼示例>>C#>>正文


C# ImageList.Draw方法代碼示例

本文整理匯總了C#中System.Windows.Forms.ImageList.Draw方法的典型用法代碼示例。如果您正苦於以下問題:C# ImageList.Draw方法的具體用法?C# ImageList.Draw怎麽用?C# ImageList.Draw使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Windows.Forms.ImageList的用法示例。


在下文中一共展示了ImageList.Draw方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: PaintImageCell

        /// <summary>
        /// Repaint an image cell with an image in an image
        /// list. Run this method in the CellPainting event
        /// of the DataGridView.
        /// 
        /// This method ignores invalid parameters. Provide
        /// it with empty or invalid indices to cause it to
        /// abort.
        /// </summary>
        public static void PaintImageCell(this DataGridView dataGridView, DataGridViewCellPaintingEventArgs e, ImageList imageList, String imageKey)
        {
            //Abort if any parameter is null or if the image does not exist
            if (e == null || imageList == null || imageKey.IsNullOrEmpty())
                return;
            if (!imageList.Images.ContainsKey(imageKey))
                return;

            //Paint the image
            e.PaintBackground(e.ClipBounds, false);
            var pt = e.CellBounds.Location;
            pt.X += (e.CellBounds.Width - imageList.ImageSize.Width) / 2;
            pt.Y += 4;
            imageList.Draw(e.Graphics, pt, imageList.Images.IndexOfKey(imageKey));
            e.Handled = true;
        }
開發者ID:xlongtang,項目名稱:nextra,代碼行數:25,代碼來源:DataGridView_Extensions.cs

示例2: button1_Click

        private void button1_Click(object sender, EventArgs e)
        {
            // Construct the ImageList.
            ImageList1 = new ImageList();

            // Set the ImageSize property to a larger size
            // (the default is 16 x 16).
            ImageList1.ImageSize = new Size(112, 112);

            // Add two images to the list.

            ImageList1.Images.Add(
                Image.FromFile("d:\\smile\\1.jpg"));
            ImageList1.Images.Add(
                Image.FromFile("d:\\smile\\2.jpg"));

            ImageList1.Images.Add(
                Image.FromFile("d:\\smile\\3.jpg"));

            ImageList1.Images.Add(
                Image.FromFile("d:\\smile\\4.jpg"));

            // Get a Graphics object from the form's handle.
            Graphics theGraphics = Graphics.FromHwnd(this.Handle);

            // Loop through the images in the list, drawing each image.
            for (int count = 0; count < ImageList1.Images.Count; count++)
            {
                ImageList1.Draw(theGraphics, new Point(count*55+85, 85), count);

                // Call Application.DoEvents to force a repaint of the form.
                Application.DoEvents();

                // Call the Sleep method to allow the user to see the image.
                System.Threading.Thread.Sleep(1000);
            }
        }
開發者ID:tranquangchau,項目名稱:cshap-2008-2013,代碼行數:37,代碼來源:Form1.cs

示例3: Init

        public bool Init(ImageList imageList, int nHSpace, int nVSpace, int nColumns, int nRows)
        {
            _imageList = imageList;
            _nColumns = nColumns;
            _nRows = nRows;
            _nHSpace = nHSpace;
            _nVSpace = nVSpace;
            _nItemWidth = _imageList.ImageSize.Width + nHSpace;
            _nItemHeight = _imageList.ImageSize.Height + nVSpace;
            _nBitmapWidth = _nColumns * _nItemWidth + 1;
            _nBitmapHeight = _nRows * _nItemHeight + 1;
            this.Width = _nBitmapWidth;
            this.Height = _nBitmapHeight;


            _Bitmap = new Bitmap(_nBitmapWidth, _nBitmapHeight);
            Graphics grfx = Graphics.FromImage(_Bitmap);
            grfx.FillRectangle(new SolidBrush(BackgroundColor), 0, 0, _nBitmapWidth, _nBitmapHeight);
            for (int i = 0; i < _nColumns; i++)
                grfx.DrawLine(new Pen(VLinesColor), i * _nItemWidth, 0, i * _nItemWidth, _nBitmapHeight - 1);
            for (int i = 0; i < _nRows; i++)
                grfx.DrawLine(new Pen(HLinesColor), 0, i * _nItemHeight, _nBitmapWidth - 1, i * _nItemHeight);

            grfx.DrawRectangle(new Pen(BorderColor), 0, 0, _nBitmapWidth - 1, _nBitmapHeight - 1);

            for (int i = 0; i < _nColumns; i++)
                for (int j = 0; j < _nRows; j++)
                    if ((j * _nColumns + i) < imageList.Images.Count)
                        imageList.Draw(grfx,
                                        i * _nItemWidth + _nHSpace / 2,
                                        j * _nItemHeight + nVSpace / 2,
                                        imageList.ImageSize.Width,
                                        imageList.ImageSize.Height,
                                        j * _nColumns + i);

            return true;
        }
開發者ID:bclark00,項目名稱:superputty,代碼行數:37,代碼來源:ImageListPopup.cs

示例4: Paint

        public void Paint( Graphics g, Rectangle r, ImageList list, Color bg )
        {
            if( style == FlatButtonType.Control ) {
                return;
            }

            if( style == FlatButtonType.Line )
                g.DrawLine( Pens.DarkGray, r.X + 2, r.Top, r.X + 2, r.Bottom - 1 );
            else {

                if( style == FlatButtonType.RadioDown ) {
                    g.FillRectangle( Brushes.Lavender, r.X, r.Y, r.Width - 1, r.Height - 1 );
                    bg = Color.Lavender;
                } else if( state != FlatButtonState.Basic ) {
                    g.FillRectangle( state == FlatButtonState.Hover ? Brushes.LightSteelBlue : Brushes.SteelBlue, r.X, r.Y, r.Width - 1, r.Height - 1 );
                    bg = state == FlatButtonState.Hover ? Color.LightSteelBlue : Color.SteelBlue;
                }

                if( style == FlatButtonType.RadioDown || state != FlatButtonState.Basic )
                    g.DrawRectangle( Pens.DarkBlue, r.Left, r.Top, r.Width - 1, r.Height - 1 );

                int hover = state == FlatButtonState.Hover ? 1 : 0;
                if( disabled )
                    ControlPaint.DrawImageDisabled( g, list.Images[image_index], r.X + 3 - hover, r.Y + 3 - hover, bg );
                else
                    list.Draw( g, r.X + 3 - hover, r.Y + 3 - hover, 16, 16, image_index );
            }
        }
開發者ID:inspirer,項目名稱:uml-designer,代碼行數:28,代碼來源:FlatToolBar.cs

示例5: CreateIcon

        Image CreateIcon(ImageList imgList, int index)
        {
            Bitmap bmp = new Bitmap(16, 16, System.Drawing.Imaging.PixelFormat.Format32bppRgb);
            using (Graphics g = Graphics.FromImage(bmp))
            using( SolidBrush sb = new SolidBrush(BackColor))
            {
                g.FillRectangle(sb, 0, 0, 16, 16);
                imgList.Draw(g, 0, 0, 16, 16, index);
            }

            return bmp;
        }
開發者ID:necora,項目名稱:ank_git,代碼行數:12,代碼來源:CheckoutProject.cs

示例6: Init

        public bool Init(ImageList imageList, int nHSpace, int nVSpace, int nColumns, int defaultImage)
        {
            int nRows;

            Brush bgBrush = new SolidBrush(BackgroundColor);
            var vPen = new Pen(VLinesColor);
            var hPen = new Pen(HLinesColor);
            var borderPen = new Pen(BorderColor);

            _imageList = imageList;
            _nColumns = nColumns;

            _defaultImage = defaultImage;
            if (_defaultImage > _imageList.Images.Count)
                _defaultImage = _imageList.Images.Count;
            if (_defaultImage < 0) _defaultImage = -1;


            nRows = imageList.Images.Count/_nColumns;
            if (imageList.Images.Count%_nColumns > 0) nRows++;

            _nRows = nRows;
            _nHSpace = nHSpace;
            _nVSpace = nVSpace;
            _nItemWidth = _imageList.ImageSize.Width + nHSpace;
            _nItemHeight = _imageList.ImageSize.Height + nVSpace;
            _nBitmapWidth = _nColumns*_nItemWidth + 1;
            _nBitmapHeight = _nRows*_nItemHeight + 1;
            Width = _nBitmapWidth;
            Height = _nBitmapHeight;


            _Bitmap = new Bitmap(_nBitmapWidth, _nBitmapHeight);
            Graphics grfx = Graphics.FromImage(_Bitmap);
            grfx.FillRectangle(bgBrush, 0, 0, _nBitmapWidth, _nBitmapHeight);
            for (int i = 0; i < _nColumns; i++)
                grfx.DrawLine(vPen, i*_nItemWidth, 0, i*_nItemWidth, _nBitmapHeight - 1);
            for (int i = 0; i < _nRows; i++)
                grfx.DrawLine(hPen, 0, i*_nItemHeight, _nBitmapWidth - 1, i*_nItemHeight);

            grfx.DrawRectangle(borderPen, 0, 0, _nBitmapWidth - 1, _nBitmapHeight - 1);

            for (int i = 0; i < _nColumns; i++)
                for (int j = 0; j < _nRows; j++)
                {
                    if ((j*_nColumns + i) < imageList.Images.Count)
                        imageList.Draw(grfx,
                                       i*_nItemWidth + _nHSpace/2,
                                       j*_nItemHeight + nVSpace/2,
                                       imageList.ImageSize.Width,
                                       imageList.ImageSize.Height,
                                       j*_nColumns + i);
                }

            /*	int a = (_defaultImage / _nColumns);  // rad
			int b = (_defaultImage % _nColumns); // kolumn;

			_nCoordX = b*(_nItemWidth+_nHSpace/2)-1;
			_nCoordY = a*(_nItemHeight+nVSpace/2)-1;
		*/

            // Clean up
            bgBrush.Dispose();
            vPen.Dispose();
            hPen.Dispose();
            borderPen.Dispose();

            Invalidate();
            return true;
        }
開發者ID:filmee24,項目名稱:Paint,代碼行數:70,代碼來源:ImageListPanel.cs

示例7: RecreateHandleEvenTest

			public void RecreateHandleEvenTest ()
			{
				Form myform = new Form ();
				myform.ShowInTaskbar = false;
				Graphics mygraphics = null;
				ImageList myimagelist = new ImageList ();
				Image myImage =	Image.FromFile("M.gif");
				myimagelist.Images.Add (myImage);
				myimagelist.ColorDepth = ColorDepth.Depth8Bit;
				myimagelist.ImageSize = new Size (50,50);
				myimagelist.RecreateHandle += new EventHandler (RecreateHandle_EventHandler);
				mygraphics = Graphics.FromHwnd(myform.Handle);
				myimagelist.Draw(mygraphics, new Point(5, 5), 0);
				myimagelist.ImageSize = new Size (100,100);
				Assert.AreEqual (true, eventhandled, "#1");
				eventhandled = false;
				myimagelist.Images.Add (myImage);
				myimagelist.ColorDepth = ColorDepth.Depth32Bit;
				Assert.AreEqual (true, eventhandled, "#2");
				myform.Dispose ();
			}
開發者ID:nlhepler,項目名稱:mono,代碼行數:21,代碼來源:ImageListTest.cs

示例8: ImageListDraw

        public static void ImageListDraw(ImageList il, int index, Graphics graphics, int x, int y, int dx, int dy)
        {
#if _DOTNET2
            il.Draw(graphics, x, y, dx, dy, index);
#else
            // In .Net 1.1, ImageList.Draw does not draw PNG images correctly
            IntPtr hdc = graphics.GetHdc();
            ImageList_DrawEx(il.Handle, index, hdc, x, y, dx, dy, 0xFFFFFFFF, 0xFF000000, 0);
            graphics.ReleaseHdc(hdc);
#endif
        }
開發者ID:ChrisMoreton,項目名稱:Test3,代碼行數:11,代碼來源:Win32Calls.cs

示例9: Init

		public bool Init(ImageList imageList, int horizontal, int vertical, int columns, int defaultImage)
		{
			int nRows;
			if (imageList!=null)
			{
				Brush bgBrush = new SolidBrush(BackgroundColor);
				Pen vPen = new Pen(VLinesColor);
				Pen hPen = new Pen(HLinesColor);
				Pen borderPen = new Pen(BorderColor);
						
				_imageList = imageList;
				_nColumns = columns;

				_defaultImage = defaultImage;
				if (_defaultImage > _imageList.Images.Count)
					_defaultImage = _imageList.Images.Count;
				if (_defaultImage < 0) _defaultImage = -1;
			
			
				nRows = imageList.Images.Count / _nColumns;
				if (imageList.Images.Count % _nColumns > 0) nRows++;

				_nRows = nRows;
				_nHSpace = horizontal;
				_nVSpace = vertical;
				_nItemWidth = _imageList.ImageSize.Width + horizontal;
				_nItemHeight = _imageList.ImageSize.Height + vertical;
				_nBitmapWidth = _nColumns * _nItemWidth + 1;
				_nBitmapHeight = _nRows * _nItemHeight + 1;
				this.Width = _nBitmapWidth;
				this.Height = _nBitmapHeight;


				_Bitmap = new Bitmap(_nBitmapWidth,_nBitmapHeight);
				Graphics grfx =	Graphics.FromImage(_Bitmap);
				grfx.FillRectangle(bgBrush, 0, 0, _nBitmapWidth, _nBitmapHeight);
				for (int i=0;i<_nColumns;i++)
					grfx.DrawLine(vPen, i*_nItemWidth, 0, i*_nItemWidth, _nBitmapHeight-1);
				for (int i=0;i<_nRows;i++)
					grfx.DrawLine(hPen, 0, i*_nItemHeight, _nBitmapWidth-1, i*_nItemHeight);
			
				grfx.DrawRectangle(borderPen, 0 ,0 , _nBitmapWidth-1, _nBitmapHeight-1);

				for (int i=0;i<_nColumns;i++)
					for (int j=0;j<_nRows ;j++)
					{
						if ((j*_nColumns+i) < imageList.Images.Count)
							imageList.Draw(grfx,
								i*_nItemWidth+_nHSpace/2,
								j*_nItemHeight+vertical/2,
								imageList.ImageSize.Width,
								imageList.ImageSize.Height,
								j*_nColumns+i);
	
					}

				/*	int a = (_defaultImage / _nColumns);  // rad
					int b = (_defaultImage % _nColumns); // kolumn;

					_nCoordX = b*(_nItemWidth+_nHSpace/2)-1;
					_nCoordY = a*(_nItemHeight+nVSpace/2)-1;
				*/	
			
				// Clean up
				bgBrush.Dispose();
				vPen.Dispose();
				hPen.Dispose();
				borderPen.Dispose();
								
				Invalidate();
				return true;
			}
			else throw new System.ArgumentNullException("imageList"); 
				
		}
開發者ID:gusper,項目名稱:Journaley,代碼行數:75,代碼來源:ImageListPanel.cs

示例10: DrawSlotItemImage

                    /// <summary>
                    /// バッファに裝備アイテム畫像を描畫する
                    /// </summary>
                    /// <param name="iconImageList"></param>
                    /// <param name="canvas"></param>
                    /// <param name="backBrush"></param>
                    /// <param name="itemIndex"></param>
                    void DrawSlotItemImage(ImageList iconImageList, Image canvas, Brush backBrush,int itemIndex)
                    {
                        using (Graphics g = Graphics.FromImage(canvas))
                        {
                            g.FillRectangle(backBrush,
                                new Rectangle(new Point(0, 0), canvas.Size));

                            //裝著されてるスロット かつ 裝備情報読み込み済み
                            if (itemIndex < iconImageList.Images.Count)
                                iconImageList.Draw(g, new Point(1, 0), itemIndex);
                            else
                                iconImageList.Draw(g, new Point(1, 0), 0);
                            
                        }
                    }
開發者ID:lscyane,項目名稱:KCBr,代碼行數:22,代碼來源:FormShipDetail.cs

示例11: Draw

 public void Draw(Graphics g, ImageList imgList)
 {
     imgList.Draw(g, new Point(x, y), cell_id - 1);
 }
開發者ID:keaton-freude,項目名稱:arena-map-editor,代碼行數:4,代碼來源:Form1.cs


注:本文中的System.Windows.Forms.ImageList.Draw方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。