예제 #1
0
        public void addFile(string fileName)
        {
            CListSubItem comboBox = new CListSubItem();
            CListSubItem fileNameLabel = new CListSubItem();

            //
            ComboBox box = new ComboBox();
            foreach (object obj in Enum.GetValues(typeof(ListFileType)))
            {
                box.Items.Add(obj);    
            }
            box.DropDownStyle = ComboBoxStyle.DropDownList;
            box.SelectedIndex = 0;
            comboBox.Control = box;

            //
            fileNameLabel.Text = fileName;


            CListItem item = new CListItem();
            item.SubItems.Add(comboBox);
            item.SubItems.Add(fileNameLabel);

            _listFiles.Items.Add(item);
        }
예제 #2
0
        /// <summary>
        ///   Indexer
        /// </summary>
        public CListSubItem this[int nItemIndex]
        {
            get
            {
                //				int nTmpCount = 0;
                //				if ( Parent == null )		// rare case when there is no parent set (almost always during collection editor)
                //					nTmpCount = 255;		// basically infinite during collection editor
                //				else
                //					nTmpCount = Parent.Columns.Count;

                int nBailout = 0;

                // check to make sure it exists first
                while (List.Count <= nItemIndex)
                {
                    CListSubItem newitem = new CListSubItem();
                    newitem.ChangedEvent += SubItem_Changed;
                    newitem.Parent        = m_Parent;
                    //newitem.Control = Parent.Columns[ nItemIndex ]

                    List.Add(newitem); // if the index doesn't yet exist, fill in the subitems till it does

                    if (nBailout++ > 25)
                    {
                        break;
                    }
                }

                return((CListSubItem)List[nItemIndex]);
            }
        }
예제 #3
0
        /// <summary>
        ///   Changes in the columns, items or subitems
        /// </summary>
        /// <param name = "ctType"></param>
        /// <param name = "column"></param>
        /// <param name = "item"></param>
        /// <param name = "subItem"></param>
        public ChangedEventArgs(ChangedTypes ctType, CColumn column, CListItem item, CListSubItem subItem)
        {
            Column  = column;
            Item    = item;
            SubItem = subItem;

            m_ctType = ctType;
        }
예제 #4
0
        /// <summary>
        ///   remove an item from the list
        /// </summary>
        /// <param name = "subItem"></param>
        public void Remove(CListSubItem subItem)
        {
            List.Remove(subItem);

            if (ChangedEvent != null)
            {
                ChangedEvent(this, new ChangedEventArgs(ChangedTypes.SubItemCollectionChanged, null, null, null));
            }
        }
예제 #5
0
        /// <summary>
        ///   insert an item into the list at specified index
        /// </summary>
        /// <param name = "nIndex"></param>
        /// <param name = "strItemText"></param>
        /// <returns></returns>
        public CListSubItem Insert(int nIndex, string strItemText)
        {
            CListSubItem subItem = new CListSubItem(); //GLItem item = new GLItem(Parent);

            //item.SubItems[0].Text = strItemText;

            nIndex = Insert(nIndex, subItem);

            return(subItem);
        }
예제 #6
0
        public bool GLLoad(CListItem item, CListSubItem subItem, CListView listctrl)
        {
            m_item    = item;
            m_subItem = subItem;
            m_Parent  = listctrl;

            Text = subItem.Text;

            Items.Add("i1");
            Items.Add("i2");
            Items.Add("i3");

            return(true);
        }
예제 #7
0
        public bool GLLoad(CListItem item, CListSubItem subItem, CListView listctrl)
        {
            m_item = item;
            m_subItem = subItem;
            m_Parent = listctrl;

            Text = subItem.Text;

            Items.Add("i1");
            Items.Add("i2");
            Items.Add("i3");

            return true;
        }
예제 #8
0
        public bool GLLoad(CListItem item, CListSubItem subItem, CListView listctrl)
        // populate this control however you wish with item
        {
            // set the styles you want for this
            BorderStyle = BorderStyle.None;
            AutoSize = false;


            m_item = item;
            m_subItem = subItem;
            m_Parent = listctrl;

            Text = subItem.Text;

            return true; // we don't do any heavy processing in this ctrl so we just return true
        }
예제 #9
0
        public bool GLLoad(CListItem item, CListSubItem subItem, CListView listctrl)
        {
            Format = DateTimePickerFormat.Long;
            try
            {
                m_item = item;
                m_subItem = subItem;
                m_Parent = listctrl;

                Text = subItem.Text;

                //this.Value = subItem.Text;
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());

                Text = DateTime.Now.ToString();
            }

            return true;
        }
예제 #10
0
        /// <summary>
        ///   lowest level of add/insert.  All add and insert routines eventually call this
        ///
        ///   in the future always have routines call this one as well to keep one point of entry
        /// </summary>
        /// <param name = "nIndex"></param>
        /// <param name = "subItem"></param>
        /// <returns></returns>
        public int Insert(int nIndex, CListSubItem subItem)
        {
            subItem.Parent = m_Parent;

            subItem.ChangedEvent += SubItem_Changed;

            if (nIndex < 0)
            {
                nIndex = List.Add(subItem); // add the subItem itself
            }
            else
            {
                List.Insert(nIndex, subItem);
            }

            if (ChangedEvent != null)
            {
                ChangedEvent(this, new ChangedEventArgs(ChangedTypes.SubItemCollectionChanged, null, null, subItem));
            }

            return(nIndex);
        }
예제 #11
0
        /// <summary>
        ///   Indexer
        /// </summary>
        public CListSubItem this[int nItemIndex]
        {
            get
            {
                //				int nTmpCount = 0;
                //				if ( Parent == null )		// rare case when there is no parent set (almost always during collection editor)
                //					nTmpCount = 255;		// basically infinite during collection editor
                //				else
                //					nTmpCount = Parent.Columns.Count;

                int nBailout = 0;

                // check to make sure it exists first
                while (List.Count <= nItemIndex)
                {
                    CListSubItem newitem = new CListSubItem();
                    newitem.ChangedEvent += SubItem_Changed;
                    newitem.Parent = m_Parent;
                    //newitem.Control = Parent.Columns[ nItemIndex ]

                    List.Add(newitem); // if the index doesn't yet exist, fill in the subitems till it does

                    if (nBailout++ > 25)
                        break;
                }

                return (CListSubItem)List[nItemIndex];
            }
        }
예제 #12
0
        /// <summary>
        ///   Changes in the columns, items or subitems
        /// </summary>
        /// <param name = "ctType"></param>
        /// <param name = "column"></param>
        /// <param name = "item"></param>
        /// <param name = "subItem"></param>
        public ChangedEventArgs(ChangedTypes ctType, CColumn column, CListItem item, CListSubItem subItem)
        {
            Column = column;
            Item = item;
            SubItem = subItem;

            m_ctType = ctType;
        }
예제 #13
0
        /// <summary>
        ///   Instance the activated embeddec control for this item/column
        /// </summary>
        /// <param name = "nColumn"></param>
        /// <param name = "item"></param>
        /// <param name = "subItem"></param>
        protected void ActivateEmbeddedControl(int nColumn, CListItem item, CListSubItem subItem)
        {
            if (m_ActivatedEmbeddedControl != null)
            {
                m_ActivatedEmbeddedControl.Dispose();
                m_ActivatedEmbeddedControl = null;
            }


            /*
			using activator.createinstance
			typeof()/GetType
			Type t = obj.GetType()
			 */

            if (Columns[nColumn].ActivatedEmbeddedControlTemplate == null)
                return;


            Type type = Columns[nColumn].ActivatedEmbeddedControlTemplate.GetType();
            Control control = (Control)Activator.CreateInstance(type);
            CEmbeddedControl icontrol = (CEmbeddedControl)control;

            if (icontrol == null)
                throw new Exception(@"Control does not implement the CEmbeddedControl interface, can't start");

            icontrol.GLLoad(item, subItem, this);


            //control.LostFocus += new EventHandler( ActivatedEmbbed_LostFocus );
            control.KeyPress += tb_KeyPress;

            control.Parent = this;
            ActivatedEmbeddedControl = control;
            //subItem.Control = control;							// seed the control


            int nYOffset = (subItem.LastCellRect.Height - m_ActivatedEmbeddedControl.Bounds.Height) / 2;
            Rectangle controlBounds;

            if (GridLineStyle == GLGridLineStyles.gridNone)
            {
                // add 1 to x to give border, add 2 to Y because to account for possible grid that you must cover up
                controlBounds = new Rectangle(subItem.LastCellRect.X + 1, subItem.LastCellRect.Y + 1,
                                              subItem.LastCellRect.Width - 3, subItem.LastCellRect.Height - 2);
            }
            else
            {
                // add 1 to x to give border, add 2 to Y because to account for possible grid that you must cover up
                controlBounds = new Rectangle(subItem.LastCellRect.X + 1, subItem.LastCellRect.Y + 2,
                                              subItem.LastCellRect.Width - 3, subItem.LastCellRect.Height - 3);
            }
            //control.Bounds = subItem.LastCellRect;	//new Rectangle( subItem.LastCellRect.X, subItem.LastCellRect.Y + nYOffset, subItem.LastCellRect.Width, subItem.LastCellRect.Height );
            control.Bounds = controlBounds;

            control.Show();
            control.Focus();
        }
예제 #14
0
        /// <summary>
        ///   lowest level of add/insert.  All add and insert routines eventually call this
        /// 
        ///   in the future always have routines call this one as well to keep one point of entry
        /// </summary>
        /// <param name = "nIndex"></param>
        /// <param name = "subItem"></param>
        /// <returns></returns>
        public int Insert(int nIndex, CListSubItem subItem)
        {
            subItem.Parent = m_Parent;

            subItem.ChangedEvent += SubItem_Changed;

            if (nIndex < 0)
                nIndex = List.Add(subItem); // add the subItem itself
            else
                List.Insert(nIndex, subItem);

            if (ChangedEvent != null)
                ChangedEvent(this, new ChangedEventArgs(ChangedTypes.SubItemCollectionChanged, null, null, subItem));

            return nIndex;
        }
예제 #15
0
        /// <summary>
        ///   remove an item from the list
        /// </summary>
        /// <param name = "subItem"></param>
        public void Remove(CListSubItem subItem)
        {
            List.Remove(subItem);

            if (ChangedEvent != null)
                ChangedEvent(this, new ChangedEventArgs(ChangedTypes.SubItemCollectionChanged, null, null, null));
        }
예제 #16
0
        /// <summary>
        ///   insert an item into the list at specified index
        /// </summary>
        /// <param name = "nIndex"></param>
        /// <param name = "strItemText"></param>
        /// <returns></returns>
        public CListSubItem Insert(int nIndex, string strItemText)
        {
            CListSubItem subItem = new CListSubItem(); //GLItem item = new GLItem(Parent);
            //item.SubItems[0].Text = strItemText;

            nIndex = Insert(nIndex, subItem);

            return subItem;
        }
예제 #17
0
 /// <summary>
 ///   add an itemto the items collection
 /// </summary>
 /// <param name = "subItem"></param>
 /// <returns></returns>
 public int Add(CListSubItem subItem)
 {
     return Insert(-1, subItem);
 }
예제 #18
0
 /// <summary>
 ///   Add range of sub items
 /// </summary>
 /// <param name = "subItems"></param>
 public void AddRange(CListSubItem[] subItems)
 {
     lock (List.SyncRoot)
     {
         for (int i = 0; i < subItems.Length; i++)
             Add(subItems[i]);
     }
 }
예제 #19
0
        /// <summary>
        ///   Draw Sub Item (Cell) at location specified
        /// </summary>
        /// <param name = "graphicsSubItem"></param>
        /// <param name = "rectSubItem"></param>
        /// <param name = "item"></param>
        /// <param name = "subItem"></param>
        /// <param name = "nColumn"></param>
        public virtual void DrawSubItem(Graphics graphicsSubItem, Rectangle rectSubItem, CListItem item,
                                        CListSubItem subItem, int nColumn)
        {
            // precheck to make sure this is big enough for the things we want to do inside it
            Rectangle subControlRect = new Rectangle(rectSubItem.X, rectSubItem.Y, rectSubItem.Width, rectSubItem.Height);


            if ((subItem.Control != null) && (!subItem.ForceText))
            {
                // custom embedded control here

                Control control = subItem.Control;

                if (control.Parent != this) // *** CRUCIAL *** this makes sure the parent is the list control
                    control.Parent = this;

                //				Rectangle subrc = new Rectangle( 
                //					subControlRect.X+this.CellPaddingSize, 
                //					subControlRect.Y+this.CellPaddingSize, 
                //					subControlRect.Width-this.CellPaddingSize*2,
                //					subControlRect.Height-this.CellPaddingSize*2 );


                Rectangle subrc = new Rectangle(
                    subControlRect.X,
                    subControlRect.Y + 1,
                    subControlRect.Width,
                    subControlRect.Height - 1);


                Type tp = control.GetType();
                PropertyInfo pi = control.GetType().GetProperty("PreferredHeight");
                if (pi != null)
                {
                    int PreferredHeight = (int)pi.GetValue(control, null);

                    if (((PreferredHeight + CellPaddingSize * 2) > ItemHeight) && AutoHeight)
                        ItemHeight = PreferredHeight + CellPaddingSize * 2;

                    subrc.Y = subControlRect.Y + ((subControlRect.Height - PreferredHeight) / 2);
                }

                NewLiveControls.Add(control); // put it in the new list, remove from old list
                if (LiveControls.Contains(control)) // make sure its in the old list first
                {
                    LiveControls.Remove(control); // remove it from list so it doesn't get put down
                }


                if (control.Bounds.ToString() != subrc.ToString())
                    control.Bounds = subrc; // this will force an invalidation

                if (control.Visible != true)
                    control.Visible = true;
            }
            else // not control based
            {
                // if the sub item color is not the same as the back color fo the control, AND the item is not selected, then color this sub item background

                if ((subItem.BackColor.ToArgb() != BackColor.ToArgb()) && (!item.Selected) &&
                    (subItem.BackColor != Color.White))
                {
                    SolidBrush bbrush = new SolidBrush(subItem.BackColor);
                    graphicsSubItem.FillRectangle(bbrush, rectSubItem);
                    bbrush.Dispose();
                }

                // do we need checkboxes in this column or not?
                if (Columns[nColumn].CheckBoxes)
                    rectSubItem = DrawCheckBox(graphicsSubItem, rectSubItem, subItem.Checked);

                // if there is an image, this routine will RETURN with exactly the space left for everything else after the image is drawn (or not drawn due to lack of space)
                if ((subItem.ImageIndex > -1) && (ImageList != null) && (subItem.ImageIndex < ImageList.Images.Count))
                    rectSubItem = DrawCellGraphic(graphicsSubItem, rectSubItem, ImageList.Images[subItem.ImageIndex],
                                                  subItem.ImageAlignment);

                // deal with text color in a box on whether it is selected or not
                Color textColor;
                if (item.Selected && Selectable)
                    textColor = SelectedTextColor;
                else
                {
                    textColor = ForeColor;
                    if (item.ForeColor.ToArgb() != ForeColor.ToArgb())
                        textColor = item.ForeColor;
                    else if (subItem.ForeColor.ToArgb() != ForeColor.ToArgb())
                        textColor = subItem.ForeColor;
                }

                DrawCellText(graphicsSubItem, rectSubItem, subItem.Text, Columns[nColumn].TextAlignment, textColor,
                             item.Selected, ItemWordWrap);

                subItem.LastCellRect = rectSubItem; // important to ONLY catch the area where the text is drawn
            }
        }
예제 #20
0
 /// <summary>
 ///   add an itemto the items collection
 /// </summary>
 /// <param name = "subItem"></param>
 /// <returns></returns>
 public int Add(CListSubItem subItem)
 {
     return(Insert(-1, subItem));
 }