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

                this.Text               = "Fields";
                this.Name               = "Fields";
                this.ImageIndex         = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose);
                this.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen);

                //Add new nodes
                var referenceCollection = (ReferenceCollection)this.Object;

                //Save the selected item
                var selectedKey = string.Empty;
                if ((this.TreeView != null) && (this.TreeView.SelectedNode != null) && (this.Nodes.Contains(this.TreeView.SelectedNode)))
                {
                    var reference = referenceCollection.GetByKey(this.TreeView.SelectedNode.Name);
                    if (reference != null)
                    {
                        selectedKey = ((CustomStoredProcedureColumn)reference.Object).Key;
                    }
                }

                foreach (Reference reference in referenceCollection)
                {
                    if (this.Nodes.Find(reference.Key, false).Length == 0)
                    {
                        var tc = new CustomStoredProcedureColumnController(reference.Object);
                        tc.Node.Name = reference.Key;
                        tc.Node.Text = ((CustomStoredProcedureColumn)reference.Object).Name;
                        this.Nodes.Add(tc.Node);
                    }
                }

                //Rename nodes if name change
                foreach (TreeNode node in this.Nodes)
                {
                    var item = referenceCollection.FirstOrDefault(x => x.Key == node.Name);
                    if (item != null)
                    {
                        node.Text = ((CustomStoredProcedureColumn)item.Object).Name;
                    }
                }

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

                //Save the selected item
                if ((this.TreeView != null) && (!string.IsNullOrEmpty(selectedKey)))
                {
                    foreach (TreeNode node in this.Nodes)
                    {
                        var reference = referenceCollection.GetByKey(node.Name);
                        if ((reference != null) && (selectedKey == ((CustomStoredProcedureColumn)reference.Object).Key))
                        {
                            this.TreeView.SelectedNode = node;
                        }
                    }
                }

                this.Sort();

                this.Controller.UIControl.Refresh();
            }
            catch (Exception ex)
            {
                throw;
            }
        }
 public CustomStoredProcedureColumnNode(CustomStoredProcedureColumnController controller)
   : base(controller)
 {
 }
		public override void Refresh()
		{
			try
			{
				if((this.TreeView != null) && (this.TreeView.InvokeRequired))
				{
					this.TreeView.Invoke(new EmptyDelegate(this.Refresh));
					return;
				}

				this.Text = "Fields";
				this.Name = "Fields";
				this.ImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderClose);
				this.SelectedImageIndex = ImageHelper.GetImageIndex(TreeIconConstants.FolderOpen);

				//Add new nodes
				var referenceCollection = (ReferenceCollection)this.Object;

				//Save the selected item
				var selectedKey = string.Empty;
				if((this.TreeView != null) && (this.TreeView.SelectedNode != null) && (this.Nodes.Contains(this.TreeView.SelectedNode)))
				{
					var reference = referenceCollection.GetByKey(this.TreeView.SelectedNode.Name);
					if(reference != null)
						selectedKey = ((CustomStoredProcedureColumn)reference.Object).Key;
				}

				foreach(Reference reference in referenceCollection)
				{
					if(this.Nodes.Find(reference.Key, false).Length == 0)
					{
						var tc = new CustomStoredProcedureColumnController(reference.Object);
						tc.Node.Name = reference.Key;
						tc.Node.Text = ((CustomStoredProcedureColumn)reference.Object).Name;
						this.Nodes.Add(tc.Node);
					}
				}

				//Rename nodes if name change
				foreach (TreeNode node in this.Nodes)
				{
					var item = referenceCollection.FirstOrDefault(x => x.Key == node.Name);
					if (item != null) node.Text = ((CustomStoredProcedureColumn)item.Object).Name;
				}

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

				//Save the selected item      
				if((this.TreeView != null) && (!string.IsNullOrEmpty(selectedKey)))
				{
					foreach(TreeNode node in this.Nodes)
					{
						var reference = referenceCollection.GetByKey(node.Name);
						if((reference != null) && (selectedKey == ((CustomStoredProcedureColumn)reference.Object).Key))
							this.TreeView.SelectedNode = node;
					}
				}

				this.Sort();

				this.Controller.UIControl.Refresh();

			}
			catch(Exception ex)
			{
				throw;
			}

		}
예제 #4
0
 public CustomStoredProcedureColumnNode(CustomStoredProcedureColumnController controller)
     : base(controller)
 {
 }