Inheritance: nHydrate.Generator.Common.GeneratorFramework.BaseModelObjectController
		public override void Refresh()
		{
			if ((this.TreeView != null) && (this.TreeView.InvokeRequired))
			{
				this.TreeView.Invoke(new EmptyDelegate(this.Refresh));
				return;
			}

			this.Text = "Entities";
			this.Name = "Entities";
			this.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.Tables);
			this.SelectedImageIndex = this.ImageIndex;

			this.Nodes.Clear();
			var cellEntryCollection = (CellEntryCollection)this.Object;
			foreach (CellEntry element in cellEntryCollection)
			{
				var tc = new TableController(element);
				this.Nodes.Add(tc.Node);
			}

			this.Controller.UIControl.Refresh();

		}
Example #2
0
		public TableNode(TableController controller)
			: base(controller)
		{
		}
Example #3
0
		public override void Refresh()
		{
			try
			{
				if ((this.TreeView != null) && (this.TreeView.InvokeRequired))
				{
					this.TreeView.Invoke(new EmptyDelegate(this.Refresh));
					return;
				}

				if (this.TreeView != null)
					this.TreeView.BeginUpdate();

				this.Text = "Entities";
				this.Name = "Entities";
				this.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.Tables);
				this.SelectedImageIndex = this.ImageIndex;

				var tableCollection = (TableCollection)this.Object;

				//Add new nodes      
				foreach (Table table in tableCollection)
				{
					if (this.Nodes.Find(table.Key, false).Length == 0)
					{
						var tc = new TableController(table);
						tc.Node.Name = table.Key;
						tc.Node.Text = table.Name;
						this.Nodes.Add(tc.Node);
					}
				}

				//Use a hash table for speed
				var tableCache = new Hashtable();
				foreach (Table table in tableCollection)
					tableCache.Add(table.Key, table);

				//Rename nodes if name change
				foreach (TreeNode node in this.Nodes)
				{
					if (tableCache.ContainsKey(node.Name))
					{
						var item = (Table)tableCache[node.Name];
						//var item = tableCollection.FirstOrDefault(x => x.Key == node.Name);
						if ((item != null) && (node.Text != item.Name)) node.Text = item.Name;
					}
				}

				//Remove non-existing nodes
				for (var ii = this.Nodes.Count - 1; ii >= 0; ii--)
				{
					var node = (TableNode)this.Nodes[ii];
					if (!tableCollection.Contains(node.Text))
					{
						this.Nodes.RemoveAt(ii);
					}
				}

				this.Sort();
				this.Controller.UIControl.Refresh();
				this.Expand();
			}
			catch (Exception ex)
			{
				throw;
			}
			finally
			{
				if (this.TreeView != null) 
					this.TreeView.EndUpdate();
			}

		}