private void UpdateTreeviewWithTypes( IRestResponse <SourceTypeResponseObject> resp, VectorIndexGeometryNode geometryNode) { var sourceNode = (VectorIndexSourceNode)geometryNode.Parent; if (resp.Data == null || resp.StatusCode != HttpStatusCode.OK) { // Remove the node from the list of checked nodes because an error occurred. this.checkedNodes.Remove(this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index]); this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Checked = false; this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Text = this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Text.Replace( GbdxResources.SearchingText, GbdxResources.Source_ErrorMessage); // Don't allow it to process further. return; } // if not using a query if (string.IsNullOrEmpty(this.query)) { this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Text = this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Text.Replace( GbdxResources.SearchingText, string.Empty); } else // if using a query { this.treeView1.Nodes[geometryNode.Index].Text = this.treeView1.Nodes[geometryNode.Index].Text.Replace(GbdxResources.SearchingText, string.Empty); } foreach (var type in resp.Data.Data) { if (string.IsNullOrEmpty(type.Name)) { continue; } var newItem = new VectorIndexTypeNode { Geometry = geometryNode.GeometryType, Type = type, Text = string.Format("{0} ({1})", type.Name, type.Count), Name = Guid.NewGuid().ToString() }; if (string.IsNullOrEmpty(this.query)) { // non query newItem.Source = sourceNode.Source; this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].ContextMenuStrip = this.CreateContextMenuStrip(this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index]); this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Nodes.Add(newItem); } else { // query newItem.Source = null; this.treeView1.Nodes[geometryNode.Index].ContextMenuStrip = this.CreateContextMenuStrip(this.treeView1.Nodes[geometryNode.Index]); this.treeView1.Nodes[geometryNode.Index].Nodes.Add(newItem); } } this.treeView1.Sort(); }
private void UpdateTreeviewWithTypes( IRestResponse<SourceTypeResponseObject> resp, VectorIndexGeometryNode geometryNode) { var sourceNode = (VectorIndexSourceNode)geometryNode.Parent; if (resp.Data == null || resp.StatusCode != HttpStatusCode.OK) { // Remove the node from the list of checked nodes because an error occurred. this.checkedNodes.Remove(this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index]); this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Checked = false; this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Text = this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Text.Replace( GbdxResources.SearchingText, GbdxResources.Source_ErrorMessage); // Don't allow it to process further. return; } // if not using a query if (string.IsNullOrEmpty(this.query)) { this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Text = this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Text.Replace( GbdxResources.SearchingText, string.Empty); } else // if using a query { this.treeView1.Nodes[geometryNode.Index].Text = this.treeView1.Nodes[geometryNode.Index].Text.Replace(GbdxResources.SearchingText, string.Empty); } foreach (var type in resp.Data.Data) { if (string.IsNullOrEmpty(type.Name)) { continue; } var newItem = new VectorIndexTypeNode { Geometry = geometryNode.GeometryType, Type = type, Text = string.Format("{0} ({1})", type.Name, type.Count), Name = Guid.NewGuid().ToString() }; if (string.IsNullOrEmpty(this.query)) { // non query newItem.Source = sourceNode.Source; this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].ContextMenuStrip = this.CreateContextMenuStrip(this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index]); this.treeView1.Nodes[sourceNode.Index].Nodes[geometryNode.Index].Nodes.Add(newItem); } else { // query newItem.Source = null; this.treeView1.Nodes[geometryNode.Index].ContextMenuStrip = this.CreateContextMenuStrip(this.treeView1.Nodes[geometryNode.Index]); this.treeView1.Nodes[geometryNode.Index].Nodes.Add(newItem); } } this.treeView1.Sort(); }