Subaru Enthusiasts Car Club of the Sierras

Subaru Enthusiasts Car Club of the Sierras (https://www.seccs.org/forums/index.php)
-   Off Topic Chat (https://www.seccs.org/forums/forumdisplay.php?f=10)
-   -   Disable MikeK's account??? (https://www.seccs.org/forums/showthread.php?t=4495)

Dean 2006-04-10 03:23 PM

Disable MikeK's account???
 
Hey Scott, can we just disable Mike's account until he finishes results?

He clearly is not spending his "work" time wisely, and needs guidance...

:)

sperry 2006-04-10 03:24 PM

Actually, I'm pretty sure he's working on results... I talked to Nick and they were PMing back and forth about verifying the LGT's classification.

Plus, me and him are probably getting together tonight to work on some scoring software.

MikeK 2006-04-10 03:36 PM

Quote:

Originally Posted by Dean
He clearly is not spending his "work" time wisely

The internet doesn't browse itself you know

tysonK 2006-04-10 03:40 PM

After you finish the software I hope you guys score.

that was a bad joke. thanks.

Kevin M 2006-04-10 03:45 PM

Quote:

Originally Posted by Keith Olbermann, circa 1996
...or even if you're alone.

.

JonnydaJibba 2006-04-11 07:06 AM

I browsed the entire interweb once. I got sweaty.

sperry 2006-04-11 08:52 AM

Quote:

Originally Posted by JonnydaJibba
I browsed the entire interweb once. I got sweaty.

Yeah well, I beat the internet. The end guy was hard.

M3n2c3 2006-04-11 09:59 PM

Well, I found the end of the internet, and then discovered how to turn it off.

sperry 2006-04-12 08:01 AM

Quote:

Originally Posted by M3n2c3

Lucky for everyone, I can't turn off the internet because Firefox prevents popups.

JonnydaJibba 2006-04-12 08:07 AM

Quote:

Originally Posted by sperry
Lucky for everyone, I can't turn off the internet because Firefox prevents popups.

Hahahaha, well I guess it's borked because I allowed it to pop up and we are still here...

Double Phister 2006-04-12 08:41 AM

Quote:

Originally Posted by sperry
Lucky for everyone, I can't turn off the internet because Firefox prevents popups.

Does FF view user initiated popups different from the automatic ones?

JonnydaJibba 2006-04-12 09:50 AM

nope.

A1337STI 2006-04-12 10:23 AM

I could have written a program to do all the calculating by now. What does Dean have to work or something ? active social life? Kids ? come on :P no excuses! Just like load one array as a lookup table for each car class with the correct PAX modifer,
then import the raw data into a 2nd set of arrays (4 or 5 diminsonal, and on each line read populate the pax value as the result of the raw time X the referenced pax modifer [in the look up table] ) probably could be done in just a few lines of code :P (tricky lines) but a few lines . then just drop in a bubble sort (or your favorite sort) based upon the last dimenson of the array (PAx adjusted) and save back to csv, maybe have it save a 2nd copy directly to html with the tables written out ...

course maybe you guys don't do programming as your 9 to 5 ... ?

A1337STI 2006-04-12 10:27 AM

Course you could also just design 2 DB tables, import data, (write a Trigger to caculate PAX based upon raw and class, and a pax adjustor look up) and write a very simple db driven results display , with an Order By selected field, so they could then choose to list by pax, or by raw time, or by best time in class, only view a given car class. etc. etc... (probably takes about the same amount of time versus 1 tricked out data importer) violoa ? (viola ? ) arg. i can't spell english ...

Kevin M 2006-04-12 10:30 AM

Quote:

Originally Posted by A1337STI
course maybe you guys don't do programming as your 9 to 5 ... ?

Only about half of SECCS. They rest of us just read the interweb. MikeK is our supreme ruler.

Dean 2006-04-12 11:30 AM

Quote:

Originally Posted by A1337STI
Course you could also just design 2 DB tables, import data, (write a Trigger to caculate PAX based upon raw and class, and a pax adjustor look up) and write a very simple db driven results display , with an Order By selected field, so they could then choose to list by pax, or by raw time, or by best time in class, only view a given car class. etc. etc... (probably takes about the same amount of time versus 1 tricked out data importer) violoa ? (viola ? ) arg. i can't spell english ...

Scott, Mike, sounds like a voulenteer to rewrite teh timing software fromthe ground up to me....

You have no ide how shitty this software is, and due to our region's scoring choices, it is largely useless for that as well as sucking at the event...

A1337STI 2006-04-12 11:35 AM

aaaah just half of them? how many Seccs members does it take to tabulate results ?
"I don't know, but your mother is a whore" - SNL

lol I'm just eager to see all the results. I can't recall if i'm dead last or 2 places from it :lol: :lol: think i'm top 4 in Novice, and I'm either first & Last in STU (alone) or Just Last in BSP depending on what i choose in a month.

sperry 2006-04-12 12:08 PM

Yeah, results software is trivial. :roll:
Code:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

namespace SeasonManager
{
        /// <summary>
        /// Summary description for Form1.
        /// </summary>
        public class MainForm : System.Windows.Forms.Form
        {
    private System.Windows.Forms.MainMenu MainMenu;
    private System.Windows.Forms.MenuItem FileMenu;
    private System.Windows.Forms.MenuItem OpenMenu;
    private System.Windows.Forms.MenuItem SaveMenu;
    private System.Windows.Forms.MenuItem SaveAsMenu;
    private System.Windows.Forms.MenuItem CloseMenu;
    private System.Windows.Forms.MenuItem SeperatorMenu;
    private System.Windows.Forms.MenuItem ExitMenu;
    private System.Windows.Forms.MenuItem ReportsMenu;
    private System.Windows.Forms.StatusBar StatusBar;
    private System.Windows.Forms.StatusBarPanel StatusPanel;
    private System.Windows.Forms.Timer StatusTimer;
    private System.ComponentModel.IContainer components;
    private System.Windows.Forms.OpenFileDialog OpenFile;
    private System.Windows.Forms.SaveFileDialog SaveFile;
    private System.Windows.Forms.MenuItem NewMenu;
    private System.Windows.Forms.StatusBarPanel FilenamePanel;
    private System.Windows.Forms.StatusBarPanel ModifiedPanel;
    private System.Windows.Forms.TabControl TabControl;
    private System.Windows.Forms.TabPage SettingsPage;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.TextBox ClassPointsText;
    private System.Windows.Forms.TextBox PaxPointsText;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.NumericUpDown EventCountUpDn;
    private System.Windows.Forms.NumericUpDown ReqEventCountUpDn;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.NumericUpDown DropCountUpDn;
    private System.Windows.Forms.Label label5;
    private System.Windows.Forms.TabPage EventsPage;
    private System.Windows.Forms.GroupBox EventDetailsGroup;
    private System.Windows.Forms.Button DeleteEventButton;
    private System.Windows.Forms.Label label10;
    private System.Windows.Forms.VScrollBar EventMover;
    private System.Windows.Forms.Label label9;
    private System.Windows.Forms.Label label8;
    private System.Windows.Forms.Label label7;
    private System.Windows.Forms.GroupBox EventActionsGroup;
    private System.Windows.Forms.Button SyncSingleEvent;
    private System.Windows.Forms.Button SyncAllEvents;
    private System.Windows.Forms.ColumnHeader DriverCol;
    private System.Windows.Forms.ColumnHeader ClassCol;
    private System.Windows.Forms.ColumnHeader CarCol;
    private System.Windows.Forms.GroupBox ClassDetailsGroup;
    private System.Windows.Forms.Label label12;
    private System.Windows.Forms.Label label13;
    private System.Windows.Forms.ListBox ClassList;
    private System.Windows.Forms.Label label14;
    private System.Windows.Forms.Button DeleteClassButton;
    private System.Windows.Forms.TextBox ClassDescText;
    private System.Windows.Forms.TextBox ClassIdText;
    private System.Windows.Forms.GroupBox ClassActionsGroup;
    private System.Windows.Forms.Button AddClassButton;
    private System.Windows.Forms.CheckBox ClassNonPointsCheck;
    private System.Windows.Forms.Button ApplyClassButton;
    private System.Windows.Forms.ListBox EventList;
    private System.Windows.Forms.TextBox EventFilenameText;
    private System.Windows.Forms.TextBox EventDateText;
    private System.Windows.Forms.TextBox EventNameText;
    private System.Windows.Forms.Label label6;
    private System.Windows.Forms.Label label11;
    private System.Windows.Forms.TextBox SeasonNameText;
    private System.Windows.Forms.TextBox ClubNameText;
    private System.Windows.Forms.MenuItem ClassReportMenu;
    private System.Windows.Forms.TabPage ClassPointsPage;
    private System.Windows.Forms.TabPage PaxPointsPage;
    private System.Windows.Forms.MenuItem PaxReportMenu;
    private System.Windows.Forms.ColumnHeader ClassPointsCol;
    private System.Windows.Forms.CheckBox ClassLadiesCheck;
    private System.Windows.Forms.Label label15;
    private System.Windows.Forms.Label label16;
    private System.Windows.Forms.TextBox SingleEntrantClassPointsText;
    private System.Windows.Forms.TextBox SingleEntrantPaxPointsText;
    private System.Windows.Forms.ListView ClassStandingsList;
    private System.Windows.Forms.ListView PaxStandingsList;
    private System.Windows.Forms.ColumnHeader PaxClassCol;
    private System.Windows.Forms.ColumnHeader PaxDriverCol;
    private System.Windows.Forms.ColumnHeader PaxCarCol;
    private System.Windows.Forms.ColumnHeader PaxPointsCol;
    private System.Windows.Forms.SaveFileDialog SaveReport;
    private System.Windows.Forms.MenuItem PerfectAttendanceMenu;
    private System.Windows.Forms.MenuItem menuItem1;
    private System.Windows.Forms.MenuItem menuItem2;
    private System.Windows.Forms.MenuItem ExcludeMenu;
    private System.Windows.Forms.Button GenerateEventReportButton;
    private System.Windows.Forms.MenuItem menuItem5;
    private System.Windows.Forms.MenuItem EventReportMenu;
    private System.Windows.Forms.MenuItem GenerateAllEventReportsMenu;

    public SeasonWrapper season_data = null;

    public MainForm()
                {
                        //
                        // Required for Windows Form Designer support
                        //
                        InitializeComponent();

      Utils.WriteToFlatLog(Utils.EXCEPTION_LOG, "Application started...", true, false);
      ClassStandingsList.ListViewItemSorter = new StandingsListSorter();
      PaxStandingsList.ListViewItemSorter = new StandingsListSorter();
      UpdateDisplay();
                }

                /// <summary>
                /// Clean up any resources being used.
                /// </summary>
                protected override void Dispose( bool disposing )
                {
                        if( disposing )
                        {
                                if (components != null)
                                {
                                        components.Dispose();
                                }
                        }
                        base.Dispose( disposing );
                }


    #region Windows Form Designer generated code
                /// <summary>
                /// Required method for Designer support - do not modify
                /// the contents of this method with the code editor.
                /// </summary>
                private void InitializeComponent()
                {
      this.components = new System.ComponentModel.Container();
      this.MainMenu = new System.Windows.Forms.MainMenu();
      this.FileMenu = new System.Windows.Forms.MenuItem();
      this.NewMenu = new System.Windows.Forms.MenuItem();
      this.OpenMenu = new System.Windows.Forms.MenuItem();
      this.SaveMenu = new System.Windows.Forms.MenuItem();
      this.SaveAsMenu = new System.Windows.Forms.MenuItem();
      this.CloseMenu = new System.Windows.Forms.MenuItem();
      this.SeperatorMenu = new System.Windows.Forms.MenuItem();
      this.ExitMenu = new System.Windows.Forms.MenuItem();
      this.ReportsMenu = new System.Windows.Forms.MenuItem();
      this.EventReportMenu = new System.Windows.Forms.MenuItem();
      this.GenerateAllEventReportsMenu = new System.Windows.Forms.MenuItem();
      this.menuItem5 = new System.Windows.Forms.MenuItem();
      this.ClassReportMenu = new System.Windows.Forms.MenuItem();
      this.PaxReportMenu = new System.Windows.Forms.MenuItem();
      this.PerfectAttendanceMenu = new System.Windows.Forms.MenuItem();
      this.menuItem1 = new System.Windows.Forms.MenuItem();
      this.menuItem2 = new System.Windows.Forms.MenuItem();
      this.ExcludeMenu = new System.Windows.Forms.MenuItem();
      this.StatusBar = new System.Windows.Forms.StatusBar();
      this.StatusPanel = new System.Windows.Forms.StatusBarPanel();
      this.FilenamePanel = new System.Windows.Forms.StatusBarPanel();
      this.ModifiedPanel = new System.Windows.Forms.StatusBarPanel();
      this.StatusTimer = new System.Windows.Forms.Timer(this.components);
      this.OpenFile = new System.Windows.Forms.OpenFileDialog();
      this.SaveFile = new System.Windows.Forms.SaveFileDialog();
      this.TabControl = new System.Windows.Forms.TabControl();
      this.SettingsPage = new System.Windows.Forms.TabPage();
      this.SingleEntrantPaxPointsText = new System.Windows.Forms.TextBox();
      this.label16 = new System.Windows.Forms.Label();
      this.SingleEntrantClassPointsText = new System.Windows.Forms.TextBox();
      this.label15 = new System.Windows.Forms.Label();
      this.ClubNameText = new System.Windows.Forms.TextBox();
      this.label11 = new System.Windows.Forms.Label();
      this.SeasonNameText = new System.Windows.Forms.TextBox();
      this.label6 = new System.Windows.Forms.Label();
      this.ClassActionsGroup = new System.Windows.Forms.GroupBox();
      this.AddClassButton = new System.Windows.Forms.Button();
      this.label14 = new System.Windows.Forms.Label();
      this.ClassDetailsGroup = new System.Windows.Forms.GroupBox();
      this.ClassLadiesCheck = new System.Windows.Forms.CheckBox();
      this.ApplyClassButton = new System.Windows.Forms.Button();
      this.ClassNonPointsCheck = new System.Windows.Forms.CheckBox();
      this.DeleteClassButton = new System.Windows.Forms.Button();
      this.ClassDescText = new System.Windows.Forms.TextBox();
      this.label12 = new System.Windows.Forms.Label();
      this.ClassIdText = new System.Windows.Forms.TextBox();
      this.label13 = new System.Windows.Forms.Label();
      this.ClassList = new System.Windows.Forms.ListBox();
      this.DropCountUpDn = new System.Windows.Forms.NumericUpDown();
      this.label5 = new System.Windows.Forms.Label();
      this.ReqEventCountUpDn = new System.Windows.Forms.NumericUpDown();
      this.label4 = new System.Windows.Forms.Label();
      this.EventCountUpDn = new System.Windows.Forms.NumericUpDown();
      this.label3 = new System.Windows.Forms.Label();
      this.PaxPointsText = new System.Windows.Forms.TextBox();
      this.label2 = new System.Windows.Forms.Label();
      this.ClassPointsText = new System.Windows.Forms.TextBox();
      this.label1 = new System.Windows.Forms.Label();
      this.EventsPage = new System.Windows.Forms.TabPage();
      this.EventActionsGroup = new System.Windows.Forms.GroupBox();
      this.GenerateEventReportButton = new System.Windows.Forms.Button();
      this.SyncAllEvents = new System.Windows.Forms.Button();
      this.SyncSingleEvent = new System.Windows.Forms.Button();
      this.EventDetailsGroup = new System.Windows.Forms.GroupBox();
      this.DeleteEventButton = new System.Windows.Forms.Button();
      this.label10 = new System.Windows.Forms.Label();
      this.EventMover = new System.Windows.Forms.VScrollBar();
      this.EventFilenameText = new System.Windows.Forms.TextBox();
      this.label9 = new System.Windows.Forms.Label();
      this.EventDateText = new System.Windows.Forms.TextBox();
      this.label8 = new System.Windows.Forms.Label();
      this.EventNameText = new System.Windows.Forms.TextBox();
      this.label7 = new System.Windows.Forms.Label();
      this.EventList = new System.Windows.Forms.ListBox();
      this.ClassPointsPage = new System.Windows.Forms.TabPage();
      this.ClassStandingsList = new System.Windows.Forms.ListView();
      this.ClassCol = new System.Windows.Forms.ColumnHeader();
      this.DriverCol = new System.Windows.Forms.ColumnHeader();
      this.CarCol = new System.Windows.Forms.ColumnHeader();
      this.ClassPointsCol = new System.Windows.Forms.ColumnHeader();
      this.PaxPointsPage = new System.Windows.Forms.TabPage();
      this.PaxStandingsList = new System.Windows.Forms.ListView();
      this.PaxClassCol = new System.Windows.Forms.ColumnHeader();
      this.PaxDriverCol = new System.Windows.Forms.ColumnHeader();
      this.PaxCarCol = new System.Windows.Forms.ColumnHeader();
      this.PaxPointsCol = new System.Windows.Forms.ColumnHeader();
      this.SaveReport = new System.Windows.Forms.SaveFileDialog();
      ((System.ComponentModel.ISupportInitialize)(this.StatusPanel)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.FilenamePanel)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.ModifiedPanel)).BeginInit();
      this.TabControl.SuspendLayout();
      this.SettingsPage.SuspendLayout();
      this.ClassActionsGroup.SuspendLayout();
      this.ClassDetailsGroup.SuspendLayout();
      ((System.ComponentModel.ISupportInitialize)(this.DropCountUpDn)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.ReqEventCountUpDn)).BeginInit();
      ((System.ComponentModel.ISupportInitialize)(this.EventCountUpDn)).BeginInit();
      this.EventsPage.SuspendLayout();
      this.EventActionsGroup.SuspendLayout();
      this.EventDetailsGroup.SuspendLayout();
      this.ClassPointsPage.SuspendLayout();
      this.PaxPointsPage.SuspendLayout();
      this.SuspendLayout();
      //
      // MainMenu
      //
      this.MainMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                            this.FileMenu,
                                                                            this.ReportsMenu});
      //
      // FileMenu
      //
      this.FileMenu.Index = 0;
      this.FileMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                            this.NewMenu,
                                                                            this.OpenMenu,
                                                                            this.SaveMenu,
                                                                            this.SaveAsMenu,
                                                                            this.CloseMenu,
                                                                            this.SeperatorMenu,
                                                                            this.ExitMenu});
      this.FileMenu.Text = "&File";
      //
      // NewMenu
      //
      this.NewMenu.Index = 0;
      this.NewMenu.Text = "&New";
      this.NewMenu.Click += new System.EventHandler(this.NewMenu_Click);
      //
      // OpenMenu
      //
      this.OpenMenu.Index = 1;
      this.OpenMenu.Text = "&Open...";
      this.OpenMenu.Click += new System.EventHandler(this.OpenMenu_Click);
      //
      // SaveMenu
      //
      this.SaveMenu.Index = 2;
      this.SaveMenu.Text = "&Save";
      this.SaveMenu.Click += new System.EventHandler(this.SaveMenu_Click);
      //
      // SaveAsMenu
      //
      this.SaveAsMenu.Index = 3;
      this.SaveAsMenu.Text = "Save &As...";
      this.SaveAsMenu.Click += new System.EventHandler(this.SaveAsMenu_Click);
      //
      // CloseMenu
      //
      this.CloseMenu.Index = 4;
      this.CloseMenu.Text = "&Close";
      this.CloseMenu.Click += new System.EventHandler(this.CloseMenu_Click);
      //
      // SeperatorMenu
      //
      this.SeperatorMenu.Index = 5;
      this.SeperatorMenu.Text = "-";
      //
      // ExitMenu
      //
      this.ExitMenu.Index = 6;
      this.ExitMenu.Text = "E&xit";
      this.ExitMenu.Click += new System.EventHandler(this.ExitMenu_Click);
      //
      // ReportsMenu
      //
      this.ReportsMenu.Index = 1;
      this.ReportsMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                                this.EventReportMenu,
                                                                                this.ClassReportMenu,
                                                                                this.PaxReportMenu,
                                                                                this.PerfectAttendanceMenu,
                                                                                this.menuItem1,
                                                                                this.menuItem2});
      this.ReportsMenu.Text = "&Reports";
      //
      // EventReportMenu
      //
      this.EventReportMenu.Index = 0;
      this.EventReportMenu.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                                    this.GenerateAllEventReportsMenu,
                                                                                    this.menuItem5});
      this.EventReportMenu.Text = "&Event Reports";
      this.EventReportMenu.Popup += new System.EventHandler(this.EventReportMenu_Popup);
      //
      // GenerateAllEventReportsMenu
      //
      this.GenerateAllEventReportsMenu.Index = 0;
      this.GenerateAllEventReportsMenu.Text = "&All Events";
      this.GenerateAllEventReportsMenu.Click += new System.EventHandler(this.GenerateAllEventReportsMenu_Click);
      //
      // menuItem5
      //
      this.menuItem5.Index = 1;
      this.menuItem5.Text = "-";
      //
      // ClassReportMenu
      //
      this.ClassReportMenu.Index = 1;
      this.ClassReportMenu.Text = "&Class Standings...";
      this.ClassReportMenu.Click += new System.EventHandler(this.GenerateReport);
      //
      // PaxReportMenu
      //
      this.PaxReportMenu.Index = 2;
      this.PaxReportMenu.Text = "&PAX Standings...";
      this.PaxReportMenu.Click += new System.EventHandler(this.GenerateReport);
      //
      // PerfectAttendanceMenu
      //
      this.PerfectAttendanceMenu.Index = 3;
      this.PerfectAttendanceMenu.Text = "Perfect &Attendance...";
      this.PerfectAttendanceMenu.Click += new System.EventHandler(this.PerfectAttendanceMenu_Click);
      //
      // menuItem1
      //
      this.menuItem1.Index = 4;
      this.menuItem1.Text = "-";
      //
      // menuItem2
      //
      this.menuItem2.Index = 5;
      this.menuItem2.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
                                                                              this.ExcludeMenu});
      this.menuItem2.Text = "Report &Options";
      //
      // ExcludeMenu
      //
      this.ExcludeMenu.Checked = true;
      this.ExcludeMenu.Index = 0;
      this.ExcludeMenu.Text = "E&xclude non-Qualified Drivers";
      this.ExcludeMenu.Click += new System.EventHandler(this.ExcludeMenu_Click);
      //
      // StatusBar
      //
      this.StatusBar.Location = new System.Drawing.Point(0, 449);
      this.StatusBar.Name = "StatusBar";
      this.StatusBar.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
                                                                                this.StatusPanel,
                                                                                this.FilenamePanel,
                                                                                this.ModifiedPanel});
      this.StatusBar.ShowPanels = true;
      this.StatusBar.Size = new System.Drawing.Size(864, 24);
      this.StatusBar.TabIndex = 0;
      //
      // StatusPanel
      //
      this.StatusPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
      this.StatusPanel.Width = 680;
      //
      // FilenamePanel
      //
      this.FilenamePanel.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
      this.FilenamePanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
      this.FilenamePanel.Text = "No season open";
      this.FilenamePanel.Width = 96;
      //
      // ModifiedPanel
      //
      this.ModifiedPanel.Alignment = System.Windows.Forms.HorizontalAlignment.Center;
      this.ModifiedPanel.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Contents;
      this.ModifiedPanel.Text = "Unmodified";
      this.ModifiedPanel.Width = 72;
      //
      // StatusTimer
      //
      this.StatusTimer.Interval = 8000;
      this.StatusTimer.Tick += new System.EventHandler(this.StatusTimer_Tick);
      //
      // OpenFile
      //
      this.OpenFile.DefaultExt = "season";
      this.OpenFile.Filter = "Season Files (*.season)|*.season|All File (*.*)|*.*";
      this.OpenFile.Title = "Open Season File";
      //
      // SaveFile
      //
      this.SaveFile.DefaultExt = "season";
      this.SaveFile.Filter = "Season Files (*.season)|*.season|All File (*.*)|*.*";
      this.SaveFile.Title = "Save Season File";
      //
      // TabControl
      //
      this.TabControl.Controls.Add(this.SettingsPage);
      this.TabControl.Controls.Add(this.EventsPage);
      this.TabControl.Controls.Add(this.ClassPointsPage);
      this.TabControl.Controls.Add(this.PaxPointsPage);
      this.TabControl.Dock = System.Windows.Forms.DockStyle.Fill;
      this.TabControl.Location = new System.Drawing.Point(0, 0);
      this.TabControl.Name = "TabControl";
      this.TabControl.SelectedIndex = 0;
      this.TabControl.Size = new System.Drawing.Size(864, 449);
      this.TabControl.TabIndex = 1;
      //
      // SettingsPage
      //
      this.SettingsPage.Controls.Add(this.SingleEntrantPaxPointsText);
      this.SettingsPage.Controls.Add(this.label16);
      this.SettingsPage.Controls.Add(this.SingleEntrantClassPointsText);
      this.SettingsPage.Controls.Add(this.label15);
      this.SettingsPage.Controls.Add(this.ClubNameText);
      this.SettingsPage.Controls.Add(this.label11);
      this.SettingsPage.Controls.Add(this.SeasonNameText);
      this.SettingsPage.Controls.Add(this.label6);
      this.SettingsPage.Controls.Add(this.ClassActionsGroup);
      this.SettingsPage.Controls.Add(this.label14);
      this.SettingsPage.Controls.Add(this.ClassDetailsGroup);
      this.SettingsPage.Controls.Add(this.ClassList);
      this.SettingsPage.Controls.Add(this.DropCountUpDn);
      this.SettingsPage.Controls.Add(this.label5);
      this.SettingsPage.Controls.Add(this.ReqEventCountUpDn);
      this.SettingsPage.Controls.Add(this.label4);
      this.SettingsPage.Controls.Add(this.EventCountUpDn);
      this.SettingsPage.Controls.Add(this.label3);
      this.SettingsPage.Controls.Add(this.PaxPointsText);
      this.SettingsPage.Controls.Add(this.label2);
      this.SettingsPage.Controls.Add(this.ClassPointsText);
      this.SettingsPage.Controls.Add(this.label1);
      this.SettingsPage.Location = new System.Drawing.Point(4, 22);
      this.SettingsPage.Name = "SettingsPage";
      this.SettingsPage.Size = new System.Drawing.Size(856, 423);
      this.SettingsPage.TabIndex = 0;
      this.SettingsPage.Text = "Settings";
      //
      // SingleEntrantPaxPointsText
      //
      this.SingleEntrantPaxPointsText.Location = new System.Drawing.Point(520, 80);
      this.SingleEntrantPaxPointsText.Name = "SingleEntrantPaxPointsText";
      this.SingleEntrantPaxPointsText.Size = new System.Drawing.Size(48, 20);
      this.SingleEntrantPaxPointsText.TabIndex = 34;
      this.SingleEntrantPaxPointsText.Text = "";
      //
      // label16
      //
      this.label16.Location = new System.Drawing.Point(392, 80);
      this.label16.Name = "label16";
      this.label16.Size = new System.Drawing.Size(120, 20);
      this.label16.TabIndex = 33;
      this.label16.Text = "Single Entrant Points:";
      this.label16.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // SingleEntrantClassPointsText
      //
      this.SingleEntrantClassPointsText.Location = new System.Drawing.Point(520, 56);
      this.SingleEntrantClassPointsText.Name = "SingleEntrantClassPointsText";
      this.SingleEntrantClassPointsText.Size = new System.Drawing.Size(48, 20);
      this.SingleEntrantClassPointsText.TabIndex = 32;
      this.SingleEntrantClassPointsText.Text = "";
      //
      // label15
      //
      this.label15.Location = new System.Drawing.Point(392, 56);
      this.label15.Name = "label15";
      this.label15.Size = new System.Drawing.Size(120, 20);
      this.label15.TabIndex = 31;
      this.label15.Text = "Single Entrant Points:";
      this.label15.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // ClubNameText
      //
      this.ClubNameText.Location = new System.Drawing.Point(144, 32);
      this.ClubNameText.Name = "ClubNameText";
      this.ClubNameText.Size = new System.Drawing.Size(248, 20);
      this.ClubNameText.TabIndex = 30;
      this.ClubNameText.Text = "";
      //
      // label11
      //
      this.label11.Location = new System.Drawing.Point(72, 32);
      this.label11.Name = "label11";
      this.label11.Size = new System.Drawing.Size(64, 20);
      this.label11.TabIndex = 29;
      this.label11.Text = "Club Name:";
      this.label11.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // SeasonNameText
      //
      this.SeasonNameText.Location = new System.Drawing.Point(144, 8);
      this.SeasonNameText.Name = "SeasonNameText";
      this.SeasonNameText.Size = new System.Drawing.Size(248, 20);
      this.SeasonNameText.TabIndex = 28;
      this.SeasonNameText.Text = "";
      //
      // label6
      //
      this.label6.Location = new System.Drawing.Point(8, 8);
      this.label6.Name = "label6";
      this.label6.Size = new System.Drawing.Size(128, 20);
      this.label6.TabIndex = 27;
      this.label6.Text = "Season Name:";
      this.label6.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // ClassActionsGroup
      //
      this.ClassActionsGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
      this.ClassActionsGroup.Controls.Add(this.AddClassButton);
      this.ClassActionsGroup.Location = new System.Drawing.Point(608, 280);
      this.ClassActionsGroup.Name = "ClassActionsGroup";
      this.ClassActionsGroup.Size = new System.Drawing.Size(232, 56);
      this.ClassActionsGroup.TabIndex = 26;
      this.ClassActionsGroup.TabStop = false;
      this.ClassActionsGroup.Text = "Class Actions";
      //
      // AddClassButton
      //
      this.AddClassButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.AddClassButton.Enabled = false;
      this.AddClassButton.Location = new System.Drawing.Point(16, 24);
      this.AddClassButton.Name = "AddClassButton";
      this.AddClassButton.Size = new System.Drawing.Size(88, 23);
      this.AddClassButton.TabIndex = 20;
      this.AddClassButton.Text = "Add Class";
      //
      // label14
      //
      this.label14.Location = new System.Drawing.Point(8, 128);
      this.label14.Name = "label14";
      this.label14.Size = new System.Drawing.Size(128, 16);
      this.label14.TabIndex = 25;
      this.label14.Text = "Classes:";
      this.label14.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // ClassDetailsGroup
      //
      this.ClassDetailsGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
      this.ClassDetailsGroup.Controls.Add(this.ClassLadiesCheck);
      this.ClassDetailsGroup.Controls.Add(this.ApplyClassButton);
      this.ClassDetailsGroup.Controls.Add(this.ClassNonPointsCheck);
      this.ClassDetailsGroup.Controls.Add(this.DeleteClassButton);
      this.ClassDetailsGroup.Controls.Add(this.ClassDescText);
      this.ClassDetailsGroup.Controls.Add(this.label12);
      this.ClassDetailsGroup.Controls.Add(this.ClassIdText);
      this.ClassDetailsGroup.Controls.Add(this.label13);
      this.ClassDetailsGroup.Enabled = false;
      this.ClassDetailsGroup.Location = new System.Drawing.Point(608, 128);
      this.ClassDetailsGroup.Name = "ClassDetailsGroup";
      this.ClassDetailsGroup.Size = new System.Drawing.Size(232, 152);
      this.ClassDetailsGroup.TabIndex = 24;
      this.ClassDetailsGroup.TabStop = false;
      this.ClassDetailsGroup.Text = "Selected Class Details";
      //
      // ClassLadiesCheck
      //
      this.ClassLadiesCheck.Location = new System.Drawing.Point(72, 64);
      this.ClassLadiesCheck.Name = "ClassLadiesCheck";
      this.ClassLadiesCheck.Size = new System.Drawing.Size(152, 20);
      this.ClassLadiesCheck.TabIndex = 22;
      this.ClassLadiesCheck.Text = "Ladies Class?";
      this.ClassLadiesCheck.CheckedChanged += new System.EventHandler(this.ClassDetailsChanged);
      //
      // ApplyClassButton
      //
      this.ApplyClassButton.Location = new System.Drawing.Point(16, 120);
      this.ApplyClassButton.Name = "ApplyClassButton";
      this.ApplyClassButton.Size = new System.Drawing.Size(96, 23);
      this.ApplyClassButton.TabIndex = 21;
      this.ApplyClassButton.Text = "Apply Changes";
      this.ApplyClassButton.Click += new System.EventHandler(this.ApplyClassButton_Click);
      //
      // ClassNonPointsCheck
      //
      this.ClassNonPointsCheck.Location = new System.Drawing.Point(72, 88);
      this.ClassNonPointsCheck.Name = "ClassNonPointsCheck";
      this.ClassNonPointsCheck.Size = new System.Drawing.Size(152, 20);
      this.ClassNonPointsCheck.TabIndex = 20;
      this.ClassNonPointsCheck.Text = "Non-Points Class?";
      this.ClassNonPointsCheck.CheckedChanged += new System.EventHandler(this.ClassDetailsChanged);
      //
      // DeleteClassButton
      //
      this.DeleteClassButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
      this.DeleteClassButton.Enabled = false;
      this.DeleteClassButton.Location = new System.Drawing.Point(120, 120);
      this.DeleteClassButton.Name = "DeleteClassButton";
      this.DeleteClassButton.Size = new System.Drawing.Size(96, 23);
      this.DeleteClassButton.TabIndex = 19;
      this.DeleteClassButton.Text = "Delete Class";
      //
      // ClassDescText
      //
      this.ClassDescText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.ClassDescText.Location = new System.Drawing.Point(72, 40);
      this.ClassDescText.Name = "ClassDescText";
      this.ClassDescText.Size = new System.Drawing.Size(152, 20);
      this.ClassDescText.TabIndex = 5;
      this.ClassDescText.Text = "";
      this.ClassDescText.TextChanged += new System.EventHandler(this.ClassDetailsChanged);
      //
      // label12
      //
      this.label12.Location = new System.Drawing.Point(8, 40);
      this.label12.Name = "label12";
      this.label12.Size = new System.Drawing.Size(56, 20);
      this.label12.TabIndex = 4;
      this.label12.Text = "Desc:";
      this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // ClassIdText
      //
      this.ClassIdText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.ClassIdText.Location = new System.Drawing.Point(72, 16);
      this.ClassIdText.Name = "ClassIdText";
      this.ClassIdText.Size = new System.Drawing.Size(152, 20);
      this.ClassIdText.TabIndex = 3;
      this.ClassIdText.Text = "";
      this.ClassIdText.TextChanged += new System.EventHandler(this.ClassDetailsChanged);
      //
      // label13
      //
      this.label13.Location = new System.Drawing.Point(8, 16);
      this.label13.Name = "label13";
      this.label13.Size = new System.Drawing.Size(56, 20);
      this.label13.TabIndex = 2;
      this.label13.Text = "Class ID:";
      this.label13.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // ClassList
      //
      this.ClassList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
        | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.ClassList.IntegralHeight = false;
      this.ClassList.Location = new System.Drawing.Point(144, 128);
      this.ClassList.Name = "ClassList";
      this.ClassList.Size = new System.Drawing.Size(456, 288);
      this.ClassList.TabIndex = 23;
      this.ClassList.SelectedIndexChanged += new System.EventHandler(this.ClassList_SelectedIndexChanged);
      //
      // DropCountUpDn
      //
      this.DropCountUpDn.Location = new System.Drawing.Point(520, 104);
      this.DropCountUpDn.Name = "DropCountUpDn";
      this.DropCountUpDn.Size = new System.Drawing.Size(48, 20);
      this.DropCountUpDn.TabIndex = 9;
      //
      // label5
      //
      this.label5.Location = new System.Drawing.Point(376, 104);
      this.label5.Name = "label5";
      this.label5.Size = new System.Drawing.Size(136, 20);
      this.label5.TabIndex = 8;
      this.label5.Text = "Number of Drops:";
      this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // ReqEventCountUpDn
      //
      this.ReqEventCountUpDn.Location = new System.Drawing.Point(328, 104);
      this.ReqEventCountUpDn.Name = "ReqEventCountUpDn";
      this.ReqEventCountUpDn.Size = new System.Drawing.Size(48, 20);
      this.ReqEventCountUpDn.TabIndex = 7;
      //
      // label4
      //
      this.label4.Location = new System.Drawing.Point(192, 104);
      this.label4.Name = "label4";
      this.label4.Size = new System.Drawing.Size(128, 20);
      this.label4.TabIndex = 6;
      this.label4.Text = "Events to Qualify:";
      this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // EventCountUpDn
      //
      this.EventCountUpDn.Location = new System.Drawing.Point(144, 104);
      this.EventCountUpDn.Name = "EventCountUpDn";
      this.EventCountUpDn.Size = new System.Drawing.Size(48, 20);
      this.EventCountUpDn.TabIndex = 5;
      //
      // label3
      //
      this.label3.Location = new System.Drawing.Point(8, 104);
      this.label3.Name = "label3";
      this.label3.Size = new System.Drawing.Size(128, 20);
      this.label3.TabIndex = 4;
      this.label3.Text = "Number of Events:";
      this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // PaxPointsText
      //
      this.PaxPointsText.Location = new System.Drawing.Point(144, 80);
      this.PaxPointsText.Name = "PaxPointsText";
      this.PaxPointsText.Size = new System.Drawing.Size(248, 20);
      this.PaxPointsText.TabIndex = 3;
      this.PaxPointsText.Text = "";
      //
      // label2
      //
      this.label2.Location = new System.Drawing.Point(8, 80);
      this.label2.Name = "label2";
      this.label2.Size = new System.Drawing.Size(128, 20);
      this.label2.TabIndex = 2;
      this.label2.Text = "PAX Points Sequence:";
      this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // ClassPointsText
      //
      this.ClassPointsText.Location = new System.Drawing.Point(144, 56);
      this.ClassPointsText.Name = "ClassPointsText";
      this.ClassPointsText.Size = new System.Drawing.Size(248, 20);
      this.ClassPointsText.TabIndex = 1;
      this.ClassPointsText.Text = "";
      //
      // label1
      //
      this.label1.Location = new System.Drawing.Point(8, 56);
      this.label1.Name = "label1";
      this.label1.Size = new System.Drawing.Size(128, 20);
      this.label1.TabIndex = 0;
      this.label1.Text = "Class Points Sequence:";
      this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // EventsPage
      //
      this.EventsPage.Controls.Add(this.EventActionsGroup);
      this.EventsPage.Controls.Add(this.EventDetailsGroup);
      this.EventsPage.Controls.Add(this.EventList);
      this.EventsPage.Location = new System.Drawing.Point(4, 22);
      this.EventsPage.Name = "EventsPage";
      this.EventsPage.Size = new System.Drawing.Size(856, 423);
      this.EventsPage.TabIndex = 2;
      this.EventsPage.Text = "Events";
      //
      // EventActionsGroup
      //
      this.EventActionsGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
      this.EventActionsGroup.Controls.Add(this.GenerateEventReportButton);
      this.EventActionsGroup.Controls.Add(this.SyncAllEvents);
      this.EventActionsGroup.Controls.Add(this.SyncSingleEvent);
      this.EventActionsGroup.Location = new System.Drawing.Point(568, 152);
      this.EventActionsGroup.Name = "EventActionsGroup";
      this.EventActionsGroup.Size = new System.Drawing.Size(280, 128);
      this.EventActionsGroup.TabIndex = 24;
      this.EventActionsGroup.TabStop = false;
      this.EventActionsGroup.Text = "Event Actions";
      //
      // GenerateEventReportButton
      //
      this.GenerateEventReportButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.GenerateEventReportButton.Location = new System.Drawing.Point(16, 88);
      this.GenerateEventReportButton.Name = "GenerateEventReportButton";
      this.GenerateEventReportButton.Size = new System.Drawing.Size(248, 23);
      this.GenerateEventReportButton.TabIndex = 22;
      this.GenerateEventReportButton.Text = "Generate event report...";
      this.GenerateEventReportButton.Click += new System.EventHandler(this.GenerateEventReportButton_Click);
      //
      // SyncAllEvents
      //
      this.SyncAllEvents.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.SyncAllEvents.Location = new System.Drawing.Point(16, 53);
      this.SyncAllEvents.Name = "SyncAllEvents";
      this.SyncAllEvents.Size = new System.Drawing.Size(248, 23);
      this.SyncAllEvents.TabIndex = 21;
      this.SyncAllEvents.Text = "Sync all events with championship...";
      //
      // SyncSingleEvent
      //
      this.SyncSingleEvent.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.SyncSingleEvent.Location = new System.Drawing.Point(16, 24);
      this.SyncSingleEvent.Name = "SyncSingleEvent";
      this.SyncSingleEvent.Size = new System.Drawing.Size(248, 23);
      this.SyncSingleEvent.TabIndex = 20;
      this.SyncSingleEvent.Text = "Sync selected event with championship...";
      this.SyncSingleEvent.Click += new System.EventHandler(this.SyncSingleEvent_Click);
      //
      // EventDetailsGroup
      //
      this.EventDetailsGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
      this.EventDetailsGroup.Controls.Add(this.DeleteEventButton);
      this.EventDetailsGroup.Controls.Add(this.label10);
      this.EventDetailsGroup.Controls.Add(this.EventMover);
      this.EventDetailsGroup.Controls.Add(this.EventFilenameText);
      this.EventDetailsGroup.Controls.Add(this.label9);
      this.EventDetailsGroup.Controls.Add(this.EventDateText);
      this.EventDetailsGroup.Controls.Add(this.label8);
      this.EventDetailsGroup.Controls.Add(this.EventNameText);
      this.EventDetailsGroup.Controls.Add(this.label7);
      this.EventDetailsGroup.Enabled = false;
      this.EventDetailsGroup.Location = new System.Drawing.Point(568, 8);
      this.EventDetailsGroup.Name = "EventDetailsGroup";
      this.EventDetailsGroup.Size = new System.Drawing.Size(280, 128);
      this.EventDetailsGroup.TabIndex = 22;
      this.EventDetailsGroup.TabStop = false;
      this.EventDetailsGroup.Text = "Selected Event Details";
      //
      // DeleteEventButton
      //
      this.DeleteEventButton.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.DeleteEventButton.Location = new System.Drawing.Point(104, 96);
      this.DeleteEventButton.Name = "DeleteEventButton";
      this.DeleteEventButton.Size = new System.Drawing.Size(168, 23);
      this.DeleteEventButton.TabIndex = 19;
      this.DeleteEventButton.Text = "Delete Event";
      //
      // label10
      //
      this.label10.Location = new System.Drawing.Point(8, 88);
      this.label10.Name = "label10";
      this.label10.Size = new System.Drawing.Size(56, 32);
      this.label10.TabIndex = 17;
      this.label10.Text = "Move:";
      this.label10.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // EventMover
      //
      this.EventMover.LargeChange = 1;
      this.EventMover.Location = new System.Drawing.Point(72, 88);
      this.EventMover.Maximum = 1;
      this.EventMover.Minimum = -1;
      this.EventMover.Name = "EventMover";
      this.EventMover.Size = new System.Drawing.Size(24, 32);
      this.EventMover.TabIndex = 16;
      this.EventMover.TabStop = true;
      //
      // EventFilenameText
      //
      this.EventFilenameText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.EventFilenameText.Location = new System.Drawing.Point(72, 64);
      this.EventFilenameText.Name = "EventFilenameText";
      this.EventFilenameText.Size = new System.Drawing.Size(200, 20);
      this.EventFilenameText.TabIndex = 7;
      this.EventFilenameText.Text = "";
      //
      // label9
      //
      this.label9.Location = new System.Drawing.Point(8, 64);
      this.label9.Name = "label9";
      this.label9.Size = new System.Drawing.Size(56, 20);
      this.label9.TabIndex = 6;
      this.label9.Text = "Filename:";
      this.label9.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // EventDateText
      //
      this.EventDateText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.EventDateText.Location = new System.Drawing.Point(72, 40);
      this.EventDateText.Name = "EventDateText";
      this.EventDateText.Size = new System.Drawing.Size(200, 20);
      this.EventDateText.TabIndex = 5;
      this.EventDateText.Text = "";
      //
      // label8
      //
      this.label8.Location = new System.Drawing.Point(8, 40);
      this.label8.Name = "label8";
      this.label8.Size = new System.Drawing.Size(56, 20);
      this.label8.TabIndex = 4;
      this.label8.Text = "Date:";
      this.label8.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // EventNameText
      //
      this.EventNameText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.EventNameText.Location = new System.Drawing.Point(72, 16);
      this.EventNameText.Name = "EventNameText";
      this.EventNameText.Size = new System.Drawing.Size(200, 20);
      this.EventNameText.TabIndex = 3;
      this.EventNameText.Text = "";
      //
      // label7
      //
      this.label7.Location = new System.Drawing.Point(8, 16);
      this.label7.Name = "label7";
      this.label7.Size = new System.Drawing.Size(56, 20);
      this.label7.TabIndex = 2;
      this.label7.Text = "Name:";
      this.label7.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
      //
      // EventList
      //
      this.EventList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
        | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.EventList.IntegralHeight = false;
      this.EventList.Location = new System.Drawing.Point(8, 8);
      this.EventList.Name = "EventList";
      this.EventList.Size = new System.Drawing.Size(552, 403);
      this.EventList.TabIndex = 21;
      this.EventList.SelectedIndexChanged += new System.EventHandler(this.EventList_SelectedIndexChanged);
      //
      // ClassPointsPage
      //
      this.ClassPointsPage.Controls.Add(this.ClassStandingsList);
      this.ClassPointsPage.Location = new System.Drawing.Point(4, 22);
      this.ClassPointsPage.Name = "ClassPointsPage";
      this.ClassPointsPage.Size = new System.Drawing.Size(856, 423);
      this.ClassPointsPage.TabIndex = 1;
      this.ClassPointsPage.Text = "Class Championship Points";
      //
      // ClassStandingsList
      //
      this.ClassStandingsList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
                                                                                        this.ClassCol,
                                                                                        this.DriverCol,
                                                                                        this.CarCol,
                                                                                        this.ClassPointsCol});
      this.ClassStandingsList.Dock = System.Windows.Forms.DockStyle.Fill;
      this.ClassStandingsList.FullRowSelect = true;
      this.ClassStandingsList.GridLines = true;
      this.ClassStandingsList.Location = new System.Drawing.Point(0, 0);
      this.ClassStandingsList.MultiSelect = false;
      this.ClassStandingsList.Name = "ClassStandingsList";
      this.ClassStandingsList.Size = new System.Drawing.Size(856, 423);
      this.ClassStandingsList.TabIndex = 2;
      this.ClassStandingsList.View = System.Windows.Forms.View.Details;
      //
      // ClassCol
      //
      this.ClassCol.Text = "Class";
      //
      // DriverCol
      //
      this.DriverCol.Text = "Driver";
      this.DriverCol.Width = 150;
      //
      // CarCol
      //
      this.CarCol.Text = "Car";
      this.CarCol.Width = 150;
      //
      // ClassPointsCol
      //
      this.ClassPointsCol.Text = "Pos (Pts/Drops)";
      this.ClassPointsCol.Width = 100;
      //
      // PaxPointsPage
      //
      this.PaxPointsPage.Controls.Add(this.PaxStandingsList);
      this.PaxPointsPage.Location = new System.Drawing.Point(4, 22);
      this.PaxPointsPage.Name = "PaxPointsPage";
      this.PaxPointsPage.Size = new System.Drawing.Size(856, 423);
      this.PaxPointsPage.TabIndex = 3;
      this.PaxPointsPage.Text = "PAX Championship Points";
      //
      // PaxStandingsList
      //
      this.PaxStandingsList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
                                                                                      this.PaxClassCol,
                                                                                      this.PaxDriverCol,
                                                                                      this.PaxCarCol,
                                                                                      this.PaxPointsCol});
      this.PaxStandingsList.Dock = System.Windows.Forms.DockStyle.Fill;
      this.PaxStandingsList.FullRowSelect = true;
      this.PaxStandingsList.GridLines = true;
      this.PaxStandingsList.Location = new System.Drawing.Point(0, 0);
      this.PaxStandingsList.MultiSelect = false;
      this.PaxStandingsList.Name = "PaxStandingsList";
      this.PaxStandingsList.Size = new System.Drawing.Size(856, 423);
      this.PaxStandingsList.TabIndex = 3;
      this.PaxStandingsList.View = System.Windows.Forms.View.Details;
      //
      // PaxClassCol
      //
      this.PaxClassCol.Text = "Class";
      //
      // PaxDriverCol
      //
      this.PaxDriverCol.Text = "Driver";
      this.PaxDriverCol.Width = 150;
      //
      // PaxCarCol
      //
      this.PaxCarCol.Text = "Car";
      this.PaxCarCol.Width = 150;
      //
      // PaxPointsCol
      //
      this.PaxPointsCol.Text = "Pos (Pts/Drops)";
      this.PaxPointsCol.Width = 100;
      //
      // SaveReport
      //
      this.SaveReport.DefaultExt = "html";
      this.SaveReport.Filter = "HTML Reports (*.html)|*.html|All Files (*.*)|*.*";
      this.SaveReport.Title = "Save Report";
      //
      // MainForm
      //
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(864, 473);
      this.Controls.Add(this.TabControl);
      this.Controls.Add(this.StatusBar);
      this.Menu = this.MainMenu;
      this.MinimumSize = new System.Drawing.Size(600, 448);
      this.Name = "MainForm";
      this.Text = "Season Manager";
      this.Closing += new System.ComponentModel.CancelEventHandler(this.MainForm_Closing);
      ((System.ComponentModel.ISupportInitialize)(this.StatusPanel)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.FilenamePanel)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.ModifiedPanel)).EndInit();
      this.TabControl.ResumeLayout(false);
      this.SettingsPage.ResumeLayout(false);
      this.ClassActionsGroup.ResumeLayout(false);
      this.ClassDetailsGroup.ResumeLayout(false);
      ((System.ComponentModel.ISupportInitialize)(this.DropCountUpDn)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.ReqEventCountUpDn)).EndInit();
      ((System.ComponentModel.ISupportInitialize)(this.EventCountUpDn)).EndInit();
      this.EventsPage.ResumeLayout(false);
      this.EventActionsGroup.ResumeLayout(false);
      this.EventDetailsGroup.ResumeLayout(false);
      this.ClassPointsPage.ResumeLayout(false);
      this.PaxPointsPage.ResumeLayout(false);
      this.ResumeLayout(false);

    }
                #endregion

                /// <summary>
                /// The main entry point for the application.
                /// </summary>
                [STAThread]
                static void Main()
                {
                        Application.Run(new MainForm());
                }

    public ulong GetNextID()
    {
      ulong rval = 0;
      if (season_data != null)
      {
        rval = season_data.Payload.DocState.next_id++;
      }
      return rval;
    }

    public void StatusMessage(string message)
    {
      StatusTimer.Enabled = false;
      StatusPanel.Text = message;
      StatusTimer.Enabled = true;
    }

    private void StatusTimer_Tick(object sender, System.EventArgs e)
    {
      StatusTimer.Enabled = false;
      StatusPanel.Text = "";
    }

    private void ExitMenu_Click(object sender, System.EventArgs e)
    {
      Close();
    }

    private void NewMenu_Click(object sender, System.EventArgs e)
    {
      CloseMenu_Click(this, e);

      if (season_data == null)
      {
        season_data = new SeasonWrapper();
        season_data.LoadDefaults();
        UpdateDisplay();
        StatusMessage("New season created.");
      }     
    }

    private void OpenMenu_Click(object sender, System.EventArgs e)
    {
      CloseMenu_Click(this, e);

      if (season_data == null)
      {
        if (OpenFile.ShowDialog(this) == DialogResult.OK)
        {
          season_data = new SeasonWrapper();
          if (season_data.LoadFromFile(OpenFile.FileName))
          {
            UpdateDisplay();
            StatusMessage("Opened file '" + OpenFile.FileName + "'.");
          }
          else
          {
            season_data = null;
            GC.Collect();
            StatusMessage("Error opening file '" + OpenFile.FileName + "'.");
          }
        }
      }     
    }

    private void SaveMenu_Click(object sender, System.EventArgs e)
    {
      if (season_data != null)
      {
        if (season_data.Payload.DocState.filename == "")
        {
          SaveAsMenu_Click(this, e);
        }
        else
        {
          season_data.Payload.DocState.modified = false;
          if (season_data.SaveToFile(season_data.Payload.DocState.filename))
          {
            StatusMessage("Season saved to file '" + season_data.Payload.DocState.filename + "'.");
          }
          else
          {
            season_data.Payload.DocState.modified = true;
            StatusMessage("Error saving to file '" + season_data.Payload.DocState.filename + "'.");
          }
        }
      }
    }

    private void SaveAsMenu_Click(object sender, System.EventArgs e)
    {
      if (season_data != null)
      {
        if (SaveFile.ShowDialog(this) == DialogResult.OK)
        {
          season_data.Payload.DocState.filename = SaveFile.FileName;
          UpdateDisplay();
          SaveMenu_Click(this, e);
        }
      }
    }

    private void CloseMenu_Click(object sender, System.EventArgs e)
    {
      if (season_data != null)
      {
        DialogResult result = DialogResult.No;

        if (season_data.Payload.DocState.modified)
        {
          result = MessageBox.Show(this, "The current season is modified, save before closing?", "Save Season?", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
        }

        switch (result)
        {
          case DialogResult.Yes:
            SaveMenu_Click(this, e);
            if (season_data.Payload.DocState.modified)
            {
              return; // user cancelled the save operation
            }
            goto case DialogResult.No;

          case DialogResult.No:
            season_data = null;
            GC.Collect();
            UpdateDisplay();
            StatusMessage("Season file closed.");
            break;

          default:
            // do nothing
            break;
        }
      }
    }

    public void UpdateDisplay()
    {
      if (season_data == null)
      {
        // Update StatusBar
        FilenamePanel.Text = "No season open";
        ModifiedPanel.Text = "Unmodified";

        // Update Season Info
        SeasonNameText.Text = "";
        ClubNameText.Text = "";

        // Update Settings
        ClassPointsText.Text = "";
        SingleEntrantClassPointsText.Text = "";
        PaxPointsText.Text = "";
        SingleEntrantPaxPointsText.Text = "";
        EventCountUpDn.Value = 0;
        ReqEventCountUpDn.Value = 0;
        DropCountUpDn.Value = 0;

        // Update Class List
        ClassList.Items.Clear();

        // Update Event List
        EventList.Items.Clear();

        // Update Class Standing List
        ClassStandingsList.Items.Clear();
      }
      else
      {
        #region Update StatusBar
        if (season_data.Payload.DocState.filename == "")
        {
          FilenamePanel.Text = "New file";
        }
        else
        {
          FilenamePanel.Text = season_data.Payload.DocState.filename;
        }

        if (season_data.Payload.DocState.modified)
        {
          ModifiedPanel.Text = "Modified";
        }
        else
        {
          ModifiedPanel.Text = "Unmodified";
        }
        #endregion

        #region Update Season Info
        SeasonNameText.Text = season_data.Payload.name;
        ClubNameText.Text = season_data.Payload.club;
        #endregion

        #region Update Settings
        ClassPointsText.Text = season_data.Payload.Settings.class_points;
        SingleEntrantClassPointsText.Text = season_data.Payload.Settings.single_entrant_class_points.ToString();
        PaxPointsText.Text = season_data.Payload.Settings.pax_points;
        SingleEntrantPaxPointsText.Text = season_data.Payload.Settings.single_entrant_pax_points.ToString();
        EventCountUpDn.Value = season_data.Payload.Settings.event_count;
        ReqEventCountUpDn.Value = season_data.Payload.Settings.min_event_count;
        DropCountUpDn.Value = season_data.Payload.Settings.drop_count;
        #endregion

        #region Update Class List
        ClassList.BeginUpdate();
        {
          ClassList.Items.Clear();
          for (int i=0; i<season_data.Payload.Classes.Length; i++)
          {
            ClassList.Items.Add(new ClassWrapper(ref season_data.Payload.Classes[i]));
          }
        }
        ClassList.EndUpdate();
        #endregion

        #region Update Event List
        EventList.BeginUpdate();
        {
          EventList.Items.Clear();
          for (int i=0; i<season_data.Payload.Events.Length; i++)
          {
            EventList.Items.Add(new EventWrapper(ref season_data.Payload.Events[i]));
          }
        }
        EventList.EndUpdate();
        #endregion

        #region Update Class Standing List
        ClassStandingsList.BeginUpdate();
        ClassStandingsList.Items.Clear();

        // update the events columns
        while (ClassStandingsList.Columns.Count > 4)
        {
          ClassStandingsList.Columns.RemoveAt(4);
        }
        for (uint i=0; i<season_data.Payload.Settings.event_count; i++)
        {
          ColumnHeader event_col = new ColumnHeader();
          event_col.Text = "Round " + (i+1).ToString();
          event_col.Width = 60;
          event_col.TextAlign = HorizontalAlignment.Center;
          ClassStandingsList.Columns.Add(event_col);
        }

        // loop through the drivers adding results
        for (int i=0; i<season_data.Payload.Drivers.Length; i++)
        {
          DriverWrapper curr_driver = new DriverWrapper(ref season_data.Payload.Drivers[i]);

          for (int j=0; j<season_data.Payload.Classes.Length; j++)
          {
            ClassWrapper curr_class = new ClassWrapper(ref season_data.Payload.Classes[j]);
            ListViewItem item = null;

            for (int k=0; k<curr_driver.Payload.Points.Length; k++)
            {
              if (curr_driver.Payload.Points[k].class_id == curr_class.Payload.id)
              {
                if (item == null)
                {
                  item = new ListViewItem();
                  item.Tag = curr_driver;
                  item.Text = curr_class.Payload.id;
                  item.SubItems.Add(curr_driver.ToString());
                  item.SubItems.Add(curr_driver.Payload.car);

                  int pos;
                  int pts;
                  int pts_d;
                  bool qual;
                  season_data.GetClassStandings(curr_driver, curr_class.Payload.id, ExcludeMenu.Checked, out pos, out pts, out pts_d, out qual);
                  if (pos == 0)
                  {
                    item.SubItems.Add("-");
                  }
                  else
                  {
                    item.SubItems.Add(pos.ToString() + " (" + pts.ToString() + "/" + pts_d.ToString() + ")");
                  }

                  for (uint c=0; c<season_data.Payload.Settings.event_count; c++)
                  {
                    item.SubItems.Add("-");
                  }

                  if (qual)
                  {
                    item.ForeColor = Color.Black;
                  }                 
                  else
                  {
                    item.ForeColor = Color.DarkGray;
                  }

                  ClassStandingsList.Items.Add(item);
                }               
                item.SubItems[(int)curr_driver.Payload.Points[k].event_number + 3].Text = curr_driver.Payload.Points[k].class_amount.ToString();
              }
            }

          }
        }

        ClassStandingsList.EndUpdate();
        #endregion

        #region Update Pax Standing List
        PaxStandingsList.BeginUpdate();
        PaxStandingsList.Items.Clear();

        // update the events columns
        while (PaxStandingsList.Columns.Count > 4)
        {
          PaxStandingsList.Columns.RemoveAt(4);
        }
        for (uint i=0; i<season_data.Payload.Settings.event_count; i++)
        {
          ColumnHeader event_col = new ColumnHeader();
          event_col.Text = "Round " + (i+1).ToString();
          event_col.Width = 60;
          event_col.TextAlign = HorizontalAlignment.Center;
          PaxStandingsList.Columns.Add(event_col);
        }

        // loop through the drivers adding results
        for (int i=0; i<season_data.Payload.Drivers.Length; i++)
        {
          DriverWrapper curr_driver = new DriverWrapper(ref season_data.Payload.Drivers[i]);

          for (int j=0; j<2; j++)
          {
            bool ladies = (j == 1);
            ListViewItem item = null;

            for (int k=0; k<curr_driver.Payload.Points.Length; k++)
            {
              if (season_data.GetClass(curr_driver.Payload.Points[k].class_id).Payload.ladies == ladies)
              {
                if (item == null)
                {
                  item = new ListViewItem();
                  item.Tag = curr_driver;
                  item.Text = ladies ? "Ladies" : "Open";
                  item.SubItems.Add(curr_driver.ToString());
                  item.SubItems.Add(curr_driver.Payload.car);

                  int pos;
                  int pts;
                  int pts_d;
                  bool qual;
                  season_data.GetPaxStandings(curr_driver, ladies, ExcludeMenu.Checked, out pos, out pts, out pts_d, out qual);
                  if (pos == 0)
                  {
                    item.SubItems.Add("-");
                  }
                  else
                  {
                    item.SubItems.Add(pos.ToString() + " (" + pts.ToString() + "/" + pts_d.ToString() + ")");
                  }

                  for (uint c=0; c<season_data.Payload.Settings.event_count; c++)
                  {
                    item.SubItems.Add("-");
                  }

                  if (qual)
                  {
                    item.ForeColor = Color.Black;
                  }                 
                  else
                  {
                    item.ForeColor = Color.DarkGray;
                  }

                  PaxStandingsList.Items.Add(item);
                }               
                item.SubItems[(int)curr_driver.Payload.Points[k].event_number + 3].Text = curr_driver.Payload.Points[k].pax_amount.ToString();
              }
            }

          }
        }

        PaxStandingsList.EndUpdate();
        #endregion

      }
    }

    private void ClassList_SelectedIndexChanged(object sender, System.EventArgs e)
    {
      ignore_class_details_change = true;
      if (ClassList.SelectedItem == null)
      {
        ClassDetailsGroup.Enabled = false;
        ClassIdText.Text = "";
        ClassDescText.Text = "";
        ClassLadiesCheck.Checked = false;
        ClassNonPointsCheck.Checked = false;
        ApplyClassButton.Enabled = false;
      }
      else
      {
        ClassWrapper c = (ClassWrapper)ClassList.SelectedItem;
        ClassIdText.Text = c.Payload.id;
        ClassDescText.Text = c.Payload.description;
        ClassLadiesCheck.Checked = c.Payload.ladies;
        ClassNonPointsCheck.Checked = c.Payload.non_points;
        ClassDetailsGroup.Enabled = true;
        ApplyClassButton.Enabled = false;
      }   
      ignore_class_details_change = false;
    }

    private void ApplyClassButton_Click(object sender, System.EventArgs e)
    {
      if (ClassList.SelectedItem != null)
      {
        ClassWrapper c = (ClassWrapper)ClassList.SelectedItem;
        c.Payload.id = ClassIdText.Text;
        c.Payload.description = ClassDescText.Text;
        c.Payload.ladies = ClassLadiesCheck.Checked;
        c.Payload.non_points = ClassNonPointsCheck.Checked;
        ApplyClassButton.Enabled = false;
        season_data.Payload.DocState.modified = true;
        UpdateDisplay();
      }
    }

    private bool ignore_class_details_change = false;
    private void ClassDetailsChanged(object sender, System.EventArgs e)
    {     
      if (ignore_class_details_change) return;
      ApplyClassButton.Enabled = true;
    }


    private void EventList_SelectedIndexChanged(object sender, System.EventArgs e)
    {
      if (EventList.SelectedItem == null)
      {
        //EventDetailsGroup.Enabled = false;
        EventNameText.Text = "";
        EventDateText.Text = "";
        EventFilenameText.Text = "";
      }
      else
      {
        EventWrapper ev = (EventWrapper)EventList.SelectedItem;
        EventNameText.Text = ev.Payload.name;
        EventDateText.Text = ev.Payload.date;
        EventFilenameText.Text = ev.Payload.data_file;
        //EventDetailsGroup.Enabled = true;
      }   
    }

    private void SyncSingleEvent_Click(object sender, System.EventArgs e)
    {
      if (EventList.SelectedItem != null)
      {
        EventWrapper curr_event = (EventWrapper)EventList.SelectedItem;
        new ImportEventForm(ref curr_event, ref season_data).ShowDialog();
        UpdateDisplay();
      }
    }

    private void MainForm_Closing(object sender, System.ComponentModel.CancelEventArgs e)
    {
      CloseMenu_Click(this, null);
      if (season_data != null)
      {
        e.Cancel = true;
      }
    }

    private void ExcludeMenu_Click(object sender, System.EventArgs e)
    {
      ExcludeMenu.Checked = !ExcludeMenu.Checked;
      UpdateDisplay();
    }

    private void GenerateEventReportButton_Click(object sender, System.EventArgs e)
    {
    }

    private void GenerateAllEventReportsMenu_Click(object sender, System.EventArgs e)
    {
      if (season_data != null)
      {
        MenuItem menuitem = (MenuItem)sender;

        if (menuitem.Index == 0)
        {
          for (int i=0; i<season_data.Payload.Events.Length; i++)
          {
            if (GenerateEventReport(i, EventReportType.CLASS) == false)
            {
              break; // out of for(i)
            }
            if (GenerateEventReport(i, EventReportType.PAX) == false)
            {
              break; // out of for(i)
            }
            if (GenerateEventReport(i, EventReportType.RAW) == false)
            {
              break; // out of for(i)
            }
          }
        }
        else
        {
          GenerateEventReport(menuitem.Index - 2, EventReportType.CLASS);
          GenerateEventReport(menuitem.Index - 2, EventReportType.PAX);
          GenerateEventReport(menuitem.Index - 2, EventReportType.RAW);
        }
      }
    }

    private void EventReportMenu_Popup(object sender, System.EventArgs e)
    {
      // blank the old menu items
      while (EventReportMenu.MenuItems.Count > 2)
      {
        EventReportMenu.MenuItems.RemoveAt(2);
      }

      // add the per-report menu items
      if (season_data != null)
      {
        for (int i=0; i<season_data.Payload.Events.Length; i++)
        {
          MenuItem menuitem = new MenuItem(MenuMerge.Add, 0, Shortcut.None, season_data.Payload.Events[i].number.ToString() + " - " + season_data.Payload.Events[i].name, new EventHandler(GenerateAllEventReportsMenu_Click), null, null, null);
          EventReportMenu.MenuItems.Add(menuitem);
        }
      }
    }

    private void GenerateReport(object sender, System.EventArgs e)
    {
      if (season_data == null) return;

      ListView list;
      string standings_type_text;
      bool class_report = true;

      if (sender == ClassReportMenu)
      {
        list = ClassStandingsList;
        standings_type_text = "Class Standings";
      }
      else
      {
        list = PaxStandingsList;
        standings_type_text = "PAX Standings";
        class_report = false;
      }

      if (ExcludeMenu.Checked)
      {
        standings_type_text += " [Qualified]";
      }

      SaveReport.FileName = season_data.Payload.name + " " + standings_type_text + ".html";
      if (SaveReport.ShowDialog() == DialogResult.OK)
      {
        string css_styles_block =
          "h1            { font-family: Arial; font-size: 16pt; font-weight: bold; text-align: center }" + Environment.NewLine +
          "table          { border-collapse: collapse }" + Environment.NewLine +
          "tr.main_header { background-color: #AAAAAA; }" + Environment.NewLine +
          "tr.sub_header  { background-color: #DDDDDD; font-weight: bold }" + Environment.NewLine +
          "tr.q          { background-color: #AAFFAA }" + Environment.NewLine +
          "tr.nq          { background-color: #FFFFFF }" + Environment.NewLine +
          "th            { font-family: Arial; font-size: 10pt; text-align: center; border: 1px solid black }" + Environment.NewLine +
          "td            { font-family: Arial; font-size: 8pt; text-align: center; border: 1px solid black }" + Environment.NewLine +
          "td.left        { font-family: Arial; font-size: 8pt; text-align: left; border: 1px solid black }";

       
        XmlTextWriter w = new XmlTextWriter(SaveReport.FileName, null);
        w.Formatting = Formatting.Indented;

        // start the html
        w.WriteStartElement("html");

        // output the html header
        w.WriteStartElement("head");
        w.WriteElementString("title", season_data.Payload.club + " - " + season_data.Payload.name + " - " + standings_type_text);
        w.WriteStartElement("style"); w.WriteAttributeString("type", "text/css");
        w.WriteString(css_styles_block);
        w.WriteEndElement();
        w.WriteEndElement();

        // start the body
        w.WriteStartElement("body");

        // write the title info
        w.WriteElementString("h1", season_data.Payload.club + " - " + season_data.Payload.name + " - " + standings_type_text);

        // start the table
        w.WriteStartElement("table");

        // write the main table header
        #region main header
        w.WriteStartElement("tr"); w.WriteAttributeString("class", "main_header");
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "5%");
        w.WriteString("Class");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "5%");
        w.WriteString("Position");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "10%");
        w.WriteString("Driver");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "10%");
        w.WriteString("Car");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "5%");
        w.WriteString("Points");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "5%");
        w.WriteString("Points w/ " + season_data.Payload.Settings.drop_count.ToString() + " Drop(s)");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("colspan", season_data.Payload.Settings.event_count.ToString());
        w.WriteElementString("center", "Round");
        w.WriteEndElement();
        w.WriteEndElement();           
        w.WriteStartElement("tr");  w.WriteAttributeString("class", "main_header");
        for (int i=0; i<season_data.Payload.Settings.event_count; i++)
        {
          w.WriteStartElement("th"); w.WriteAttributeString("width", Convert.ToString((int)50 / season_data.Payload.Settings.event_count) + "%");
          w.WriteString((i+1).ToString());
          w.WriteEndElement();
        }
        w.WriteEndElement();
        #endregion

        // loop through all the rows
        ArrayList items = new ArrayList();
        items.AddRange(list.Items);
        items.Sort(new StandingsListSorter());

        string last_class_name = "";

        foreach (ListViewItem item in items)
        {
          DriverWrapper driver = (DriverWrapper)item.Tag;

          // skip unqualified drivers if allowed
          //if (ExcludeMenu.Checked && (driver.Payload.Points.Length + (season_data.Payload.Settings.event_count - season_data.Payload.Events.Length) < season_data.Payload.Settings.min_event_count))
          if (ExcludeMenu.Checked &&
              ((class_report && !driver.GetClassQualifiedStatus(item.Text, season_data.Payload.Settings.min_event_count)) ||
              (!class_report && !driver.GetPaxQualifiedStatus((item.Text == "Ladies"), season_data.Payload.Settings.min_event_count, season_data))))
          {
            continue;
          }

          // write the sub table header (if necessary)
          #region sub header
          if (last_class_name != item.Text)
          {
            last_class_name = item.Text;
           
            string class_desc;
            if (sender == ClassReportMenu)
            {
              class_desc = season_data.GetClass(item.Text).Payload.description;
            }
            else
            {
              class_desc = item.Text + " PAX Championship";
            }

            w.WriteStartElement("tr"); w.WriteAttributeString("class", "sub_header");
            w.WriteStartElement("td"); w.WriteAttributeString("colspan", "4"); w.WriteAttributeString("class", "left");
            w.WriteString(class_desc);
            w.WriteEndElement();
            w.WriteElementString("td", "Points");
            w.WriteElementString("td", "w/ Drops");
            for (int i=0; i<season_data.Payload.Settings.event_count; i++)
            {
              w.WriteElementString("td", (i+1).ToString());
            }
            w.WriteEndElement();   
          }
          #endregion
       
          // write the current row
          string[] standings = item.SubItems[3].Text.Split(" (/)".ToCharArray(), 10);
          string position = standings[0];
          string points = standings[2];
          string points_w_drops = standings[3];

          w.WriteStartElement("tr"); w.WriteAttributeString("class", (item.ForeColor == Color.Black) ? "q" : "nq");
          w.WriteStartElement("td"); w.WriteAttributeString("class", "left");
          w.WriteString(item.Text);
          w.WriteEndElement();
          w.WriteStartElement("td"); w.WriteAttributeString("class", "left");
          w.WriteString(position);
          w.WriteEndElement();
          w.WriteStartElement("td"); w.WriteAttributeString("class", "left");
          w.WriteString(driver.Payload.first_name + " " + driver.Payload.last_name.Substring(0,1));
          w.WriteEndElement();
          w.WriteStartElement("td"); w.WriteAttributeString("class", "left");
          w.WriteString(driver.Payload.car);
          w.WriteEndElement();
          w.WriteElementString("td", points);
          w.WriteElementString("td", points_w_drops);
          for (int i=0; i<season_data.Payload.Settings.event_count; i++)
          {
            w.WriteElementString("td", item.SubItems[i+4].Text);
          }
          w.WriteEndElement();
        }

        // stop the table
        w.WriteEndElement();

        // stop the body
        w.WriteEndElement();

        // stop the html
        w.WriteEndElement();

        // close the file
        w.Close();
      }       
    }

    private void PerfectAttendanceMenu_Click(object sender, System.EventArgs e)
    {
      if (season_data == null) return;

      SaveReport.FileName = season_data.Payload.name + " Perfect Attendance.html";
      if (SaveReport.ShowDialog() == DialogResult.OK)
      {
        XmlTextWriter w = new XmlTextWriter(SaveReport.FileName, null);
        w.Formatting = Formatting.Indented;

        w.WriteStartElement("html");

          w.WriteStartElement("head");
            w.WriteElementString("title", season_data.Payload.club + " - " + season_data.Payload.name + " - Perfect Attendance");
          w.WriteEndElement();

          w.WriteStartElement("body");         

            w.WriteStartElement("center");
              w.WriteStartElement("h2");
                w.WriteString(season_data.Payload.club + " - " + season_data.Payload.name + " - Perfect Attendance");
              w.WriteEndElement();
            w.WriteEndElement();

            w.WriteStartElement("table");
              w.WriteAttributeString("align", "center");
              w.WriteAttributeString("border", "0");
              w.WriteAttributeString("width", "60%");

            foreach (DriverType driver in season_data.Payload.Drivers)
            {
              int event_count = 0;

              for (ulong i=0; i<season_data.Payload.Settings.event_count; i++)
              {
                foreach (PointsType points in driver.Points)
                {
                  if (points.event_number == i)
                  {
                    event_count++;
                    break; // out of foreach(points)
                  }
                }               
              }             

              if (event_count >= season_data.Payload.Events.Length)
              {
                w.WriteStartElement("tr");
                  w.WriteStartElement("td");
                    w.WriteElementString("p", driver.first_name + " " + driver.last_name);
                  w.WriteEndElement();
                w.WriteEndElement();
              }
            }
           
            w.WriteEndElement();

          w.WriteEndElement();       
        w.WriteEndElement();

        w.Close();
      }   
    }


    private enum EventReportType
    {
      CLASS,
      PAX,
      RAW
    }
    private bool GenerateEventReport(int event_number, EventReportType report_type)
    {
      // make sure there's season data
      if (season_data == null) return false;

      // make sure we're trying to report on a valid event
      EventType event_data = null;
      if ((event_number >= 0) && (event_number < season_data.Payload.Events.Length))
      {
        event_data = season_data.Payload.Events[event_number];
      }
      if (event_data == null) return false;

      // parse the results file
      ArrayList results_array = Utils.ParseResultsFile(event_data);
      if (results_array.Count == 0) return false;

      // generate the title for this report
      string standings_type_text = "";
      switch (report_type)
      {
        case EventReportType.CLASS:
          standings_type_text = "Class Results";
          break;
        case EventReportType.PAX:
          standings_type_text = "PAX Results";
          break;
        case EventReportType.RAW:
          standings_type_text = "Raw Results";
          break;
      }

      string standings_title_text = "Round " + event_data.number.ToString() + " - " + event_data.date + " - " + event_data.name + " - " + standings_type_text;

      SaveReport.FileName = season_data.Payload.name + " " + standings_type_text + ".html";
      if (SaveReport.ShowDialog() == DialogResult.OK)
      {
/*
          string css_styles_block =
          "h1            { font-family: Arial; font-size: 16pt; font-weight: bold; text-align: center }" + Environment.NewLine +
          "table          { border-collapse: collapse }" + Environment.NewLine +
          "tr.main_header { background-color: #AAAAAA; }" + Environment.NewLine +
          "tr.sub_header  { background-color: #DDDDDD; font-weight: bold }" + Environment.NewLine +
          "tr.q          { background-color: #AAFFAA }" + Environment.NewLine +
          "tr.nq          { background-color: #FFFFFF }" + Environment.NewLine +
          "th            { font-family: Arial; font-size: 10pt; text-align: center; border: 1px solid black }" + Environment.NewLine +
          "td            { font-family: Arial; font-size: 8pt; text-align: center; border: 1px solid black }" + Environment.NewLine +
          "td.left        { font-family: Arial; font-size: 8pt; text-align: left; border: 1px solid black }";

       
        XmlTextWriter w = new XmlTextWriter(SaveReport.FileName, null);
        w.Formatting = Formatting.Indented;

        // start the html
        w.WriteStartElement("html");

        // output the html header
        w.WriteStartElement("head");
        w.WriteElementString("title", season_data.Payload.club + " - " + season_data.Payload.name + " - " + standings_title_text);
        w.WriteStartElement("style"); w.WriteAttributeString("type", "text/css");
        w.WriteString(css_styles_block);
        w.WriteEndElement();
        w.WriteEndElement();

        // start the body
        w.WriteStartElement("body");

        // write the title info
        w.WriteElementString("h1", season_data.Payload.club + " - " + season_data.Payload.name + " - " + standings_title_text);

        // start the table
        w.WriteStartElement("table");

        // write the main table header
        #region main header
        w.WriteStartElement("tr"); w.WriteAttributeString("class", "main_header");
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "5%");
        w.WriteString("Class");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "5%");
        w.WriteString("Position");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "10%");
        w.WriteString("Driver");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "10%");
        w.WriteString("Car");
        w.WriteEndElement();


        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "5%");
        w.WriteString("Points");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("rowspan", "2"); w.WriteAttributeString("width", "5%");
        w.WriteString("Points w/ " + season_data.Payload.Settings.drop_count.ToString() + " Drop(s)");
        w.WriteEndElement();
        w.WriteStartElement("th"); w.WriteAttributeString("colspan", season_data.Payload.Settings.event_count.ToString());
        w.WriteElementString("center", "Round");
        w.WriteEndElement();
        w.WriteEndElement();           
        w.WriteStartElement("tr");  w.WriteAttributeString("class", "main_header");
        for (int i=0; i<season_data.Payload.Settings.event_count; i++)
        {
          w.WriteStartElement("th"); w.WriteAttributeString("width", Convert.ToString((int)50 / season_data.Payload.Settings.event_count) + "%");
          w.WriteString((i+1).ToString());
          w.WriteEndElement();
        }
        w.WriteEndElement();
        #endregion

        // loop through all the rows
        ArrayList items = new ArrayList();
        items.AddRange(list.Items);
        items.Sort(new StandingsListSorter());

        string last_class_name = "";

        foreach (ListViewItem item in items)
        {
          DriverWrapper driver = (DriverWrapper)item.Tag;

          // skip unqualified drivers if allowed
          //if (ExcludeMenu.Checked && (driver.Payload.Points.Length + (season_data.Payload.Settings.event_count - season_data.Payload.Events.Length) < season_data.Payload.Settings.min_event_count))
          if (ExcludeMenu.Checked &&
            ((class_report && !driver.GetClassQualifiedStatus(item.Text, season_data.Payload.Settings.min_event_count)) ||
            (!class_report && !driver.GetPaxQualifiedStatus((item.Text == "Ladies"), season_data.Payload.Settings.min_event_count, season_data))))
          {
            continue;
          }

          // write the sub table header (if necessary)
          #region sub header
          if (last_class_name != item.Text)
          {
            last_class_name = item.Text;
           
            string class_desc;
            if (sender == ClassReportMenu)
            {
              class_desc = season_data.GetClass(item.Text).Payload.description;
            }
            else
            {
              class_desc = item.Text + " PAX Championship";
            }

            w.WriteStartElement("tr"); w.WriteAttributeString("class", "sub_header");
            w.WriteStartElement("td"); w.WriteAttributeString("colspan", "4"); w.WriteAttributeString("class", "left");
            w.WriteString(class_desc);
            w.WriteEndElement();
            w.WriteElementString("td", "Points");
            w.WriteElementString("td", "w/ Drops");
            for (int i=0; i<season_data.Payload.Settings.event_count; i++)
            {
              w.WriteElementString("td", (i+1).ToString());
            }
            w.WriteEndElement();   
          }
          #endregion
       
          // write the current row
          string[] standings = item.SubItems[3].Text.Split(" (/)".ToCharArray(), 10);
          string position = standings[0];
          string points = standings[2];
          string points_w_drops = standings[3];

          w.WriteStartElement("tr"); w.WriteAttributeString("class", (item.ForeColor == Color.Black) ? "q" : "nq");
          w.WriteStartElement("td"); w.WriteAttributeString("class", "left");
          w.WriteString(item.Text);
          w.WriteEndElement();
          w.WriteStartElement("td"); w.WriteAttributeString("class", "left");
          w.WriteString(position);
          w.WriteEndElement();
          w.WriteStartElement("td"); w.WriteAttributeString("class", "left");
          w.WriteString(driver.Payload.first_name + " " + driver.Payload.last_name.Substring(0,1));
          w.WriteEndElement();
          w.WriteStartElement("td"); w.WriteAttributeString("class", "left");
          w.WriteString(driver.Payload.car);
          w.WriteEndElement();
          w.WriteElementString("td", points);
          w.WriteElementString("td", points_w_drops);
          for (int i=0; i<season_data.Payload.Settings.event_count; i++)
          {
            w.WriteElementString("td", item.SubItems[i+4].Text);
          }
          w.WriteEndElement();
        }

        // stop the table
        w.WriteEndElement();

        // stop the body
        w.WriteEndElement();

        // stop the html
        w.WriteEndElement();

        // close the file
        w.Close();
       
*/
      }
      else
      {
        return false;
      }

      return true;
    }

  }
}


using System;
using System.IO;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace SeasonManager
{
        /// <summary>
        /// Summary description for ImportEventForm.
        /// </summary>
        public class ImportEventForm : System.Windows.Forms.Form
        {
    private System.Windows.Forms.ListView ResultsList;
    private System.Windows.Forms.Button Accept;
    private System.Windows.Forms.Button Cancel;
   
    /// <summary>
                /// Required designer variable.
                /// </summary>
                private System.ComponentModel.Container components = null;
    private System.Windows.Forms.GroupBox ResultDetailsGroup;
    private System.Windows.Forms.ComboBox DriverList;
    private System.Windows.Forms.RadioButton LinkDriverRadio;
    private System.Windows.Forms.StatusBar StatusBar;
    private System.Windows.Forms.RadioButton IgnoreDriverRadio;
    private System.Windows.Forms.RadioButton AddDriverRadio;
    private System.Windows.Forms.ColumnHeader MatchedDriverCol;
    private System.Windows.Forms.ColumnHeader MatchedClassCol;
    private System.Windows.Forms.ColumnHeader ClassCol;
    private System.Windows.Forms.ColumnHeader FirstNameCol;
    private System.Windows.Forms.ColumnHeader LastNameCol;
    private System.Windows.Forms.ColumnHeader CarCol;
    private System.Windows.Forms.ColumnHeader TotalCol;
    private System.Windows.Forms.ColumnHeader PaxCol;
    private System.Windows.Forms.ColumnHeader ClassPosCol;
    private System.Windows.Forms.ColumnHeader PaxPosCol;
   
    private EventWrapper event_data = null;
    private ArrayList results_array = null;   
    private SeasonWrapper season_data = null;

                public ImportEventForm(ref EventWrapper event_to_import, ref SeasonWrapper sw)
                {
                        //
                        // Required for Windows Form Designer support
                        //
                        InitializeComponent();

      event_data = event_to_import;
      results_array = new ArrayList();
      season_data = sw;
    }


    /// <summary>
                /// Clean up any resources being used.
                /// </summary>
                protected override void Dispose( bool disposing )
                {
                        if( disposing )
                        {
                                if(components != null)
                                {
                                        components.Dispose();
                                }
                        }
                        base.Dispose( disposing );
                }


    #region Windows Form Designer generated code
                /// <summary>
                /// Required method for Designer support - do not modify
                /// the contents of this method with the code editor.
                /// </summary>
                private void InitializeComponent()
                {
      this.ResultsList = new System.Windows.Forms.ListView();
      this.MatchedClassCol = new System.Windows.Forms.ColumnHeader();
      this.MatchedDriverCol = new System.Windows.Forms.ColumnHeader();
      this.ClassPosCol = new System.Windows.Forms.ColumnHeader();
      this.PaxPosCol = new System.Windows.Forms.ColumnHeader();
      this.ClassCol = new System.Windows.Forms.ColumnHeader();
      this.FirstNameCol = new System.Windows.Forms.ColumnHeader();
      this.LastNameCol = new System.Windows.Forms.ColumnHeader();
      this.CarCol = new System.Windows.Forms.ColumnHeader();
      this.TotalCol = new System.Windows.Forms.ColumnHeader();
      this.PaxCol = new System.Windows.Forms.ColumnHeader();
      this.ResultDetailsGroup = new System.Windows.Forms.GroupBox();
      this.IgnoreDriverRadio = new System.Windows.Forms.RadioButton();
      this.AddDriverRadio = new System.Windows.Forms.RadioButton();
      this.LinkDriverRadio = new System.Windows.Forms.RadioButton();
      this.DriverList = new System.Windows.Forms.ComboBox();
      this.Cancel = new System.Windows.Forms.Button();
      this.Accept = new System.Windows.Forms.Button();
      this.StatusBar = new System.Windows.Forms.StatusBar();
      this.ResultDetailsGroup.SuspendLayout();
      this.SuspendLayout();
      //
      // ResultsList
      //
      this.ResultsList.CheckBoxes = true;
      this.ResultsList.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
                                                                                  this.MatchedClassCol,
                                                                                  this.MatchedDriverCol,
                                                                                  this.ClassPosCol,
                                                                                  this.PaxPosCol,
                                                                                  this.ClassCol,
                                                                                  this.FirstNameCol,
                                                                                  this.LastNameCol,
                                                                                  this.CarCol,
                                                                                  this.TotalCol,
                                                                                  this.PaxCol});
      this.ResultsList.Dock = System.Windows.Forms.DockStyle.Fill;
      this.ResultsList.FullRowSelect = true;
      this.ResultsList.GridLines = true;
      this.ResultsList.HideSelection = false;
      this.ResultsList.Location = new System.Drawing.Point(0, 0);
      this.ResultsList.MultiSelect = false;
      this.ResultsList.Name = "ResultsList";
      this.ResultsList.Size = new System.Drawing.Size(552, 494);
      this.ResultsList.TabIndex = 0;
      this.ResultsList.View = System.Windows.Forms.View.Details;
      this.ResultsList.ColumnClick += new System.Windows.Forms.ColumnClickEventHandler(this.ResultsList_ColumnClick);
      this.ResultsList.SelectedIndexChanged += new System.EventHandler(this.ResultsList_SelectedIndexChanged);
      this.ResultsList.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.ResultsList_ItemCheck);
      //
      // MatchedClassCol
      //
      this.MatchedClassCol.Text = "Matched Class";
      this.MatchedClassCol.Width = 85;
      //
      // MatchedDriverCol
      //
      this.MatchedDriverCol.Text = "Matched Driver";
      this.MatchedDriverCol.Width = 100;
      //
      // ClassPosCol
      //
      this.ClassPosCol.Text = "Class Pos (Points)";
      this.ClassPosCol.Width = 100;
      //
      // PaxPosCol
      //
      this.PaxPosCol.Text = "PAX Pos (Points)";
      this.PaxPosCol.Width = 100;
      //
      // ClassCol
      //
      this.ClassCol.Text = "Class";
      this.ClassCol.Width = 85;
      //
      // FirstNameCol
      //
      this.FirstNameCol.Text = "First Name";
      this.FirstNameCol.Width = 85;
      //
      // LastNameCol
      //
      this.LastNameCol.Text = "Last Name";
      this.LastNameCol.Width = 85;
      //
      // CarCol
      //
      this.CarCol.Text = "Car";
      this.CarCol.Width = 100;
      //
      // TotalCol
      //
      this.TotalCol.Text = "Total Time";
      this.TotalCol.Width = 75;
      //
      // PaxCol
      //
      this.PaxCol.Text = "PAX Time";
      this.PaxCol.Width = 75;
      //
      // ResultDetailsGroup
      //
      this.ResultDetailsGroup.Controls.Add(this.IgnoreDriverRadio);
      this.ResultDetailsGroup.Controls.Add(this.AddDriverRadio);
      this.ResultDetailsGroup.Controls.Add(this.LinkDriverRadio);
      this.ResultDetailsGroup.Controls.Add(this.DriverList);
      this.ResultDetailsGroup.Controls.Add(this.Cancel);
      this.ResultDetailsGroup.Controls.Add(this.Accept);
      this.ResultDetailsGroup.Dock = System.Windows.Forms.DockStyle.Right;
      this.ResultDetailsGroup.Location = new System.Drawing.Point(552, 0);
      this.ResultDetailsGroup.Name = "ResultDetailsGroup";
      this.ResultDetailsGroup.Size = new System.Drawing.Size(216, 494);
      this.ResultDetailsGroup.TabIndex = 4;
      this.ResultDetailsGroup.TabStop = false;
      this.ResultDetailsGroup.Text = "Selected Result Import Options";
      //
      // IgnoreDriverRadio
      //
      this.IgnoreDriverRadio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.IgnoreDriverRadio.Checked = true;
      this.IgnoreDriverRadio.Location = new System.Drawing.Point(8, 16);
      this.IgnoreDriverRadio.Name = "IgnoreDriverRadio";
      this.IgnoreDriverRadio.Size = new System.Drawing.Size(200, 24);
      this.IgnoreDriverRadio.TabIndex = 5;
      this.IgnoreDriverRadio.TabStop = true;
      this.IgnoreDriverRadio.Text = "Ignore Result";
      this.IgnoreDriverRadio.CheckedChanged += new System.EventHandler(this.ResultStatusChanged);
      //
      // AddDriverRadio
      //
      this.AddDriverRadio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.AddDriverRadio.Location = new System.Drawing.Point(8, 40);
      this.AddDriverRadio.Name = "AddDriverRadio";
      this.AddDriverRadio.Size = new System.Drawing.Size(200, 24);
      this.AddDriverRadio.TabIndex = 4;
      this.AddDriverRadio.Text = "Create New Driver";
      this.AddDriverRadio.CheckedChanged += new System.EventHandler(this.ResultStatusChanged);
      //
      // LinkDriverRadio
      //
      this.LinkDriverRadio.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.LinkDriverRadio.Location = new System.Drawing.Point(8, 64);
      this.LinkDriverRadio.Name = "LinkDriverRadio";
      this.LinkDriverRadio.Size = new System.Drawing.Size(200, 24);
      this.LinkDriverRadio.TabIndex = 3;
      this.LinkDriverRadio.Text = "Link to Existing Driver";
      this.LinkDriverRadio.CheckedChanged += new System.EventHandler(this.ResultStatusChanged);
      //
      // DriverList
      //
      this.DriverList.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
        | System.Windows.Forms.AnchorStyles.Right)));
      this.DriverList.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
      this.DriverList.Location = new System.Drawing.Point(24, 88);
      this.DriverList.MaxDropDownItems = 25;
      this.DriverList.Name = "DriverList";
      this.DriverList.Size = new System.Drawing.Size(184, 21);
      this.DriverList.Sorted = true;
      this.DriverList.TabIndex = 2;
      this.DriverList.SelectedIndexChanged += new System.EventHandler(this.DriverList_SelectedIndexChanged);
      //
      // Cancel
      //
      this.Cancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
      this.Cancel.Location = new System.Drawing.Point(112, 464);
      this.Cancel.Name = "Cancel";
      this.Cancel.TabIndex = 1;
      this.Cancel.Text = "Cancel";
      this.Cancel.Click += new System.EventHandler(this.CancelButton_Click);
      //
      // Accept
      //
      this.Accept.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
      this.Accept.Location = new System.Drawing.Point(32, 464);
      this.Accept.Name = "Accept";
      this.Accept.TabIndex = 0;
      this.Accept.Text = "Accept";
      this.Accept.Click += new System.EventHandler(this.Accept_Click);
      //
      // StatusBar
      //
      this.StatusBar.Location = new System.Drawing.Point(0, 494);
      this.StatusBar.Name = "StatusBar";
      this.StatusBar.Size = new System.Drawing.Size(768, 16);
      this.StatusBar.TabIndex = 5;
      //
      // ImportEventForm
      //
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(768, 510);
      this.Controls.Add(this.ResultsList);
      this.Controls.Add(this.ResultDetailsGroup);
      this.Controls.Add(this.StatusBar);
      this.Name = "ImportEventForm";
      this.Text = "Import Event Results";
      this.Load += new System.EventHandler(this.ImportEventForm_Load);
      this.ResultDetailsGroup.ResumeLayout(false);
      this.ResumeLayout(false);

    }
                #endregion

    private void CancelButton_Click(object sender, System.EventArgs e)
    {
      Close();
    }

   
    private void ImportEventForm_Load(object sender, System.EventArgs e)
    {
      // load the list of drivers into the drop down
      if (season_data != null)
      {
        DriverList.BeginUpdate();
        DriverList.Items.Clear();

        for (int i=0; i<season_data.Payload.Drivers.Length; i++)
        {
          DriverList.Items.Add(new DriverWrapper(ref season_data.Payload.Drivers[i]).ToString());
        }

        DriverList.EndUpdate();
      }

      // load the data from the event file
      results_array = Utils.ParseResultsFile(event_data.Payload);
      if (results_array.Count == 0)
      {
        Close();
        return;
      }


      // match the results to the current roster
      try
      {
        foreach (ResultWrapper result in results_array)
        {
          string proposed_alias = result.Payload.ImportedData.First_Name + " " + result.Payload.ImportedData.Last_Name;
         
          DriverWrapper curr_driver = season_data.FindDriverByAlias(proposed_alias);
          ClassWrapper curr_class = season_data.FindClassByImportedID(result.Payload.ImportedData.Class);

          if (curr_class == null)
          {
            result.Payload.MatchedData.ignored = true;
            result.Payload.MatchedData.alias = "";
            result.Payload.MatchedData.class_id = "";
            result.Payload.MatchedData.mode = ResultTypeMatchedDataMode.INVALID;
          }
          else if (curr_driver == null)
          {
            result.Payload.MatchedData.ignored = season_data.GetClass(curr_class.Payload.id).Payload.non_points;
            result.Payload.MatchedData.alias = "";
            result.Payload.MatchedData.class_id = curr_class.Payload.id;
            result.Payload.MatchedData.mode = ResultTypeMatchedDataMode.ADD_DRIVER;
          }
          else
          {
            result.Payload.MatchedData.ignored = season_data.GetClass(curr_class.Payload.id).Payload.non_points;
            result.Payload.MatchedData.alias = proposed_alias;
            result.Payload.MatchedData.class_id = curr_class.Payload.id;
            result.Payload.MatchedData.mode = ResultTypeMatchedDataMode.EXISTING_LINK;
          }
        }

      }
      catch (Exception ex)
      {
        MessageBox.Show(ex.Message, "Error Matching To Roster");
        Close();
      }

      ResultsList.ListViewItemSorter = new ResultsListSorter();
      UpdateResultsList();

      if (ResultsList.Items.Count > 0)
      {
        ResultsList.Items[0].Selected = true;
      }
    }


    private bool UpdateResultsList_reentry_blocked = false;
    public void UpdateResultsList()
    {
      if (UpdateResultsList_reentry_blocked) return;
      UpdateResultsList_reentry_blocked = true;

      ListViewItem LastSelected = null;
      if (ResultsList.SelectedItems.Count > 0)
      {
        LastSelected = ResultsList.SelectedItems[0];
      }

      ResultsList.BeginUpdate();
      ResultsList.Items.Clear();

      for (int i=0; i<results_array.Count; i++)
      {
        ResultWrapper result = (ResultWrapper)results_array[i];
        ListViewItem item = new ListViewItem();
        UpdateResultListItem(ref item, ref result);
        ResultsList.Items.Add(item);
      }

      ResultsList.Sort();
      ResultsList.EndUpdate();

      if (LastSelected != null)
      {
        LastSelected.Selected = true;
      }

      //ResultsList_SelectedIndexChanged(this, null);

      UpdateResultsList_reentry_blocked = false;
    }

    private void UpdateResultListItem(ref ListViewItem item, ref ResultWrapper result)
    {
      CalculatePointsFromEventResult(ref result);

      item.Tag = result;
      item.Checked = !result.Payload.MatchedData.ignored;

      item.Text = result.Payload.MatchedData.class_id;

      if (result.Payload.MatchedData.mode == ResultTypeMatchedDataMode.EXISTING_LINK)
      {
        item.SubItems.Add(season_data.FindDriverByAlias(result.Payload.MatchedData.alias).ToString());
      }
      else
      {
        item.SubItems.Add(result.Payload.MatchedData.alias);
      }

      ulong class_position = result.Payload.StandingsData.class_position;
      int class_points = result.Payload.StandingsData.class_points;
      ulong pax_position = result.Payload.StandingsData.pax_position;
      int pax_points = result.Payload.StandingsData.pax_points;

      if (class_position == 0)
      {
        item.SubItems.Add("-");
      }
      else
      {
        item.SubItems.Add(class_position.ToString() + " (" + class_points.ToString() + ")");
      }

      if (pax_position == 0)
      {
        item.SubItems.Add("-");
      }
      else
      {
        item.SubItems.Add(pax_position.ToString() + " (" + pax_points.ToString() + ")");
      }

      item.SubItems.Add(result.Payload.ImportedData.Class);
      item.SubItems.Add(result.Payload.ImportedData.First_Name);
      item.SubItems.Add(result.Payload.ImportedData.Last_Name);
      item.SubItems.Add(result.Payload.ImportedData.Car);
      item.SubItems.Add(result.Payload.ImportedData.Total.ToString());
      item.SubItems.Add(result.Payload.ImportedData.Pax_Time.ToString());

      if (result.Payload.MatchedData.ignored)
      {
        item.ForeColor = Color.LightGray;
        item.BackColor = Color.White;
      }
      else
      {
        item.ForeColor = Color.Black;

        switch (result.Payload.MatchedData.mode)
        {
          case ResultTypeMatchedDataMode.INVALID:
            item.BackColor = Color.Red;
            break;

          case ResultTypeMatchedDataMode.ADD_DRIVER:
            item.BackColor = Color.Yellow;
            break;

          case ResultTypeMatchedDataMode.NEW_LINK:
            item.BackColor = Color.LightGreen;
            break;

          case ResultTypeMatchedDataMode.EXISTING_LINK:
            item.BackColor = Color.White;
            break;
        }
      }   
    }

    private void CalculatePointsFromEventResult(ref ResultWrapper curr_result)
    {
      ulong class_position = 0;
      int class_points = 0;
      ulong pax_position = 0;
      int pax_points = 0;

      if (!curr_result.Payload.MatchedData.ignored)
      {
        // calculate class finishing position
        class_position = 1;
        int class_count = 0;
        foreach (ResultWrapper opponent in results_array)
        {
          if ((!opponent.Payload.MatchedData.ignored) &&
            (opponent.Payload.MatchedData.class_id == curr_result.Payload.MatchedData.class_id))
          {
            class_count++;
            if (Convert.ToSingle(opponent.Payload.ImportedData.Total) < Convert.ToSingle(curr_result.Payload.ImportedData.Total))
            {
              class_position++;
            }
          }
        }

        // calculate class points
        if (season_data.GetClass(curr_result.Payload.MatchedData.class_id).Payload.non_points)
        {
          class_points = 0;
        }
        else
        {
          if (class_count == 1)
          {
            class_points = season_data.Payload.Settings.single_entrant_class_points;
          }
          else
          {
            string[] class_points_list = season_data.Payload.Settings.class_points.Split(',');
            if (class_position >= (ulong)class_points_list.LongLength)
            {
              class_points = Convert.ToInt32(class_points_list[class_points_list.Length-1]);
            }
            else
            {
              class_points = Convert.ToInt32(class_points_list[class_position-1]);
            }
          }
        }

        // calculate pax finishing position
        pax_position = 1;
        int pax_count = 0;
        foreach (ResultWrapper opponent in results_array)
        {
          if ((!opponent.Payload.MatchedData.ignored) &&
            (season_data.GetClass(opponent.Payload.MatchedData.class_id).Payload.ladies ==
            season_data.GetClass(curr_result.Payload.MatchedData.class_id).Payload.ladies))
          {
            pax_count++;
            if (Convert.ToSingle(opponent.Payload.ImportedData.Pax_Time) < Convert.ToSingle(curr_result.Payload.ImportedData.Pax_Time))
            {
              pax_position++;
            }
          }
        }

        // calculate pax points
        if (season_data.GetClass(curr_result.Payload.MatchedData.class_id).Payload.non_points)
        {
          pax_points = 0;
        }
        else
        {
          if (pax_count == 1)
          {
            pax_points = season_data.Payload.Settings.single_entrant_pax_points;
          }
          else
          {
            string[] pax_points_list = season_data.Payload.Settings.pax_points.Split(',');
            if (pax_position >= (ulong)pax_points_list.LongLength)
            {
              pax_points = Convert.ToInt32(pax_points_list[pax_points_list.Length-1]);
            }
            else
            {
              pax_points = Convert.ToInt32(pax_points_list[pax_position-1]);
            }
          }
        }
      }

      curr_result.Payload.StandingsData.class_position = class_position;
      curr_result.Payload.StandingsData.class_points = class_points;
      curr_result.Payload.StandingsData.pax_position = pax_position;
      curr_result.Payload.StandingsData.pax_points = pax_points;
    }


    //private bool MatchResultDetailsInterfaceToData_reentry_blocked = false;
    private void MatchResultDetailsInterfaceToData(ref ResultWrapper curr_result)
    {
      //if (MatchResultDetailsInterfaceToData_reentry_blocked) return;
      //MatchResultDetailsInterfaceToData_reentry_blocked = true;

      abort_status_change_handler = true;

      if (curr_result != null)
      {
        switch (curr_result.Payload.MatchedData.mode)
        {
          case ResultTypeMatchedDataMode.INVALID:
            IgnoreDriverRadio.Enabled = true;
            IgnoreDriverRadio.Checked = true;

            AddDriverRadio.Enabled = false;
            AddDriverRadio.Checked = false;

            LinkDriverRadio.Enabled = false;
            LinkDriverRadio.Checked = false;

            DriverList.Enabled = false;
            DriverList.SelectedIndex = -1;
            break;
 
          case ResultTypeMatchedDataMode.ADD_DRIVER:
            IgnoreDriverRadio.Enabled = true;
            IgnoreDriverRadio.Checked = curr_result.Payload.MatchedData.ignored;

            AddDriverRadio.Enabled = true;
            AddDriverRadio.Checked = !curr_result.Payload.MatchedData.ignored;

            LinkDriverRadio.Enabled = (DriverList.Items.Count > 0);
            LinkDriverRadio.Checked = false;

            DriverList.Enabled = (DriverList.Items.Count > 0);
            DriverList.SelectedIndex = -1;
            break;

          case ResultTypeMatchedDataMode.NEW_LINK:
            IgnoreDriverRadio.Enabled = true;
            IgnoreDriverRadio.Checked = curr_result.Payload.MatchedData.ignored;

            AddDriverRadio.Enabled = true;
            AddDriverRadio.Checked = false;

            LinkDriverRadio.Enabled = (DriverList.Items.Count > 0);
            LinkDriverRadio.Checked = !curr_result.Payload.MatchedData.ignored;

            DriverList.Enabled = (DriverList.Items.Count > 0);
            if (curr_result.Payload.MatchedData.alias != null)
            {
              DriverList.SelectedIndex = DriverList.Items.IndexOf(curr_result.Payload.MatchedData.alias);
            }
            else
            {
              DriverList.SelectedIndex = -1;
            }
            break;

          case ResultTypeMatchedDataMode.EXISTING_LINK:
            IgnoreDriverRadio.Enabled = true;
            IgnoreDriverRadio.Checked = curr_result.Payload.MatchedData.ignored;

            AddDriverRadio.Enabled = false;
            AddDriverRadio.Checked = false;

            LinkDriverRadio.Enabled = (DriverList.Items.Count > 0);
            LinkDriverRadio.Checked = !curr_result.Payload.MatchedData.ignored;

            DriverList.Enabled = false;
            if (curr_result.Payload.MatchedData.alias != null)
            {
              DriverList.SelectedIndex = DriverList.Items.IndexOf(season_data.FindDriverByAlias(curr_result.Payload.MatchedData.alias).ToString());
            }
            else
            {
              DriverList.SelectedIndex = -1;
            }
            break;
        }
      }

      abort_status_change_handler = false;

      //MatchResultDetailsInterfaceToData_reentry_blocked = false;
    }

    //private bool MatchResultDetailsDataToInterface_reentry_blocked = false;
    private void MatchResultDetailsDataToInterface(ref ResultWrapper curr_result)
    {
      //if (MatchResultDetailsDataToInterface_reentry_blocked) return;
      //MatchResultDetailsDataToInterface_reentry_blocked = true;

      if (curr_result != null)
      {
        if (IgnoreDriverRadio.Checked)
        {
          curr_result.Payload.MatchedData.ignored = true;
          if (curr_result.Payload.MatchedData.mode != ResultTypeMatchedDataMode.EXISTING_LINK)
          {
            curr_result.Payload.MatchedData.alias = "";
          }
        }
        else
        {
          curr_result.Payload.MatchedData.ignored = false;
         
          if (AddDriverRadio.Checked)
          {
            curr_result.Payload.MatchedData.mode = ResultTypeMatchedDataMode.ADD_DRIVER;
            curr_result.Payload.MatchedData.alias = "";
          }
         
          if (LinkDriverRadio.Checked)
          {
            if (curr_result.Payload.MatchedData.mode != ResultTypeMatchedDataMode.EXISTING_LINK)
            {
              curr_result.Payload.MatchedData.mode = ResultTypeMatchedDataMode.NEW_LINK;
              curr_result.Payload.MatchedData.alias = (string)DriverList.SelectedItem;
            }
          }
        }
      }

      //MatchResultDetailsDataToInterface_reentry_blocked = false;
    }

   
    private void ResultsList_SelectedIndexChanged(object sender, System.EventArgs e)
    {
      ResultWrapper curr_result = null;
      if (ResultsList.SelectedItems.Count > 0)
      {
        curr_result = (ResultWrapper)(ResultsList.SelectedItems[0].Tag);
      }
      MatchResultDetailsInterfaceToData(ref curr_result);
    }


    private bool abort_status_change_handler = false;
    private void ResultStatusChanged(object sender, System.EventArgs e)
    {
      if (abort_status_change_handler) return;

      ResultWrapper curr_result = null;
      if (ResultsList.SelectedItems.Count > 0)
      {
        curr_result = (ResultWrapper)(ResultsList.SelectedItems[0].Tag);
      }
      MatchResultDetailsDataToInterface(ref curr_result);
      UpdateResultsList();
    }

    private void DriverList_SelectedIndexChanged(object sender, System.EventArgs e)
    {
      if (abort_status_change_handler) return;

      LinkDriverRadio.Checked = true;
    }


    private bool ResultsList_ItemCheck_reentry_block = false;
    private void ResultsList_ItemCheck(object sender, System.Windows.Forms.ItemCheckEventArgs e)
    {
      if (ResultsList_ItemCheck_reentry_block) return;
      ResultsList_ItemCheck_reentry_block = true;

      ListViewItem item = ResultsList.Items[e.Index];
      ResultWrapper curr_result = (ResultWrapper)(item.Tag);

      if (curr_result.Payload.MatchedData.mode == ResultTypeMatchedDataMode.INVALID)
      {
        e.NewValue = e.CurrentValue;
      }

      curr_result.Payload.MatchedData.ignored = (e.NewValue != CheckState.Checked);
     
      UpdateResultsList();

      ResultsList_ItemCheck_reentry_block = false;
    }

    private void ResultsList_ColumnClick(object sender, System.Windows.Forms.ColumnClickEventArgs e)
    {
      ResultsList.ListViewItemSorter = new ResultsListSorter(e.Column, ref season_data);
    }

    private void Accept_Click(object sender, System.EventArgs e)
    {
      ResultWrapper curr_result;
      for (int i=0; i<results_array.Count; i++)
      {
        curr_result = (ResultWrapper)results_array[i];

        if (curr_result.Payload.MatchedData.ignored) continue;

        switch (curr_result.Payload.MatchedData.mode)
        {
          case ResultTypeMatchedDataMode.ADD_DRIVER:
          {
            string alias = curr_result.Payload.ImportedData.First_Name + " " + curr_result.Payload.ImportedData.Last_Name;
            season_data.AddNewDriver(curr_result.Payload.ImportedData.First_Name, curr_result.Payload.ImportedData.Last_Name, curr_result.Payload.ImportedData.Car, alias);
            season_data.FindDriverByAlias(alias).UpdatePoints(event_data.Payload.number, curr_result.Payload.MatchedData.class_id, curr_result.Payload.StandingsData.class_points, curr_result.Payload.StandingsData.pax_points);
          }
          break;

          case ResultTypeMatchedDataMode.NEW_LINK:
          {
            string alias = curr_result.Payload.ImportedData.First_Name + " " + curr_result.Payload.ImportedData.Last_Name;
            DriverWrapper found_driver = season_data.FindDriverByCombinedName(curr_result.Payload.MatchedData.alias);
            if (found_driver != null)
            {
              found_driver.AddAlias(alias);
              found_driver.UpdatePoints(event_data.Payload.number, curr_result.Payload.MatchedData.class_id, curr_result.Payload.StandingsData.class_points, curr_result.Payload.StandingsData.pax_points);
            }
          }
          break;

          case ResultTypeMatchedDataMode.EXISTING_LINK:
          {
            season_data.FindDriverByAlias(curr_result.Payload.MatchedData.alias).UpdatePoints(event_data.Payload.number, curr_result.Payload.MatchedData.class_id, curr_result.Payload.StandingsData.class_points, curr_result.Payload.StandingsData.pax_points);
          }
          break;
        }
      }
      season_data.Payload.DocState.modified = true;
      Close();
    }
        }
}


using System;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Collections;
using System.Windows.Forms;

namespace SeasonManager
{
        /// <summary>
        /// Summary description for Utils.
        /// </summary>
        public class Utils
        {   
    public const string EXCEPTION_LOG = "exception.log";

    private static XmlDocument m_xmldoc = new XmlDocument();

                public Utils()
                {
                }


    public static bool WriteToFlatLog(string filename, string message, bool timestamp, bool append)
    {
      bool result = true;

      try
      {
        System.IO.StreamWriter sw = new System.IO.StreamWriter(filename, append);
        if (timestamp)
        {
          sw.WriteLine(DateTime.Now.ToLongTimeString());
        }
        sw.WriteLine(message);
        sw.WriteLine("");
        sw.Close();
      }
      catch (Exception ex)
      {
        result = false;
        WriteToFlatLog("exception.log", ex.ToString(), true, true);
      }

      return result;
    }


    public static bool ParseXML(string xml, out XmlElement xmlel)
    {
      bool result;
      xmlel = null;

      try
      {
        XmlDocument parse_doc = new XmlDocument();
        parse_doc.LoadXml(xml);
        xmlel = (XmlElement)m_xmldoc.ImportNode((XmlNode)parse_doc.DocumentElement, true);
        result = true;
      }
      catch (Exception e)
      {
        Utils.WriteToFlatLog(EXCEPTION_LOG, e.ToString(), true, true);
        result = false;
      }

      return result;
    }

   
    public static bool SerializeObject(object o, out string xml)
    {
      bool result = false;
      xml = "";
      if (o != null)
      {
        try
        {
          XmlSerializer s = new XmlSerializer(o.GetType());
          StringWriter w = new StringWriter();
          s.Serialize(w, o);
          xml = w.ToString();
          w.Close();
          result = true;
        }
        catch (Exception e)
        {
          Utils.WriteToFlatLog(Utils.EXCEPTION_LOG, e.ToString(), true, true);
          result = false;
        }
      }
      return result;
    }


    public static bool DeserializeObject(string xml, ref object o)
    {
      bool result = false; 
      if (o != null)
      {
        try
        {
          XmlSerializer s = new XmlSerializer(o.GetType());
          StringReader r = new StringReader(xml);
          o = Convert.ChangeType(s.Deserialize(r), o.GetType());
          r.Close();
          result = true;
        }
        catch (Exception e)
        {
          Utils.WriteToFlatLog(Utils.EXCEPTION_LOG, e.ToString(), true, true);
          o = null;
          result = false;
        }
      }
      return result;
    }

   
    public static bool ElementizeObject(object o, out XmlElement xmlel)
    {
      bool result = false;
      xmlel = null;
      if (o != null)
      {
        try
        {
          string xml;
          if (SerializeObject(o, out xml))
          {
            if (ParseXML(xml, out xmlel))
            {
              result = true;
            }
            else
            {
              result = false;
            }
          }
          else
          {
            result = false;
          }
        }
        catch (Exception e)
        {
          Utils.WriteToFlatLog(Utils.EXCEPTION_LOG, e.ToString(), true, true);
          result = false;
        }
      }
      return result;
    }


    public static bool DeelementizeObject(XmlElement xmlel, ref object o)
    {     
      bool result = false;
      if (xmlel != null)
      {
        result = DeserializeObject(xmlel.OuterXml, ref o);
      }
      return result;
    }


    public static Array AppendElement(Array array, object element)
    {
      ArrayList new_array = new ArrayList();
      new_array.AddRange(array);
      new_array.Add(element);
      return new_array.ToArray(element.GetType());

      /*
      Array new_array = Array.CreateInstance(element.GetType(), array.Length + 1);
      array.CopyTo(new_array, 0);
      new_array.SetValue(element, new_array.Length-1);
      array = new_array;
      */
    }

    public static ArrayList ParseResultsFile(EventType event_data)
    {
      ArrayList results_array = new ArrayList();

      try
      {
        StreamReader sr = new StreamReader(event_data.data_file);

        ArrayList column_headers = new ArrayList();
        column_headers.AddRange(sr.ReadLine().Split('\t'));

        string curr_line = sr.ReadLine();
        while (curr_line != null)
        {
          string[] curr_data_fields = curr_line.Split('\t');

          ResultWrapper curr_result = new ResultWrapper();         
          curr_result.Payload.ImportedData.Car = curr_data_fields[column_headers.IndexOf("Car Model")];
          curr_result.Payload.ImportedData.Class = curr_data_fields[column_headers.IndexOf("Class")];
          curr_result.Payload.ImportedData.First_Name = curr_data_fields[column_headers.IndexOf("First Name")];
          curr_result.Payload.ImportedData.Last_Name = curr_data_fields[column_headers.IndexOf("Last Name")];
         
          try
          {
            curr_result.Payload.ImportedData.Pax_Time = Convert.ToSingle(curr_data_fields[column_headers.IndexOf("Pax Time")]);
          }
          catch (FormatException)
          {
            curr_result.Payload.ImportedData.Pax_Time = 999.999f;
          }
         
          try
          {
            curr_result.Payload.ImportedData.Total = Convert.ToSingle(curr_data_fields[column_headers.IndexOf("Total")]);
          }
          catch (FormatException)
          {
            curr_result.Payload.ImportedData.Pax_Time = 999.999f;
          }

          int run_index = 1;
          string run_header_string = "Run 1";
          string pen_header_string = "Pen 1";

          while (column_headers.IndexOf(run_header_string) != -1)
          {           
            RunType curr_run = new RunType();

            try
            {
              curr_run.time = Convert.ToSingle(curr_data_fields[column_headers.IndexOf(run_header_string)]);
            }
            catch (FormatException)
            {
              curr_run.time = 999.999f;
            }

            try
            {
              curr_run.cone_count = Convert.ToInt32(curr_data_fields[column_headers.IndexOf(pen_header_string)]);
              curr_run.penalty = "";
            }
            catch (FormatException)
            {
              curr_run.cone_count = 0;
              curr_run.penalty = curr_data_fields[column_headers.IndexOf(pen_header_string)];
            }

            curr_result.Payload.ImportedData.Runs = (RunType[])Utils.AppendElement(curr_result.Payload.ImportedData.Runs, curr_run);
          }

          results_array.Add(curr_result);

          curr_line = sr.ReadLine();
        }

        sr.Close();
      }
      catch (Exception ex)
      {
        MessageBox.Show(ex.Message, "Error Parsing Results File");
      }

      return results_array;
    }
        }


  public class ResultsListSorter : IComparer
  {
    private int col;
    private SeasonWrapper season_data;

    public ResultsListSorter()
    {
      col = 0;
      season_data = null;
    }
    public ResultsListSorter(int column, ref SeasonWrapper sw)
    {
      col = column;
      season_data = sw;
    }
    public int Compare(object x, object y)
    {
      int rval = 0;

      ResultWrapper res_x = (ResultWrapper)((ListViewItem)x).Tag;
      ResultWrapper res_y = (ResultWrapper)((ListViewItem)y).Tag;

      switch (col)
      {
        case 0:      // by class then by class position
        case 2:     
          rval = String.Compare(res_x.Payload.MatchedData.class_id, res_y.Payload.MatchedData.class_id);
          if (rval == 0)
          {
            rval = res_y.Payload.StandingsData.class_points - res_x.Payload.StandingsData.class_points;
          }
          break;

        case 3:      // by pax position
          if (season_data.GetClass(res_x.Payload.MatchedData.class_id).Payload.ladies ==
            season_data.GetClass(res_y.Payload.MatchedData.class_id).Payload.ladies)
          {
            rval = ((ResultWrapper)((ListViewItem)y).Tag).Payload.StandingsData.pax_points - ((ResultWrapper)((ListViewItem)x).Tag).Payload.StandingsData.pax_points;
          }
          else
          {
            rval = season_data.GetClass(res_x.Payload.MatchedData.class_id).Payload.ladies ? 1 : -1;
          }
          break;

        case 8:      // by time
        case 9:
          rval = (int)((Convert.ToSingle(((ListViewItem)x).SubItems[col].Text) - Convert.ToSingle(((ListViewItem)y).SubItems[col].Text)) * 1000);
          break;

        default:
          rval = String.Compare(((ListViewItem)x).SubItems[col].Text, ((ListViewItem)y).SubItems[col].Text);
          break;
      }
       
      return rval;
    }
  }

  public class StandingsListSorter : IComparer
  {
    private int col;
    private SeasonWrapper season_data;

    public StandingsListSorter()
    {
      col = 0;
      season_data = null;
    }
    public StandingsListSorter(int column, ref SeasonWrapper sw)
    {
      col = column;
      season_data = sw;
    }
    public int Compare(object x, object y)
    {
      int rval = 0;

      string text_x = ((ListViewItem)x).SubItems[col].Text;
      string text_y = ((ListViewItem)y).SubItems[col].Text;

      DriverWrapper driver_x = (DriverWrapper)((ListViewItem)x).Tag;
      DriverWrapper driver_y = (DriverWrapper)((ListViewItem)y).Tag;

      switch (col)
      {
        case 0:      // by class then by class position
        case 3:
          char[] delimiters = " (/)".ToCharArray();
          string[] standings_x = ((ListViewItem)x).SubItems[3].Text.Split(delimiters, 10);
          string[] standings_y = ((ListViewItem)y).SubItems[3].Text.Split(delimiters, 10);

          rval = String.Compare(((ListViewItem)x).SubItems[0].Text, ((ListViewItem)y).SubItems[0].Text);
          if (rval == 0)
          {
            rval = Convert.ToInt32(standings_y[3]) - Convert.ToInt32(standings_x[3]);
          }
          if (rval == 0)
          {
            rval = Convert.ToInt32(standings_y[2]) - Convert.ToInt32(standings_x[2]);
          }
          break;

        default:
          rval = String.Compare(text_x, text_y);
          break;
      }
       
      return rval;
    }
  }
}


using System;
using System.IO;
using System.Xml;
using System.Collections;

namespace SeasonManager
{
  public class SeasonWrapper
        {
    public const string DEFAULT_SEASON_NAME = "New Solo2 Season";
    public const string DEFAULT_CLUB_NAME = "Reno SCCA";
    public const string DEFAULT_CLASS_POINTS = "21,16,14,12,11,10,9,8,7,6,5,4,3,2,1,0";
    public const string DEFAULT_PAX_POINTS = "21,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1";
    public const uint  DEFAULT_EVENT_COUNT = 15;
    public const uint  DEFAULT_MIN_EVENT_COUNT = 8;
    public const uint  DEFAULT_DROP_COUNT = 4;

    public SeasonType Payload = null;

    public SeasonWrapper()
    {
      Payload = new SeasonType();
      Payload.DocState = new DocStateType();
      Payload.Settings = new SettingsType();
      Payload.Classes = new ClassType[] {};
      Payload.Events = new EventType[] {};
      Payload.Drivers = new DriverType[] {};
    }

   
    public bool LoadDefaults()
    {
      bool result;

      try
      {
        Payload = new SeasonType();
        Payload.DocState = new DocStateType();
        Payload.Settings = new SettingsType();
        Payload.Classes = new ClassType[] {};
        Payload.Events = new EventType[] {};
        Payload.Drivers = new DriverType[] {};

        Payload.name = DEFAULT_SEASON_NAME;
        Payload.club = DEFAULT_CLUB_NAME;

        Payload.Settings.class_points = DEFAULT_CLASS_POINTS;
        Payload.Settings.pax_points = DEFAULT_PAX_POINTS;
        Payload.Settings.event_count = DEFAULT_EVENT_COUNT;
        Payload.Settings.min_event_count = DEFAULT_MIN_EVENT_COUNT;
        Payload.Settings.drop_count = DEFAULT_DROP_COUNT;

        result = true;
      }
      catch (Exception e)
      {
        Utils.WriteToFlatLog(Utils.EXCEPTION_LOG, e.ToString(), true, true);
        result = false;
      }

      return result;
    }

   
    public bool SaveToFile(string filename)
    {
      bool result;

      try
      {
        string xml;
        if (Utils.SerializeObject(Payload, out xml))
        {
          StreamWriter w = new StreamWriter(filename, false);
          w.Write(xml);
          w.Close();
          Payload.DocState.filename = filename;
          result = true;
        }
        else
        {
          result = false;
        }
      }
      catch (Exception e)
      {
        Utils.WriteToFlatLog(Utils.EXCEPTION_LOG, e.ToString(), true, true);
        result = false;
      }

      return result;
    }

    public bool LoadFromFile(string filename)
    {
      bool result;

      try
      {
        StreamReader r = new StreamReader(filename);
        string xml = r.ReadToEnd();
        r.Close();

        object new_payload = new SeasonType();
        if (Utils.DeserializeObject(xml, ref new_payload))
        {
          Payload = (SeasonType)new_payload;
          Payload.DocState.filename = filename;
          result = true;
        }
        else
        {
          result = false;
        }
      }
      catch (Exception e)
      {
        Utils.WriteToFlatLog(Utils.EXCEPTION_LOG, e.ToString(), true, true);
        result = false;
      }

      return result;
    }

   
    public override string ToString()
    {
      return Payload.name;
    }


    public void AddNewDriver(string first_name, string last_name, string car, string alias)
    {
      DriverWrapper new_driver = new DriverWrapper();
      new_driver.Payload.first_name = first_name;
      new_driver.Payload.last_name = last_name;
      new_driver.Payload.car = car;
      new_driver.AddAlias(alias);

      DriverType[] new_drivers = new DriverType[Payload.Drivers.Length + 1];
      Payload.Drivers.CopyTo(new_drivers, 0);
      Payload.Drivers = new_drivers;
      Payload.Drivers.SetValue(new_driver.Payload, Payload.Drivers.Length-1);

      /*
      XmlElement season_xmlel;
      XmlElement driver_xmlel;
      if (Utils.ElementizeObject(Payload, out season_xmlel))
      {
        string xml = "<Driver>" +
                    "  <first_name>" + first_name + "</first_name>" +
                    "  <last_name>" + last_name + "</last_name>" +
                    "  <car>" + car + "</car>" +
                    "  <Aliases>" +
                    "    <alias>" + alias + "</Alias>" +
                    "  </Aliases>" +
                    "  </Points>" +
                    "</Driver>";
        Utils.ParseXML(xml, out driver_xmlel);       
        season_xmlel.SelectSingleNode("./Drivers").AppendChild(driver_xmlel);
        object out_payload = null;
        Utils.DeelementizeObject(season_xmlel, out out_payload);
        Payload = (SeasonType)out_payload;
      }
      */
    }
   
    public DriverWrapper FindDriverByAlias(string alias)
    {
      DriverWrapper rval = null;

      for (int i=0; i<Payload.Drivers.Length; i++)
      {
        DriverType curr_driver = Payload.Drivers[i];
        foreach (string curr_alias in curr_driver.Aliases)
        {
          if (curr_alias.ToUpper() == alias.ToUpper())
          {
            rval = new DriverWrapper(ref curr_driver);
            break; // out of foreach(alias)
          }
        }

        if (rval != null)
        {
          break; // out of for(i)
        }
      }

      return rval;
    }
   
    public DriverWrapper FindDriverByName(string first_name, string last_name)
    {
      DriverWrapper rval = null;

      for (int i=0; i<Payload.Drivers.Length; i++)
      {
        DriverType curr_driver = Payload.Drivers[i];
        if ((curr_driver.first_name.ToUpper() == first_name.ToUpper()) && (curr_driver.last_name.ToUpper() == last_name.ToUpper()))
        {
          rval = new DriverWrapper(ref curr_driver);
          break; // out of for(i)
        }
      }

      return rval;
    }

    public DriverWrapper FindDriverByCombinedName(string name)
    {
      DriverWrapper rval = null;

      for (int i=0; i<Payload.Drivers.Length; i++)
      {
        DriverType curr_driver = Payload.Drivers[i];
        if (curr_driver.first_name.ToUpper() + " " + curr_driver.last_name.ToUpper() == name.ToUpper())
        {
          rval = new DriverWrapper(ref curr_driver);
          break; // out of for(i)
        }
      }

      return rval;
    }


    public ClassWrapper FindClassByImportedID(string imported_id)
    {
      ClassWrapper rval = null;

      // do a simple check
      if (rval == null)
      {
        for (int i=0; i<Payload.Classes.Length; i++)
        {
          ClassType curr_class = Payload.Classes[i];
          if (imported_id.ToUpper() == curr_class.id.ToUpper())
          {
            rval = new ClassWrapper(ref curr_class);
            break; // out of for(i)
          }
        }
      }
 
      // do a starts-with check (to find PAX classes)
      if (rval == null)
      {
        int matched_length = 0;
        for (int i=0; i<Payload.Classes.Length; i++)
        {
          ClassType curr_class = Payload.Classes[i];
          if ((imported_id.ToUpper().StartsWith(curr_class.id.ToUpper()) &&
              (curr_class.id.ToUpper().Length > matched_length)))
          {
            rval = new ClassWrapper(ref curr_class);
            matched_length = curr_class.id.ToUpper().Length;           
          }
        }
      }

      return rval;
    }
   

    public ClassWrapper GetClass(string class_id)
    {
      ClassWrapper rval = null;

      for (int i=0; i<Payload.Classes.Length; i++)
      {
        if (Payload.Classes[i].id == class_id)
        {
          rval = new ClassWrapper(ref Payload.Classes[i]);
          break; // out of for(i)
        }
      }

      return rval;
    }

    public void GetClassStandings(DriverWrapper driver, string class_id, bool exclude_nonqualified, out int position_with_drops, out int point_total, out int point_total_with_drops, out bool qualified)
    {
      position_with_drops = 0;
      point_total = 0;
      point_total_with_drops = 0;
      qualified = false;

      if (driver != null)
      {
        position_with_drops = 1;
        point_total = driver.GetClassPointsTotal(class_id, 0, Payload.Settings.event_count);
        point_total_with_drops = driver.GetClassPointsTotal(class_id, Payload.Settings.drop_count, Payload.Settings.event_count);
        qualified = driver.GetClassQualifiedStatus(class_id, Payload.Settings.min_event_count);

        for (int i=0; i<Payload.Drivers.Length; i++)
        {
          DriverWrapper opponent = new DriverWrapper(ref Payload.Drivers[i]);
          if ((point_total_with_drops < opponent.GetClassPointsTotal(class_id, Payload.Settings.drop_count, Payload.Settings.event_count)) &&
              (opponent.GetClassQualifiedStatus(class_id, Payload.Settings.min_event_count) || !exclude_nonqualified))
          {
            position_with_drops++;
          }
        }
      }
    }

    public void GetPaxStandings(DriverWrapper driver, bool ladies, bool exclude_nonqualified, out int position_with_drops, out int point_total, out int point_total_with_drops, out bool qualified)
    {
      position_with_drops = 0;
      point_total = 0;
      point_total_with_drops = 0;
      qualified = false;

      if (driver != null)
      {
        position_with_drops = 1;
        point_total = driver.GetPaxPointsTotal(ladies, 0, Payload.Settings.event_count, this);
        point_total_with_drops = driver.GetPaxPointsTotal(ladies, Payload.Settings.drop_count, Payload.Settings.event_count, this);
        qualified = driver.GetPaxQualifiedStatus(ladies, Payload.Settings.min_event_count, this);

        for (int i=0; i<Payload.Drivers.Length; i++)
        {
          DriverWrapper opponent = new DriverWrapper(ref Payload.Drivers[i]);
          if ((point_total_with_drops < opponent.GetPaxPointsTotal(ladies, Payload.Settings.drop_count, Payload.Settings.event_count, this)) &&
            (opponent.GetPaxQualifiedStatus(ladies, Payload.Settings.min_event_count, this) || !exclude_nonqualified))
          {
            position_with_drops++;
          }
        }
      }
    }
        }


  public class ClassWrapper
  {
    public ClassType Payload = new ClassType();

    public ClassWrapper(ref ClassType payload)
    {
      Payload = payload;
    }

    public override string ToString()
    {
      return Payload.id;
    }
  }


  public class EventWrapper
  {
    public EventType Payload = new EventType();

    public EventWrapper(ref EventType payload)
    {
      Payload = payload;
    }

    public override string ToString()
    {
      return Payload.data_file;
    }
  }


  public class DriverWrapper
  {
    public DriverType Payload;

    public DriverWrapper()
    {
      Payload = new DriverType();
      Payload.Aliases = new string[] {};
      Payload.Points = new PointsType[] {};
    }

    public DriverWrapper(ref DriverType payload)
    {
      Payload = payload;
    }

    public override string ToString()
    {
      return Payload.first_name + " " + Payload.last_name;
    }

    public void UpdatePoints(ulong event_number, string class_id, int class_amount, int pax_amount)
    {
      PointsType points = null;
      for (int i=0; i<Payload.Points.Length; i++)
      {
        if (Payload.Points[i].event_number == event_number)
        {
          points = Payload.Points[i];
          break; // out of for(i)
        }
      }

      if (points == null)
      {
        points = new PointsType();
        points.event_number = event_number;
        Payload.Points = (PointsType[])Utils.AppendElement(Payload.Points, points);
      }

      points.class_id = class_id;
      points.class_amount = class_amount;
      points.pax_amount = pax_amount;
    }
    public void AddAlias(string alias)
    {
      string[] new_aliases = new string[Payload.Aliases.Length + 1];
      Payload.Aliases.CopyTo(new_aliases, 0);
      Payload.Aliases = new_aliases;
      Payload.Aliases.SetValue(alias, Payload.Aliases.Length - 1);
    }
    public int GetClassPointsTotal(string class_id, uint drops, uint season_event_count)
    {
      int rval = 0;

      int drops_taken = 0;
      int[] drops_array = new int[drops];
      Array.Clear(drops_array, 0, (int)drops);
      uint event_count = 0;

      PointsType points = null;
      for (int i=0; i<Payload.Points.Length; i++)
      {
        points = Payload.Points[i];
        if (points.class_id.ToUpper() == class_id.ToUpper())
        {
          event_count++;

          if (drops_taken < drops)
          {
            drops_array[drops_taken] = points.class_amount;
            drops_taken++;
          }
          else
          {
            Array.Sort(drops_array);
            Array.Reverse(drops_array);
            for (int j=0; j<drops; j++)
            {
              if (points.class_amount < drops_array[j])
              {
                drops_array[j] = points.class_amount;
                break;
              }
            }
          }
          rval += points.class_amount;
        }
      }

      drops_taken -= (int)(season_event_count - event_count);
      Array.Sort(drops_array);
      for (int i=0; i<drops_taken; i++)
      {
        rval -= drops_array[i];
      }

      return rval;
    }

    public int GetPaxPointsTotal(bool ladies, uint drops, uint season_event_count, SeasonWrapper season_data)
    {
      int rval = 0;

      int drops_taken = 0;
      int[] drops_array = new int[drops];
      Array.Clear(drops_array, 0, (int)drops);
      uint event_count = 0;

      PointsType points = null;
      for (int i=0; i<Payload.Points.Length; i++)
      {
        points = Payload.Points[i];
        if (season_data.GetClass(points.class_id).Payload.ladies == ladies)
        {
          event_count++;

          if (drops_taken < drops)
          {
            drops_array[drops_taken] = points.pax_amount;
            drops_taken++;
          }
          else
          {
            Array.Sort(drops_array);
            Array.Reverse(drops_array);
            for (int j=0; j<drops; j++)
            {
              if (points.class_amount < drops_array[j])
              {
                drops_array[j] = points.pax_amount;
                break;
              }
            }
          }
          rval += points.pax_amount;
        }
      }

      drops_taken -= (int)(season_event_count - event_count);
      Array.Sort(drops_array);
      for (int i=0; i<drops_taken; i++)
      {
        rval -= drops_array[i];
      }

      return rval;
    }

    public bool GetClassQualifiedStatus(string class_id, uint required_events)
    {
      uint event_count = 0;
      PointsType points = null;
      for (int i=0; i<Payload.Points.Length; i++)
      {
        points = Payload.Points[i];
        if (points.class_id.ToUpper() == class_id.ToUpper())
        {
          event_count++;
        }
      }

      return (event_count >= required_events);
    }
    public bool GetPaxQualifiedStatus(bool ladies, uint required_events, SeasonWrapper season_data)
    {
      uint event_count = 0;
      PointsType points = null;
      for (int i=0; i<Payload.Points.Length; i++)
      {
        points = Payload.Points[i];
        if (season_data.GetClass(points.class_id).Payload.ladies == ladies)
        {
          event_count++;
        }
      }

      return (event_count >= required_events);
    }
  }

  public class ResultWrapper
  {
    public ResultType Payload = new ResultType();

    public ResultWrapper()
    {
      Payload = new ResultType();
      Payload.ImportedData = new ResultTypeImportedData();
      Payload.MatchedData = new ResultTypeMatchedData();
      Payload.StandingsData = new ResultTypeStandingsData();
    }

    public ResultWrapper(ref ResultType payload)
    {
      Payload = payload;
    }

  }
}
//------------------------------------------------------------------------------
// <autogenerated>
//    This code was generated by a tool.
//    Runtime Version: 1.1.4322.2032
//
//    Changes to this file may cause incorrect behavior and will be lost if
//    the code is regenerated.
// </autogenerated>
//------------------------------------------------------------------------------

//
// This source code was auto-generated by xsd, Version=1.1.4322.2032.
//
namespace SeasonManager {
    using System.Xml.Serialization;
   
   
    /// <remarks/>
    [System.Xml.Serialization.XmlRootAttribute("Season", Namespace="", IsNullable=false)]
    public class SeasonType {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("New Season")]
        public string name = "New Season";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("")]
        public string club = "";
       
        /// <remarks/>
        public DocStateType DocState;
       
        /// <remarks/>
        public SettingsType Settings;
       
        /// <remarks/>
        [System.Xml.Serialization.XmlArrayItemAttribute("Class", IsNullable=false)]
        public ClassType[] Classes;
       
        /// <remarks/>
        [System.Xml.Serialization.XmlArrayItemAttribute("Event", IsNullable=false)]
        public EventType[] Events;
       
        /// <remarks/>
        [System.Xml.Serialization.XmlArrayItemAttribute("Driver", IsNullable=false)]
        public DriverType[] Drivers;
    }
   
    /// <remarks/>
    public class DocStateType {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(false)]
        public bool modified = false;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("")]
        public string filename = "";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.UInt64), "0")]
        public System.UInt64 next_id = ((System.UInt64)(0m));
    }
   
    /// <remarks/>
    public class PointsType {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("")]
        public string class_id = "";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.UInt64), "0")]
        public System.UInt64 event_number = ((System.UInt64)(0m));
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(0)]
        public int class_amount = 0;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(0)]
        public int pax_amount = 0;
    }
   
    /// <remarks/>
    public class DriverType {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("New")]
        public string first_name = "New";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("Driver")]
        public string last_name = "Driver";
       
        /// <remarks/>
        [System.Xml.Serialization.XmlArrayItemAttribute("alias", IsNullable=false)]
        public string[] Aliases;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("")]
        public string car = "";
       
        /// <remarks/>
        [System.Xml.Serialization.XmlArrayItemAttribute("Points", IsNullable=false)]
        public PointsType[] Points;
    }
   
    /// <remarks/>
    public class EventType {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("New Event")]
        public string name = "New Event";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("")]
        public string date = "";
       
        /// <remarks/>
        public System.UInt64 number;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("")]
        public string data_file = "";
    }
   
    /// <remarks/>
    public class PrefixModifierType {
       
        /// <remarks/>
        public string prefix;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.Single), "1")]
        public System.Single modifier = ((System.Single)(1F));
    }
   
    /// <remarks/>
    public class ClassType {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("NEW")]
        public string id = "NEW";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("New Class")]
        public string description = "New Class";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(false)]
        public bool ladies = false;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(false)]
        public bool non_points = false;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(false)]
        public bool pax_class = false;
       
        /// <remarks/>
        [System.Xml.Serialization.XmlArrayItemAttribute("PrefixModifier", IsNullable=false)]
        public PrefixModifierType[] PrefixModifiers;
    }
   
    /// <remarks/>
    public class SettingsType {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("10,8,6,5,4,3,2,1,0")]
        public string class_points = "10,8,6,5,4,3,2,1,0";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(5)]
        public int single_entrant_class_points = 5;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("10,8,6,5,4,3,2,1")]
        public string pax_points = "10,8,6,5,4,3,2,1";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(10)]
        public int single_entrant_pax_points = 10;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.UInt32), "0")]
        public System.UInt32 event_count = ((System.UInt32)(0));
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.UInt32), "0")]
        public System.UInt32 min_event_count = ((System.UInt32)(0));
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.UInt32), "0")]
        public System.UInt32 drop_count = ((System.UInt32)(0));
    }
   
    /// <remarks/>
    [System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
    public class ImportedResults {
       
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute("Result")]
        public ResultType[] Result;
    }
   
    /// <remarks/>
    public class ResultType {
       
        /// <remarks/>
        public ResultTypeImportedData ImportedData;
       
        /// <remarks/>
        public ResultTypeMatchedData MatchedData;
       
        /// <remarks/>
        public ResultTypeStandingsData StandingsData;
    }
   
    /// <remarks/>
    public class ResultTypeImportedData {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("")]
        public string Class = "";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("Unknown")]
        public string First_Name = "Unknown";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("Driver")]
        public string Last_Name = "Driver";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("")]
        public string Car = "";
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.Single), "999.999")]
        public System.Single Total = ((System.Single)(999.999F));
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.Single), "999.999")]
        public System.Single Pax_Time = ((System.Single)(999.999F));
       
        /// <remarks/>
        [System.Xml.Serialization.XmlArrayItemAttribute("Run", IsNullable=false)]
        public RunType[] Runs;
    }
   
    /// <remarks/>
    public class RunType {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.Single), "999.999")]
        public System.Single time = ((System.Single)(999.999F));
       
        /// <remarks/>
        public string penalty;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(0)]
        public int cone_count = 0;
    }
   
    /// <remarks/>
    public class ResultTypeMatchedData {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute("")]
        public string class_id = "";
       
        /// <remarks/>
        public string alias;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(ResultTypeMatchedDataMode.INVALID)]
        public ResultTypeMatchedDataMode mode = ResultTypeMatchedDataMode.INVALID;
       
        /// <remarks/>
        public bool ignored;
    }
   
    /// <remarks/>
    public enum ResultTypeMatchedDataMode {
       
        /// <remarks/>
        INVALID,
       
        /// <remarks/>
        ADD_DRIVER,
       
        /// <remarks/>
        NEW_LINK,
       
        /// <remarks/>
        EXISTING_LINK,
    }
   
    /// <remarks/>
    public class ResultTypeStandingsData {
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.UInt64), "0")]
        public System.UInt64 class_position = ((System.UInt64)(0m));
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(0)]
        public int class_points = 0;
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(typeof(System.UInt64), "0")]
        public System.UInt64 pax_position = ((System.UInt64)(0m));
       
        /// <remarks/>
        [System.ComponentModel.DefaultValueAttribute(0)]
        public int pax_points = 0;
    }
}

Why don't you just go and finish up the changes for generating individual event reports and fix the calculation for the new Street Tire rules for me, since my 9 to 5 (occationally 8am to 1am) job of server software development is taking up too much of my time.

Nick Koan 2006-04-12 12:14 PM

I am so pirating that code.

sperry 2006-04-12 12:18 PM

Quote:

Originally Posted by nKoan
I am so pirating that code.

Cool, when you're done, can you email it back to me with the bugs fixed?

Nick Koan 2006-04-12 12:21 PM

Bugs, fixed?

I'm sorry, thats not my department.

A1337STI 2006-04-12 02:16 PM

Nice Code :) that will give me something to play around with

sperry 2006-04-12 03:12 PM

Quote:

Originally Posted by A1337STI
Nice Code :) that will give me something to play around with

Knock yourself out buddy.

See if you can note the way I handle street tire, ladies classes, season points for both class and pax championships, novice results, run no points, drops, perfect attendance reporting, driver aliases, name scrambling, .RGG importing, single event reporting, season standings reporting, and probably 20 other nuances I can't even recall since I wrote this software like 8 months ago.

Basically, the problem isn't anywhere as simple as 2 DB tables and a PAX lookup. For example, you tell me how that will tell the connection between SM and TSM and how you'll know to consider them in the same championship but applying the street tire PAX factor to just one of them before final classification. Or how you'll know that "Allen Snellbaker" and "Alan Snellbacher" are actually the same person even though his name changed between the Round 1 results and the Round 3 results because someone in the bus mis-typed his name. Or how you'll handle the consolidation of PAX points for one driver even though s/he's changed classes throughout the season. Finally, tell me how a web-based DB driven application is going to do a lick of good on a laptop that's running off a generator in a bus parked on the tarmac at Stead airport, you got satalite internet access you'll loan to SCCA so we can update and print results from the bus, or am I going to have to install a webserver on the SCCA laptop and run it locally?

The problem set for this software is non-trivial.

khail19 2006-04-12 03:16 PM

Cool, Scott's panties are in a bunch again. Good ol' Scott!

sperry 2006-04-12 03:24 PM

Quote:

Originally Posted by khail19
Cool, Scott's panties are in a bunch again. Good ol' Scott!

:P :lol:

A1337STI 2006-04-12 03:29 PM

It is doable with just a few DB Tables. its all in the table design , and the right SQL statements.

Seariously if someone can give me some Raw data files, or a sample of a raw data file I'll come up with a new set of tools. (or I'll find out how non-trivial it is)

and DUDE you can't be searious that you can't figure out 1 method of using a web app on a laptop with out a live net connection? (not that doing so would be ideal , i was more thinking of 1 data collection tool, 1 importer, and 1 web app)
Method #1 windows 2k advanced, install SQL 2k, run IIS, (windows xp pro won't work becuase you can't install a server instance of sql. course you could make the web app run on M$ Access, but i generally avoid that) run it all locally ... :P
Method #2 Design the data collection software to store offline, and to have an upload feature. and when that laptop gets to an internet connection it Then uploads the data...
Method #3 still have the results manually written down at the event, Input them into a computer when that person gets home.
Method #4 Write an email server and set it up on its own email address and have T&S send it emails Via cell phones
Method #5 (okay you got the point now i hope)

Nasa spent lots of man hours coming up with a pen that will work in 0 G. the soviets used pencils .... i commonly go for the pencil approach. :)

:lol: I'de fully understand if you don't trust the new guy with doing any official results, but a sample file to play with can't hurt (you can change out the real data if you want) or the Raw visual studio project files to your current app. (only briefly looked but that's either C# or VC++, and it looks more like C#) if so zip and send to alex@ridelaketahoe.com

A1337STI 2006-04-12 03:42 PM

is Scott going to hate me if i make a new program and it works ? :(

Dean 2006-04-12 03:42 PM

While Scott is right, the complexity of Solo timing and scoring is non trivial, we really could use some help!

Using the software is actually not that hard if you can type, and not want to bash the keyboard to hard when it does something stupid.

If you want to understand why this topic brings the three of us to a boil so quickly, I encourage you to voulenteer for T&S duty.

Get to the event early, and get your name down next to timing computer, timing paper or cone count.

You want to go above and beyond, take the initiative, and come out and learn to set up the lights, PA and so forth.

The more people that know how to do this stuff, the easier it is on event days for all of us.

If you want to help out on coding the scoring software, you have to understand the timing system first, and then the "rules" for scoring. Take a look at our supplemental regulations if you want to get your hands dirty.

If we actually have some interest, I would be happy to teach a T&S "class" before one of our meets. Say 6PM at Bully's some week.

We really would like more people who can see, think, react, and type working in the bus. Right now during some run groups, it is a refuge for people who don't want to, or can't work the course, and have marginal abilities to do some of the above list, and it kills us when it comes time to produce results in a timely manner.

If we could get a core 10 or so people who actually knew the system, and could operate many if not all of it's real time features, many of our reruns, missed cones, and other BS in T&S would magically disappear, and we would make that position one that you had to be pre approved to sign up for, kind of like safety steward.

So, if you want to help out, Step Up. Otherwise, you got no rights to complain about how long it takes us to publish results.

Kevin M 2006-04-12 03:44 PM

Pencil method= manually tabulating results and posting to website. 0 G pen=writing sweet software to do it.

Nick Koan 2006-04-12 03:48 PM

Quote:

Originally Posted by A1337STI
It is doable with just a few DB Tables. its all in the table design , and the right SQL statements.

Seariously if someone can give me some Raw data files, or a sample of a raw data file I'll come up with a new set of tools. (or I'll find out how non-trivial it is)

Raw data? You mean, like that stuff coming from the timing lights? You'll have to write an interface for that.

sperry 2006-04-12 03:51 PM

Alex:

First, I'd like to know how a web application is going to communicate with the timing lights, which is where we'd like to go w/ this software. I could be wrong but I don't think mysql/php has a way to spawn a thread to read from a serial port and write to shared memory.

The real solution to the problem is to write a windows application that doesn't require any rediculous steps like uploading scores via a cell phone :roll: or buying a new OS for the laptop as well as DBMS systems. Your options start at expensive and rediculous and end with pure retardation (the people running the bus have a hard time understanding the term "click the mouse"... you think they'll be able to mange debugging a cell-phone based internet connection? And who's paying for all that connectivity?).

And in general, running an "application" on a network designed to share text files will *always* be the zero-g pen and *never* the pencil. Using port 80 for anything beyond the serving of pure text documents is a hack. Hell, I'm surprised email even works.

Now I'm not trying to come down on your enthusiasm, but enthusiasm alone doesn't solve problems. You need experience w/ the problem 1st. You learn the current T&S software, the way season points are managed, be chief of timing and scoring for a season or two, and figure out when web services are useful vs. when regular applications are useful, and then we can talk about a new software development project. I thought it was easy too when I first took the job of T&S chief in 2004... it's not easy, it sucks, especially when the design requirements change every year. For now, the software I wrote will be updated to the new scoring rules before the next event, and will be plenty adequate for this years results.

sperry 2006-04-12 03:54 PM

Quote:

Originally Posted by nKoan
Raw data? You mean, like that stuff coming from the timing lights? You'll have to write an interface for that.

I've already reverse engineered the timing hardware and have an API and test application for it. I just haven't done anything with it.

Dean 2006-04-12 03:57 PM

Quote:

Originally Posted by A1337STI
is Scott going to hate me if i make a new program and it works ? :(

Just chill out a little. What appears to be trivial is not.

It's not about web servers on laptops, it's about dealing with the human component of this system, the poor basic design of the timing application, and last but not least, our convoluted rules for individual event and season scoring.

I can give you most if not all of last year's data, but without context, it will be mostly meaningless.

I'm glad you want to help, and personally would appreciate the help, but rather than just saying how easy it is to do, try understanding the problem first.

Pretend this is one of those sheets that you got in grammer school with all these instructions on them telling you to do a bunch of random stuff, but the first instruction was "read the entire sheet before doing anything", and the last said "ignore all other directions, and write your name on the piece of paper, and turn it over on your desk"

Don't be the kid singing "mary had a little lamb" and doing long division of a twelve digit number, instead, go read the scoring rules, and come back and ask questions...

MikeK 2006-04-12 04:00 PM

Quote:

Originally Posted by Dean
I encourage you to voulenteer for T&S duty.

... or something even remotely related to timing (or anything else) :devil:

... that's how I got the job!

sperry 2006-04-12 04:02 PM

Quote:

Originally Posted by MikeK
... or something even remotely related to timing (or anything else) :devil:

... that's how I got the job!

Dude, you volenteered for T&S chief, you said "I'll update the season results after each event". What do you think the T&S chief does? :P

Nick Koan 2006-04-12 04:04 PM

I think Mike agreed to upload the files after the T&S cheif was done with them :p

Now he's the dude who has to tabulate the results.

MikeK 2006-04-12 04:07 PM

Quote:

Originally Posted by sperry
Dude, you volenteered for T&S chief, you said "I'll update the season results after each event". What do you think the T&S chief does? :P

I guess I was T+S chief last year too then :P

What I really meant was that I didn't want to be the type of T+S chief who says things or does stuff. Plus there's no internet connection in the bus, so it's hard to pass the time.

sperry 2006-04-12 04:10 PM

Quote:

Originally Posted by MikeK
I guess I was T+S chief last year too then :P

What I really meant was that I didn't want to be the type of T+S chief who says things or does stuff. Plus there's no internet connection in the bus, so it's hard to pass the time.

Filling out a spreadsheet too make sure you're winning PAX doesn't quite cut it as "updating the season results after each event". :P

Dean 2006-04-12 04:10 PM

Quote:

Originally Posted by nKoan
I think Mike agreed to upload the files after the T&S cheif was done with them :p

Now he's the dude who has to tabulate the results.

Technically, I think Scott is right. Mike offered to do the season results.

But to do those you have to have the event data... So we enter the grey area...

We actually had a pretty good handle on getting event results out last year, but the new Street tire rules for this year are making it a bitch.

Should we have maybe done a little more planning and prep before the season started, yes... Are we paying the price now? Yes...

We will get a handle on it between the 3 or more of us. Just bear(or is it bare) with us.

sperry 2006-04-12 04:15 PM

Dean, like I mentioned earlier, I'm updating the software that was working well at the end of the season last year to handle the new rules. I'm also adding the ability to generate per-round results so we won't have to hand merge Street Tire classes w/ their parent classes.

Hell, we actually might be able to get away with using AXWare w/o ever entering names, all we really need are the class/number pairs and the times. Though, the announcer wouldn't get jack to talk about, since we both know how bad AXWare is about reporting things like run count if you haven't pre-entered a driver into the roster.

A1337STI 2006-04-12 04:40 PM

I never wrote that it was Easy; I did write I am in the belief with some raw data I could setup something that would work, which at some point in the system would include a Database.

Ya I’d like to see the results, but I honestly don't care if it takes 3 more weeks. I’m stoked to find a safe recreational outlet for driving. I'm stoked its so affordable, which is only due to volunteer work. Which I am very thankful for.

I find I work best when I start at the start and attempt to feel out the whole problem, (i.e. get what ever raw data it starts as and think of how to get to the end result) which was my goal here, I was hoping someone would just say "here's the raw data, take a look "

But Apparently this is a very sensitive toe I was about to Drive over, you could have saved a lot of typing (and a few unintentional jabs at your ego) by putting something like "This is a bit of a pet project of Mine, thanks for the offer, but no thanks"

and if its easier for you to accept, Okay its impossible And Cost prohibitive to integrate a DB with your system.

Dean 2006-04-12 04:44 PM

Quote:

Originally Posted by sperry
Dean, like I mentioned earlier, I'm updating the software that was working well at the end of the season last year to handle the new rules. I'm also adding the ability to generate per-round results so we won't have to hand merge Street Tire classes w/ their parent classes.

Hell, we actually might be able to get away with using AXWare w/o ever entering names, all we really need are the class/number pairs and the times. Though, the announcer wouldn't get jack to talk about, since we both know how bad AXWare is about reporting things like run count if you haven't pre-entered a driver into the roster.

I understood that. All I was saying is that things were simpler last year, and though it sucked, we could get event results out of AXWare after only a small amount of head banging and some minor manipulation of the Street tire class. This year the new ST rules are far beyond anything AXWare can remotely handle.

The first events are always the worst becasue of all the changes. You guys were brave to not use last year's driver data at all. I'd be happy to do some cleanup and correlation of driver info back into AXWare if you want. And we have to enter the new info somewhere, so it may as well be in AXWare at the event.

All we need is the last raw event file to start the next one, so as long as we can get names and cars straightened out once, we should be fairly well off moving forward.

The problem we ran into last year was we kept using the same base membership file rather than using the last event, or updating the base file, so we had to make the same changes event after event.

Dean 2006-04-12 04:56 PM

1 Attachment(s)
Quote:

Originally Posted by A1337STI
I never wrote that it was Easy; I did write I am in the belief with some raw data I could setup something that would work, which at some point in the system would include a Database.

Ya I’d like to see the results, but I honestly don't care if it takes 3 more weeks. I’m stoked to find a safe recreational outlet for driving. I'm stoked its so affordable, which is only due to volunteer work. Which I am very thankful for.

I find I work best when I start at the start and attempt to feel out the whole problem, (i.e. get what ever raw data it starts as and think of how to get to the end result) which was my goal here, I was hoping someone would just say "here's the raw data, take a look "

But Apparently this is a very sensitive toe I was about to Drive over, you could have saved a lot of typing (and a few unintentional jabs at your ego) by putting something like "This is a bit of a pet project of Mine, thanks for the offer, but no thanks"

and if its easier for you to accept, Okay its impossible And Cost prohibitive to integrate a DB with your system.

Alex, you just don't get it... Nobody wants to do this, and it's nobody's pet project. We hate the software, and the fact that it makes us jump through rediculous hoops.

What we are trying to say is walk before you run. The reason this software sucks so bad is that Vitek, the guy who wrote did a lot of things similar to what you are describing, and didn't think about the ramifications.

The data from a couple last year events are attached... Knock yourself out... But don't ask us for any context, or help understanding the issues, because that's not how you roll...

Use Windows Jet DBs, they are free. Don't forget to assume that the data for the next event will be completely different.

I was young, and knew everything once too....

Enjoy...

Double Phister 2006-04-13 08:02 AM

Quote:

Originally Posted by A1337STI
...Method #1 windows 2k advanced, install SQL 2k, run IIS, (windows xp pro won't work becuase you can't install a server instance of sql. course you could make the web app run on M$ Access, but i generally avoid that) run it all locally ... :P

We use web app locally on our laptops.

WinXP Pro w/ IIS. MSDE for the database. MSDE has a 2GB database limit and slows itself down when more than 5 connections to it are opened.

Java GUI --> IIS --> MSDE

Then later if you need to expand you can move up to SQL Server.

sperry 2006-04-13 09:59 AM

Quote:

Originally Posted by R4ND0M_AX3
We use web app locally on our laptops.

WinXP Pro w/ IIS. MSDE for the database. MSDE has a 2GB database limit and slows itself down when more than 5 connections to it are opened.

Java GUI --> IIS --> MSDE

Then later if you need to expand you can move up to SQL Server.

Cool, now who pays for that? The SCCA laptop came with XP Home, and no one's paying for the upgrade.

Also, the idea of writing and testing a web application to be used locally makes me want to eat my own face. There are development tools and languages that are about 1000 times better than what you get w/ a web interface designed specifically for writing local applications. Just because you can get something to work as a "web application" does not make it the correct solution. Web apps are still about 20 years behind the curve as far as user interface capabilities when compared to true native applications.

Everyone together now: "The best way to write a windows application is to write a windows application." It's not: "Create an online database, write a script that accesses the database, implement a flash interface that gives you a slick (non-standard) GUI but only works on Internet Explorer and only if you have the latest updates, create a downloadable Java app that will talk to the serial port for timing I/O but only if the user has administrator privledges and has updated to the latest version of Java from Sun, interface the Java comms app to the flash page, and wrap the whole thing into a complicated cookies-based state machine that will never be 100% stable because the web is inherently stateless. Oh and nevermind the security issues that will allow anyone with an associated degree in 'web guruism' to enter their own run times into the database at will."

Dan, if your business thinks local web apps are the way to go, someone at your company should be fired IMO. The *only* reason to go that route is if you already had the web software written and you're using it while someone implements a local version.

Sorry to rant, but this is a pet peeve of mine... The internet is a fucking mess. Basic web browsing (plain old text and pictures) is pretty good, and the whole message board thing is pretty well sorted out. Online shopping is getting pretty close to decent (mostly just out of necessity) but is still very hit-or-miss based on the vendor. However, in general, the internet is chock full of terrible code, poor design practices, awful user interfaces, and security holes large enough to barrel roll a triple-7 through. Having done both apps and web development for the last 10 years, choosing to keep that web-based shit off my local system is a no-brainer. There is no reason to install $1000 in licenses, 15 GB of software, and 7 different supporting applications (that all need to be constantly updated online), and one hacked together web-app just to get the functionality that a 200k C++ Builder app that took 15 hours to design, implement, test and debug is insane.

Double Phister 2006-04-13 12:12 PM

Quote:

Originally Posted by sperry
Dan, if your business thinks local web apps are the way to go, someone at your company should be fired IMO. The *only* reason to go that route is if you already had the web software written and you're using it while someone implements a local version.

LOLLERZ <----I hope you hate that as much as I do.


I didn't say what we did here was pretty. I just wanted to make the suggestion of a server OS and SQL server slightly more affordable.

(the controllers we work with use the java inteface and the manufactuer decided to make the offline programming tool similar to the live device)

Agreed. Make a real windows app.


All times are GMT -8. The time now is 07:10 PM.

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
All Content Copyright Subaru Enthusiasts Car Club of the Sierras unless otherwise noted.