/// <summary> /// Occurs when the user clicks the Save button. /// The barrier information is collected out of the junction and edge barrier /// dataGrids, then stored back into the original barrier feature as a replacement /// to the existing barrier information. The original geometry of the barrier remains /// unaltered. /// <param name="sender">The control raising this event</param> /// <param name="e">Arguments associated with the event</param> /// </summary> private void btnSave_Click(object sender, EventArgs e) { if (!ValidateDataGrid(dataGridViewEdges)) { return; } if (!ValidateDataGrid(dataGridViewJunctions)) { return; } // The existing NALocationRanges for the barrier will be replaced with a new one INALocationRanges naLocRanges = new NALocationRangesClass(); // First gather the edge ranges foreach (DataGridViewRow row in dataGridViewEdges.Rows) { // ignore the extra row in the dataGrid if (row.IsNewRow) { continue; } // gather the EID value for the new range int eid = Int32.Parse(row.Cells[0].Value.ToString()); // gather the edge direction value for the new range string directionValue = row.Cells[1].Value.ToString(); esriNetworkEdgeDirection direction = esriNetworkEdgeDirection.esriNEDNone; if (directionValue == EDGE_ALONG) { direction = esriNetworkEdgeDirection.esriNEDAlongDigitized; } else if (directionValue == EDGE_AGAINST) { direction = esriNetworkEdgeDirection.esriNEDAgainstDigitized; } // gather the from and to position values for the new range double fromPos = Double.Parse(row.Cells[2].Value.ToString()); double toPos = Double.Parse(row.Cells[3].Value.ToString()); // load the values for this range into the NALocationRanges object naLocRanges.AddEdgeRange(eid, direction, fromPos, toPos); } // Now gather the junctions to be included in the barrier foreach (DataGridViewRow row in dataGridViewJunctions.Rows) { // ignore the extra row in the dataGrid if (row.IsNewRow) { continue; } // gather the EID value for the junction to include int eid = Int32.Parse(row.Cells[0].Value.ToString()); // load this junction into the NALocationRanges object naLocRanges.AddJunction(eid); } // Cast the barrier feature to INALocationRanges Object, then populate // its NALocationRanges value with the new barrier that was created above. // Then, save the new barrier with a call to Store() INALocationRangesObject naLocationRangesObject = m_barrier as INALocationRangesObject; naLocationRangesObject.NALocationRanges = naLocRanges; m_barrier.Store(); this.Close(); }
/// <summary> /// Occurs when the user clicks the Save button. /// The barrier information is collected out of the junction and edge barrier /// dataGrids, then stored back into the original barrier feature as a replacement /// to the existing barrier information. The original geometry of the barrier remains /// unaltered. /// <param name="sender">The control raising this event</param> /// <param name="e">Arguments associated with the event</param> /// </summary> private void btnSave_Click(object sender, EventArgs e) { if (!ValidateDataGrid(dataGridViewEdges)) return; if (!ValidateDataGrid(dataGridViewJunctions)) return; // The existing NALocationRanges for the barrier will be replaced with a new one INALocationRanges naLocRanges = new NALocationRangesClass(); // First gather the edge ranges foreach (DataGridViewRow row in dataGridViewEdges.Rows) { // ignore the extra row in the dataGrid if (row.IsNewRow) continue; // gather the EID value for the new range int eid = Int32.Parse(row.Cells[0].Value.ToString()); // gather the edge direction value for the new range string directionValue = row.Cells[1].Value.ToString(); esriNetworkEdgeDirection direction = esriNetworkEdgeDirection.esriNEDNone; if (directionValue == EDGE_ALONG) direction = esriNetworkEdgeDirection.esriNEDAlongDigitized; else if (directionValue == EDGE_AGAINST) direction = esriNetworkEdgeDirection.esriNEDAgainstDigitized; // gather the from and to position values for the new range double fromPos = Double.Parse(row.Cells[2].Value.ToString()); double toPos = Double.Parse(row.Cells[3].Value.ToString()); // load the values for this range into the NALocationRanges object naLocRanges.AddEdgeRange(eid, direction, fromPos, toPos); } // Now gather the junctions to be included in the barrier foreach (DataGridViewRow row in dataGridViewJunctions.Rows) { // ignore the extra row in the dataGrid if (row.IsNewRow) continue; // gather the EID value for the junction to include int eid = Int32.Parse(row.Cells[0].Value.ToString()); // load this junction into the NALocationRanges object naLocRanges.AddJunction(eid); } // Cast the barrier feature to INALocationRanges Object, then populate // its NALocationRanges value with the new barrier that was created above. // Then, save the new barrier with a call to Store() INALocationRangesObject naLocationRangesObject = m_barrier as INALocationRangesObject; naLocationRangesObject.NALocationRanges = naLocRanges; m_barrier.Store(); this.Close(); }