<commit_before>using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Dependinator.Utils.UI;
using Dependinator.Utils.UI.Mvvm;


namespace Dependinator.ModelViewing.DependencyExploring.Private
{
	internal class DependencyItemViewModel : ViewModel
	{

		private readonly IItemCommands itemCommands;
		private readonly bool isSourceItem;
		public static readonly TimeSpan MouseEnterDelay = TimeSpan.FromMilliseconds(300);
		
		private readonly DelayDispatcher delayDispatcher = new DelayDispatcher();
		private bool isHidden = false;
		private bool isSubReferences = false;


		public DependencyItemViewModel(
			DependencyItem item,
			IItemCommands itemCommands,
			bool isSourceItem)
		{
			this.Item = item;
			this.itemCommands = itemCommands;
			this.isSourceItem = isSourceItem;

			SubItems = ToSubItems(item.SubItems);
		}


		public DependencyItem Item { get; }

		public string Text => Item.Node.IsRoot ? "all nodes" : Item.Node.Name.DisplayName;

		public ObservableCollection<DependencyItemViewModel> SubItems { get; }
		public bool IsShowCodeButton => IsShowButtons && Item.Node.CodeText != null;
		public bool IsShowVisibilityButton => IsShowButtons;

		public string ToolTip { get => Get(); set => Set(value); }


		public bool IsShowButtons
		{
			get => Get();
			set => Set(value).Notify(nameof(IsShowCodeButton), nameof(IsShowVisibilityButton));
		}

		public bool IsSelected { get => Get(); set => Set(value); }
		public bool IsExpanded { get => Get(); set => Set(value); }
		//public Command ToggleVisibilityCommand => Command(ToggleVisibility);
		public Command ShowCodeCommand => Command(() => itemCommands.ShowCode(Item.Node));
		public Command ToggleCollapseCommand => Command(() => SetExpand(!IsExpanded));
		public Command FilterCommand => Command(() => Filter());


		private void Filter()
		{
			IsSelected = true;
			itemCommands.FilterOn(Item, isSourceItem);
		}


		private void SetExpand(bool isExpand)
		{
			IsExpanded = isExpand;
			SubItems.ForEach(i => i.SetExpand(isExpand));
		}


		private ObservableCollection<DependencyItemViewModel> ToSubItems(
			IEnumerable<DependencyItem> subItems)
		{
			return new ObservableCollection<DependencyItemViewModel>(
				subItems.Select(i => new DependencyItemViewModel(i, itemCommands, isSourceItem)));
		}


		//private void ToggleVisibility()
		//{
		//	SetVisibility(!isHidden);

		//	if (isHidden)
		//	{
		//		IsExpanded = false;
		//	}
		//}



		//private void SetVisibility(bool isHide)
		//{
		//	isHidden = isHide;
		//	TextBrush = isHidden ? Item.ItemTextHiddenBrush() : Item.ItemTextBrush();
		//	SubItems.ForEach(s => s.SetVisibility(isHide));
		//}


		public void OnMouseEnter()
		{
			delayDispatcher.Delay(MouseEnterDelay, _ => { IsShowButtons = true; });
		}


		public void OnMouseLeave()
		{
			delayDispatcher.Cancel();
			IsShowButtons = false;
		}


		public void UpdateToolTip()
		{
			string filter = isSourceItem ? "to target" : "from source";
			ToolTip = $"{Item.Node.Name.DisplayFullName}\nClick to filter dependencies {filter}";
		}
	}
}<commit_msg>Small change<commit_after>using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Dependinator.Utils.UI;
using Dependinator.Utils.UI.Mvvm;


namespace Dependinator.ModelViewing.DependencyExploring.Private
{
	internal class DependencyItemViewModel : ViewModel
	{

		private readonly IItemCommands itemCommands;
		private readonly bool isSourceItem;
		public static readonly TimeSpan MouseEnterDelay = TimeSpan.FromMilliseconds(300);
		
		private readonly DelayDispatcher delayDispatcher = new DelayDispatcher();
		private bool isHidden = false;
		private bool isSubReferences = false;


		public DependencyItemViewModel(
			DependencyItem item,
			IItemCommands itemCommands,
			bool isSourceItem)
		{
			this.Item = item;
			this.itemCommands = itemCommands;
			this.isSourceItem = isSourceItem;

			SubItems = ToSubItems(item.SubItems);
		}


		public DependencyItem Item { get; }

		public string Text => Item.Node.IsRoot ? "all nodes" : Item.Node.Name.DisplayName;

		public ObservableCollection<DependencyItemViewModel> SubItems { get; }
		public bool IsShowCodeButton => IsShowButtons && Item.Node.CodeText != null;
		public bool IsShowVisibilityButton => IsShowButtons;

		public string ToolTip { get => Get(); set => Set(value); }


		public bool IsShowButtons
		{
			get => Get();
			set => Set(value).Notify(nameof(IsShowCodeButton), nameof(IsShowVisibilityButton));
		}

		public bool IsSelected { get => Get(); set => Set(value); }
		public bool IsExpanded { get => Get(); set => Set(value); }
		//public Command ToggleVisibilityCommand => Command(ToggleVisibility);
		public Command ShowCodeCommand => Command(() => itemCommands.ShowCode(Item.Node));
		public Command ToggleCollapseCommand => Command(SetExpand);
		public Command FilterCommand => Command(Filter);


		private void Filter()
		{
			IsSelected = true;
			itemCommands.FilterOn(Item, isSourceItem);
		}


		private void SetExpand() => SetExpand(!IsExpanded);


		private void SetExpand(bool isExpand)
		{
			IsExpanded = isExpand;
			SubItems.ForEach(i => i.SetExpand(isExpand));
		}


		private ObservableCollection<DependencyItemViewModel> ToSubItems(
			IEnumerable<DependencyItem> subItems)
		{
			return new ObservableCollection<DependencyItemViewModel>(
				subItems.Select(i => new DependencyItemViewModel(i, itemCommands, isSourceItem)));
		}


		//private void ToggleVisibility()
		//{
		//	SetVisibility(!isHidden);

		//	if (isHidden)
		//	{
		//		IsExpanded = false;
		//	}
		//}



		//private void SetVisibility(bool isHide)
		//{
		//	isHidden = isHide;
		//	TextBrush = isHidden ? Item.ItemTextHiddenBrush() : Item.ItemTextBrush();
		//	SubItems.ForEach(s => s.SetVisibility(isHide));
		//}


		public void OnMouseEnter()
		{
			delayDispatcher.Delay(MouseEnterDelay, _ => { IsShowButtons = true; });
		}


		public void OnMouseLeave()
		{
			delayDispatcher.Cancel();
			IsShowButtons = false;
		}


		public void UpdateToolTip()
		{
			string filter = isSourceItem ? "to target" : "from source";
			ToolTip = $"{Item.Node.Name.DisplayFullName}\nClick to filter dependencies {filter}";
		}
	}
}
{'fraction_non_alphanumeric': 0.11368724016629357, 'fraction_numerical': 0.0009593859929645027, 'mean_word_length': 4.251889168765743, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 54, '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': '2280167', 'n_tokens_mistral': 2140, 'n_tokens_neox': 1858, 'n_words': 425}