• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Forms.MeasureItemEventArgs类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Windows.Forms.MeasureItemEventArgs的典型用法代码示例。如果您正苦于以下问题:C# MeasureItemEventArgs类的具体用法?C# MeasureItemEventArgs怎么用?C# MeasureItemEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MeasureItemEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了MeasureItemEventArgs类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: MenuItem_MeasureItem

        static void MenuItem_MeasureItem(object sender, MeasureItemEventArgs e)
        {
            Font font = ((MenuItem) sender).DefaultItem
                            ? menuBoldFont
                            : SystemFonts.MenuFont;

            if (((MenuItem)sender).Text == "-")
                e.ItemHeight = SEPARATOR_HEIGHT;
            else
            {
                e.ItemHeight = ((SystemFonts.MenuFont.Height > ICON_SIZE) ? SystemFonts.MenuFont.Height : ICON_SIZE)
                                + BORDER_VERTICAL;

                e.ItemWidth = LEFT_MARGIN + ICON_SIZE + RIGHT_MARGIN

                    //item text width
                    + TextRenderer.MeasureText(((MenuItem)sender).Text, font, Size.Empty, TextFormatFlags.SingleLine | TextFormatFlags.NoClipping).Width
                    + SHORTCUT_MARGIN

                    //shortcut text width
                    + TextRenderer.MeasureText(ShortcutToString(((MenuItem)sender).Shortcut), font, Size.Empty, TextFormatFlags.SingleLine | TextFormatFlags.NoClipping).Width

                    //arrow width
                    + ((((MenuItem)sender).IsParent) ? ARROW_MARGIN : 0);
            }
        }
开发者ID:wilson212,项目名称:BF2Editor,代码行数:26,代码来源:OwnerDrawnMenu.cs


示例2: GetPreferredSize

 public override Size GetPreferredSize(Size proposedSize)
 {
     Size preferredSize = base.GetPreferredSize(proposedSize);
     int num = 0;
     if (base.Items.Count == 0)
     {
         num = 80;
     }
     else
     {
         using (Graphics graphics = Graphics.FromHwndInternal(base.Handle))
         {
             for (int i = 0; i < base.Items.Count; i++)
             {
                 if (this.DrawMode == System.Windows.Forms.DrawMode.Normal)
                 {
                     Size size2 = TextRenderer.MeasureText(graphics, base.GetItemText(base.Items[i]), this.Font);
                     num = Math.Max(num, size2.Width);
                 }
                 else
                 {
                     MeasureItemEventArgs e = new MeasureItemEventArgs(graphics, i);
                     this.OnMeasureItem(e);
                     num = Math.Max(num, e.ItemWidth);
                 }
             }
         }
     }
     preferredSize.Width = Math.Max(this.MinimumSize.Width, (num + (SystemInformation.Border3DSize.Width * 2)) + SystemInformation.VerticalScrollBarWidth);
     if (this.MaximumSize.Width > 0)
     {
         preferredSize.Width = Math.Min(this.MaximumSize.Width, preferredSize.Width);
     }
     return preferredSize;
 }
开发者ID:shankithegreat,项目名称:commanderdotnet,代码行数:35,代码来源:ComboBoxEx.cs


示例3: MeasureRichItem

    /// <summary>
    /// Calcul de la hauteur en pixels d'un élément de la liste
    /// </summary>
    /// <param name="e">descripteur issue d'un événement MeasureItem de l'hôte</param>
    /// <param name="item">référence non null sur l'item à peindre</param>
    public void MeasureRichItem( MeasureItemEventArgs e, RichItem item ) {

      // déterminer la font associée à l'item
      Font itemFont = item.Font;
      if ( itemFont == null ) itemFont = host.Font;

      // dimensions requises pour le texte
      Size textMetrics = TextRenderer.MeasureText( item.Text, itemFont );
      e.ItemHeight = textMetrics.Height;
      e.ItemWidth = textMetrics.Width;

      // forcer les chaînes vides à être visibles
      if ( e.ItemHeight == 0 )
        e.ItemHeight = (int) System.Math.Ceiling( itemFont.GetHeight( e.Graphics ) );

      // assurer l'espce vertical entre les items en ce qui concerne le texte
      e.ItemHeight += textVSpace;

      // considérer l'image si nécessaire
      Image itemImage = host.ImageShow ? item.Image : null;
      if (itemImage == null) return ;

      // éviter de stretcher les images pour un petit nombre de pixels
      int imageMissing = itemImage.Height + imageVSpace - e.ItemHeight;
      if ( 0 < imageMissing && imageMissing < imageVStretchMin ) 
        e.ItemHeight = itemImage.Height + imageVSpace;
    }
开发者ID:NicolasR,项目名称:Composants,代码行数:32,代码来源:RichListPainter.cs


示例4: OnMeasureItem

		protected override void OnMeasureItem(MeasureItemEventArgs e)
		{
			// base.OnMeasureItem(e);

			e.ItemWidth = m_qSize;
			e.ItemHeight = m_qSize;
		}
开发者ID:dbremner,项目名称:keepass2,代码行数:7,代码来源:ColorMenuItem.cs


示例5: CustomMeasurements

        /// <summary>
        /// Creates a new <see>CustomMeasurements</see>.
        /// </summary>
        /// <param name="args">The <see>MeasureItemEventArgs</see> contained by this object.</param>
        /// <param name="itemBeingMeasured">The actual item being measured.</param>
        public CustomMeasurements(MeasureItemEventArgs args, object itemBeingMeasured)
        {
            Debug.Assert(!object.ReferenceEquals(args, null));
            Debug.Assert(!object.ReferenceEquals(itemBeingMeasured, null));

            m_args = args;
            m_obj = itemBeingMeasured;
        }
开发者ID:Mofsy,项目名称:jinxbot,代码行数:13,代码来源:CustomMeasurements.cs


示例6: OnMeasureItem

 protected override void OnMeasureItem(MeasureItemEventArgs e)
 {
     base.OnMeasureItem(e);
     //製造一點空隙
     e.ItemHeight = Font.Height + 5;
     //畫標題的時候 是畫 標題 + item 所以*2
     if (IsGroupHeader(e.Index, out header))
         e.ItemHeight = e.ItemHeight * 2;
 }
开发者ID:seaklovisa,项目名称:ACS254_HW,代码行数:9,代码来源:ProductCombox.cs


示例7: MeasureItem

 internal void MeasureItem(MeasureItemEventArgs context, object item)
 {
     if (item != null)
     {
         Size itemSize = MeasureItemCore(context, item);
         context.ItemWidth = itemSize.Width;
         context.ItemHeight = itemSize.Height;
     }
 }
开发者ID:tommy-carlier,项目名称:tc-libs,代码行数:9,代码来源:ListItemRenderer.cs


示例8: OnMeasureItem

        protected override void OnMeasureItem(MeasureItemEventArgs e)
        {
            base.OnMeasureItem(e);

            e.ItemWidth += 22;

            if (e.ItemHeight < 20)
                e.ItemHeight = 20;
        }
开发者ID:huamanhtuyen,项目名称:VNACCS,代码行数:9,代码来源:ImageListBox.cs


示例9: OnMeasureItem

 protected void OnMeasureItem(object sender, MeasureItemEventArgs e)
 {
     if (e.Index > -1 && e.Index < Items.Count)
     {
         Font myFont = new Font(this.Font.FontFamily, GetFontSize(e.Index), FontStyle.Bold);
         e.ItemHeight = (int)e.Graphics.MeasureString(Items[e.Index].ToString(), myFont).Height;
         e.ItemWidth = (int)e.Graphics.MeasureString(Items[e.Index].ToString(), myFont).Width;
     }
 }
开发者ID:tewuapple,项目名称:WinHtmlEditor,代码行数:9,代码来源:ToolStripFontSizeComboBox.cs


示例10: ExListBox_MeasureItem

		void ExListBox_MeasureItem(object sender, MeasureItemEventArgs e)
		{
			if (e.Index >= this.Items.Count) return;

			IConfigMenuItem cfgItem = this.Items[e.Index] as IConfigMenuItem;
			if (cfgItem == null) return;

			e.ItemHeight = cfgItem.Height;
		}
开发者ID:iraychen,项目名称:IpMsg.Net,代码行数:9,代码来源:ExListBox.cs


示例11: OnMeasureItem

 /// <summary>
 /// Measure item size
 /// </summary>
 /// <param name="e"></param>
 protected override void OnMeasureItem(MeasureItemEventArgs e)
 {
     if (Site == null && e.Index > -1)
     {
         SizeF sizeF = e.Graphics.MeasureString(Items[e.Index].ToString(), Font, Width);
         e.ItemHeight = (int)sizeF.Height;
         e.ItemWidth = (int)sizeF.Width;
     }
 }
开发者ID:sergey-podolsky,项目名称:university,代码行数:13,代码来源:MultiLineListBox.cs


示例12: OnMeasureItem

        protected override void OnMeasureItem(MeasureItemEventArgs e)
        {
            SizeF itmSize;
            SizeF S = new SizeF(this.Width, 0);

            itmSize = e.Graphics.MeasureString(this.Items[e.Index].ToString(), this.Font, S);

            e.ItemHeight = Convert.ToInt32(itmSize.Height);
            e.ItemWidth = Convert.ToInt32(itmSize.Width);
        }
开发者ID:kstawiski,项目名称:neurexam,代码行数:10,代码来源:ListBox.cs


示例13: listBox1_MeasureItem

        void listBox1_MeasureItem(object sender, MeasureItemEventArgs e)
        {
            Pair<string, string> s = (Pair<string, string>)listBox1.Items[e.Index];
            string[] lines = s.First.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);

            int count = Math.Min(lines.Length, 5) + 1;

            e.ItemWidth = Width;
            e.ItemHeight = count * listBox1.Font.Height;
        }
开发者ID:chrisforbes,项目名称:corfu,代码行数:10,代码来源:ClipboardHistory.cs


示例14: ComboBox1_MeasureItem

 /// <summary>
 /// I have set the Draw property to DrawMode.OwnerDrawVariable, so I must caluclate the item measurement.  
 /// I will set the height and width of each item before it is drawn. 
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void ComboBox1_MeasureItem(object sender, MeasureItemEventArgs e)
 {
     var g = CreateGraphics();
     var maxWidth = 0;
     foreach (var width in Items.ItemsBase.Cast<object>().Select(element => (int)g.MeasureString(element.ToString(), Font).Width).Where(width => width > maxWidth))
     {
         maxWidth = width;
     }
     DropDownWidth = maxWidth + 20;
 }
开发者ID:Kendry06,项目名称:BaseSistemasIntegrados,代码行数:16,代码来源:CuadroCombinadoGrafico.cs


示例15: OnMeasureItem

 protected override void OnMeasureItem(MeasureItemEventArgs e)
 {
     if (e.Index >= 0 && e.Index < Items.Count) {
         var item = Items[e.Index] as ScoredSearchResult;
         int h = Font.Height;
         if (item.RequiresPathLine) h *= 2;
         h += ItemMargin * 2;
         e.ItemHeight = h;
     }
 }
开发者ID:akx,项目名称:lauo,代码行数:10,代码来源:ResultListBox.cs


示例16: OnMeasureItem

		void OnMeasureItem(object sender, MeasureItemEventArgs e)
		{
			if(e.Index<0||e.Index>=Items.Count) return;

			Bitmap bm=Items[e.Index] as Bitmap;
			if(bm!=null)
			{
				e.ItemWidth=bm.Width;
				e.ItemHeight=bm.Height;
			}
		}
开发者ID:shintadono,项目名称:Free.Controls,代码行数:11,代码来源:BitmapComboBox.cs


示例17: lst_MeasureItem

 public void lst_MeasureItem(object sender, MeasureItemEventArgs e)
 {
     var lst = (ListBoxControl) sender;
     if (e.Index >= 0)
     {
         var text = lst.GetItemText(e.Index);
         var textSize = TextUtils.GetStringSize(e.Graphics, text, _font, StringFormat.GenericDefault, lst.ClientRectangle.Width - 24);
         e.ItemHeight = textSize.Height + 5;
         
     }
 }
开发者ID:superbatonchik,项目名称:EduFormManager,代码行数:11,代码来源:CollapsableSideListBoxControl.cs


示例18: listBoxMessage_MeasureItem

 private void listBoxMessage_MeasureItem(object sender, MeasureItemEventArgs e)
 {
     var lst = (ListBoxControl) sender;
     var msg = (message) lst.GetItem(e.Index);
     int itemHeight = 0;
     itemHeight += (int) e.Graphics.MeasureString(msg.subject, SubjectFont, lst.Width).Height;
     itemHeight += (int)e.Graphics.MeasureString(msg.edu.number_sysname, FromFont, lst.Width).Height;
     itemHeight += (int)e.Graphics.MeasureString(msg.send_date.ToString("G"), DateFont, lst.Width).Height;
     e.ItemHeight = itemHeight + 32;
     e.ItemWidth += 24;
 }
开发者ID:superbatonchik,项目名称:EduFormManager,代码行数:11,代码来源:XtraMessageListControl.cs


示例19: OnMeasureItem

        protected override void OnMeasureItem(MeasureItemEventArgs e)
        {
            if (IsItemVisible(e.Index))
            {
                e.ItemWidth = ClientSize.Width;
                e.ItemHeight = 18;
            }
            else
                e.ItemHeight = 0;

            base.OnMeasureItem(e);
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:12,代码来源:GroupListBox.cs


示例20: OnMeasureItem

        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.ComboBox.MeasureItem"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Forms.MeasureItemEventArgs"/> that was raised.</param>
        protected override void OnMeasureItem(MeasureItemEventArgs e)
        {
            if (e.Index < 0)
                return;

            Image bmp = this.Items[e.Index] as Image;

            if (bmp == null && this.Items[e.Index] as NamedImage != null)
                bmp = (this.Items[e.Index] as NamedImage).Image;

            if (bmp != null)
                e.ItemHeight = m_itemHeight + MARGIN * 3;
            else
                base.OnMeasureItem(e);
        }
开发者ID:kanbang,项目名称:Colt,代码行数:19,代码来源:ImageStylePicker.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Forms.Menu类代码示例发布时间:2022-05-26
下一篇:
C# Forms.MaskedTextBox类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap