Class that represents a row in a CustomList
Inheritance: IComparable
Beispiel #1
0
        // if row.equals(any other row) then you start to have weird behavior

        /// <summary>
        /// Deletes the row.
        /// </summary>
        /// <param name="row">The row to delete.</param>
        public virtual void DeleteRow(ObjRow row)
        {
            Object obj = null;

            for (int i = 0; i < items.Count; i++)
            {
                if (obj != null)                 // move this row's object to the one above it, move obj to the end to delete
                {
                    items[i - 1].Object = items[i].Object;
                }
                else if (obj == null && items[i].Equals(row))                 // found it, will start moving up on the next iteration
                {
                    obj = items[i].Object;
                }
            }

            if (obj != null)             // actually deleted something
            {
                items[items.Count - 1].Object        = obj;
                items[items.Count - 1].RefreshEvent -= new RefreshDelegate(Refresh);

                items.Remove(items[items.Count - 1]);
                startY -= Font.Height + columns.RowSpace * 2;

                if (refreshOnAdd)
                {
                    Refresh();
                }
            }
        }
 /// <summary>
 /// Raises the OnClick event for the specified row
 /// </summary>
 /// <param name="row">Row to raise event with</param>
 public void FireClick(ObjRow row)
 {
     if (OnClick != null)
     {
         OnClick(this, new RowClickEventArgs(row, this));
     }
 }
 /// <summary>
 /// Raises the KeyPress event for the specified row
 /// </summary>
 /// <param name="row">Row to raise event with</param>
 /// <param name="e">Args</param>
 public void FireKeyPress(ObjRow row, KeyPressEventArgs e)
 {
     if (KeyPress != null)
     {
         KeyPress(row, this, e);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Adds an item to the collection. Creates an ObjRow and calls AddItem(ObjRow row)
        /// </summary>
        /// <param name="o">The item to add</param>
        public virtual void AddItem(object o)
        {
            ConstructorInfo ci  = rowType.GetConstructor(new Type[] { typeof(object) });
            ObjRow          row = (ObjRow)ci.Invoke(new object[] { o });

            AddItem(row);
        }
Beispiel #5
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.LostFocus"></see> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
        protected override void OnLostFocus(EventArgs e)
        {
            if (clicked != null)
            {
                clicked.UnClick();
            }

            clicked = null;
            Refresh();
        }
Beispiel #6
0
        /// <summary>
        /// Raises the <see cref="E:System.Windows.Forms.Control.Paint"></see> event.
        /// </summary>
        /// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"></see> that contains the event data.</param>
        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);
            int rowHeight = 0;

            for (int i = 0; i < items.Count; i++)
            {
                ObjRow row = (ObjRow)items[i];
                if (rowHeight + yOffset + row.Height >= 0 && rowHeight + yOffset < Height)
                {
                    row.Render(e, yOffset);
                }

                rowHeight += row.Height;
            }
            columns.Render(e, rowHeight, yOffset);
        }
Beispiel #7
0
        /// <summary>
        /// Adds an ObjRow to the collection
        /// </summary>
        /// <param name="row">The row to add</param>
        public virtual void AddItem(ObjRow row)
        {
            row.Top   = startY;
            row.Width = Width;
//			row.Height = RowHeight;
            row.Height       += Font.Height + columns.RowSpace * 2;
            row.Columns       = columns;
            row.RefreshEvent += new RefreshDelegate(Refresh);
            row.RowIndex      = items.Count;
            items.Add(row);
            startY += Font.Height + columns.RowSpace * 2;

            if (refreshOnAdd)
            {
                Refresh();
            }
        }
Beispiel #8
0
        private void mouseOverRows(int mouseY, CustomListColumn overCol)
        {
            int overY = (mouseY - (columns.HeaderHeight + yOffset)) / (Font.Height + columns.RowSpace * 2);

            if (selected != null)
            {
                selected.MouseLeave();
            }

            selected = null;

            if (overCol != null && overY >= 0 && overY < items.Count)
            {
                selRow   = overY;
                selected = items[selRow];
                selected.MouseOver(overCol);
            }
            this.overCol = overCol;
            // else its the same, do nothing
        }
Beispiel #9
0
        private void rowClicked(object sender, MouseEventArgs e)
        {
//			int overY = (e.Y - (columns.HeaderHeight + yOffset)) / (Font.Height + columns.RowSpace * 2);
            if (clicked != null)
            {
                clicked.UnClick();
            }

            if (selected != null && overCol != null)
            {
                selected.Click(overCol);
            }

            clicked = selected;

            if (RowClick != null && clicked != null)
            {
                RowClick(this, clicked);
            }
        }
Beispiel #10
0
		/// <summary>
		/// Adds an ObjRow to the collection
		/// </summary>
		/// <param name="row">The row to add</param>
		public virtual void AddItem(ObjRow row)
		{
			row.Top=startY;
			row.Width=Width;
			//row.Height=RowHeight;
			row.Height+=Font.Height+columns.RowSpace*2;
			row.Columns=columns;
			row.RefreshEvent+=new RefreshDelegate(Refresh);
			row.RowIndex=items.Count;
			items.Add(row);
			startY+=Font.Height+columns.RowSpace*2;

			if(refreshOnAdd)
				Refresh();
		}
		/// <summary>
		/// Raises the OnClick event for the specified row
		/// </summary>
		/// <param name="row">Row to raise event with</param>
		public void FireClick(ObjRow row)
		{
			if(OnClick!=null)
				OnClick(this,new RowClickEventArgs(row,this));
		}
Beispiel #12
0
		/// <summary>
		/// Raises the <see cref="E:System.Windows.Forms.Control.LostFocus"></see> event.
		/// </summary>
		/// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
		protected override void OnLostFocus(EventArgs e)
		{
			if(clicked!=null)
				clicked.UnClick();

			clicked=null;
			Refresh();
		}
Beispiel #13
0
		private void mouseOverRows(int mouseY,CustomListColumn overCol)
		{
			int overY=(mouseY-(columns.HeaderHeight+yOffset))/(Font.Height+columns.RowSpace*2);
			
			if(selected!=null)
				selected.MouseLeave();

			selected=null;

			if(overCol!=null && overY>=0 && overY<items.Count)
			{
				selRow=overY;
				selected=items[selRow];
				selected.MouseOver(overCol);
			}
			this.overCol=overCol;
			//else its the same, do nothing
		}
Beispiel #14
0
		private void rowClicked(object sender, MouseEventArgs e)
		{
			//int overY=(e.Y-(columns.HeaderHeight+yOffset))/(Font.Height+columns.RowSpace*2);
			if(clicked!=null)
				clicked.UnClick();

			if(selected!=null && overCol!=null)
				selected.Click(overCol);

			clicked=selected;

			if(RowClick!=null && clicked!=null)
				RowClick(this,clicked);
		}
Beispiel #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:RowClickEventArgs"/> class.
 /// </summary>
 /// <param name="row">The row that was clicked on</param>
 /// <param name="col">The column that was clicked under</param>
 public RowClickEventArgs(ObjRow row, CustomListColumn col)
 {
     this.row = row;
     this.col = col;
 }
		/// <summary>
		/// Initializes a new instance of the <see cref="T:RowClickEventArgs"/> class.
		/// </summary>
		/// <param name="row">The row that was clicked on</param>
		/// <param name="col">The column that was clicked under</param>
		public RowClickEventArgs(ObjRow row, CustomListColumn col)
		{
			this.row=row;
			this.col=col;
		}
Beispiel #17
0
		//if row.equals(any other row) then we start to have weird behavior

		/// <summary>
		/// Deletes the row.
		/// </summary>
		/// <param name="row">The row to delete.</param>
		public virtual void DeleteRow(ObjRow row)
		{
			Object obj=null;
			for(int i=0;i<items.Count;i++)
			{
				if(obj!=null) //move this row's object to the one above it, move obj to the end to delete
					items[i-1].Object=items[i].Object;
				else if(obj==null && items[i].Equals(row)) //found it, will start moving up on the next iteration
					obj=items[i].Object;
			}

			if(obj!=null)//actually deleted something
			{
				items[items.Count-1].Object=obj;
				items[items.Count-1].RefreshEvent-=new RefreshDelegate(Refresh);

				items.Remove(items[items.Count-1]);
				startY-=Font.Height+columns.RowSpace*2;

				if(refreshOnAdd)
					Refresh();
			}
		}
		/// <summary>
		/// Raises the KeyPress event for the specified row
		/// </summary>
		/// <param name="row">Row to raise event with</param>
		/// <param name="e">Args</param>
		public void FireKeyPress(ObjRow row, KeyPressEventArgs e)
		{
			if(KeyPress!=null)
				KeyPress(row,this,e);
		}