Exemple #1
0
        /// <summary>
        /// Обновляет информацию
        /// </summary>
        public void UpdateInformation()
        {
            List <ReferenceAvalonButtonM> leftLandingGears  = new List <ReferenceAvalonButtonM>();
            List <ReferenceAvalonButtonM> noseLandingGears  = new List <ReferenceAvalonButtonM>();
            List <ReferenceAvalonButtonM> rightLandingGears = new List <ReferenceAvalonButtonM>();
            List <ReferenceAvalonButtonM> noneLandingGears  = new List <ReferenceAvalonButtonM>();

            for (int i = 0; i < currentAircraft.LandingGears.Length; i++)
            {
                ReferenceAvalonButtonM button = new ReferenceAvalonButtonM();

                button.ActiveColor           = Css.BaseDetailInfoControl.Colors.InactiveTopColorHovered;
                button.ExtendedColor         = Css.BaseDetailInfoControl.Colors.InactiveBottomColor;
                button.Font                  = Css.BaseDetailInfoControl.Fonts.PrimaryFont;
                button.ForeColor             = Css.BaseDetailInfoControl.Colors.PrimaryForeColor;
                button.Icon                  = icons.GrayArrow;
                button.MouseDownColor        = Css.BaseDetailInfoControl.Colors.InactiveTopColorPressed;
                button.NormalColor           = Css.BaseDetailInfoControl.Colors.InactiveTopColor;
                button.ReflectionType        = ReflectionTypes.DisplayInNew;
                button.SecondFont            = Css.BaseDetailInfoControl.Fonts.SecondaryFont;
                button.SecondForeColor       = Css.BaseDetailInfoControl.Colors.SecondaryForeColor;
                button.SecondTextAlign       = ContentAlignment.TopLeft;
                button.SecondTextPadding     = new Padding(10, 0, 0, 0);
                button.TextAlign             = ContentAlignment.TopLeft;
                button.TextPadding           = new Padding(0, 6, 0, 0);
                button.SecondaryTextPosition = 44;
                button.SecondText            = "P/N: " + currentAircraft.LandingGears[i].PartNumber;// +Environment.NewLine + "Amount: " + currentAircraft.LandingGears[i].Amount;
                button.Tag                 = currentAircraft.LandingGears[i];
                button.DisplayerText       = currentAircraft.Model + ". Component PN " + currentAircraft.LandingGears[i].PartNumber;
                button.DisplayerRequested += button_DisplayerRequested;
                if (currentAircraft.LandingGears[i].LandingGearMark == LandingGearMarkType.Left)
                {
                    button.Text = UsefulMethods.GetLandingGearPositionName(currentAircraft.LandingGears[i]);
                    leftLandingGears.Add(button);
                }
                else if (currentAircraft.LandingGears[i].LandingGearMark == LandingGearMarkType.General)
                {
                    button.Text = UsefulMethods.GetLandingGearPositionName(currentAircraft.LandingGears[i]);
                    noseLandingGears.Add(button);
                }
                else if (currentAircraft.LandingGears[i].LandingGearMark == LandingGearMarkType.Right)
                {
                    button.Text = UsefulMethods.GetLandingGearPositionName(currentAircraft.LandingGears[i]);
                    rightLandingGears.Add(button);
                }
                else
                {
                    button.Text = UsefulMethods.GetLandingGearPositionName(currentAircraft.LandingGears[i]);
                    noneLandingGears.Add(button);
                }
                ContextMenuStrip contextMenuStrip = CreateContextMenuToLandingGear(currentAircraft.LandingGears[i]);
                contextMenuStrip.Tag    = currentAircraft.LandingGears[i];
                button.ContextMenuStrip = contextMenuStrip;
            }
            leftLandingGears.Sort(new ReferenceAvalonButtonMComparer());
            noseLandingGears.Sort(new ReferenceAvalonButtonMComparer());
            rightLandingGears.Sort(new ReferenceAvalonButtonMComparer());
            noneLandingGears.Sort(new ReferenceAvalonButtonMComparer());

            panel.Controls.Clear();
            landingGearButtons.Clear();
            panel.Controls.AddRange(leftLandingGears.ToArray());
            panel.Controls.AddRange(noseLandingGears.ToArray());
            panel.Controls.AddRange(rightLandingGears.ToArray());
            panel.Controls.AddRange(noneLandingGears.ToArray());
            landingGearButtons.AddRange(leftLandingGears);
            landingGearButtons.AddRange(noseLandingGears);
            landingGearButtons.AddRange(rightLandingGears);
            landingGearButtons.AddRange(noneLandingGears);

            if (landingGearButtons.Count > 0)
            {
                Size = new Size(750, 100);
            }
            else
            {
                Size = new Size(750, 0);
            }
        }