Get() публичный статический Метод

public static Get ( byte type ) : Block
type byte
Результат Block
Пример #1
0
        public override void PaintValue(PaintValueEventArgs e)
        {
            Graphics  g        = e.Graphics;
            Rectangle area     = e.Bounds;
            Rectangle iconArea = area;

            iconArea.Width = 16;
            if (e.Value != null)
            {
                //e.DrawBackground();
                Block ent = Blocks.Get((byte)e.Value);

                // Draw block icon
                g.DrawImage(ent.Image, iconArea);

                /*
                 * Font monospace = new Font(FontFamily.GenericMonospace,12f);
                 * Font sans = new Font(FontFamily.GenericSansSerif,12f);
                 * // ID.
                 * string idtxt = string.Format("{0:D3} 0x{0:X3}", ent.ID);
                 * SizeF idSz = g.MeasureString(idtxt, monospace);
                 * Rectangle idArea = area;
                 * idArea.X = iconArea.Right + 3;
                 * idArea.Width = (int)idSz.Width + 1;
                 * g.DrawString(idtxt, monospace, Brushes.Gray, idArea);
                 *
                 * // Block name
                 * SizeF entName = g.MeasureString(ent.ToString(), sans);
                 * Rectangle ctxt = area;
                 * ctxt.X = idArea.Right + 3;
                 * ctxt.Width = (int)entName.Width + 1;
                 * g.DrawString(ent.ToString(), sans, Brushes.Black, ctxt);*/
            }
        }
Пример #2
0
        void selectionControl_DrawItem(object sender, DrawItemEventArgs e)
        {
            Graphics  g        = e.Graphics;
            Rectangle area     = e.Bounds;
            Rectangle iconArea = area;

            iconArea.Width = 16;
            if (e.Index >= 0)
            {
                e.DrawBackground();
                Block ent = Blocks.Get((byte)(sender as ComboBox).Items[e.Index]);

                // Draw block icon
                g.DrawImage(ent.Image, iconArea);

                // ID
                string    idtxt  = string.Format("{0:D3} 0x{0:X3}", ent.ID);
                SizeF     idSz   = g.MeasureString(idtxt, (sender as ComboBox).Font);
                Rectangle idArea = area;
                idArea.X     = iconArea.Right + 3;
                idArea.Width = (int)idSz.Width + 1;
                g.DrawString(idtxt, (sender as ComboBox).Font, new SolidBrush(Color.FromArgb(128, e.ForeColor)), idArea);

                // Block name
                SizeF     entName = g.MeasureString(ent.ToString(), (sender as ComboBox).Font);
                Rectangle ctxt    = area;
                ctxt.X     = idArea.Right + 3;
                ctxt.Width = (int)entName.Width + 1;
                g.DrawString(ent.ToString(), (sender as ComboBox).Font, new SolidBrush(e.ForeColor), ctxt);
            }
        }