示例#1
0
        void InitialiseButtons()
        {
            MyToolTip tooltip;

            if (stintIndex != 0)
            {
                Up                  = new StintControlButton(0);
                Up.Size             = btnDefault;
                Up.BackgroundImage  = Properties.Resources.Stint_Up;
                tooltip             = new MyToolTip(Up, "Swap with previous stint");
                Up.OnButtonClicked += ButtonClicked;
                this.Controls.Add(Up, 0, 0);
            }

            if (stintIndex != thisStrategy.NoOfStints - 1)
            {
                Down                  = new StintControlButton(1);
                Down.Size             = btnDefault;
                Down.BackgroundImage  = Properties.Resources.Stint_Down;
                tooltip               = new MyToolTip(Down, "Swap with next stint");
                Down.OnButtonClicked += ButtonClicked;
                this.Controls.Add(Down, 0, 1);
            }

            AddBefore                 = new StintControlButton(2);
            AddBefore.Size            = btnDefault;
            AddBefore.BackgroundImage = Properties.Resources.Stint_Add;
            tooltip = new MyToolTip(AddBefore, "Add a new stint before this one");
            AddBefore.OnButtonClicked += ButtonClicked;
            this.Controls.Add(AddBefore, 1, 0);

            if (thisStrategy.NoOfStints > 2)
            {
                Remove                  = new StintControlButton(3);
                Remove.Size             = btnDefault;
                Remove.BackgroundImage  = Properties.Resources.Stint_Remove;
                tooltip                 = new MyToolTip(Remove, "Remove this stint from the strategy");
                Remove.OnButtonClicked += ButtonClicked;
                this.Controls.Add(Remove, 1, 1);
            }
        }
示例#2
0
        void AddControls()
        {
            MyToolTip toolTip;

            stintLabel          = new Label();
            stintLabel.Location = new Point(10, 10);
            stintLabel.Size     = lblDefault;
            stintLabel.Text     = "Stint " + (this.StintNumber + 1);
            this.Controls.Add(stintLabel);

            //Start the stint buttons layout panel.
            Buttons          = new StintButtonsLayoutPanel(thisDriver, stintIndex, thisStrategy);
            Buttons.Location = new Point(10, 40);
            this.Controls.Add(Buttons);

            length          = new Label();
            length.Location = new Point(100, 10);
            length.Size     = lblDefault;
            length.Text     = "Length";
            this.Controls.Add(length);

            time          = new Label();
            time.Location = new Point(100, 35);
            time.Size     = lblDefault;
            time.Text     = "Time";
            this.Controls.Add(time);

            tyre          = new Label();
            tyre.Location = new Point(100, 60);
            tyre.Size     = lblDefault;
            tyre.Text     = "Tyre";
            this.Controls.Add(tyre);

            //calculate the length and upper bounds.
            originalLength = thisStrategy.Stints[stintIndex].stintLength;

            //upper bound depends on either previous or next stint
            if (stintIndex == thisStrategy.NoOfStints - 1) //if stint is last in strategy
            {
                upperBound = originalLength + thisStrategy.Stints[stintIndex - 1].stintLength;
            }
            else
            {
                upperBound = originalLength + thisStrategy.Stints[stintIndex + 1].stintLength;
            }

            stintLength             = new TextBox();
            stintLength.Size        = txtDefault;
            stintLength.Location    = new Point(200, 10);
            stintLength.Text        = Convert.ToString(originalLength);
            stintLength.BorderStyle = System.Windows.Forms.BorderStyle.None;
            toolTip = new MyToolTip(stintLength, "The laps in this stint");
            stintLength.LostFocus += stintLength_LostFocus;
            this.Controls.Add(stintLength);

            stintTime             = new Label();
            stintTime.Size        = lblDefault;
            stintTime.Location    = new Point(200, 35);
            stintTime.Text        = Convert.ToString(thisStrategy.Stints[stintIndex].TotalTime());
            stintTime.BorderStyle = System.Windows.Forms.BorderStyle.None;
            toolTip = new MyToolTip(stintTime, "The total time for this stint");
            this.Controls.Add(stintTime);

            tyreType = new ComboBox();
            foreach (var type in (TyreType[])Enum.GetValues(typeof(TyreType)))
            {
                tyreType.Items.Add(Convert.ToString(type));
            }
            tyreType.Size                  = txtDefault;
            tyreType.Location              = new Point(200, 60);
            tyreType.SelectedIndex         = (int)thisStrategy.Stints[stintIndex].tyreType;
            tyreType.FlatStyle             = global::MyFlowLayout.Properties.Settings.Default.FlatStyle;
            tyreType.DropDownStyle         = ComboBoxStyle.DropDownList;
            tyreType.SelectedIndexChanged += tyreType_SelectedIndexChanged;
            toolTip = new MyToolTip(tyreType, "The tyre type for this stint");
            this.Controls.Add(tyreType);
        }