コード例 #1
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 public void AddRange(ListItem[] items)
 {
     for (IEnumerator e = items.GetEnumerator(); e.MoveNext(); )
         Insert(-1, (ListItem)e.Current);
 }
コード例 #2
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 public bool Contains(ListItem item)
 {
     return items.Contains(item);
 }
コード例 #3
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 public void Remove(ListItem item)
 {
     List.Remove(item);
 }
コード例 #4
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 public int Add(ListItem item)
 {
     return Insert(-1, item);
 }
コード例 #5
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 /**/
 /// <summary>
 /// 绑定数据。
 /// </summary>
 public void DataBind()
 {
     if ((this.DataSource != null) && (base.DisplayMember != null))
     {
         switch (this.DataSource.GetType().Name)
         {
             case "DataTable":
                 {
                     DataTable dtblTmp = (DataTable)this.DataSource;
                     foreach (DataRow drowTmp in dtblTmp.Rows)
                     {
                         string strText = drowTmp[base.DisplayMember].ToString();
                         string strValue = (base.ValueMember == null) ? null : drowTmp[base.ValueMember].ToString();
                         ListItem item = new ListItem(strText, strValue, this.ImageIndex);
                         this.m_items.Add(item);
                     }
                     break;
                 }
         }
     }
 }
コード例 #6
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 public void Add(ListItem item)
 {
     List.Add(item);
 }
コード例 #7
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 private void FindItem(int id, ListItem item, ref ListItem find)
 {
     foreach (object lt in item.Items)
     {
         ListItem lt1 = (ListItem)lt;
         if (lt1.id == id)
         {
             find = lt1;
             break;
         }
         FindItem(id, lt1, ref find);
     }
 }
コード例 #8
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 public void Remove(ListItem item)
 {
     if (owner != null) owner.RemoveItem(item);
     items.Remove(item);
 }
コード例 #9
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 //画背景
 private void DrawBackground(DrawItemEventArgs e, Rectangle rect, ListItem item)
 {
     if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
     {
         if (m_ItemHoverGradientBackColor != Color.Empty)
         {
             //渐变
             Rectangle r = new Rectangle(rect.Left, rect.Top, rect.Width, rect.Height / 2);
             e.Graphics.FillRectangle(new LinearGradientBrush(r, m_ItemHoverBackColor, m_ItemHoverGradientBackColor, 90f), r);
             r = new Rectangle(rect.Left, rect.Top + rect.Height / 2, rect.Width, rect.Height / 2);
             if (r.Height % 2 == 0) { r.Y -= 2; r.Height += 2; }
             e.Graphics.FillRectangle(new LinearGradientBrush(r, m_ItemHoverBackColor, m_ItemHoverGradientBackColor, 270f), r);
             ControlPaint.DrawBorder(e.Graphics, rect, m_ItemHoverGradientBackColor, ButtonBorderStyle.Solid);
         }
         else
             e.Graphics.FillRectangle(new SolidBrush(m_ItemHoverBackColor), rect);
     }
     else
     {
         e.Graphics.FillRectangle(new SolidBrush(item.BackColor), rect);
     }
 }
コード例 #10
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
        //画文本
        private void DrawString(DrawItemEventArgs e, ListItem item, Rectangle rect)
        {
            StringFormat sf = new StringFormat();
            sf.LineAlignment = StringAlignment.Center;
            rect.Offset(0, 1);

            SolidBrush sb = null;
            if (!item.ForeColor.Equals(SystemColors.WindowText) || m_ItemHoverGradientBackColor != Color.Empty)
            {
                sb = new SolidBrush(item.ForeColor);
            }
            else if ((e.State & DrawItemState.Selected) == DrawItemState.Selected)
            {
                sb = new SolidBrush(m_ItemHoverColor);
            }
            else
            {
                sb = new SolidBrush(SystemColors.WindowText);
            }

            e.Graphics.DrawString(item.Text, item.Font, sb, rect, sf);
            sb.Dispose();
        }
コード例 #11
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 internal void SetItem(int id, ListItem item)
 {
     int index = FindItem(id);
     if (index != -1)
         base.Items[index] = item.CloneData();
 }
コード例 #12
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 internal void RemoveItem(ListItem item)
 {
     if (isUpdate) return;
     int index = FindItem(item.id);
     if (index != -1)
         base.Items.RemoveAt(index);
 }
コード例 #13
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
        //插入新项
        internal int InsertItem(int index, ListItem item, int method)
        {
            if (isUpdate) return 0;
            ListItem lit = item.CloneData();
            lit.Items = null;
            lit.level = item.level;
            int count = 0;
            if (item.Parent.GetType() == typeof(ListItem))
            {
                ListItem parent = (ListItem)item.Parent;
                foreach (ListItem lt1 in parent.Items)
                {
                    GetItemLocation(lt1.Items, lit, ref count);
                }
                lit.Parent = parent;
                int i = 0;
                for (; i < base.Items.Count; i++)
                {
                    if (GetItem(i).id == parent.id)
                    {
                        break;
                    }
                }

                base.Items.Insert(i + 1 + index + count, lit);
            }
            else
            {
                foreach (ListItem lt1 in ((EnforceLawComboBox)item.Parent).Items)
                {
                    GetItemLocation(lt1.Items, lit, ref count);
                }

                base.Items.Insert(index + count, lit);
            }
            return base.Items.Count - 1;
        }
コード例 #14
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 public int IndexOf(ListItem item)
 {
     return items.IndexOf(item);
 }
コード例 #15
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 private ListItem FindRealListItem(ListItem item)
 {
     if (item.Parent == null) //为根节点
     {
         foreach (ListItem lt in this.m_items)
         {
             if (lt.id == item.id)
                 return lt;
         }
         return null;
     }
     else
     {
         ListItem temp = item;
         while (true) // 找到根级
         {
             if (temp.Parent == null) break;
             if (temp.Parent.GetType() == typeof(EnforceLawComboBox)) break;
             temp = (temp.Parent as ListItem);
         }
         ListItem find = null;
         //找子项里
         FindItem(item.id, temp, ref find);
         return find;
     }
 }
コード例 #16
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
            public int Insert(int index, ListItem item)
            {
                int ret = 0;
                if (inserted)
                    item.level = level;
                int m = 1;
                if (index == -1)
                {
                    index = this.Count;
                    m = 0; //为添加
                }
                item.Host(owner);
                item.Parent = parent;
                item.Text = (item.Text.Length == 0) ? item.GetType().Name : item.Text;
                items.Insert(index, item);
                if (inserted)
                {
                    item.id = EnforceLawComboBox.nextId++;
                    if (owner != null)
                    {
                        ret = item.Index = owner.InsertItem(index, item, m);
                        AddItem(item, item.Items);
                    }
                }

                return ret;
            }
コード例 #17
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 private void GetItemLocation(ListItemCollection items, ListItem owner, ref int count)
 {
     foreach (ListItem lt in items)
     {
         if (owner.id != lt.id && CheckIsInItems(lt.id))
         {
             count++;
             GetItemLocation(lt.Items, owner, ref count);
         }
     }
 }
コード例 #18
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 private void AddItem(ListItem parent, ListItemCollection items)
 {
     int i = 0;
     foreach (ListItem item in items)
     {
         item.Host(owner);
         item.Parent = parent;
         item.level = items.level;
         item.Index = owner.InsertItem(i, item, 0);
         i++;
     }
 }
コード例 #19
0
ファイル: EnforceLawComboBox.cs プロジェクト: Oman/Maleos
 internal ListItem CloneData()
 {
     ListItem lt = new ListItem();
     lt.Text = this.Text;
     lt.ImageIndex = this.ImageIndex;
     lt.Font = this.Font;
     lt.ForeColor = this.ForeColor;
     lt.BackColor = this.BackColor;
     lt.Checked = this.Checked;
     lt.id = id;
     return lt;
 }