<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace biz.dfch.CS.CoffeeTracker.Client.Wpf.UserInterface.UserControls.Components
{
    /// <summary>
    /// Interaction logic for CoffeeForm.xaml
    /// </summary>
    public partial class CoffeeForm : IValidatable
    {
        public CoffeeForm()
        {
            InitializeComponent();
        }

        public bool IsValid()
        {
            var priceText = CoffeeFormPriceTextBox.Text;
            decimal priceDecimal;
            var priceValid = decimal.TryParse(priceText, out priceDecimal);

            var stockText = CoffeeFormStockTextBox.Text;
            int stockInt;
            var stockValid = int.TryParse(stockText, out stockInt);

            var lastDeliveryText = CoffeeFormDatePicker.Text;
            DateTimeOffset lastDeliveryDateTimeOffset;
            var dateTimeOffsetValid = DateTimeOffset.TryParse(lastDeliveryText, out lastDeliveryDateTimeOffset);

            return priceValid && stockValid && dateTimeOffsetValid;
        }
    }
}<commit_msg>added control enabling<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace biz.dfch.CS.CoffeeTracker.Client.Wpf.UserInterface.UserControls.Components
{
    /// <summary>
    /// Interaction logic for CoffeeForm.xaml
    /// </summary>
    public partial class CoffeeForm : IValidatable
    {
        public Brush oldBorderBrush;

        public CoffeeForm()
        {
            InitializeComponent();
            oldBorderBrush = CoffeeFormNameTextBox.BorderBrush;
        }

        public bool IsValid()
        {
            var priceText = CoffeeFormPriceTextBox.Text;
            decimal priceDecimal;
            var priceValid = decimal.TryParse(priceText, out priceDecimal);
            CoffeeFormPriceTextBox.BorderBrush = !priceValid ? Brushes.Red : oldBorderBrush;

            var stockText = CoffeeFormStockTextBox.Text;
            int stockInt;
            var stockValid = int.TryParse(stockText, out stockInt);
            CoffeeFormStockTextBox.BorderBrush = !stockValid ? Brushes.Red : oldBorderBrush;

            var lastDeliveryText = CoffeeFormDatePicker.Text;
            DateTimeOffset lastDeliveryDateTimeOffset;
            var dateTimeOffsetValid = DateTimeOffset.TryParse(lastDeliveryText, out lastDeliveryDateTimeOffset);
            CoffeeFormDatePicker.BorderBrush = !dateTimeOffsetValid ? Brushes.Red : oldBorderBrush;

            return priceValid && stockValid && dateTimeOffsetValid;
        }

        public void DisableControls()
        {
            SetControlsIsEnabled(false);
        }

        public void EnableControls()
        {
            SetControlsIsEnabled(true);
        }

        private void SetControlsIsEnabled(bool enabled)
        {
            CoffeeFormNameTextBox.IsEnabled = enabled;
            CoffeeFormBrandTextBox.IsEnabled = enabled;
            CoffeeFormPriceTextBox.IsEnabled = enabled;
            CoffeeFormStockTextBox.IsEnabled = enabled;
            CoffeeFormDatePicker.IsEnabled = enabled;
        }
    }
}
{'fraction_non_alphanumeric': 0.0774365821094793, 'fraction_numerical': 0.0, 'mean_word_length': 2.7199602780536245, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '7595098', 'n_tokens_mistral': 960, 'n_tokens_neox': 942, 'n_words': 203}