Ejemplo n.º 1
0
        private bool CheckGroupHeight(TableItem check, TableGroup parent, ref float height)
        {
            height += GroupHeight;

            if (parent.Expanded)
            {
                //Add sub groups
                foreach (TableGroup subgroup in parent.Groups)
                {
                    if (subgroup == check)
                    {
                        return(true);
                    }
                    if (CheckGroupHeight(check, subgroup, ref height))
                    {
                        return(true);
                    }
                }

                //Add sub rows
                if (GetRowsHeight(check, parent, ref height))
                {
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        //Returns the first visible group or row from the item provided.
        private TableItem GetVisibleItem(TableItem item)
        {
            List <TableItem> list = new List <TableItem>();

            list.Add(item);

            TableItem child = item;

            //Create a list parent items
            while (child.Parent != null)
            {
                list.Insert(0, child.Parent);
                child = child.Parent;
            }

            //Loop through list and find bottom most viisble item
            foreach (TableItem loop in list)
            {
                if (loop is TableGroup)
                {
                    TableGroup group = loop as TableGroup;
                    if (!group.Expanded)
                    {
                        return(group);
                    }
                }
            }

            return(item);
        }
Ejemplo n.º 3
0
        //Fired when a group or top level row is added to the table
        private void TableItems_InsertItem(object sender, TableItemsEventArgs e)
        {
            TableItem item = e.Value;

            //Set common values and event handlers for row or group
            item.SetTable(this);
            item.Backcolor = GradientColor;

            //If is a row then set the indent
            if (item is TableRow)
            {
                item.SetIndent(Indent);
            }

            if (item is TableGroup)
            {
                TableGroup group = (TableGroup)item;
                group.HeightChanged   += new EventHandler(TableGroup_HeightChanged);
                group.ExpandedChanged += new ExpandedChangedEventHandler(TableGroup_ExpandedChanged);

                //Set all the table references correctly
                group.SetTable();
            }

            item.TableItemInvalid += new EventHandler(TableItems_TableItemInvalid);

            SetHeight();

            //Make sure diagram is redrawn
            OnElementInvalid();
        }
Ejemplo n.º 4
0
        private TableItem GetGroupTableItem(TableGroups groups, PointF local, ref float currentHeight)
        {
            //Check the groups and each rows collection inside groups
            foreach (TableGroup tableGroup in groups)
            {
                if (local.Y >= currentHeight && local.Y <= currentHeight + GroupHeight)
                {
                    return(tableGroup);
                }
                currentHeight += GroupHeight;

                if (tableGroup.Expanded)
                {
                    TableItem item = GetGroupTableItem(tableGroup.Groups, local, ref currentHeight);
                    if (item != null)
                    {
                        return(item);
                    }

                    foreach (TableRow tableRow in tableGroup.Rows)
                    {
                        if (local.Y >= currentHeight && local.Y <= currentHeight + GroupHeight)
                        {
                            return(tableRow);
                        }
                        currentHeight += RowHeight;
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 5
0
        public override void LocatePort(Port port)
        {
            if (port is TablePort)
            {
                TablePort tablePort = port as TablePort;
                if (tablePort.TableItem == null)
                {
                    base.LocatePort(port);
                    return;
                }

                //Calculate position of port based on position of table item
                TableItem visibleItem = GetVisibleItem(tablePort.TableItem);

                PointF start = TransformRectangle.Location;
                start.Y += visibleItem.Rectangle.Top + (visibleItem.Rectangle.Height / 2);

                //Determine which side of the shape the port should be placed
                if (tablePort.Orientation == PortOrientation.Right)
                {
                    start.X += visibleItem.Rectangle.Width;
                }

                tablePort.Validate = false;
                tablePort.Location = start;
                tablePort.Validate = true;
            }
            else
            {
                base.LocatePort(port);
            }
        }
Ejemplo n.º 6
0
        public virtual PointF GetItemPosition(TableItem item)
        {
            float height = HeadingHeight + 2;

            //Add top level groups
            foreach (TableGroup group in Groups)
            {
                if (group == item)
                {
                    return(new PointF(0, height));
                }
                if (CheckGroupHeight(item, group, ref height))
                {
                    return(new PointF(0, height));
                }
            }

            //Add top level rows
            foreach (TableRow row in Rows)
            {
                if (row == item)
                {
                    return(new PointF(0, height));
                }
                height += RowHeight;
            }

            return(Point.Empty);
        }
Ejemplo n.º 7
0
        public virtual bool ExecuteMouseCommand(MouseCommand command)
        {
            //Only consider left button
            if (command.MouseButtons != MouseCommandButtons.Left)
            {
                return(false);
            }

            //Only process mouse down
            if (command is MouseDownCommand)
            {
                PointF location = command.Location; //view.PointToDiagram(e.X, e.Y);
                PointF local    = PointToElement(location);

                TableItem old = SelectedItem;
                SelectedItem = GetTableItemFromLocation(local);
                if (SelectedItem != old && Selected)
                {
                    return(true);
                }

                //Check to see if any groups can be expanded
                TableGroup group = GetTableGroupExpander(Groups, local);
                if (group != null)
                {
                    group.Expanded = !group.Expanded;
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 8
0
		//Inserts an elelemnt into the list
		public virtual void Insert(int index, TableItem value)  
		{
			if (value == null) throw new ArgumentNullException("TableItem parameter cannot be null reference.","value");
			if (! mBaseType.IsInstanceOfType(value) && ! value.GetType().IsSubclassOf(mBaseType)) throw new ArgumentException("Items added to this collection must be of or inherit from type '" + mBaseType.ToString());
			List.Insert(index, value);

			if (! mSuspendEvents && InsertItem!=null) InsertItem(this, new TableItemsEventArgs((TableItem) value));
		}
Ejemplo n.º 9
0
        //Removes an TableItem from the list
        public virtual void Remove(TableItem value)
        {
            List.Remove(value);

            if (!mSuspendEvents && RemoveItem != null)
            {
                RemoveItem(this, new TableItemsEventArgs((TableItem)value));
            }
        }
Ejemplo n.º 10
0
 public TableItem(TableItem prototype)
 {
     mText      = prototype.Text;
     mFont      = prototype.Font;
     mForecolor = prototype.Forecolor;
     mBackcolor = prototype.Backcolor;
     mIndent    = prototype.Indent;
     mTag       = prototype.Tag;
     mParent    = prototype.Parent;
     mTable     = prototype.Table;
 }
Ejemplo n.º 11
0
 public TableItem(TableItem prototype)
 {
     _text      = prototype.Text;
     _font      = prototype.Font;
     _forecolor = prototype.Forecolor;
     _backcolor = prototype.Backcolor;
     _indent    = prototype.Indent;
     _tag       = prototype.Tag;
     _parent    = prototype.Parent;
     _table     = prototype.Table;
 }
Ejemplo n.º 12
0
		public TableItem(TableItem prototype)
		{
			mText = prototype.Text;
			mFont = prototype.Font;
			mForecolor = prototype.Forecolor;
			mBackcolor = prototype.Backcolor;
			mIndent = prototype.Indent;
			mTag = prototype.Tag;
			mParent = prototype.Parent;
			mTable = prototype.Table;
		}
Ejemplo n.º 13
0
        private bool GetRowsHeight(TableItem check, TableGroup parent, ref float height)
        {
            //Add top level rows
            foreach (TableRow row in parent.Rows)
            {
                if (row == check)
                {
                    return(true);
                }
                height += RowHeight;
            }

            return(false);
        }
Ejemplo n.º 14
0
        private void TableItems_RemoveItem(object sender, TableItemsEventArgs e)
        {
            TableItem item = e.Value;

            //Remove handlers
            if (item is TableGroup)
            {
                TableGroup group = (TableGroup)item;
                group.HeightChanged   -= new EventHandler(TableGroup_HeightChanged);
                group.ExpandedChanged -= new ExpandedChangedEventHandler(TableGroup_ExpandedChanged);
            }
            item.TableItemInvalid -= new EventHandler(TableItems_TableItemInvalid);

            SetHeight();
            OnElementInvalid();
        }
Ejemplo n.º 15
0
        //Inserts an elelemnt into the list
        public virtual void Insert(int index, TableItem value)
        {
            if (value == null)
            {
                throw new ArgumentNullException("TableItem parameter cannot be null reference.", "value");
            }
            if (!mBaseType.IsInstanceOfType(value) && !value.GetType().IsSubclassOf(mBaseType))
            {
                throw new ArgumentException("Items added to this collection must be of or inherit from type '" + mBaseType.ToString());
            }
            List.Insert(index, value);

            if (!mSuspendEvents && InsertItem != null)
            {
                InsertItem(this, new TableItemsEventArgs((TableItem)value));
            }
        }
Ejemplo n.º 16
0
		public virtual PointF GetItemPosition(TableItem item)
		{
			float height = HeadingHeight + 2;

			//Add top level groups
			foreach (TableGroup group in Groups)
			{
				if (group == item) return new PointF(0, height);
				if (GetGroupHeight(item, group, ref height)) return new PointF(0, height);
			}
			
			//Add top level rows
			foreach (TableRow row in Rows)
			{
				if (row == item) return new PointF(0, height);
				height += RowHeight;
			}
			
			return Point.Empty;
		}
Ejemplo n.º 17
0
		private bool GetGroupHeight(TableItem check, TableGroup parent, ref float height)
		{
			height += GroupHeight;
			
			if (parent.Expanded) 
			{
				//Add sub groups
				foreach (TableGroup subgroup in parent.Groups)
				{
					if (subgroup == check) return true;
					if (GetGroupHeight(check, subgroup, ref height)) return true;
				}

				//Add sub rows
				if (GetRowsHeight(check, parent, ref height)) return true;
			}

			return false;
		}
Ejemplo n.º 18
0
		private bool GetRowsHeight(TableItem check, TableGroup parent, ref float height)
		{
			//Add top level rows
			foreach (TableRow row in parent.Rows)
			{
				if (row == check) return true;
				height += RowHeight;
			}

			return false;
		}
Ejemplo n.º 19
0
		//Returns true if list contains TableItem
		public virtual bool Contains(TableItem value)  
		{
			return List.Contains(value);
		}
Ejemplo n.º 20
0
		public TableItemsEventArgs(TableItem value)
		{
			mValue = value;
		}
Ejemplo n.º 21
0
		//Returns the index of an TableItem
		public virtual int IndexOf(TableItem value)  
		{
			return List.IndexOf(value);
		}
Ejemplo n.º 22
0
		//Sets the internal table reference
		protected internal virtual void SetParent(TableItem parent)
		{
			mParent = parent;
		}
Ejemplo n.º 23
0
 private void ResetTable(TableItem item, Table table) {
     if (item is TableRow) {
         TableRow tableRow = (TableRow)item;
         if (tableRow is EsriTableRow) {
             ((EsriTableRow)tableRow).SetTable2(table);
         }
     }
     else if (item is TableGroup) {
         TableGroup tableGroup = (TableGroup)item;
         if (tableGroup is EsriTableGroup) {
             ((EsriTableGroup)tableGroup).SetTable2(table);
         }
         foreach (TableItem item2 in tableGroup.Groups) {
             this.ResetTable(item2, table);
         }
         foreach (TableItem item3 in tableGroup.Rows) {
             this.ResetTable(item3, table);
         }
     }
 }
Ejemplo n.º 24
0
 //Sets the internal table reference
 protected internal virtual void SetParent(TableItem parent)
 {
     _parent = parent;
 }
Ejemplo n.º 25
0
 public TableItemsEventArgs(TableItem value)
 {
     mValue = value;
 }
Ejemplo n.º 26
0
 //Returns the index of an TableItem
 public virtual int IndexOf(TableItem value)
 {
     return(List.IndexOf(value));
 }
Ejemplo n.º 27
0
 //Returns true if list contains TableItem
 public virtual bool Contains(TableItem value)
 {
     return(List.Contains(value));
 }
Ejemplo n.º 28
0
 public TablePort(TableItem tableItem) : base(0F)
 {
     TableItem = tableItem;
     Fixed     = true;
 }
Ejemplo n.º 29
0
		//Removes an TableItem from the list
		public virtual void Remove(TableItem value )  
		{
			List.Remove(value);

			if (! mSuspendEvents && RemoveItem!=null) RemoveItem(this, new TableItemsEventArgs((TableItem) value));
		}