public static void CreateNewLanguageColumn(this DataGrid dataGrid, Configuration configuration, CultureInfo?culture)
        {
            var cultureKey = new CultureKey(culture);

            dataGrid.AddLanguageColumn(configuration, cultureKey);

            var key = cultureKey.ToString(NeutralCultureKeyString);

            HiddenLanguageColumns = HiddenLanguageColumns.Where(col => !string.Equals(col, key, StringComparison.OrdinalIgnoreCase));
        }
        public static void CreateNewLanguageColumn([NotNull] this DataGrid dataGrid, [NotNull] Configuration configuration, [CanBeNull] CultureInfo culture)
        {
            Contract.Requires(dataGrid != null);
            Contract.Requires(configuration != null);

            var cultureKey = new CultureKey(culture);

            dataGrid.AddLanguageColumn(configuration, cultureKey);

            var key = cultureKey.ToString(NeutralCultureKeyString);

            HiddenLanguageColumns = HiddenLanguageColumns.Where(col => !string.Equals(col, key, StringComparison.OrdinalIgnoreCase));
        }
        public static void SetupColumns([NotNull] this DataGrid dataGrid, [NotNull] ResourceManager resourceManager, [NotNull] ResourceViewModel resourceViewModel, [NotNull] Configuration configuration)
        {
            Contract.Requires(dataGrid != null);
            Contract.Requires(resourceManager != null);
            Contract.Requires(resourceViewModel != null);
            Contract.Requires(configuration != null);

            var dataGridEvents = dataGrid.GetAdditionalEvents();

            dataGridEvents.ColumnVisibilityChanged -= DataGrid_ColumnVisibilityChanged;
            dataGridEvents.ColumnVisibilityChanged += DataGrid_ColumnVisibilityChanged;

            dataGrid.CurrentCellChanged -= DataGrid_CurrentCellChanged;
            dataGrid.CurrentCellChanged += DataGrid_CurrentCellChanged;

            var columns = dataGrid.Columns;

            if (columns.Count == 0)
            {
                columns.Add(CreateKeyColumn());
                columns.Add(CreateIndexColumn(resourceViewModel, configuration));
                columns.Add(CreateCodeReferencesColumn(dataGrid));
            }

            var languageColumns = columns.Skip(3).ToArray();

            IEnumerable <CultureKey> cultureKeys = resourceManager.Cultures;

            var disconnectedColumns = languageColumns.Where(col => cultureKeys.All(cultureKey => !Equals(col.GetCultureKey(), cultureKey)));

            foreach (var column in disconnectedColumns)
            {
                columns.Remove(column);
            }

            var addedcultureKeys = cultureKeys.Where(cultureKey => languageColumns.All(col => !Equals(col.GetCultureKey(), cultureKey)));

            foreach (var cultureKey in addedcultureKeys)
            {
                Contract.Assume(cultureKey != null);
                dataGrid.AddLanguageColumn(configuration, cultureKey);
            }
        }