Esempio n. 1
0
        public ColorArrayForm(Color[] colors, string title, IColorArrayEditorCaller caller)
        {
            InitializeComponent();

            if (colors != null)
            {
                foreach (Color c in colors)
                {
                    ColorArrayItem it = new ColorArrayItem(c, this);
                    lsb.Items.Add(it);
                }
            }
            this.Text = title;

            if (caller != null)
            {
                lsb.BackColor = caller.BackColorForColorArrayEditor;
                lsb.ForeColor = caller.ForeColorForColorArrayEditor;

                foreach (Control con in this.Controls)
                {
                    if (con is Button)
                    {
                        con.Text = caller.GetButtonText(con.Text);
                    }
                }
            }

            btnRemove.Enabled = (lsb.SelectedItems.Count > 0 &&
                                 lsb.Items.Count > 0);
        }
Esempio n. 2
0
        internal void ReSelectedObject(ColorArrayItem cai)
        {
            int sel = lsb.SelectedIndex;

            if (sel != -1)
            {
                Rectangle rc = lsb.GetItemRectangle(sel);
                lsb.Invalidate(rc);
            }
        }
Esempio n. 3
0
        private void Lsb_DrawItem(object sender, DrawItemEventArgs e)
        {
            // Set the DrawMode property to draw fixed sized items.
            lsb.DrawMode = DrawMode.OwnerDrawFixed;

            StringFormat stringFormat = StringFormat.GenericDefault;

            stringFormat.LineAlignment = StringAlignment.Center;
            stringFormat.Alignment     = StringAlignment.Near;
            stringFormat.Trimming      = StringTrimming.None;
            stringFormat.FormatFlags   = StringFormatFlags.NoWrap | StringFormatFlags.LineLimit;

            if (e.Index > -1)
            {
                ColorArrayItem item = (ColorArrayItem)lsb.Items[e.Index];
                item.DrawItem(e, stringFormat);
            }

            stringFormat.Dispose();

            // If the ListBox has focus, draw a focus rectangle around the selected item.
            e.DrawFocusRectangle();
        }