//Apply the new settings to the temporal feature class private void btnApply_Click(object sender, EventArgs e) { try { ILayer lyr = GetSelectedLayer(); if (lyr != null) { ITemporalFeatureClass temporalFC = (ITemporalFeatureClass)((IFeatureLayer)lyr).FeatureClass; if (temporalFC != null) { temporalFC.AutoPurge = checkAutoPurge.Checked; //only set the other properties if Auto Purge is true if (checkAutoPurge.Checked) { temporalFC.PurgeRule = (enumPurgeRule)cbPurgeRule.SelectedIndex; temporalFC.Threshold = Convert.ToInt32(txtThreshold.Text); temporalFC.PurgePercentage = Convert.ToDouble(txtPurgePercent.Text); } } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); } }
//Repopulate the dialog controls when a different layer is selected private void cbTrackingLayers_SelectionChangeCommitted(object sender, EventArgs e) { ILayer lyr = GetSelectedLayer(); if (lyr != null) { ITemporalFeatureClass temporalFC = ((IFeatureLayer)lyr).FeatureClass as ITemporalFeatureClass; LoadDialogFromFeatureClassSettings(temporalFC); } }
//Set the dialog controls according to the settings of the specified temporal feature class private void LoadDialogFromFeatureClassSettings(ITemporalFeatureClass temporalFC) { //If no feature class is specified clear all the controls if (temporalFC == null) { btnApply.Enabled = false; checkAutoPurge.Checked = false; cbPurgeRule.SelectedIndex = 0; txtThreshold.Text = ""; txtPurgePercent.Text = ""; return; } btnApply.Enabled = true; checkAutoPurge.Checked = temporalFC.AutoPurge; cbPurgeRule.SelectedIndex = (int)temporalFC.PurgeRule; txtThreshold.Text = Convert.ToString(temporalFC.Threshold); txtPurgePercent.Text = Convert.ToString(temporalFC.PurgePercentage); }
//Set the dialog controls according to the settings of the specified temporal feature class private void LoadDialogFromFeatureClassSettings(ITemporalFeatureClass temporalFC) { //If no feature class is specified clear all the controls if (temporalFC == null) { btnApply.Enabled = false; checkAutoPurge.Checked = false; cbPurgeRule.SelectedIndex = 0; txtThreshold.Text = ""; txtPurgePercent.Text = ""; return; } btnApply.Enabled = true; checkAutoPurge.Checked = temporalFC.AutoPurge; cbPurgeRule.SelectedIndex = (int)temporalFC.PurgeRule; txtThreshold.Text = Convert.ToString(temporalFC.Threshold); txtPurgePercent.Text = Convert.ToString(temporalFC.PurgePercentage); }