View Single Post
Old 07.05.2006, 22:15   #2
humordwarf
Архивный участник
 
Join Date: Feb 2006
Posts: 453
Default [SHARE] HD SAE .NET (skillacquire.txt explorer) + sources

NOT EDITOR, JUST VIEWER
no any AntiLE keys needed

.net framework 2.0 required

shot:


sources:
Code:
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace hd_sae
{
    public partial class Main : Form
    {
        const int SAParamCount  = 8;
        const string sInclude   = "include";
        const string sBegin     = "begin";
        const string sEnd       = "end";
        const string sSkill     = "skill";
        const string sError     = "error";

        ArrayList SA = new ArrayList();
        StreamReader sr;

        void AddClassToTree(string ClassName)
        {
            Tree.Nodes.Add(ClassName);
        }

        void AddSkillToListView(string SkillLine)
        {
            string[] ss = SkillLine.Split('\t');
            if (ss.Length == SAParamCount)
            {
                ListViewItem li = ListView.Items.Add(GetSkillValue(ss[2]));
                li.SubItems.Add(GetSkillValue(ss[3]));
                li.SubItems.Add(GetSkillValue(ss[4]));
                li.SubItems.Add(GetSkillValue(ss[5]));
                li.SubItems.Add(GetSkillValue(ss[6]));
            }
        }

        void BuildTree()
        {
            string s1="", s2="";
            Tree.Nodes.Clear();
            ListView.Items.Clear();
            for (int i = 0; i < SA.Count; i++)
            {
                if (ExtractParams((string)SA[i], ref s1, ref s2))
                {
                    if (s1 == sSkill)
                    {
                    }
                    else if (s1 == sInclude)
                    {
                    }
                    else if (s2 == sBegin)
                    {
                        AddClassToTree(s1);
                    }
                }
            }
        }

        string GetSkillValue(string s)
        {
            string[] ss = s.Split('=');
            if (ss.Length == 2)
            {
                return ss[1];
            }
            else
            {
                return sError;
            }
        }
    
        void AddClassToListView(string ClassName)
        {
            ArrayList IncList = GetIncludeList(ClassName);
            for (int i = 0; i < IncList.Count; i++)
            {
                AddClassToListView((string)IncList[i]);
            }

            string s1 = "", s2 = "", cc = "";
            for (int i = 0; i < SA.Count; i++)
            {
                if (ExtractParams((string)SA[i], ref s1, ref s2))
                {
                    if (s1 == sSkill)
                    {
                        if (cc == ClassName)
                        {
                            AddSkillToListView((string)SA[i]);
                        }
                    }
                    else if (s1 == sInclude)
                    {
                    }
                    else if (s2 == sBegin)
                    {
                        cc = s1;
                    }
                    else if (s2 == sEnd && cc == ClassName)
                    {
                        cc = "";
                        break;
                    }

                }
            }
        }

        ArrayList GetIncludeList(string ClassName)
        {
            ArrayList r = new ArrayList();
            string s1="",s2="",cc="";
            for (int i = 0; i < SA.Count; i++)
            {
                if (ExtractParams((string)SA[i], ref s1, ref s2))
                {
                    if (s1 == sSkill)
                    {
                    }
                    else if (s1 == sInclude)
                    {
                        if (cc == ClassName)
                        {
                            r.Add(s2);
                        }
                    }
                    else if (s2 == sBegin)
                    {
                        cc = s1;
                    }
                    else if (s2 == sEnd && cc==ClassName)
                    {
                        cc = "";
                        break;
                    }

                }
            }
            return r;
        }

        bool ExtractParams(string Line, ref string s1, ref string s2)
        {
            string[] ss = Line.Split('\t');
            if (ss.Length == SAParamCount)
            {
                string[] s0 = ss[0].Split('_');
                if (s0.Length >= 2)
                {
                    s1 = s0[0];
                    s2 = s0[s0.Length - 1];

                    if (s1 == sInclude)
                    {
                        for (int i = 1; i < s0.Length - 1; i++)
                        {
                            s2 = s0[i] + "_" + s2;
                        }

                    }
                    else
                    {
                        for (int i = 1; i < s0.Length - 1; i++)
                        {
                            s1 = s1 + "_" + s0[i];
                        }
                    }
                    return true;
                }
            }
            s1 = "";
            s2 = "";
            return false;
        }

        public Main()
        {
            InitializeComponent();
        }

        private void openToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (OpenDlg.ShowDialog() == DialogResult.OK)
            {
                string Line;
                sr = File.OpenText(OpenDlg.FileName);
                SA.Clear();
                while ((Line = sr.ReadLine()) != null)
                {
                    SA.Add(Line);
                }
                sr.Close();
                BuildTree();
            }
        }

        private void exitToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }

        private void aboutToolStripMenuItem_Click(object sender, EventArgs e)
        {
            frmAbout About = new frmAbout();
            About.ShowDialog();
        }

        private void Tree_AfterSelect(object sender, TreeViewEventArgs e)
        {
            ListView.ListViewItemSorter = null;
            ListView.Sorting = SortOrder.None;
            ListView.Items.Clear();
            AddClassToListView(Tree.SelectedNode.Text);
        }

        private void ListView_ColumnClick(object sender, ColumnClickEventArgs e)
        {
            ListView.ListViewItemSorter = new ListViewItemComparer(e.Column);
        }

        class ListViewItemComparer : IComparer
        {
            private int col;
            public ListViewItemComparer()
            {
                col = 0;
            }
            public ListViewItemComparer(int column)
            {
                col = column;
            }
            public int Compare(object x, object y)
            {
                int a, b;
                if (col == 1 || col == 2)
                {
                    try
                    {
                        a = int.Parse(((ListViewItem)x).SubItems[col].Text);
                        b = int.Parse(((ListViewItem)y).SubItems[col].Text);
                        return a - b;
                    }
                    catch
                    {
                        return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
                    }
                }
                else
                {
                    return String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
                }
            }
        }
    }
}
humordwarf is offline