<commit_before>﻿using System.Data;
using System.Windows.Controls;
using System.Windows.Interactivity;

namespace FAManagementStudio.Views.Behaviors
{
    public class GridHeaderDisplayNameBehavior : Behavior<DataGrid>
    {
        public GridHeaderDisplayNameBehavior() { }
        protected override void OnAttached()
        {
            base.OnAttached();
            AssociatedObject.AutoGeneratingColumn += AssociatedObject_AutoGeneratingColumn;
        }

        private void AssociatedObject_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            e.Column.Header = (AssociatedObject.ItemsSource as DataView).Table.Columns[int.Parse(e.Column.Header.ToString())].Caption;
        }

        protected override void OnDetaching()
        {
            AssociatedObject.AutoGeneratingColumn -= AssociatedObject_AutoGeneratingColumn;
            base.OnDetaching();
        }
    }<commit_msg>change foregroud when value is null<commit_after>﻿using System.Data;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Interactivity;

namespace FAManagementStudio.Views.Behaviors
{
    public class GridHeaderDisplayNameBehavior : Behavior<DataGrid>
    {
        public GridHeaderDisplayNameBehavior() { }
        protected override void OnAttached()
        {
            base.OnAttached();
            AssociatedObject.AutoGeneratingColumn += AssociatedObject_AutoGeneratingColumn;
        }

        private const string NullString = "(DB_Null)";

        private void AssociatedObject_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e)
        {
            var propertyName = e.Column.Header.ToString();
            e.Column.Header = (AssociatedObject.ItemsSource as DataView).Table.Columns[int.Parse(propertyName)].Caption;
            ((DataGridBoundColumn)e.Column).Binding.TargetNullValue = NullString;

            //Null Value
            var style = new Style(typeof(TextBlock));
            var trigger = new DataTrigger { Binding = new Binding(propertyName), Value = null };
            trigger.Setters.Add(new Setter(TextBlock.ForegroundProperty, new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.LightGray)));
            style.Triggers.Add(trigger);
            ((DataGridTextColumn)e.Column).ElementStyle = style;
        }

        protected override void OnDetaching()
        {
            AssociatedObject.AutoGeneratingColumn -= AssociatedObject_AutoGeneratingColumn;
            base.OnDetaching();
        }
    }
{'fraction_non_alphanumeric': 0.08381839348079162, 'fraction_numerical': 0.0, 'mean_word_length': 3.040752351097179, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3403008', 'n_tokens_mistral': 656, 'n_tokens_neox': 636, 'n_words': 117}