Example #1
0
        //validas diversos campos das telas de acordo com o tipo
        public static string ValidaCampos(Control.ControlCollection componentes)
        {
            string mensagem = "";

            Control[] a = new Control[componentes.Count];

            componentes.CopyTo(a, 0);

            List <Control> controles = a.OrderBy(x => x.TabIndex).ToList();

            foreach (Control controle in controles)
            {
                if (controle.HasChildren)
                {
                    mensagem += ValidaCampos(controle.Controls);
                }

                //Verifica os campos TextBox
                if (controle.GetType() == typeof(TextBox))
                {
                    bool r = CampoVazio((TextBox)controle);

                    if (r)
                    {
                        // escrever a mensagem
                        String nomeDoCampo = ((TextBox)controle).Name.Remove(0, 3);
                        mensagem += string.Format("\nO campo {0} deve ser preenchido!", nomeDoCampo);
                    }
                }
                //verifica os campos MaskedTextBox
                if (controle.GetType() == typeof(MaskedTextBox))
                {
                    bool r = CampoVazio((MaskedTextBox)controle);

                    if (r)
                    {
                        // escrever a mensagem
                        String nomeDoCampo = ((MaskedTextBox)controle).Name.Remove(0, 3);
                        mensagem += string.Format("\nO campo {0} deve ser preenchido!", nomeDoCampo);
                    }
                }
                //verifica os campos ComboBox
                if (controle.GetType() == typeof(ComboBox))
                {
                    bool r = CampoVazio((ComboBox)controle);

                    if (r)
                    {
                        // escrever a mensagem
                        String nomeDoCampo = ((ComboBox)controle).Name.Remove(0, 3);
                        mensagem += string.Format("\nO campo {0} deve ser preenchido!", nomeDoCampo);
                    }
                }
            }


            return(mensagem);
        }
        /// <summary>
        /// Translate controls using the current assembly translation XML. It matches the control name.
        /// </summary>
        /// <param name="controls">Controls to translate.</param>
        /// <param name="xmlName">Subelement inside the XML file.</param>
        public static void TranslateControls(Control.ControlCollection controls, string xmlName)
        {
            string assemblyName = Assembly.GetCallingAssembly().ManifestModule.Name;

            assemblyName = assemblyName.Substring(0, assemblyName.LastIndexOf('.'));    // Remove extension

            Control[] controlArray = new Control[controls.Count];
            controls.CopyTo(controlArray, 0);

            TranslateControls(controlArray, xmlName, assemblyName);
        }
Example #3
0
        public static void Dispose(this Control.ControlCollection controls)
        {
            object[] ctrls = new object[controls.Count];
            controls.CopyTo(ctrls, 0);

            foreach (var ctrl in ctrls)
            {
                if (ctrl is IDisposable elem)
                {
                    elem.Dispose();
                }
            }
        }
Example #4
0
 private Control getControlFromInt(int i)
 {
     Control.ControlCollection c = Form1.defaultForm.groupBox_BingoBoard.Controls;
     Control[] ctrls             = new Control[c.Count];
     c.CopyTo(ctrls, 0);
     for (int ii = 0; ii < ctrls.Length; ii++)
     {
         if ((ii + 1) == i)
         {
             return(ctrls[ii]);
         }
     }
     return(null);
 }
Example #5
0
        private void authLinkGenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DiscordAuthLinkGen.Form1  f = new DiscordAuthLinkGen.Form1();
            Control.ControlCollection l = f.Controls;
            int    color = Settings.settings.global_background;
            String back  = Settings.colors[color];

            f.BackColor = ColorTranslator.FromHtml(back);
            int    color2 = Settings.settings.global_foreground;
            String fore   = Settings.colors[color2];

            f.ForeColor = ColorTranslator.FromHtml(fore);
            Control[] arr = new Control[l.Count];
            l.CopyTo(arr, 0);
            paintControls(arr, fore, back);
            f.ShowDialog();
        }
        //makes a list of checkboxes from inside a panel
        private List <CheckBox> GetCheckBoxes(Panel panel)
        {
            Control.ControlCollection controlCollection = panel.Controls;
            Control[]       controls     = new Control[controlCollection.Count];
            List <Control>  controlsList = new List <Control>();
            List <CheckBox> checkBoxList = new List <CheckBox>();

            controlCollection.CopyTo(controls, 0);

            controlsList.AddRange(controls);

            foreach (CheckBox item in controlsList)
            {
                checkBoxList.Add(item);
            }

            checkBoxList.Reverse();

            return(checkBoxList);
        }
        private void UpdatePanel(Panel panel)
        {
            Control.ControlCollection controlCollection = panel.Controls;
            Control[]      controls     = new Control[controlCollection.Count];
            List <Control> controlsList = new List <Control>();

            controlCollection.CopyTo(controls, 0);


            controlsList.AddRange(controls);

            Pizza selectedPizza = Pizzaria.Pizzas.Find(y => y.Id == Convert.ToInt32(panel.Tag)).GetPizza();

            selectedPizza.Ingredients.Insert(0, pizzaProperties.dough.Find(x => x.name == DoughBox.SelectedValue.ToString()));

            selectedPizza.Size = pizzaProperties.sizes.Find(x => x.name == PizzaSizeBox.SelectedValue.ToString());

            controlsList.First(x => x.Name.Contains("name")).Text  = selectedPizza.Name;
            controlsList.First(x => x.Name.Contains("price")).Text = selectedPizza.Price.ToString();
        }
Example #8
0
        private string genBoard()
        {
            int xL     = Settings.settings.sizeX;
            int yL     = Settings.settings.sizeY;
            int amount = xL * yL;

            Control.ControlCollection c = Form1.defaultForm.groupBox_BingoBoard.Controls;
            Control[] ctrls             = new Control[c.Count];
            c.CopyTo(ctrls, 0);
            int           maxrow       = xL;
            int           amountt      = 0;
            string        all          = "Current Board:\n";
            string        line         = "";
            int           number       = 1;
            int           crow         = 0;
            List <string> disablednums = new List <string>();

            for (int i = 0; i < ctrls.Length; i++)
            {
                if (!ctrls[i].Enabled)
                {
                    disablednums.Add((i + 1) + "");
                }
            }

            for (int i = 0; i < amount; i++)
            {
                string toput = "" + number;
                if (disablednums.Contains(number + ""))
                {
                    toput = "///";
                }
                if (toput.ToCharArray().Length == 1)
                {
                    toput += "--";
                }
                else if (toput.ToCharArray().Length == 2)
                {
                    toput += "-";
                }
                if (string.IsNullOrWhiteSpace(line))
                {
                    line = toput;
                }
                else
                {
                    line += "|" + toput;
                }
                number += yL;
                amountt++;
                if (amountt >= maxrow)
                {
                    string eqgen = "";
                    for (int ii = 0; ii < line.Length; ii++)
                    {
                        eqgen += "=";
                    }
                    amountt = 0;
                    if (crow != 0)
                    {
                        all += "\n" + eqgen + "\n" + line;
                    }
                    else
                    {
                        all += "\n" + line;
                    }
                    line = "";
                    crow++;
                    number = crow + 1;
                }
            }

            all += "\n\n";
            for (int i = 0; i < ctrls.Length; i++)
            {
                if (i == 0)
                {
                    all += (i + 1) + " = " + ctrls[i].Text;
                }
                else
                {
                    all += " | " + (i + 1) + " = " + ctrls[i].Text;
                }
            }
            all += "\n\nScore: " + Form1.defaultForm.label3.Text;
            return(all);
        }
Example #9
0
 /// <summary>
 /// Copies the elements of the collection to an Array, starting at a particular Array index.
 /// </summary>
 /// <param name="xpanderPanels">The one-dimensional Array that is the destination of the elements copied from ICollection.
 /// The Array must have zero-based indexing.
 ///</param>
 /// <param name="index">The zero-based index in array at which copying begins.</param>
 public void CopyTo(XPanderPanel[] xpanderPanels, int index)
 {
     m_controlCollection.CopyTo(xpanderPanels, index);
 }