Miner.Interop.Framework Assembly > Miner.Interop Namespace : IMMSearchConfiguration Interface |
'Declaration <TypeLibTypeAttribute(TypeLibTypeFlags.FOleAutomation)> <GuidAttribute("66390BFC-A00A-47F9-B262-D93BB9153417")> <InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> <ComImportAttribute()> Public Interface IMMSearchConfiguration
'Usage Dim instance As IMMSearchConfiguration
[TypeLibType(TypeLibTypeFlags.FOleAutomation)] [Guid("66390BFC-A00A-47F9-B262-D93BB9153417")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport()] public interface IMMSearchConfiguration
Here is the code from the UI which passes the parameters to the search strategy (IMMSearchStrategy):
public IMMSearchConfiguration GetSearchConfiguration(mmSearchOptionFlags optionFlags) { FieldModelNameObjectClassSearchStrategy.SearchParameters searchParameters = new FieldModelNameObjectClassSearchStrategy.SearchParameters(); FeatureLayerComboBoxItem featureLayerComboBoxItem = (FeatureLayerComboBoxItem)layerComboBox.SelectedItem; IObjectClass objectClass = featureLayerComboBoxItem.FeatureLayer.FeatureClass; searchParameters.ObjectClass = objectClass; searchParameters.FieldModelName = "FACILITYID"; searchParameters.Value = facilityIDTextBox.Text; SearchConfiguration searchConfiguration = new SearchConfiguration(); searchConfiguration.SearchParameters = searchParameters; return searchConfiguration; }
Having nested classes makes some names a little long, but writing this code gets a lot of help from Visual Studio. You don't need to know anything about ESRI or PropertySets. You know exactly what types to pass in the search parameters. You don't need to worry about case sensitivity with the property names. We pass in the object class which is selected in a drop down box on the UI. We pass in the model name of the field we want to query. We finally pass in the value we are searching for from a text box in the UI. The search strategy does the rest.
The example above creates the FeatureLayerComboBoxItem class using IFeatureLayer. (IFeatureLayer is an Esri interface; refer to ArcGIS documentation for more information.) This class can be reused to help make the search strategy UIs a little easier to code. Here's an example:
class FeatureLayerComboBoxItem { public readonly IFeatureLayer FeatureLayer; public FeatureLayerComboBoxItem(IFeatureLayer featureLayer) { FeatureLayer = featureLayer; } public override string ToString() { return FeatureLayer.Name; } }
It is very common for search strategies (or locators) to provide a combo box from which to choose the layer to search. This class will help to make it easier to get the selected layer from that combo box. We simply store the feature layer in this combo box item so that we can access it from the combo box SelectedItem property. The ToString method returns the feature layer's name so that it can be displayed in the combo box. Here is how this code can be used to initialize a search strategy UI:
public void InitializeStrategyUI(IMap map, IObjectClass classFilter) { IMMModelNameManager modelNameManager = ModelNameManager.Instance; layerComboBox.Items.Clear(); IEnumLayer enumLayer = map.get_Layers(null, true); for (ILayer layer = enumLayer.Next(); layer != null; layer = enumLayer.Next()) { if (layer.Valid && layer is IFeatureLayer) { IFeatureLayer featureLayer = (IFeatureLayer)layer; if (modelNameManager.FieldFromModelName(featureLayer.FeatureClass, "FACILITYID") != null) { layerComboBox.Items.Add(new FeatureLayerComboBoxItem(featureLayer)); } } } }
Here we are iterating through all the valid feature layers and testing to see if they contain the field model name we are searching against. If we find a layer which contains that field model name, we add a new FeatureLayerComboBoxItem containing that layer to the drop down box. This makes it possible to get the selected feature layer with a single line of code in the GetSearchParameters method.
Target Platforms: Windows XP SP3 (32-bit and 64-bit), Windows 7 (32-bit and 64-bit)
Not all Operating Systems are supported on all products. Visit the ArcFM Solution Supported Versions page for full details.
'Declaration <TypeLibTypeAttribute(TypeLibTypeFlags.FOleAutomation)> <GuidAttribute("66390BFC-A00A-47F9-B262-D93BB9153417")> <InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIUnknown)> <ComImportAttribute()> Public Interface IMMSearchConfiguration
'Usage Dim instance As IMMSearchConfiguration
[TypeLibType(TypeLibTypeFlags.FOleAutomation)] [Guid("66390BFC-A00A-47F9-B262-D93BB9153417")] [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [ComImport()] public interface IMMSearchConfiguration
Here is the code from the UI which passes the parameters to the search strategy (IMMSearchStrategy):
public IMMSearchConfiguration GetSearchConfiguration(mmSearchOptionFlags optionFlags) { FieldModelNameObjectClassSearchStrategy.SearchParameters searchParameters = new FieldModelNameObjectClassSearchStrategy.SearchParameters(); FeatureLayerComboBoxItem featureLayerComboBoxItem = (FeatureLayerComboBoxItem)layerComboBox.SelectedItem; IObjectClass objectClass = featureLayerComboBoxItem.FeatureLayer.FeatureClass; searchParameters.ObjectClass = objectClass; searchParameters.FieldModelName = "FACILITYID"; searchParameters.Value = facilityIDTextBox.Text; SearchConfiguration searchConfiguration = new SearchConfiguration(); searchConfiguration.SearchParameters = searchParameters; return searchConfiguration; }
Having nested classes makes some names a little long, but writing this code gets a lot of help from Visual Studio. You don't need to know anything about ESRI or PropertySets. You know exactly what types to pass in the search parameters. You don't need to worry about case sensitivity with the property names. We pass in the object class which is selected in a drop down box on the UI. We pass in the model name of the field we want to query. We finally pass in the value we are searching for from a text box in the UI. The search strategy does the rest.
The example above creates the FeatureLayerComboBoxItem class using IFeatureLayer. (IFeatureLayer is an Esri interface; refer to ArcGIS documentation for more information.) This class can be reused to help make the search strategy UIs a little easier to code. Here's an example:
class FeatureLayerComboBoxItem { public readonly IFeatureLayer FeatureLayer; public FeatureLayerComboBoxItem(IFeatureLayer featureLayer) { FeatureLayer = featureLayer; } public override string ToString() { return FeatureLayer.Name; } }
It is very common for search strategies (or locators) to provide a combo box from which to choose the layer to search. This class will help to make it easier to get the selected layer from that combo box. We simply store the feature layer in this combo box item so that we can access it from the combo box SelectedItem property. The ToString method returns the feature layer's name so that it can be displayed in the combo box. Here is how this code can be used to initialize a search strategy UI:
public void InitializeStrategyUI(IMap map, IObjectClass classFilter) { IMMModelNameManager modelNameManager = ModelNameManager.Instance; layerComboBox.Items.Clear(); IEnumLayer enumLayer = map.get_Layers(null, true); for (ILayer layer = enumLayer.Next(); layer != null; layer = enumLayer.Next()) { if (layer.Valid && layer is IFeatureLayer) { IFeatureLayer featureLayer = (IFeatureLayer)layer; if (modelNameManager.FieldFromModelName(featureLayer.FeatureClass, "FACILITYID") != null) { layerComboBox.Items.Add(new FeatureLayerComboBoxItem(featureLayer)); } } } }
Here we are iterating through all the valid feature layers and testing to see if they contain the field model name we are searching against. If we find a layer which contains that field model name, we add a new FeatureLayerComboBoxItem containing that layer to the drop down box. This makes it possible to get the selected feature layer with a single line of code in the GetSearchParameters method.
Miner.Interop.IMMSearchConfiguration
Target Platforms: Windows XP SP3 (32-bit and 64-bit), Windows 7 (32-bit and 64-bit)
Not all Operating Systems are supported on all products. Visit the ArcFM Solution Supported Versions page for full details.