当前位置: 首页>>代码示例>>C#>>正文


C# ImageListViewItem.GetSubItemText方法代码示例

本文整理汇总了C#中Manina.Windows.Forms.ImageListViewItem.GetSubItemText方法的典型用法代码示例。如果您正苦于以下问题:C# ImageListViewItem.GetSubItemText方法的具体用法?C# ImageListViewItem.GetSubItemText怎么用?C# ImageListViewItem.GetSubItemText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Manina.Windows.Forms.ImageListViewItem的用法示例。


在下文中一共展示了ImageListViewItem.GetSubItemText方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawItem

            /// <summary>
            /// Draws the specified item on the given graphics.
            /// </summary>
            /// <param name="g">The System.Drawing.Graphics to draw on.</param>
            /// <param name="item">The ImageListViewItem to draw.</param>
            /// <param name="state">The current view state of item.</param>
            /// <param name="bounds">The bounding rectangle of item in client coordinates.</param>
            public override void DrawItem(Graphics g, ImageListViewItem item, ItemState state, Rectangle bounds)
            {
                if (ImageListView.View == Manina.Windows.Forms.View.Thumbnails)
                {
                    Size itemPadding = new Size(4, 4);

                    // Paint background
                    using (Brush bItemBack = new SolidBrush(item.BackColor))
                    {
                        g.FillRectangle(bItemBack, bounds);
                    }
                    if ((ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None)) ||
                        (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None) && ((state & ItemState.Hovered) != ItemState.None)))
                    {
                        using (Brush bSelected = new LinearGradientBrush(bounds, Color.FromArgb(16, SystemColors.Highlight), Color.FromArgb(64, SystemColors.Highlight), LinearGradientMode.Vertical))
                        {
                            Utility.FillRoundedRectangle(g, bSelected, bounds, 4);
                        }
                    }
                    else if (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None))
                    {
                        using (Brush bGray64 = new LinearGradientBrush(bounds, Color.FromArgb(16, SystemColors.GrayText), Color.FromArgb(64, SystemColors.GrayText), LinearGradientMode.Vertical))
                        {
                            Utility.FillRoundedRectangle(g, bGray64, bounds, 4);
                        }
                    }
                    if (((state & ItemState.Hovered) != ItemState.None))
                    {
                        using (Brush bHovered = new LinearGradientBrush(bounds, Color.FromArgb(8, SystemColors.Highlight), Color.FromArgb(32, SystemColors.Highlight), LinearGradientMode.Vertical))
                        {
                            Utility.FillRoundedRectangle(g, bHovered, bounds, 4);
                        }
                    }

                    // Draw the image
                    Image img = item.ThumbnailImage;
                    if (img != null)
                    {
                        Rectangle pos = Utility.GetSizedImageBounds(img, new Rectangle(bounds.Location + itemPadding, ImageListView.ThumbnailSize), 0.0f, 50.0f);
                        g.DrawImage(img, pos);
                        // Draw image border
                        if (Math.Min(pos.Width, pos.Height) > 32)
                        {
                            using (Pen pGray128 = new Pen(Color.FromArgb(128, Color.Gray)))
                            {
                                g.DrawRectangle(pGray128, pos);
                            }
                            using (Pen pWhite128 = new Pen(Color.FromArgb(128, Color.White)))
                            {
                                g.DrawRectangle(pWhite128, Rectangle.Inflate(pos, -1, -1));
                            }
                        }

                        // Draw item text
                        int lineHeight = CaptionFont.Height;
                        RectangleF rt;
                        using (StringFormat sf = new StringFormat())
                        {
                            rt = new RectangleF(bounds.Left + 2 * itemPadding.Width + ImageListView.ThumbnailSize.Width,
                                bounds.Top + itemPadding.Height + (Math.Max(ImageListView.ThumbnailSize.Height, mTextHeight) - mTextHeight) / 2,
                                mTileWidth, lineHeight);
                            sf.Alignment = StringAlignment.Near;
                            sf.FormatFlags = StringFormatFlags.NoWrap;
                            sf.LineAlignment = StringAlignment.Center;
                            sf.Trimming = StringTrimming.EllipsisCharacter;
                            using (Brush bItemFore = new SolidBrush(item.ForeColor))
                            {
                                g.DrawString(item.Text, CaptionFont, bItemFore, rt, sf);
                            }
                            using (Brush bItemDetails = new SolidBrush(Color.Gray))
                            {
                                rt.Offset(0, 1.5f * lineHeight);
                                if (!string.IsNullOrEmpty(item.FileType))
                                {
                                    g.DrawString(item.GetSubItemText(ColumnType.FileType),
                                        ImageListView.Font, bItemDetails, rt, sf);
                                    rt.Offset(0, 1.1f * lineHeight);
                                }
                                if (item.Dimensions != Size.Empty || item.Resolution != SizeF.Empty)
                                {
                                    string text = "";
                                    if (item.Dimensions != Size.Empty)
                                        text += item.GetSubItemText(ColumnType.Dimensions) + " pixels ";
                                    if (item.Resolution != SizeF.Empty)
                                        text += item.Resolution.Width + " dpi";
                                    g.DrawString(text, ImageListView.Font, bItemDetails, rt, sf);
                                    rt.Offset(0, 1.1f * lineHeight);
                                }
                                if (item.FileSize != 0)
                                {
                                    g.DrawString(item.GetSubItemText(ColumnType.FileSize),
                                        ImageListView.Font, bItemDetails, rt, sf);
                                    rt.Offset(0, 1.1f * lineHeight);
//.........这里部分代码省略.........
开发者ID:RyuaNerin,项目名称:OtakuImage,代码行数:101,代码来源:ImageListViewRenderers.cs

示例2: DrawPane

            /// <summary>
            /// Draws the left pane in Pane view mode.
            /// </summary>
            /// <param name="g">The System.Drawing.Graphics to draw on.</param>
            /// <param name="item">The ImageListViewItem to draw.</param>
            /// <param name="image">The image to draw.</param>
            /// <param name="bounds">The bounding rectangle of the pane.</param>
            public override void DrawPane(Graphics g, ImageListViewItem item, Image image, Rectangle bounds)
            {
                // Draw resize handle
                using (Brush bBorder = new SolidBrush(Color.FromArgb(64, 64, 64)))
                {
                    g.FillRectangle(bBorder, bounds.Right - 2, bounds.Top, 2, bounds.Height);
                }
                bounds.Width -= 2;

                if (item != null && image != null)
                {
                    // Calculate image bounds
                    Size itemMargin = MeasureItemMargin(ImageListView.View);
                    Rectangle pos = Utility.GetSizedImageBounds(image, new Rectangle(bounds.Location + itemMargin, bounds.Size - itemMargin - itemMargin), 50.0f, 0.0f);
                    // Draw image
                    g.DrawImage(image, pos);

                    bounds.X += itemMargin.Width;
                    bounds.Width -= 2 * itemMargin.Width;
                    bounds.Y = pos.Height + 16;
                    bounds.Height -= pos.Height + 16;

                    // Item text
                    if (mImageListView.Columns[ColumnType.Name].Visible && bounds.Height > 0)
                    {
                        int y = Utility.DrawStringPair(g, bounds, "", item.Text, mImageListView.Font,
                            Brushes.White, Brushes.White);
                        bounds.Y += 2 * y;
                        bounds.Height -= 2 * y;
                    }

                    // File type
                    if (mImageListView.Columns[ColumnType.FileType].Visible && bounds.Height > 0 && !string.IsNullOrEmpty(item.FileType))
                    {
                        using (Brush bCaption = new SolidBrush(Color.FromArgb(196, 196, 196)))
                        using (Brush bText = new SolidBrush(Color.White))
                        {
                            int y = Utility.DrawStringPair(g, bounds, mImageListView.Columns[ColumnType.FileType].Text + ": ",
                                item.FileType, mImageListView.Font, bCaption, bText);
                            bounds.Y += y;
                            bounds.Height -= y;
                        }
                    }

                    // Metatada
                    foreach (ImageListView.ImageListViewColumnHeader column in mImageListView.Columns)
                    {
                        if (column.Type == ColumnType.ImageDescription)
                        {
                            bounds.Y += 8;
                            bounds.Height -= 8;
                        }

                        if (bounds.Height <= 0) break;

                        if (column.Visible &&
                            column.Type != ColumnType.FileType &&
                            column.Type != ColumnType.DateAccessed &&
                            column.Type != ColumnType.FileName &&
                            column.Type != ColumnType.FilePath &&
                            column.Type != ColumnType.Name)
                        {
                            string caption = column.Text;
                            string text = item.GetSubItemText(column.Type);
                            if (!string.IsNullOrEmpty(text))
                            {
                                using (Brush bCaption = new SolidBrush(Color.FromArgb(196, 196, 196)))
                                using (Brush bText = new SolidBrush(Color.White))
                                {
                                    int y = Utility.DrawStringPair(g, bounds, caption + ": ", text,
                                        mImageListView.Font, bCaption, bText);
                                    bounds.Y += y;
                                    bounds.Height -= y;
                                }
                            }
                        }
                    }
                }
            }
开发者ID:RyuaNerin,项目名称:OtakuImage,代码行数:86,代码来源:ImageListViewRenderers.cs

示例3: DrawItem


//.........这里部分代码省略.........
                                {
                                    g.DrawRectangle(pInnerBorder, imageX + 1, imageY + 1, imageWidth - 2, imageHeight - 2);
                                }
                            }
                        }
                    }
                    else
                    {
                        // Paint background
                        if (ImageListView.Enabled)
                        {
                            using (Brush bItemBack = new SolidBrush(ImageListView.Colors.BackColor))
                            {
                                g.FillRectangle(bItemBack, bounds);
                            }
                        }
                        else
                        {
                            using (Brush bItemBack = new SolidBrush(ImageListView.Colors.DisabledBackColor))
                            {
                                g.FillRectangle(bItemBack, bounds);
                            }
                        }
                    }

                    // Draw item text
                    if ((state & ItemState.Hovered) != ItemState.None)
                    {
                        RectangleF rt;
                        using (StringFormat sf = new StringFormat())
                        {
                            rt = new RectangleF(bounds.Left + 4, bounds.Top + 4, bounds.Width - 8, (bounds.Height - imageHeight) / 2 - 8);
                            sf.Alignment = StringAlignment.Center;
                            sf.FormatFlags = StringFormatFlags.NoWrap;
                            sf.LineAlignment = StringAlignment.Center;
                            sf.Trimming = StringTrimming.EllipsisCharacter;
                            using (Brush bItemFore = new SolidBrush(ImageListView.Colors.ForeColor))
                            {
                                g.DrawString(item.Text, ImageListView.Font, bItemFore, rt, sf);
                            }
                            rt.Y = bounds.Bottom - (bounds.Height - imageHeight) / 2 + 4;
                            string details = "";
                            string dimensions = item.GetSubItemText(ColumnType.Dimensions);
                            if (!string.IsNullOrEmpty(dimensions))
                                details += dimensions + " pixels ";
                            string fileSize = item.GetSubItemText(ColumnType.FileSize);
                            if (!string.IsNullOrEmpty(fileSize))
                                details += item.GetSubItemText(ColumnType.FileSize);
                            using (Brush bGrayText = new SolidBrush(ImageListView.Colors.PaneLabelColor))
                            {
                                g.DrawString(details, ImageListView.Font, bGrayText, rt, sf);
                            }
                        }
                    }

                    // Item border
                    using (Pen pWhite128 = new Pen(Color.FromArgb(128, ImageListView.Colors.ControlBackColor)))
                    {
                        Utility.DrawRoundedRectangle(g, pWhite128, bounds.Left + 1, bounds.Top + 1, bounds.Width - 3, bounds.Height - 3, 4);
                    }
                    if (((state & ItemState.Disabled) != ItemState.None))
                    {
                        using (Pen pHighlight128 = new Pen(ImageListView.Colors.DisabledBorderColor))
                        {
                            Utility.DrawRoundedRectangle(g, pHighlight128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4);
                        }
                    }
                    else if (ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None))
                    {
                        using (Pen pHighlight128 = new Pen(ImageListView.Colors.SelectedBorderColor))
                        {
                            Utility.DrawRoundedRectangle(g, pHighlight128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4);
                        }
                    }
                    else if (!ImageListView.Focused && ((state & ItemState.Selected) != ItemState.None))
                    {
                        using (Pen pGray128 = new Pen(ImageListView.Colors.UnFocusedBorderColor))
                        {
                            Utility.DrawRoundedRectangle(g, pGray128, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4);
                        }
                    }
                    else if ((state & ItemState.Selected) == ItemState.None)
                    {
                        using (Pen pGray64 = new Pen(ImageListView.Colors.BorderColor))
                        {
                            Utility.DrawRoundedRectangle(g, pGray64, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4);
                        }
                    }

                    if (ImageListView.Focused && ((state & ItemState.Hovered) != ItemState.None))
                    {
                        using (Pen pHighlight64 = new Pen(ImageListView.Colors.HoverBorderColor))
                        {
                            Utility.DrawRoundedRectangle(g, pHighlight64, bounds.Left, bounds.Top, bounds.Width - 1, bounds.Height - 1, 4);
                        }
                    }
                }
                else
                    base.DrawItem(g, item, state, bounds);
            }
开发者ID:headchen,项目名称:imagelistview,代码行数:101,代码来源:ImageListViewRenderers.cs

示例4: DrawPane

            /// <summary>
            /// Draws the left pane in Pane view mode.
            /// </summary>
            /// <param name="g">The System.Drawing.Graphics to draw on.</param>
            /// <param name="item">The ImageListViewItem to draw.</param>
            /// <param name="image">The image to draw.</param>
            /// <param name="bounds">The bounding rectangle of the pane.</param>
            public override void DrawPane(Graphics g, ImageListViewItem item, Image image, Rectangle bounds)
            {
                // Draw pane background
                if (ImageListView.Enabled)
                    g.FillRectangle(SystemBrushes.Window, bounds);
                else
                    g.FillRectangle(SystemBrushes.Control, bounds);

                using (Brush bBorder = new SolidBrush(Color.FromArgb(128, SystemColors.GrayText)))
                {
                    g.FillRectangle(bBorder, bounds.Right - 2, bounds.Top, 2, bounds.Height);
                }
                bounds.Width -= 2;

                if (item != null && image != null)
                {
                    // Calculate image bounds
                    Size itemMargin = MeasureItemMargin(ImageListView.View);
                    Rectangle pos = Utility.GetSizedImageBounds(image, new Rectangle(bounds.Location + itemMargin, bounds.Size - itemMargin - itemMargin), 50.0f, 0.0f);
                    // Draw image
                    g.DrawImage(image, pos);
                    // Draw image border
                    if (Math.Min(pos.Width, pos.Height) > 32)
                    {
                        using (Pen pBorder = new Pen(SystemColors.WindowText))
                        {
                            g.DrawRectangle(pBorder, pos);
                        }
                    }
                    bounds.X += itemMargin.Width;
                    bounds.Width -= 2 * itemMargin.Width;
                    bounds.Y = pos.Height + 16;
                    bounds.Height -= pos.Height + 16;

                    // Item text
                    if (ImageListView.Columns.HasType(ColumnType.Name) && ImageListView.Columns[ColumnType.Name].Visible && bounds.Height > 0)
                    {
                        string text = item.GetSubItemText(ColumnType.Name);
                        int y = Utility.DrawStringPair(g, bounds, "", text, ImageListView.Font, SystemBrushes.GrayText, SystemBrushes.WindowText);
                        bounds.Y += 2 * y;
                        bounds.Height -= 2 * y;
                    }

                    // File type
                    string fileType = item.GetSubItemText(ColumnType.FileType);
                    if (ImageListView.Columns.HasType(ColumnType.FileType) && ImageListView.Columns[ColumnType.FileType].Visible && bounds.Height > 0 && !string.IsNullOrEmpty(fileType))
                    {
                        int y = Utility.DrawStringPair(g, bounds, ImageListView.Columns[ColumnType.FileType].Text + ": ",
                            fileType, ImageListView.Font, SystemBrushes.GrayText, SystemBrushes.WindowText);
                        bounds.Y += y;
                        bounds.Height -= y;
                    }

                    // Metatada
                    foreach (ImageListView.ImageListViewColumnHeader column in ImageListView.Columns)
                    {
                        if (column.Type == ColumnType.ImageDescription)
                        {
                            bounds.Y += 8;
                            bounds.Height -= 8;
                        }

                        if (bounds.Height <= 0) break;

                        if (column.Visible &&
                            column.Type != ColumnType.Custom &&
                            column.Type != ColumnType.FileType &&
                            column.Type != ColumnType.DateAccessed &&
                            column.Type != ColumnType.FileName &&
                            column.Type != ColumnType.FilePath &&
                            column.Type != ColumnType.Name)
                        {
                            string caption = column.Text;
                            string text = item.GetSubItemText(column.Type);
                            if (!string.IsNullOrEmpty(text))
                            {
                                int y = Utility.DrawStringPair(g, bounds, caption + ": ", text,
                                    ImageListView.Font, SystemBrushes.GrayText, SystemBrushes.WindowText);
                                bounds.Y += y;
                                bounds.Height -= y;
                            }
                        }
                    }
                }
            }
开发者ID:headchen,项目名称:imagelistview,代码行数:92,代码来源:ImageListViewRenderers.cs

示例5: DrawItem


//.........这里部分代码省略.........
                            {
                                g.DrawRectangle(pen, imgback.X, imgback.Y, imgback.Width - 1, imgback.Height - 1);
                            }
                        }
                        // Image
                        g.DrawImage(img, pos);
                    }

                    // Draw item text
                    Size szt = TextRenderer.MeasureText(item.Text, ImageListView.Font);
                    Rectangle rt = new Rectangle(
                        bounds.Left + itemPadding.Width, bounds.Top + 2 * itemPadding.Height + ImageListView.ThumbnailSize.Height,
                        ImageListView.ThumbnailSize.Width, szt.Height);
                    Color textColor = this.ImageListView._palette.GetContentShortTextColor1(PaletteContentStyle.ButtonListItem, GetButtonState(state));
                    TextRenderer.DrawText(g, item.Text, ImageListView.Font, rt, textColor,
                        TextFormatFlags.EndEllipsis | TextFormatFlags.HorizontalCenter | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping);
                }
                else // if (ImageListView.View == View.Details)
                {
                    List<ImageListView.ImageListViewColumnHeader> uicolumns = ImageListView.Columns.GetDisplayedColumns();

                    // Separators
                    int x = bounds.Left - 2;
                    foreach (ImageListView.ImageListViewColumnHeader column in uicolumns)
                    {
                        x += column.Width;
                        if (!ReferenceEquals(column, uicolumns[uicolumns.Count - 1]))
                        {
                            using (Pen pGray32 = new Pen(Color.FromArgb(32, 128, 128, 128)))
                            {
                                g.DrawLine(pGray32, x, bounds.Top, x, bounds.Bottom);
                            }
                        }
                    }
                    Size offset = new Size(2, (bounds.Height - ImageListView.Font.Height) / 2);
                    // Sub text
                    int firstWidth = 0;
                    if (uicolumns.Count > 0)
                        firstWidth = uicolumns[0].Width;
                    Rectangle rt = new Rectangle(bounds.Left + offset.Width, bounds.Top + offset.Height, firstWidth - 2 * offset.Width, bounds.Height - 2 * offset.Height);
                    foreach (ImageListView.ImageListViewColumnHeader column in uicolumns)
                    {
                        rt.Width = column.Width - 2 * offset.Width;
                        using (Brush bItemFore = new SolidBrush(SystemColors.ControlText))
                        {
                            int iconOffset = 0;
                            if (column.Type == ColumnType.Name)
                            {
                                // Allocate space for checkbox and file icon
                                if (ImageListView.ShowCheckBoxes && ImageListView.ShowFileIcons)
                                    iconOffset += 2 * 16 + 3 * 2;
                                else if (ImageListView.ShowCheckBoxes)
                                    iconOffset += 16 + 2 * 2;
                                else if (ImageListView.ShowFileIcons)
                                    iconOffset += 16 + 2 * 2;
                            }
                            rt.X += iconOffset;
                            rt.Width -= iconOffset;
                            // Rating stars
                            if (column.Type == ColumnType.Rating && ImageListView.RatingImage != null && ImageListView.EmptyRatingImage != null)
                            {
                                int rating = item.GetSimpleRating();
                                if (rating > 0)
                                {
                                    int w = ImageListView.RatingImage.Width;
                                    int y = (int)(rt.Top + (rt.Height - ImageListView.RatingImage.Height) / 2.0f);

                                    for (int i = 1; i <= 5; i++)
                                    {
                                        if (rating >= i)
                                            g.DrawImage(ImageListView.RatingImage, rt.Left + (i - 1) * w, y);
                                        else
                                            g.DrawImage(ImageListView.EmptyRatingImage, rt.Left + (i - 1) * w, y);
                                    }
                                }
                            }
                            else if (column.Type == ColumnType.Custom)
                                TextRenderer.DrawText(g, item.GetSubItemText(column.Guid), ImageListView.Font, rt, SystemColors.ControlText,
                                    TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping);
                            else
                                TextRenderer.DrawText(g, item.GetSubItemText(column.Type), ImageListView.Font, rt, SystemColors.ControlText,
                                    TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping);

                            rt.X -= iconOffset;
                        }
                        rt.X += column.Width;
                    }
                }

                // Focus rectangle
                //if (ImageListView.Focused && ((state & ItemState.Focused) != ItemState.None))
                //{
                //    Rectangle focusBounds = bounds;
                //    focusBounds.Inflate(-2, -2);
                //    ControlPaint.DrawFocusRectangle(g, focusBounds);
                //}

                //else
                //    base.DrawItem(g, item, state, bounds);
            }
开发者ID:Cocotteseb,项目名称:imagelistview,代码行数:101,代码来源:ImageListViewRenderers.cs


注:本文中的Manina.Windows.Forms.ImageListViewItem.GetSubItemText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。