tools/profiler/csharp/Form1.cs
author Ruben Gonzalez <drifter01620@gmail.com>
Thu May 22 09:49:27 2014 -0400 (2014-05-22)
changeset 4378 568f4497ef4a
parent 3086 912942c905da
permissions -rw-r--r--
Update CS:GO team score gamedata.
     1 using System;
     2 using System.Collections.Generic;
     3 using System.ComponentModel;
     4 using System.Data;
     5 using System.Drawing;
     6 using System.Text;
     7 using System.Windows.Forms;
     8 
     9 namespace profviewer
    10 {
    11     public partial class Main : Form
    12     {
    13         private ProfileReport m_Report;
    14 
    15         public Main()
    16         {
    17             InitializeComponent();
    18         }
    19 
    20         private void menu_file_open_Click(object sender, EventArgs e)
    21         {
    22             DialogResult res;
    23             
    24             res = dialog_open.ShowDialog(this);
    25 
    26             if (res != DialogResult.OK)
    27             {
    28                 return;
    29             }
    30 
    31             m_Report = null;
    32 
    33             try
    34             {
    35                 m_Report = new ProfileReport(dialog_open.FileName);
    36             }
    37             catch (System.Exception ex)
    38             {
    39                 MessageBox.Show("Error opening or parsing file: " + ex.Message);
    40             }
    41 
    42             UpdateListView();
    43         }
    44 
    45         private void UpdateListView()
    46         {
    47             ProfileItem atom;
    48             ListViewItem item;
    49 
    50             report_list.Items.Clear();
    51             report_info_duration.Text = "";
    52             report_info_starttime.Text = "";
    53 
    54             report_info_duration.Text = m_Report.Duration.ToString() + " seconds";
    55             report_info_starttime.Text = m_Report.StartTime.ToString();
    56 
    57             for (int i = 0; i < m_Report.Count; i++)
    58             {
    59                 atom = m_Report.GetItem(i);
    60                 item = new ListViewItem(ProfileReport.TypeStrings[(int)atom.type]);
    61 
    62                 item.SubItems.Add(atom.name);
    63                 item.SubItems.Add(atom.num_calls.ToString());
    64                 item.SubItems.Add(atom.AverageTime.ToString("F6"));
    65                 item.SubItems.Add(atom.min_time.ToString("F6"));
    66                 item.SubItems.Add(atom.max_time.ToString("F6"));
    67                 item.SubItems.Add(atom.total_time.ToString("F6"));
    68 
    69                 report_list.Items.Add(item);
    70             }
    71         }
    72 
    73         private void menu_file_exit_Click(object sender, EventArgs e)
    74         {
    75             Application.Exit();
    76         }
    77 
    78         private void report_list_ColumnClick(object sender, ColumnClickEventArgs e)
    79         {
    80             if (e.Column == 1)
    81             {
    82                 report_list.ListViewItemSorter = new LIStringComparator(1);
    83             }
    84             else if (e.Column == 2)
    85             {
    86                 report_list.ListViewItemSorter = new LIIntComparator(2);
    87             }
    88             else if (e.Column > 2)
    89             {
    90                 report_list.ListViewItemSorter = new LIDoubleComparator(e.Column);
    91             }
    92         }
    93     }
    94 }