FeatureExplorerControl user control

Land Desktop Map 3D Samples

 
FeatureExplorerControl user control
 
 
 

When the FeatureExplorerControl is first created, it does the following:

  1. Adds events handlers for when the items in the data grid are modified, when the view of the data grid is changed, and a property in the grid is changed.
  2. Gets a reference to the current map, an object of type AcMapMap.
  3. Creates a data binding object and assigns the current map’s list of layers as the data source.
  4. Creates a Windows Forms combo box object to wrap the WPF combo box, which does not have a data binding feature. It then connects the combo box to the previously created data binding. The combo box will now always list the names of all the layers in the current Map document.
  5. Add event handlers for when features are selected or deselected in the current Map document.

The following are the actions taken by the FeatureExplorerControl user control in response to user input:

  • OnGridSelectedItemsChanged - Modifies the list of selected features in the document to match changes of selected features in the FeatureExplorer form.
    1. Creates an instance of the MgPropertyDefinitionCollection class to hold the property names from the layer’s class definition.
    2. Creates an instance of the MgBatchPropertyCollection class to hold all the properties of all the features to be displayed in the grid.
    3. Loops through all the selected rows in the grid.
    4. For each row, creates a MgPropertyCollection object. It then loops through all the property definitions in the MgPropertyDefinitionCollection object to find property titles that match column titles in the data grid. When a match is found, creates a new MgProperty object to contain the property name and value pair, and adds it to the MgPropertyCollection object. It then adds the MgPropertyCollection object representing a single feature to the MgBatchPropertyCollection object, which will contain the new list of selected features.
    5. Calls the AcMapFeatureEntityService.UnhighlightFeatures method to unhighlight the currently selected features in the document.
    6. Builds a AcMapSelection object with the list of features in the MgBatchPropertyCollection object.
    7. Calls the AcMapFeatureEntityService.HighlightFeatures method to highlight the new list of selected features.
  • OnGridViewChanged - Responds to requests to change the theme of the data grid.
    1. Calls the SetTheme function to change the appearance of the data grid control.
  • layers_SelectionChanged
    1. Gets the AcMapLayer object associated with the currently selected layer in the layers combo box through the data binding.
    2. Creates a MgFeatureReader object to hold the collection of selected features within the layer and a MgClassDefinition object to hold the layer class definition.
    3. Using both the MgFeatureReader object and the MgClassDefinition object, calls the GetFeatures function to get a MgBatchPropertyCollection object containing all the property collections of all the selected features.
    4. Calls the BindDataGrid function to create a DataTable of the list of selected features and to bind the data grid to this DataTable.
  • tabControl_SelectionChanged
    1. Gets a reference to the TabItem object representing the new selection in the tabControl control.
    2. If the user selected the tab to list all features, then the function ends. If the user selected the tab to list only selected features, then the function continues.
    3. Gets a reference to the AutoCAD Editor object.
    4. Calls the Editor.SelectImplied method, which makes the editor think that a selection happened. This means that the ed_SlectionAdded event will fire, and it will be passed a list of the already selected items.
  • ed_SelectionAdded - Triggered when features in the document are selected.
    1. Calls the ShowFeatures function with the list of just selected items.
    2. ShowFeatures calls the AcMapFeatureEntityService.GetSelection method to get a list of selected items.
    3. ShowFeatures creates a MgReadOnlyLayerCollection collection of all the layers that the selected features reside in.
    4. For each layer, Show Features uses both Windows and third part controls to create a list of grids which , using data-binding, list the properties of the selected features within that layer. It also creates the saveToSDF, SaveToExistingSDF, and filterBtn buttons and adds the event handlers for each. The saveToSDF and SaveToExistingSDF buttons are given tags consisting of a SelectedLayerData object containing a list of selected features.
  • ed_SelectionRemoved - Triggered when features in the document are deselected.
    1. Calls the ShowFeatures function with the list of just deselected items. See ed_SelectionAdded for information on the ShowFeatures function.
  • SaveToExistingSDF_Click
    1. Gets the SelectedLayerData object from the button Tag property which contains a list of selected features.
    2. Creates an OpenFileDialog to allow the user to select an existing SDF file.
    3. Calls the SaveLayerData function to add the selected features to the specified SDF file.
  • saveToSDF_Click
    1. Gets the SelectedLayerData object from the button Tag property which contains a list of selected features.
    2. Creates a SaveFileDialog to allow the user to select the location and name for the new SDF file.
    3. Calls the SaveLayerData function to create a new SDF file and add the selected features to it.
  • expander_Expanded
    1. Calls the OnGridViewChanged function.
    2. OnGridViewChanged only functions when the “Layer data” tab is selected.
    3. OnGridViewChanged creates a Windows Control ScrollViewer object to wrap the WPF component containing all the controls in this tab.
    4. For each of the controls in the tab, OnGridViewChanged checks to see if it is a Xceed DataGridControl. If it is, it calls the SetTheme function to set the graphical style of that grid to the new style.
  • filterBtn_Click
    1. Creates a new FilterSelectedDataWindow, which is a WPF form defined in the FilterSelectedDataWindow.xaml and FilterSelectedDataWindow.xaml.cs files.
    2. Gets the SelectedLayerData object containing a list of selected features from tbe filterBtn Tag property.
    3. Calls the AutoCAD Application.ShowModalWindow method to display the FilterSelectedDataWindow form.
    4. Retrieves a string containing the filter from the filterWindow form.
    5. Gets the MgBatchPropertyCollection object containing the selected features and the MgClassDefinition object containing hte feature class definition from the SelectedLayerData object.
    6. Creates an instance of the MgPropertyDefinitionCollection class to hold the property names from the layer’s class definition.
    7. each feature’s set of properties in the MgBatchPropertyCollection object
NoteThere are also a large number of event handlers which control the appearance of the data grid control.