private static void RebuildIndex()
        {
            if (GisEditor.LayerListManager.SelectedLayerListItem == null)
            {
                return;
            }
            ShapeFileFeatureLayer layer = GisEditor.LayerListManager.SelectedLayerListItem.ConcreteObject as ShapeFileFeatureLayer;

            if (layer != null)
            {
                BuildIndexFileDialog dialog = new BuildIndexFileDialog();

                if (dialog.ShowDialog().GetValueOrDefault())
                {
                    BuildIndexFileDialog.BuildIndexInBackgroundThread(layer);
                }
            }
        }
        private void BuildIndexSync(Collection <FeatureLayer> pendingLayersToBuildIndex, Collection <FeatureLayer> pendingLayersToBuildInBackground, ref BuildLargeIndexMode buildLargeIndexMode)
        {
            bool applyForAll = false;
            bool canceled    = false;

            Collection <FeatureLayer> notAddLayers = new Collection <FeatureLayer>();

            if (pendingLayersToBuildIndex.Count > 0)
            {
                foreach (var featureLayer in pendingLayersToBuildIndex)
                {
                    if (!applyForAll)
                    {
                        BuildIndexFileDialog buildIndexDialog = new BuildIndexFileDialog();
                        buildIndexDialog.HasMultipleFiles = pendingLayersToBuildIndex.Count > 1;
                        if (buildIndexDialog.ShowDialog().GetValueOrDefault())
                        {
                            canceled = false;
                            if (buildIndexDialog.BuildIndexFileMode == BuildIndexFileMode.BuildAll)
                            {
                                applyForAll = true;
                            }
                        }
                        else
                        {
                            canceled = true;
                            if (buildIndexDialog.BuildIndexFileMode == BuildIndexFileMode.DoNotBuildAll)
                            {
                                applyForAll = true;
                            }
                        }
                    }

                    if (applyForAll && canceled)
                    {
                        break;
                    }
                    else if (canceled)
                    {
                        continue;
                    }

                    if (CheckIsBuildSync(featureLayer))
                    {
                        BuildIndexSync(featureLayer);
                    }
                    else
                    {
                        if (!applyForAll || buildLargeIndexMode == BuildLargeIndexMode.Unknown)
                        {
                            BuildLargeIndexSyncWindow buildLargeIndexWindow = new BuildLargeIndexSyncWindow();
                            buildLargeIndexWindow.FileName = featureLayer.Name;
                            if (buildLargeIndexWindow.ShowDialog().GetValueOrDefault())
                            {
                                buildLargeIndexMode = buildLargeIndexWindow.BuildLargeIndexMode;
                            }
                        }

                        switch (buildLargeIndexMode)
                        {
                        case BuildLargeIndexMode.NormalBuild:
                            BuildIndexSync(featureLayer);
                            break;

                        case BuildLargeIndexMode.DoNotAdd:
                            featureLayer.IsVisible = false;
                            notAddLayers.Add(featureLayer);
                            break;

                        case BuildLargeIndexMode.BackgroundBuild:
                            featureLayer.IsVisible = false;
                            pendingLayersToBuildInBackground.Add(featureLayer);
                            break;

                        case BuildLargeIndexMode.DoNotBuild:
                        default:
                            break;
                        }
                    }
                }
            }

            if (notAddLayers.Count > 0)
            {
                notAddLayers.ForEach(l => pendingLayersToBuildIndex.Remove(l));
            }
        }