<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using NBTExplorer.Model;
using NBTExplorer.Vendor.MultiSelectTreeView;
using NBTExplorer.Windows;
using Substrate.Nbt;

namespace NBTExplorer.Controllers
{
    public class MessageBoxEventArgs : EventArgs
    {
        public bool Cancel { get; set; }
        public string Message { get; set; }

        public MessageBoxEventArgs (string message)
        {
            Message = message;
        }
    }

    public class NodeTreeController
    {
        private TreeView _nodeTree;
        private MultiSelectTreeView _multiTree;

        private IconRegistry _iconRegistry;

        //private TagCompoundDataNode _rootData;
        private RootDataNode _rootData;

        public NodeTreeController (TreeView nodeTree)
        {
            _nodeTree = nodeTree;
            _multiTree = nodeTree as MultiSelectTreeView;

            InitializeIconRegistry();
            ShowVirtualRoot = true;

            //_rootData = new TagCompoundDataNode(new TagNodeCompound());
            _rootData = new RootDataNode();
            RefreshRootNodes();
        }

        public RootDataNode Root
        {
            get { return _rootData; }
        }
<commit_msg>Add new sort order to NBT Tree view.<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using NBTExplorer.Model;
using NBTExplorer.Vendor.MultiSelectTreeView;
using NBTExplorer.Windows;
using Substrate.Nbt;
using System.Collections;

namespace NBTExplorer.Controllers
{
    public class MessageBoxEventArgs : EventArgs
    {
        public bool Cancel { get; set; }
        public string Message { get; set; }

        public MessageBoxEventArgs (string message)
        {
            Message = message;
        }
    }

    public class NodeTreeComparer : IComparer
    {
        public int orderForTag(TagType tagID)
        {
            switch (tagID)
            {
                case TagType.TAG_COMPOUND:
                    return 0;
                case TagType.TAG_LIST:
                    return 1;
                case TagType.TAG_BYTE:
                case TagType.TAG_SHORT:
                case TagType.TAG_INT:
                case TagType.TAG_LONG:
                case TagType.TAG_FLOAT:
                case TagType.TAG_DOUBLE:
                case TagType.TAG_STRING:
                    return 2;
                default:
                    return 3;
            }
        }

        public int Compare(object x, object y)
        {
            TreeNode tx = x as TreeNode;
            TreeNode ty = y as TreeNode;
            TagDataNode dx = tx.Tag as TagDataNode;
            TagDataNode dy = ty.Tag as TagDataNode;

            if (dx == null || dy == null)
            {
                return tx.Text.CompareTo(ty.Text);
            }

            TagType idx = dx.Tag.GetTagType();
            TagType idy = dy.Tag.GetTagType();
            int tagOrder = this.orderForTag(idx).CompareTo(this.orderForTag(idy));
            if (tagOrder != 0)
            {
                return tagOrder;
            } 
            else 
            {
                return dx.NodeDisplay.CompareTo(dy.NodeDisplay);
            }
            
        }
    }

    public class NodeTreeController
    {
        private TreeView _nodeTree;
        private MultiSelectTreeView _multiTree;

        private IconRegistry _iconRegistry;

        //private TagCompoundDataNode _rootData;
        private RootDataNode _rootData;

        public NodeTreeController (TreeView nodeTree)
        {
            _nodeTree = nodeTree;
            nodeTree.TreeViewNodeSorter = new NodeTreeComparer();
            _multiTree = nodeTree as MultiSelectTreeView;

            InitializeIconRegistry();
            ShowVirtualRoot = true;

            //_rootData = new TagCompoundDataNode(new TagNodeCompound());
            _rootData = new RootDataNode();
            RefreshRootNodes();
        }

        public RootDataNode Root
        {
            get { return _rootData; }
        }

{'fraction_non_alphanumeric': 0.0667637776159262, 'fraction_numerical': 0.0012138868657441126, 'mean_word_length': 1.6875407697325506, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1681368', 'n_tokens_mistral': 1112, 'n_tokens_neox': 1059, 'n_words': 265}