thientung / winforms-geplugin-control-library

Automatically exported from code.google.com/p/winforms-geplugin-control-library
GNU General Public License v3.0
0 stars 0 forks source link

KmlTreeView->Refresh does not refresh the node labels after the correspondent KmlObject names changed #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create a placemark and name it with setName("Name1") method
2. Create KmlTreeView and add the placemark with ParseKmlObject(pm) method. 
You'll see a new node in the tree labeled as "Name1".
3. Change the placemark name to "Name2"
4. Call Refresh method of the KmlTreeView

What is the expected output? What do you see instead?
Expected to see the node with changed name "Name2" after the refresh. Instead 
you see the old name in the KmlTreeView

What version of the product are you using? On what operating system?
Use the latest revision of the plugin-control-library on Windows Vista

Original issue reported on code.google.com by alex.nes...@3dcondox.com on 29 Dec 2011 at 11:34

GoogleCodeExporter commented 9 years ago
Actually I found that same problem happens with ApiObjectVisible and other 
properties of nodes - you just do not refresh them. I suggest to add the 
following public method to your KmlTreeViewNode class:

        public void RefreshNode()
        {
            try
            {
                this.Name = this.ApiObject.getId();
                this.ApiType = GEHelpers.GetApiType(this.ApiObject);
                this.Text = this.ApiObject.getName();
                this.ApiObjectVisible = Convert.ToBoolean(this.ApiObject.getVisibility());
                this.StateImageIndex = this.ApiObjectVisible ? 1 : 0;
                this.Checked = this.ApiObjectVisible;
            }
            catch (RuntimeBinderException)
            {
            }
        }

In this case the constructor of this class will be turned into:

        /// <summary>
        /// Initializes a new instance of the KmlTreeViewNode class.
        /// </summary>
        /// <param name="kmlObject">A kml object to base the treenode on</param>
        internal KmlTreeViewNode(dynamic kmlObject)
            : base()
        {
            this.ApiObject = kmlObject;
            RefreshNode();

            this.SetStyle();
        }

... , and the KmlTreeView->Refresh method will have to call the 
KmlTreeViewNode->RefreshNode method - something like this:

        public override void Refresh()
        {
            [...]

            Stack<KmlTreeViewNode> stack =
                new Stack<KmlTreeViewNode>(this.Nodes.Count);

            foreach (KmlTreeViewNode node in this.Nodes)
            {
                node.RefreshNode(); // Refreshing internal properties of each node
                stack.Push(node);
            }

            [...]
        }

Alexander ;o)

Original comment by alex.nes...@3dcondox.com on 30 Dec 2011 at 6:24

GoogleCodeExporter commented 9 years ago
Many thanks for this Alexander, I have actually just been updating the  
KmlTreeView, KmlTreeViewNode and GEServer classes to introduce richer support 
for NetworkLinks and I have included this functionality. Not sure how I missed 
that, great catch!

Thanks,

Fraser

Original comment by fraser.c...@gmail.com on 7 Feb 2012 at 8:29

GoogleCodeExporter commented 9 years ago

Original comment by fraser.c...@gmail.com on 8 Feb 2012 at 6:22