Exemplo n.º 1
0
        private static object FindControl(string name, Control.ControlCollection c)
        {
            Control control = c.Find(name, true).FirstOrDefault();

            if (control != null)
            {
                return(control);
            }
            foreach (MenuStrip menu in c.OfType <MenuStrip>())
            {
                var item = menu.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                {
                    return(item);
                }
            }
            foreach (ContextMenuStrip strip in FindContextMenuStrips(c.OfType <Control>()))
            {
                var item = strip.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                {
                    return(item);
                }
            }
            return(null);
        }
Exemplo n.º 2
0
        private void AtualizaDados(object sender, EventArgs e)
        {
            ComboBox comboBox = (ComboBox)sender;
            Champion champion = (Champion_HS)comboBox.SelectedItem;

            PictureBox pictureBox = form_Controls.OfType <PictureBox>().ToList().Where(x => x.Name.Contains(comboBox.Name.Substring(3, 4))).ToList()[0];

            pictureBox.Image = champion.GetImage();
        }
Exemplo n.º 3
0
 public static void FillControls(Dictionary <string, string> collection, Control.ControlCollection controls, IDefinitionSavable saveable)
 {
     if (controls?.Count == 0)
     {
         return;
     }
     controls.OfType <Control>().Where(y => y.Tag != null).OrderBy(y => y.TabIndex).ToList().ForEach(c => FillControl(collection, c, saveable));
     controls.OfType <Panel>().OrderBy(p => p.TabIndex).ToList().ForEach(p => FillControls(collection, p.Controls, saveable));
 }
        private void PreencheCampos()
        {
            if (!File.Exists(JSON_PATH))
            {
                FileStream file = File.Create(JSON_PATH);
                file.Close();
            }

            deleteStripButton.Visible = false;

            LeArquivo(Properties.Resources.champions_paladins);
            LeArquivo(Properties.Resources.maps_paladins);

            form_Controls = this.Controls;
            List <ComboBox>   comboBoxes   = form_Controls.OfType <ComboBox>().ToList().Where(x => !x.Name.Contains("mapa")).ToList();
            List <PictureBox> pictureBoxes = form_Controls.OfType <PictureBox>().ToList();

            int cont_ally = 0, cont_enemy = 0;

            for (int i = 0; i < comboBoxes.Count; i++)
            {
                Champion_Paladins[] championsTemp = new Champion_Paladins[champions.Count];
                champions.CopyTo(championsTemp);
                comboBoxes[i].DataSource    = championsTemp;
                comboBoxes[i].DisplayMember = "Nome";

                PictureBox pictureBox = pictureBoxes.Where(x => x.Name.Contains(comboBoxes[i].Name.Substring(3))).ToArray()[0];
                Label      label      = form_Controls.OfType <Label>().ToList().Where(x => x.Name.Contains(comboBoxes[i].Name.Substring(3))).ToList()[0];

                if (comboBoxes[i].Name.Contains("ally"))
                {
                    comboBoxes[i].SelectedItem = champions[cont_ally];
                    pictureBox.Image           = champions[cont_ally].GetImage();
                    label.Text = champions[cont_ally].Classe;
                    cont_ally++;
                }
                else
                {
                    comboBoxes[i].SelectedItem = champions[cont_enemy];
                    pictureBox.Image           = champions[cont_enemy].GetImage();
                    label.Text = champions[cont_enemy].Classe;
                    cont_enemy++;
                }

                pictureBox.BringToFront();
                comboBoxes[i].SelectedIndexChanged += new EventHandler(AtualizaDados);
            }

            cb_mapa.DataSource = mapas.OrderBy(x => x).ToList();
            pb_mapa.Image      = (Bitmap)Properties.Resources.ResourceManager.GetObject((cb_mapa.SelectedItem as string).ToLower().Replace(" ", "_"));

            seu_heroi = (Champion_Paladins)comboBoxes.Where(x => x.Name.Contains("ally1")).ToList()[0].SelectedItem;
            partida   = null;
        }
        private void SelecionaHeroi(object sender, EventArgs e)
        {
            PictureBox pictureBox = (PictureBox)sender;
            Point      position   = pictureBox.Location;

            pictureBox.BringToFront();

            pn_selecao_heroi.Location = new Point(pn_selecao_heroi.Location.X, position.Y - 10);
            seu_heroi = (Champion_Paladins)form_Controls.OfType <ComboBox>().ToList().Where(x => x.Name.Contains(pictureBox.Name.Substring(3))).ToList()[0].SelectedItem;
        }
Exemplo n.º 6
0
        private void SettingsForm_Load(object sender, EventArgs e)
        {
            checkUpdatesCB.Checked = Program.MainConfig.CheckForUpdates;

            // Load panels into an array
            Control.ControlCollection arrayPanelCollection = arrayPanel.Controls;
            panelList = new List <Panel>();
            //panelArray.OrderByDescending(x => x.Name);
            panelList.AddRange(arrayPanelCollection.OfType <Panel>());
            panelList.Sort((x, y) => string.Compare(x.Name, y.Name));
            for (int i = 0; i < panelList.Count; i++)
            {
                string path = GetPathByGame(SupportedDatabase.SupportedGames[i]);

                Game game = SupportedDatabase.SupportedGames[i];
                SettingsGameIconControl sgic = new SettingsGameIconControl(game, path, game.Icon);
                sgic.MainPB.MouseEnter += GameIcon_MouseEnter;
                panelList[i].Controls.Add(sgic);
            }

            // TODO: Minimize it to one function that takes care of all the paths and icons.

            /*ApplyGameIconRendererGrayscaleByPathValidation(Program.MainConfig.HP2DirPath, hp2PB);
             * ApplyGameIconRendererGrayscaleByPathValidation(Program.MainConfig.UGDirPath, ugPB);
             * ApplyGameIconRendererGrayscaleByPathValidation(Program.MainConfig.UG2DirPath, ug2PB);
             * ApplyGameIconRendererGrayscaleByPathValidation(Program.MainConfig.MWDirPath, mwPB);
             * ApplyGameIconRendererGrayscaleByPathValidation(Program.MainConfig.CarbonDirPath, carbonPB);
             * ApplyGameIconRendererGrayscaleByPathValidation(Program.MainConfig.ProStreetDirPath, psPB);
             * ApplyGameIconRendererGrayscaleByPathValidation(Program.MainConfig.UndercoverDirPath, ucPB);
             * ApplyGameIconRendererGrayscaleByPathValidation(Program.MainConfig.WorldDirPath, worldPB);*/
        }
Exemplo n.º 7
0
 public static IEnumerable <T> GetItems <T>(this Control.ControlCollection collection, int firstId, int lastId)
     where T : ISelectable
 {
     return
         (collection.OfType <T>()
          .Where(x => x.Id >= firstId && x.Id < lastId));
 }
Exemplo n.º 8
0
 private string TextRadioButton(Control.ControlCollection controls)
 {
     return(controls
            .OfType <RadioButton>()
            .FirstOrDefault(rb => rb.Checked)
            ?.Text);
 }
Exemplo n.º 9
0
 public static void Translate(Control.ControlCollection controls)
 {
     foreach (Control control in controls.OfType <Control>())
     {
         Translate(control);
     }
 }
Exemplo n.º 10
0
        public static IEnumerable <TControl> RenderControlList <TModel, TKey, TControl>(this IEnumerable <TModel> models, Control.ControlCollection controls, Func <TModel, int, TKey> key, Func <TModel, int, TControl> builder) where TControl : Control
        {
            var existingKeys = controls.OfType <Control>().Where(x => x.Tag is ControlKey).ToDictionary(x => ((ControlKey)x.Tag).Key);
            var index        = 0;
            var result       = new List <TControl>();

            foreach (var m in models)
            {
                var k = key(m, index);
                if (existingKeys.TryGetValue(k, out Control c))
                {
                    // not build again
                    existingKeys.Remove(k);
                }
                else
                {
                    c     = builder(m, index);
                    c.Tag = new ControlKey(k);
                    controls.Add(c);
                }

                controls.SetChildIndex(c, index);
                index++;
                result.Add((TControl)c);
            }

            // remove unused controls
            foreach (var value in existingKeys.Values)
            {
                controls.Remove(value);
            }

            return(result);
        }
 public static void ResetTextboxes(this Control.ControlCollection controls)
 {
     foreach (var control in controls.OfType <MaterialSingleLineTextField>())
     {
         control.Text = string.Empty;
     }
 }
        private static List <Control> ToList(Control.ControlCollection collection)
        {
            List <Control> list = new List <Control>();

            list.AddRange(collection.OfType <Control>());
            return(list);
        }
Exemplo n.º 13
0
        protected override void AddFilterPanel(string text, object viewSiteControl)
        {
            Control.ControlCollection controlCollection = ((Control)viewSiteControl).Controls;
            if (string.IsNullOrEmpty(text))
            {
                FilterPanel filterPanel = controlCollection.OfType <FilterPanel>().FirstOrDefault();
                if (filterPanel != null)
                {
                    controlCollection.Remove(filterPanel);
                }
            }
            else
            {
                var filterPanel = new FilterPanel {
                    BackColor   = Color.LightGoldenrodYellow,
                    Dock        = DockStyle.Bottom,
                    MaxRows     = 25,
                    TabIndex    = 0,
                    TabStop     = false,
                    MinimumSize = new Size(350, 33),
                    Text        = text
                };

                Control.ControlCollection collection = controlCollection;
                collection.Add(filterPanel);
            }
        }
Exemplo n.º 14
0
 private void setPanel(Control.ControlCollection controles)
 {
     foreach (Panel _x in controles.OfType <Panel>())
     {
         _x.BackColor = Secundario;
         setControls(_x.Controls);
     }
 }
 public static async Task ResizePanel(int width)
 {
     Panel.Width = width - 36;
     panelControl.OfType <TextBox>().ToList().ForEach(c =>
     {
         c.Width = width - 36;
     });
 }
Exemplo n.º 16
0
 private void setProgressBar(Control.ControlCollection controles)
 {
     foreach (ProgressBar _x in controles.OfType <ProgressBar>())
     {
         _x.BackColor = Controls;
         _x.ForeColor = Words;
     }
 }
Exemplo n.º 17
0
 private void setTextBox(Control.ControlCollection controles)
 {
     foreach (TextBox _x in controles.OfType <TextBox>())
     {
         _x.ForeColor   = Words;
         _x.BackColor   = Controls;
         _x.BorderStyle = BorderStyle.None;
     }
 }
Exemplo n.º 18
0
 private void setLabel(Control.ControlCollection controles)
 {
     foreach (Label _x in controles.OfType <Label>())
     {
         _x.ForeColor   = Words;
         _x.FlatStyle   = FlatStyle.Flat;
         _x.BorderStyle = BorderStyle.None;
     }
 }
Exemplo n.º 19
0
 private void setComboBox(Control.ControlCollection controles)
 {
     foreach (ComboBox _x in controles.OfType <ComboBox>())
     {
         _x.ForeColor = Words;
         _x.BackColor = Controls;
         _x.FlatStyle = FlatStyle.Flat;
     }
 }
Exemplo n.º 20
0
 private void setGroupBox(Control.ControlCollection controles)
 {
     foreach (GroupBox _x in controles.OfType <GroupBox>())
     {
         _x.BackColor = Secundario;
         _x.ForeColor = Words;
         setControls(_x.Controls);
     }
 }
Exemplo n.º 21
0
        public static void RemoveAll(this Control.ControlCollection collection, bool dispose = true)
        {
            if (dispose)
            {
                collection.OfType <Control>().ForEach(c => c.Dispose());
            }

            collection.Clear();
        }
Exemplo n.º 22
0
        private static object FindControl(string name, Control.ControlCollection c)
        {
            Control control = c.Find(name, true).FirstOrDefault();

            if (control != null)
            {
                return(control);
            }
            foreach (MenuStrip menu in c.OfType <MenuStrip>())
            {
                var item = menu.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                {
                    return(item);
                }
            }
            foreach (ContextMenuStrip strip in FindContextMenuStrips(c.OfType <Control>()))
            {
                var item = strip.Items.Find(name, true).FirstOrDefault();
                if (item != null)
                {
                    return(item);
                }
            }
            foreach (DataGridView dg in c.OfType <DataGridView>())
            {
                foreach (var col in dg.Columns.OfType <DataGridViewColumn>())
                {
                    if (col.Name == name)
                    {
                        return(col);
                    }
                }
            }
            foreach (Control x in c)
            {
                var z = FindControl(name, x.Controls);
                if (z != null)
                {
                    return(z);
                }
            }
            return(null);
        }
Exemplo n.º 23
0
 private void setCheckBox(Control.ControlCollection controles)
 {
     foreach (CheckBox _x in controles.OfType <CheckBox>())
     {
         _x.ForeColor = Words;
         _x.FlatStyle = FlatStyle.Flat;
         _x.FlatAppearance.BorderColor = Terciario;
         _x.FlatAppearance.BorderSize  = 2;
     }
 }
Exemplo n.º 24
0
        public static Control[] SortByName(this Control.ControlCollection controlCollection)
        {
            IEnumerable <Control> controls = controlCollection.OfType <Control>();

            Control[] controlsArray = controls.ToArray();
            Array.Sort(controlsArray, delegate(Control a, Control b) {
                return(a.Name.CompareTo(b.Name));
            });
            return(controlsArray);
        }
Exemplo n.º 25
0
 private void SetNoReadonlyControls(Control.ControlCollection controlCollection)
 {
     if (controlCollection == null)
     {
         return;
     }
     foreach (RadioButton r in controlCollection.OfType <RadioButton>())
     {
         r.Enabled = true; //RadioButtons do not have readonly property
     }
     foreach (ComboBox c in controlCollection.OfType <ComboBox>())
     {
         c.Enabled = true;//ComboBoxes do not have readonly property
     }
     foreach (TextBoxBase c in controlCollection.OfType <TextBoxBase>())
     {
         c.ReadOnly = false;
     }
 }
 private void SetReadonlyControls(Control.ControlCollection controlCollection)
 {
     if (controlCollection == null)
     {
         return;
     }
     foreach (DateTimePicker d in controlCollection.OfType <DateTimePicker>())
     {
         d.Enabled = false;
     }
     foreach (ComboBox c in controlCollection.OfType <ComboBox>())
     {
         c.Enabled = false;
     }
     foreach (TextBoxBase c in controlCollection.OfType <TextBoxBase>())
     {
         c.ReadOnly    = true;
         c.BorderStyle = BorderStyle.None;
     }
 }
Exemplo n.º 27
0
 //Recursive method that iterates over all textboxes to empty them
 private void ClearTextBoxes(Control.ControlCollection controls)
 {
     foreach (TextBox tb in controls.OfType <TextBox>())
     {
         tb.Clear();
     }
     foreach (Control c in controls)
     {
         ClearTextBoxes(c.Controls);
     }
 }
Exemplo n.º 28
0
 private void setButton(Control.ControlCollection controles)
 {
     foreach (Button _x in controles.OfType <Button>())
     {
         _x.ForeColor = Words;
         _x.BackColor = Controls;
         _x.FlatStyle = FlatStyle.Flat;
         _x.FlatAppearance.BorderColor = Terciario;
         _x.FlatAppearance.BorderSize  = 1;
     }
 }
Exemplo n.º 29
0
 private void setToolStrip(Control.ControlCollection controles)
 {
     foreach (ToolStrip _x in controles.OfType <ToolStrip>())
     {
         _x.BackColor = Secundario;
         _x.Renderer  = new MySR();
         _x.GripStyle = ToolStripGripStyle.Hidden;
         setToolStripButton(_x);
         setToolStripDropDownButton(_x);
     }
 }
Exemplo n.º 30
0
        private void PreencheComboBoxes()
        {
            if (!File.Exists(JSON_PATH))
            {
                FileStream file = File.Create(JSON_PATH);
                file.Close();
            }

            LeArquivo(Properties.Resources.classes);

            deleteStripButton.Visible = false;

            form_Controls = this.Controls;
            List <ComboBox>   comboBoxes   = form_Controls.OfType <ComboBox>().ToList().Where(x => !x.Name.Contains("vencedor")).ToList();
            List <PictureBox> pictureBoxes = form_Controls.OfType <PictureBox>().ToList();

            champions = champions.OrderBy(x => x.Nome).ToList <Champion_HS>();

            for (int i = 0; i < comboBoxes.Count; i++)
            {
                Champion_HS[] championsTemp = new Champion_HS[champions.Count];
                champions.CopyTo(championsTemp);

                comboBoxes[i].DataSource = null;
                comboBoxes[i].Items.Clear();
                comboBoxes[i].DataSource            = championsTemp;
                comboBoxes[i].DisplayMember         = "Nome";
                comboBoxes[i].SelectedIndexChanged += new EventHandler(AtualizaDados);


                PictureBox pictureBox = pictureBoxes.Where(x => x.Name.Contains(comboBoxes[i].Name.Substring(3, 4))).ToArray()[0];
                pictureBox.Image = championsTemp[0].GetImage();
            }

            ComboBox comboVencedor = form_Controls.OfType <ComboBox>().ToList().Where(x => x.Name.Contains("vencedor")).ToList()[0];

            comboVencedor.SelectedIndex = 0;
            partida = null;

            this.partidas = LeJSON();
        }