Esempio n. 1
0
        internal static void placeMaxControlInForm(Form triggeredForm, List <myControl> retControls, Control toReplace)
        {
            toReplace.Visible = false;
            myControl maxControl = getMaxControl(retControls);

            if (toReplace is Label)
            {
                Label newLbl = maxControl.convertToLabel();
                newLbl.Location = toReplace.Location;
                triggeredForm.Controls.Remove(maxControl);
                newLbl.Name = "ButtonLabel_MinMax_RectangleSquare_control";
                triggeredForm.Controls.Add(newLbl);
                newLbl.Visible = true;
            }
            else
            {
                Button newBtn = maxControl.convertToButton();
                newBtn.Location = toReplace.Location;
                triggeredForm.Controls.Remove(maxControl);
                newBtn.Name = "ButtonLabel_MinMax_RectangleSquare_control";
                triggeredForm.Controls.Add(newBtn);
                newBtn.Visible = true;
            }
            triggeredForm.Controls.Remove(toReplace);
        }
Esempio n. 2
0
        public static myControl getMaxControl(List <myControl> controls)
        {
            myControl a = null;

            try
            {
                a = controls.OrderByDescending(c => c.myHeight * c.myWidth).First();
            }
            catch (System.InvalidOperationException)
            {
                Console.WriteLine("Missing control");
            }
            return(a);
        }