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


C# ImageListViewItem.GetSimpleRating方法代码示例

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


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

示例1: DrawItem


//.........这里部分代码省略.........
                        }

                        // Draw item text
                        Color foreColor = SystemColors.ControlText;
                        if ((state & ItemState.Disabled) != ItemState.None)
                            foreColor = SystemColors.GrayText;
                        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);
                        TextRenderer.DrawText(g, item.Text, ImageListView.Font, rt, foreColor,
                            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);
                        Color foreColor = SystemColors.ControlText;
                        if ((state & ItemState.Disabled) != ItemState.None)
                            foreColor = SystemColors.GrayText;
                        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, foreColor,
                                        TextFormatFlags.EndEllipsis | TextFormatFlags.VerticalCenter | TextFormatFlags.SingleLine | TextFormatFlags.PreserveGraphicsClipping);
                                else
                                    TextRenderer.DrawText(g, item.GetSubItemText(column.Type), ImageListView.Font, rt, foreColor,
                                        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:headchen,项目名称:imagelistview,代码行数:101,代码来源:ImageListViewRenderers.cs

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