<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: LINETYPE in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/linetype/m-p/8401976#M24297</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a little example which displays the loaded line types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    public struct Linetype
    {
        public Linetype(string name, ObjectId id)
        {
            Name = name;
            ObjectId = id;
        }
        public string Name { get; }
        public ObjectId ObjectId { get; }
    }

    public partial class Dialog : Form
    {
        Linetype[] source;

        public Linetype Linetype =&amp;gt; (Linetype)comboLinetypes.SelectedItem;

        public Dialog()
        {
            InitializeComponent();

            // get the current database loaded line types
            var db = HostApplicationServices.WorkingDatabase;
            using (var tr = db.TransactionManager.StartOpenCloseTransaction())
            {
                source = ((LinetypeTable)tr.GetObject(db.LinetypeTableId, OpenMode.ForRead))
                    .Cast&amp;lt;ObjectId&amp;gt;()
                    .Select(id =&amp;gt; (LinetypeTableRecord)tr.GetObject(id, OpenMode.ForRead))
                    .Select(lt =&amp;gt; new Linetype(lt.Name, lt.ObjectId))
                    .ToArray();
            }

            // set the combo box binding and properties
            comboLinetypes.DropDownStyle = ComboBoxStyle.DropDownList;
            comboLinetypes.DataSource = source;
            comboLinetypes.DisplayMember = "Name";
            comboLinetypes.DrawMode = DrawMode.OwnerDrawFixed;
            comboLinetypes.DrawItem += ComboLinetypesnDrawItem;
        }

        // draw the combo box items
        private void ComboLinetypesnDrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index &amp;gt; -1)
            {
                var item = source[e.Index];
                var bounds = e.Bounds;
                int height = bounds.Height;
                int width = bounds.Width;
                Graphics graphics = e.Graphics;
                e.DrawBackground();
                graphics.DrawString(
                    item.Name,
                    e.Font,
                    new SolidBrush(e.ForeColor),
                    new Rectangle(bounds.Left, bounds.Top, 120, height));

                IntPtr iPtr = Autodesk.AutoCAD.Internal.Utils.DrawLineTypePattern(
                    item.ObjectId,
                    0, 0, width - 120, height);
                var img = System.Drawing.Image.FromHbitmap(iPtr);
                graphics.DrawImage(img, bounds.Left + 120, bounds.Top);
                e.DrawFocusRectangle();
            }
        }
    }&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dialog.png" style="width: 384px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/569541i04098E8008C51C50/image-size/large?v=v2&amp;amp;px=999" role="button" title="dialog.png" alt="dialog.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Nov 2018 17:10:40 GMT</pubDate>
    <dc:creator>_gile</dc:creator>
    <dc:date>2018-11-14T17:10:40Z</dc:date>
    <item>
      <title>LINETYPE</title>
      <link>https://forums.autodesk.com/t5/net-forum/linetype/m-p/8401355#M24295</link>
      <description>&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Linetype.JPG" style="width: 140px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/569415i89BD08089D682BC0/image-size/large?v=v2&amp;amp;px=999" role="button" title="Linetype.JPG" alt="Linetype.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Dear, is it possible to create a combobox in c# with line styles (see image)?&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 14:01:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/linetype/m-p/8401355#M24295</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-14T14:01:51Z</dc:date>
    </item>
    <item>
      <title>Re: LINETYPE</title>
      <link>https://forums.autodesk.com/t5/net-forum/linetype/m-p/8401519#M24296</link>
      <description>&lt;P&gt;I am not aware of this kind of ready-to-use control available. If I were you, when there is need to ask user to select a line type on a custom UI, I would use a button beside a read-only text box (to show linetype name, but maybe a picture showing the line type image). Clicking the button would open the AutoCAD built-in LineType dialog as second level dialog. The AutoCAD LineType dialog can be found in Autodesk.AutoCAD.Windows.LineTypeDialog in acmgd.dll.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 15:00:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/linetype/m-p/8401519#M24296</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2018-11-14T15:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: LINETYPE</title>
      <link>https://forums.autodesk.com/t5/net-forum/linetype/m-p/8401976#M24297</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a little example which displays the loaded line types.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;    public struct Linetype
    {
        public Linetype(string name, ObjectId id)
        {
            Name = name;
            ObjectId = id;
        }
        public string Name { get; }
        public ObjectId ObjectId { get; }
    }

    public partial class Dialog : Form
    {
        Linetype[] source;

        public Linetype Linetype =&amp;gt; (Linetype)comboLinetypes.SelectedItem;

        public Dialog()
        {
            InitializeComponent();

            // get the current database loaded line types
            var db = HostApplicationServices.WorkingDatabase;
            using (var tr = db.TransactionManager.StartOpenCloseTransaction())
            {
                source = ((LinetypeTable)tr.GetObject(db.LinetypeTableId, OpenMode.ForRead))
                    .Cast&amp;lt;ObjectId&amp;gt;()
                    .Select(id =&amp;gt; (LinetypeTableRecord)tr.GetObject(id, OpenMode.ForRead))
                    .Select(lt =&amp;gt; new Linetype(lt.Name, lt.ObjectId))
                    .ToArray();
            }

            // set the combo box binding and properties
            comboLinetypes.DropDownStyle = ComboBoxStyle.DropDownList;
            comboLinetypes.DataSource = source;
            comboLinetypes.DisplayMember = "Name";
            comboLinetypes.DrawMode = DrawMode.OwnerDrawFixed;
            comboLinetypes.DrawItem += ComboLinetypesnDrawItem;
        }

        // draw the combo box items
        private void ComboLinetypesnDrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index &amp;gt; -1)
            {
                var item = source[e.Index];
                var bounds = e.Bounds;
                int height = bounds.Height;
                int width = bounds.Width;
                Graphics graphics = e.Graphics;
                e.DrawBackground();
                graphics.DrawString(
                    item.Name,
                    e.Font,
                    new SolidBrush(e.ForeColor),
                    new Rectangle(bounds.Left, bounds.Top, 120, height));

                IntPtr iPtr = Autodesk.AutoCAD.Internal.Utils.DrawLineTypePattern(
                    item.ObjectId,
                    0, 0, width - 120, height);
                var img = System.Drawing.Image.FromHbitmap(iPtr);
                graphics.DrawImage(img, bounds.Left + 120, bounds.Top);
                e.DrawFocusRectangle();
            }
        }
    }&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dialog.png" style="width: 384px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/569541i04098E8008C51C50/image-size/large?v=v2&amp;amp;px=999" role="button" title="dialog.png" alt="dialog.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Nov 2018 17:10:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/linetype/m-p/8401976#M24297</guid>
      <dc:creator>_gile</dc:creator>
      <dc:date>2018-11-14T17:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: LINETYPE</title>
      <link>https://forums.autodesk.com/t5/net-forum/linetype/m-p/9237883#M24298</link>
      <description>&lt;P&gt;Dear Gilles,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thank you for the previous collaboration.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, with the autocad 2019, the command&amp;nbsp;&amp;nbsp;DrawLineTypePatter is replace with DrawLineType, but not work me.&lt;/P&gt;&lt;P&gt;the image is all black. Do you have a idea about?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;</description>
      <pubDate>Wed, 08 Jan 2020 15:16:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/linetype/m-p/9237883#M24298</guid>
      <dc:creator>MassimilianoBaratta</dc:creator>
      <dc:date>2020-01-08T15:16:00Z</dc:date>
    </item>
  </channel>
</rss>

