private void AddMenuItems()
        {
            if (CanRename)
            {
                MenuItem renameFileItem = new MenuItem();
                renameFileItem.Header  = GisEditor.LanguageManager.GetStringResource("DataRepositoryRenameMenuItemLabel");
                renameFileItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/rename.png", 16, 16);
                renameFileItem.Command = new RelayCommand(() => DataRepositoryContentViewModel.SelectedDataRepositoryItem.IsRenaming = true);
                ContextMenu.Items.Add(renameFileItem);
            }

            if (fileInfo.Extension.Equals(".csv", StringComparison.InvariantCultureIgnoreCase))
            {
                MenuItem editConfigItem = new MenuItem();
                editConfigItem.Header  = GisEditor.LanguageManager.GetStringResource("DataRepositoryEditColumnMappingMenuItemLabel");
                editConfigItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/dr_edit.png", 16, 16);
                editConfigItem.Command = new RelayCommand(() =>
                {
                    try
                    {
                        var configFilePath              = fileInfo.FullName + ".config";
                        CSVInfoModel csvInfoModel       = File.Exists(configFilePath) ? CSVInfoModel.FromConfig(configFilePath) : new CSVInfoModel(fileInfo.FullName, ",");
                        CSVConfigWindow csvConfigWindow = new CSVConfigWindow(new CSVViewModel(new Collection <CSVInfoModel> {
                            csvInfoModel
                        }));
                        csvConfigWindow.ShowDialog();
                    }
                    catch (Exception ex)
                    {
                        GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                        System.Windows.Forms.MessageBox.Show(ex.Message, GisEditor.LanguageManager.GetStringResource("DataRepositoryWarningLabel"));
                    }
                });
                ContextMenu.Items.Add(editConfigItem);
            }

            MenuItem showInWindowsExplorerItem = new MenuItem();

            showInWindowsExplorerItem.Header  = GisEditor.LanguageManager.GetStringResource("ShowInWindowsExplorerMenuItemLabel");
            showInWindowsExplorerItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/windows explorer.png", 16, 16);
            showInWindowsExplorerItem.Command = new ObservedCommand(() => ProcessUtils.OpenPath(fileInfo.FullName), () => fileInfo != null && File.Exists(fileInfo.FullName));
            ContextMenu.Items.Add(showInWindowsExplorerItem);

            MenuItem propertyItem = new MenuItem();

            propertyItem.Icon    = DataRepositoryHelper.GetMenuIcon("/GisEditorPluginCore;component/Images/properties.png", 16, 16);
            propertyItem.Header  = "Properties";
            propertyItem.Command = new RelayCommand(() =>
            {
                GetLayersParameters getLayersParameters = new GetLayersParameters();
                getLayersParameters.LayerUris.Add(new Uri(fileInfo.FullName));
                Layer layer             = matchingLayerPlugin.GetLayers(getLayersParameters).FirstOrDefault();
                UserControl userControl = matchingLayerPlugin.GetPropertiesUI(layer);

                Window propertiesDockWindow = new Window()
                {
                    Content       = userControl,
                    Title         = GisEditor.LanguageManager.GetStringResource("MapElementsListPluginProperties"),
                    SizeToContent = SizeToContent.WidthAndHeight,
                    ResizeMode    = System.Windows.ResizeMode.NoResize,
                    Style         = Application.Current.FindResource("WindowStyle") as System.Windows.Style
                };

                propertiesDockWindow.ShowDialog();
            });
            ContextMenu.Items.Add(propertyItem);
        }
        protected override Collection <Layer> GetLayersCore(GetLayersParameters getLayersParameters)
        {
            Collection <Layer> resultLayers = base.GetLayersCore(getLayersParameters);

            Collection <CSVInfoModel> entities = new Collection <CSVInfoModel>();
            bool hasUnconfiguredCsv            = false;

            foreach (string fileName in getLayersParameters.LayerUris.Select(u => u.LocalPath))
            {
                string configFileName = Path.ChangeExtension(fileName, Path.GetExtension(fileName) + ".config");
                if (File.Exists(configFileName))
                {
                    var csvFileLastWriteTime = new FileInfo(fileName).LastWriteTime;
                    var csvConfLastWriteTime = GetConfigFileLastWriteTime(fileName);

                    if (csvFileLastWriteTime.ToString(CultureInfo.InvariantCulture).Equals(csvConfLastWriteTime.ToString(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase))
                    {
                        entities.Add(CSVInfoModel.FromConfig(configFileName));
                    }
                    else
                    {
                        CleanAttachedFiles(fileName, configFileName);
                        entities.Add(new CSVInfoModel(fileName, ","));
                        hasUnconfiguredCsv = true;
                    }
                }
                else
                {
                    entities.Add(new CSVInfoModel(fileName, ","));
                    hasUnconfiguredCsv = true;
                }
            }

            try
            {
                if (entities.Count == 0)
                {
                    return(resultLayers);
                }

                List <CSVModel> csvModels = new List <CSVModel>();
                if (hasUnconfiguredCsv)
                {
                    var             viewModel = new CSVViewModel(entities);
                    CSVConfigWindow window    = new CSVConfigWindow(viewModel);
                    viewModel.SelectedCSVModel.AutoMatch();
                    if (window.ShowDialog().GetValueOrDefault())
                    {
                        window.CSVModelList.ForEach(csvModels.Add);
                    }
                }
                else
                {
                    foreach (var csvModel in new CSVViewModel(entities).CSVModelList)
                    {
                        csvModels.Add(csvModel);
                    }
                }

                csvModels.ForEach(m => resultLayers.Add(m.CsvFeatureLayer));
                foreach (CsvFeatureLayer delimitedFeatureLayer in resultLayers.OfType <CsvFeatureLayer>())
                {
                    delimitedFeatureLayer.FeatureSource.CommittedTransaction -= delegate { CSVModel.BuildDelimitedConfigurationFile(delimitedFeatureLayer); };
                    delimitedFeatureLayer.FeatureSource.CommittedTransaction += delegate { CSVModel.BuildDelimitedConfigurationFile(delimitedFeatureLayer); };
                }
            }
            catch (Exception ex)
            {
                GisEditor.LoggerManager.Log(LoggerLevel.Debug, ex.Message, new ExceptionInfo(ex));
                System.Windows.Forms.MessageBox.Show(ex.Message, "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }

            return(resultLayers);
        }