Esempio n. 1
0
        protected void GenerateLine(Adjacent frame)
        {
            // At some point I'm going to change this so column visibility is checked only once
            // And not for every row in a datagrid

            foreach (int columnIndex in selectedColumns)
            {
                if (dataGrid.Columns[columnIndex].HeaderText != "Flip Sequence" &&
                    dataGrid.Columns[columnIndex].HeaderText != "Seed")
                {
                    sb.AppendFormat("{0:" + dataGrid.Columns[columnIndex].DefaultCellStyle.Format + "}",
                                    frame.GetType().GetProperty(dataGrid.Columns[columnIndex].DataPropertyName).GetValue
                                        (frame, null));
                    sb.Append("\t");
                }
                else
                {
                    sb.AppendFormat("{0:" + dataGrid.Columns[columnIndex].DefaultCellStyle.Format + "}",
                                    frame.GetType().GetProperty(dataGrid.Columns[columnIndex].DataPropertyName).GetValue
                                        (frame, null));
                    sb.Append("\t");
                }
            }

            sb.Append(Environment.NewLine);
        }
Esempio n. 2
0
 private bool IsTarget(Adjacent adjacent)
 {
     var timeAndDelay = (TimeAndDelay) dataGridViewValues.SelectedRows[0].DataBoundItem;
     return adjacent.Date == timeAndDelay.Date && adjacent.Delay == timeAndDelay.Delay;
 }
Esempio n. 3
0
        private void buttonGenerateAdjacents_Click(object sender, EventArgs e)
        {
            if (radioBtnDPPt.Checked)
            {
                ColumnFlipSequence.Visible = true;
                ColumnElmResponse.Visible = false;
                ColumnRoamers.Visible = false;
                ColumnGen5IVs.Visible = false;
            }
            else if (radioBtnHgSs.Checked)
            {
                ColumnFlipSequence.Visible = false;
                ColumnElmResponse.Visible = true;
                ColumnRoamers.Visible = true;
                ColumnGen5IVs.Visible = false;
            }
            else
            {
                ColumnFlipSequence.Visible = false;
                ColumnElmResponse.Visible = false;
                ColumnRoamers.Visible = false;
                ColumnGen5IVs.Visible = true;
                ColumnCGearAdjust.Visible = sekrit;
            }

            if (maskedTextBoxMDelay.Text == "")
            {
                maskedTextBoxMDelay.Focus();
                return;
            }

            if (maskedTextBoxPDelay.Text == "")
            {
                maskedTextBoxPDelay.Focus();
                return;
            }

            if (maskedTextBoxMSecond.Text == "")
            {
                maskedTextBoxMSecond.Focus();
                return;
            }

            if (maskedTextBoxPSecond.Text == "")
            {
                maskedTextBoxPSecond.Focus();
                return;
            }

            //  Make sure that something is selected in the main
            //  times grid and then go ahead and get that item
            if (dataGridViewValues.SelectedRows.Count == 0)
            {
                return;
            }

            //  Load all of our +/- so we can use them to generate
            //  or list of adjacent frames.
            int mDelay = int.Parse(maskedTextBoxMDelay.Text);
            int pDelay = int.Parse(maskedTextBoxPDelay.Text);
            int mSecond = int.Parse(maskedTextBoxMSecond.Text);
            int pSecond = int.Parse(maskedTextBoxPSecond.Text);

            var timeAndDelay = (TimeAndDelay) dataGridViewValues.SelectedRows[0].DataBoundItem;

            //  From the actual time we need to build a start
            //  time and an end time so that we can iterate
            DateTime startTime = timeAndDelay.Date - new TimeSpan(0, 0, mSecond);
            DateTime endTime = timeAndDelay.Date + new TimeSpan(0, 0, pSecond);

            //  Figure out how many seconds there are between the times
            //  as this is going to be the number of times that we are
            //  going to loop, plus 1.
            TimeSpan span = endTime - startTime;

            int startDelay = timeAndDelay.Delay - mDelay;
            int endDelay = timeAndDelay.Delay + pDelay;

            // Grab our roamer information so we only have to do it one
            // time and can just run the code and pass the results into
            // the adjacents.
            uint rRoute = 0;
            uint eRoute = 0;
            uint lRoute = 0;

            // need to tryparse out all of the route values
            if (maskedTextBoxRRoute.Text != "")
                rRoute = uint.Parse(maskedTextBoxRRoute.Text);

            if (maskedTextBoxERoute.Text != "")
                eRoute = uint.Parse(maskedTextBoxERoute.Text);

            if (maskedTextBoxLRoute.Text != "")
                lRoute = uint.Parse(maskedTextBoxLRoute.Text);

            var adjacents = new List<Adjacent>();

            int oddEven = timeAndDelay.Delay & 1;

            int minFrame;
            int maxFrame;

            int.TryParse(maskedTextBoxMinFrame.Text, out minFrame);
            int.TryParse(maskedTextBoxMaxFrame.Text, out maxFrame);

            if (minFrame == 0)
            {
                minFrame = 1;
            }

            if (maxFrame == 0)
            {
                maxFrame = 10;
            }

            if (checkBoxRoamer.Checked)
            {
                minFrame++;
                maxFrame++;
            }

            for (int cnt = 0; cnt <= (int) span.TotalSeconds; cnt++)
            {
                DateTime seedTime = startTime + new TimeSpan(0, 0, cnt);

                //  Now we need to loop through all of our delay range
                //  so that we have all of the information to create
                //  a seed.
                for (int delayCnt = startDelay; delayCnt <= endDelay; delayCnt++)
                {
                    if (!checkBoxOddEven.Checked || (delayCnt & 1) == oddEven)
                    {
                        //  Create the seed an add to the collection

                        var adjacent = new Adjacent
                            {
                                Delay = delayCnt,
                                Date = seedTime,
                                MinFrame = minFrame,
                                MaxFrame = maxFrame + 6,
                                Seed = ((((uint) seedTime.Month*
                                          (uint) seedTime.Day +
                                          (uint) seedTime.Minute +
                                          (uint) seedTime.Second)%0x100)*0x1000000) +
                                       ((uint) seedTime.Hour*0x10000) +
                                       ((uint) seedTime.Year - 2000 + (uint) delayCnt) +
                                       // only part of the MAC Address is used
                                       ((uint) MAC_Address & 0xFFFFFF)
                            };

                        adjacent.RoamerInformtion = HgSsRoamers.GetHgSsRoamerInformation(
                            adjacent.Seed,
                            checkBoxRPresent.Checked,
                            checkBoxEPresent.Checked,
                            checkBoxLPresent.Checked,
                            rRoute,
                            eRoute,
                            lRoute);

                        adjacents.Add(adjacent);
                    }
                }
            }

            //  Bind to the collection
            dataGridViewAdjacents.DataSource = adjacents;

            //highlight the target
            int target = adjacents.FindIndex(IsTarget);
            dataGridViewAdjacents.FirstDisplayedScrollingRowIndex = target;
        }
Esempio n. 4
0
 private bool HasElms(Adjacent adjacent)
 {
     return adjacent.ElmResponses.Contains(textBoxResponses.Text) &&
            (RoamerText == "" || RoamerText == adjacent.RoamerLocations);
 }
Esempio n. 5
0
        protected void GenerateLine(Adjacent frame)
        {
            // At some point I'm going to change this so column visibility is checked only once
            // And not for every row in a datagrid

            foreach (int columnIndex in selectedColumns)
            {
                if (dataGrid.Columns[columnIndex].HeaderText != "Flip Sequence" &&
                    dataGrid.Columns[columnIndex].HeaderText != "Seed")
                {
                    sb.AppendFormat("{0:" + dataGrid.Columns[columnIndex].DefaultCellStyle.Format + "}",
                                    frame.GetType().GetProperty(dataGrid.Columns[columnIndex].DataPropertyName).GetValue
                                        (frame, null));
                    sb.Append("\t");
                }
                else
                {
                    sb.AppendFormat("{0:" + dataGrid.Columns[columnIndex].DefaultCellStyle.Format + "}",
                                    frame.GetType().GetProperty(dataGrid.Columns[columnIndex].DataPropertyName).GetValue
                                        (frame, null));
                    sb.Append("\t");
                }
            }

            sb.Append(Environment.NewLine);
        }
Esempio n. 6
0
 private bool HasFlips(Adjacent adjacent)
 {
     return adjacent.Flips.Contains(txtFlips.Text);
 }