Пример #1
0
        private bool closing = false;  // form was acting weird when closed, I think because of stuff trying to update after wrapper closed
        #endregion

        #region Form stuff
        public mainForm()
        {
            if (!File.Exists(logFile))  // make sure file exists
            {
                // File.Create(logFile); // if not, create it
                using (StreamWriter sw = File.AppendText(logFile))
                {
                    sw.WriteLine(DateTime.Now.ToString("h:mm:ss") + " - File created");
                }
            }

            InitializeComponent();                                                             // initialize the component, you know, that component

            numericUpDown1.Value        = Properties.Settings.Default.CautionShortcutKey;      // set shortcut key to users settings
            lblLargeCounter.ForeColor   = Properties.Settings.Default.LargeCounterNumberColor; // set color for large counter text
            lblCountdownTitle.ForeColor = Properties.Settings.Default.LargeCounterNumberColor;

            num10MinHotkey.Value = Properties.Settings.Default.TenMinWarningHotkey;
            num5MinHotkey.Value  = Properties.Settings.Default.FiveMinWarningHotkey;
            num1MinHotkey.Value  = Properties.Settings.Default.OneMinWarningHotkey;

            chkEnableMinWarnings.Checked = Properties.Settings.Default.EnableMinuteWarnings;
            chkControlsCautions.Checked  = Properties.Settings.Default.ControlCautionClock;

            if (Properties.Settings.Default.LargeCounterStreamerFriendly)  // set background of large counter to users settings
            {
                tabControl1.TabPages[1].BackColor = Color.LawnGreen;
            }
            else
            {
                tabControl1.TabPages[1].BackColor = Color.Transparent;
            }
            // chkControlsCautions.Checked = false;  // disabled because it's kind of just annoying
            // chkControlsCautions.Enabled = false;
            chkPlayAudioOnCaution.Checked = Properties.Settings.Default.PlayAudioFileOnCaution;
            //lblCountdownTitle.Visible = false;
            //lblLargeCounter.Visible = false;

            #region wrapper stuff
            try
            {
                wrapper = new iRacingSdkWrapper.SdkWrapper();       // create wrapper instance

                wrapper.TelemetryUpdated   += OnTelemetryUpdated;   // listen to telemetry events
                wrapper.SessionInfoUpdated += OnSessionInfoUpdated; // listen to session events

                wrapper.Start();                                    // start wrapper


                tabPgLargeCountdown.BackColor = Properties.Settings.Default.tabPgLargeCountdownBackColor; // had to move this to the bottom because form kept trying to overwrite color, not sure why
            } catch (Exception exc)
            {
                WriteToLogFile("wrapper stuff", exc.Message.ToString());
            }


            #endregion
        }  // basic form stuff
Пример #2
0
        public Form1()  // this is run when the program is first started, it's essentially the same as form load for the primary form
        {
            #if (DEBUG)
            Console.WriteLine("\n\n~~~~~~~~~~~~~~~~~~~~\nIn Debug\n~~~~~~~~~~~~~~~~~~~~\n\n");
            #endif

            InitializeComponent();  // do magic stuff

            TopMost = true;

            InitializeSegmentTop10S();

            #region Set Defaults
            nudClosePitsMacro.Value    = userSettings.ClosePitsMacro;
            nudThrowCautionMacro.Value = userSettings.ThrowCautionMacro;
            nudClosePits.Value         = userSettings.ClosePitsLap;
            #endregion

            #region Data Grid Views setup
            #region dgvSeg1Results
            dgvSeg1Results.RowHeadersVisible = false; // hide left margin
            dgvSeg1Results.ColumnCount       = 3;     // set number of columns

            // set column names
            dgvSeg1Results.Columns[0].Name = "Pos.";
            dgvSeg1Results.Columns[1].Name = "Car #";
            dgvSeg1Results.Columns[2].Name = "Name";

            // set column widths
            dgvSeg1Results.Columns[0].Width = 50;
            dgvSeg1Results.Columns[1].Width = 56;
            dgvSeg1Results.Columns[2].Width = 179;
            #endregion

            #region dgvSeg2Results
            dgvSeg2Results.RowHeadersVisible = false; // hide left margin
            dgvSeg2Results.ColumnCount       = 3;     // set number of columns

            // set column names
            dgvSeg2Results.Columns[0].Name = "Pos.";
            dgvSeg2Results.Columns[1].Name = "Car #";
            dgvSeg2Results.Columns[2].Name = "Name";

            // set column widths
            dgvSeg2Results.Columns[0].Width = 50;
            dgvSeg2Results.Columns[1].Width = 56;
            dgvSeg2Results.Columns[2].Width = 179;
            #endregion
            #endregion

            #region wrapper stuff
            try
            {
                wrapper = new iRacingSdkWrapper.SdkWrapper();       // create wrapper instance

                wrapper.TelemetryUpdated   += OnTelemetryUpdated;   // listen to telemetry events
                wrapper.SessionInfoUpdated += OnSessionInfoUpdated; // listen to session events

                wrapper.Start();                                    // start wrapper
            }
            catch (Exception exc)
            {
                Console.WriteLine(exc.Message);
                //WriteToLogFile("wrapper stuff", exc.Message.ToString());
            }
            #endregion
        }