Class representing a column in a CustomList control
예제 #1
0
        /// <summary>
        /// This method is called before another row is clicked. This is used as a 'turn off' function
        /// </summary>
        public void UnClick()
        {
            cursorTimer.Stop();

            if (clickCol != null && clickCol.Property != null)
            {
                try
                {
                    switch (clickCol.Property.EditType)
                    {
                    case EditStrType.String:
                        clickCol.Property.SetValue(obj, editBuffer);
                        break;

                    case EditStrType.Int:
                        clickCol.Property.SetValue(obj, int.Parse(editBuffer));
                        break;

                    case EditStrType.Float:
                        clickCol.Property.SetValue(obj, double.Parse(editBuffer));
                        break;
                    }
                }
                catch
                {}

                editing = false;
            }

            clickCol = null;
            addStr   = "";

            FireRefresh();
        }
예제 #2
0
        /// <summary>
        /// Renders this control to the supplied PaintEventArgs
        /// </summary>
        /// <param name="e">The <see cref="T:System.Windows.Forms.PaintEventArgs"/> instance containing the event data.</param>
        /// <param name="rowHeight">Height of the row.</param>
        /// <param name="yOffset">The y offset.</param>
        public void Render(PaintEventArgs e, int rowHeight, int yOffset)
        {
            e.Graphics.FillRectangle(headerBrush, offX, offY, tableWidth - 1, headerHeight + rowSpace * 2);

            int startX = 0;

            for (int i = 0; i < list.Count; i++)
            {
                CustomListColumn col = list[i] as CustomListColumn;
                if (col == overCol)
                {
                    e.Graphics.FillRectangle(Brushes.LightBlue, col.Left, offY, col.Width, headerHeight + rowSpace * 2);
                }

                //vertical lines
                e.Graphics.DrawLine(Pens.Black, col.Width + startX - colSpace + offX, offY, col.Width + startX - colSpace + offX, HeaderHeight + rowHeight + yOffset);
                e.Graphics.DrawString(col.Title, Font, foreBrush, new RectangleF(startX + offX, offY, startX + col.Width, Font.Height));      //locs[i],0);
                //e.Graphics.DrawLine(Pens.Red,col.Left+col.Width,HeaderHeight+rowHeight+yOffset,col.Left+col.Width,Height);

                startX += col.Width;
            }

            e.Graphics.DrawLine(Pens.Black, offX, offY + headerHeight + rowSpace * 2, tableWidth - 1, offY + headerHeight + rowSpace * 2);

            switch (bStyle)
            {
            case BorderStyle.Fixed3D:
                System.Windows.Forms.ControlPaint.DrawBorder3D(e.Graphics, 0, 0, Width, Height, border);
                break;

            case BorderStyle.FixedSingle:
                System.Windows.Forms.ControlPaint.DrawBorder(e.Graphics, new Rectangle(0, 0, Width, Height), Color.Black, ButtonBorderStyle.Solid);
                break;
            }
        }
예제 #3
0
        private void colLeftChanged(CustomListColumn col, int amount)
        {
            if (!leftChangeLock)
            {
                if (col.Index == 0)
                {
                    return;
                }

                if (this[col.Index - 1].Width - amount >= CustomListColumn.MinWidth)
                {
                    leftChangeLock             = true;
                    this[col.Index - 1].Width -= amount;

                    int startX = this[col.Index - 1].Width + this[col.Index - 1].Left;
                    for (int i = col.Index; i < Count; i++)
                    {
                        this[i].Left = startX;
                        startX      += this[i].Width;
                    }

                    if (RefreshEvent != null)
                    {
                        RefreshEvent();
                    }

                    leftChangeLock = false;
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Called when the mouse clicks on a row
        /// </summary>
        /// <param name="col">The column the mouse was over when the button was clicked</param>
        public void Click(CustomListColumn col)
        {
            clickCol = col;
            addStr   = "|";
            cursorTimer.Start();

            if (col.Property != null)
            {
                editBuffer = clickCol.Property.Value(obj).ToString();
                editing    = true;
            }
            col.FireClick(this);
        }
예제 #5
0
 /// <summary>
 /// The parent calls this when the mouse button is pressed
 /// </summary>
 /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
 public void MouseDown(MouseEventArgs e)
 {
     if (e.Y < headerHeight)
     {
         if (overThreshhold != null)
         {
             movingCol = overThreshhold;
         }
     }
     else
     {
         if (RowClicked != null)
         {
             RowClicked(this, e);
         }
     }
 }
예제 #6
0
        /// <summary>
        /// Adds the specified column to the collection
        /// </summary>
        /// <param name="column">The column.</param>
        public void Add(CustomListColumn column)
        {
            if (list.Contains(column))
            {
                return;
            }

            colHash[column.Title] = column;

            column.Left  = tableWidth;
            column.Index = list.Count;

            column.LeftChanged  += new CustomListColumChangedDelegate(colLeftChanged);
            column.WidthChanged += new CustomListColumChangedDelegate(colWidthChanged);
            tableWidth          += column.Width;

            list.Add(column);
        }
예제 #7
0
        private void colWidthChanged(CustomListColumn col, int amount)
        {
            tableWidth -= amount;

            if (!leftChangeLock)
            {
                leftChangeLock = true;
                for (int i = col.Index + 1; i < Count; i++)
                {
                    this[i].Left -= amount;
                }

                if (RefreshEvent != null)
                {
                    RefreshEvent();
                }
                leftChangeLock = false;
            }
        }
예제 #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
        }
예제 #9
0
		/// <summary>
		/// This method is called before another row is clicked. This is used as a 'turn off' function
		/// </summary>
		public void UnClick()
		{			
			cursorTimer.Stop();

			if(clickCol!=null && clickCol.Property!=null)
			{
				try
				{
					switch(clickCol.Property.EditType)
					{
						case EditStrType.String:
							clickCol.Property.SetValue(obj,editBuffer);
							break;
						case EditStrType.Int:
							clickCol.Property.SetValue(obj,int.Parse(editBuffer));
							break;
						case EditStrType.Float:
							clickCol.Property.SetValue(obj,double.Parse(editBuffer));
							break;
					}
				}
				catch{}
				editing=false;
			}

			clickCol=null;
			addStr="";

			FireRefresh();
		}
예제 #10
0
		/// <summary>
		/// Called when the mouse clicks on a row 
		/// </summary>
		/// <param name="col">The column the mouse was over when the button was clicked</param>
		public void Click(CustomListColumn col)
		{
			clickCol=col;
			addStr="|";
			cursorTimer.Start();
			if(col.Property!=null)
			{
				editBuffer = clickCol.Property.Value(obj).ToString();
				editing=true;
			}

			col.FireClick(this);
		}
예제 #11
0
		/// <summary>
		/// Called when the mouse leaves the row's bounding rectangle
		/// </summary>
		public void MouseLeave()
		{	
			selCol=null;
		}
예제 #12
0
		/// <summary>
		/// called when a mouse moves over the row
		/// </summary>
		/// <param name="col"></param>
		public void MouseOver(CustomListColumn col)
		{
			selCol=col;
		}
예제 #13
0
 /// <summary>
 /// called when a mouse moves over the row
 /// </summary>
 /// <param name="col"></param>
 public void MouseOver(CustomListColumn col)
 {
     selCol = col;
 }
예제 #14
0
 /// <summary>
 /// The parent calls this when the mouse button is released
 /// </summary>
 /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
 public void MouseUp(MouseEventArgs e)
 {
     movingCol = null;
 }
		private void colWidthChanged(CustomListColumn col,int amount)
		{
			tableWidth-=amount;

			if(!leftChangeLock)
			{
				leftChangeLock=true;
				for(int i=col.Index+1;i<Count;i++)
					this[i].Left-=amount;

				if(RefreshEvent!=null)
					RefreshEvent();
				leftChangeLock=false;
			}
		}
예제 #16
0
        /// <summary>
        /// Method that paints this row
        /// </summary>
        /// <param name="e"></param>
        /// <param name="yOffset"></param>
        public virtual void Render(PaintEventArgs e, int yOffset)
        {
//			base.OnPaint(e);

            if (obj != null)
            {
                int startX = 0;
                System.Drawing.RectangleF rowRect = new System.Drawing.RectangleF(
                    columns.OffX,
                    top + yOffset + 1,
                    columns.TableWidth - 1,
                    columns.Font.Height + columns.RowSpace * 2 - 1);
                if (selCol != null)
                {
                    e.Graphics.FillRectangle(Brushes.LightGreen, rowRect);
                }

                if (clickCol != null)
                {
                    System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
                        clickCol.Left,
                        top + yOffset + 1,
                        clickCol.Width,
                        columns.Font.Height + columns.RowSpace + 1);
                    e.Graphics.FillRectangle(Brushes.LightSeaGreen, rowRect);
                    e.Graphics.FillRectangle(Brushes.LightSteelBlue, rect);
                }

                for (int i = 0; i < columns.Count; i++)
                {
                    CustomListColumn col = columns[i] as CustomListColumn;

                    System.Drawing.Rectangle rect = new System.Drawing.Rectangle(
                        startX + columns.OffX,
                        top + yOffset + columns.RowSpace,
                        col.Width - 4,
                        columns.Font.Height);

                    if (clickCol == col &&
                        col.Property != null &&
                        clickCol.Property.EditType == EditStrType.Custom)
                    {
                        e.Graphics.DrawString(
                            col.Property.Value(obj).ToString() + addStr,
                            columns.Font,
                            System.Drawing.Brushes.Black,
                            rect);
                    }
                    else if (clickCol == col &&
                             col.Property != null &&
                             clickCol.Property.EditType != EditStrType.None)
                    {
                        e.Graphics.DrawString(
                            (editing ? editBuffer : col.Property.Value(obj).ToString()) + addStr,
                            columns.Font,
                            System.Drawing.Brushes.Black,
                            rect);
                    }
                    else if (col.Property != null)
                    {
                        e.Graphics.DrawString(
                            col.Property.Value(obj).ToString() + (putDecimal ? "." : ""),
                            columns.Font,
                            System.Drawing.Brushes.Black,
                            rect);
                    }

                    startX += col.Width;
                    if (selCol == col)
                    {
                        e.Graphics.DrawRectangle(Pens.Red, rect);
                    }
                }

                e.Graphics.DrawLine(
                    Pens.Black,
                    columns.OffX,
                    top + columns.Font.Height + columns.RowSpace * 2 + yOffset,
                    columns.TableWidth - 1,
                    top + columns.Font.Height + columns.RowSpace * 2 + yOffset);
            }
        }
예제 #17
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>
		/// The parent calls this when the mouse button is pressed
		/// </summary>
		/// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
		public void MouseDown(MouseEventArgs e)
		{
			if(e.Y<headerHeight)
			{
				if(overThreshhold!=null)
					movingCol=overThreshhold;
			}
			else
			{
				if(RowClicked!=null)
					RowClicked(this,e);
			}
		}
		/// <summary>
		/// The parent calls this when the mouse button is released
		/// </summary>
		/// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
		public void MouseUp(MouseEventArgs e)
		{
			movingCol=null;
		}
		private void colLeftChanged(CustomListColumn col,int amount)
		{
			if(!leftChangeLock)
			{
				if(col.Index==0)
					return;

				if(this[col.Index-1].Width-amount>=CustomListColumn.MinWidth)
				{
					leftChangeLock=true;
					this[col.Index-1].Width-=amount;

					int startX=this[col.Index-1].Width+this[col.Index-1].Left;
					for(int i=col.Index;i<Count;i++)
					{
						this[i].Left=startX;
						startX+=this[i].Width;
					}

					if(RefreshEvent!=null)
						RefreshEvent();

					leftChangeLock=false;
				}
			}
		}
예제 #21
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
		}
예제 #22
0
 /// <summary>
 /// Called when the mouse leaves the row's bounding rectangle
 /// </summary>
 public void MouseLeave()
 {
     selCol = null;
 }
예제 #23
0
		/// <summary>
		/// Adds a column to the collection
		/// </summary>
		/// <param name="column">The column to add</param>
		public void AddColumn(CustomListColumn column)
		{
			columns.Add(column);
			column.ResizeTitle(Font);
		}
		/// <summary>
		/// Adds the specified column to the collection
		/// </summary>
		/// <param name="column">The column.</param>
		public void Add(CustomListColumn column)
		{
			if (list.Contains(column))
				return;

			colHash[column.Title]=column;

			column.Left=tableWidth;
			column.Index=list.Count;

			column.LeftChanged += new CustomListColumChangedDelegate(colLeftChanged);
			column.WidthChanged += new CustomListColumChangedDelegate(colWidthChanged);
			tableWidth+=column.Width;

			list.Add(column);
		}
예제 #25
0
 /// <summary>
 /// Adds a column to the collection
 /// </summary>
 /// <param name="column">The column to add</param>
 public void AddColumn(CustomListColumn column)
 {
     columns.Add(column);
     column.ResizeTitle(Font);
 }
예제 #26
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;
		}