private void btnAddColorToTeam_Click(object sender, EventArgs e)
        {
            if (lstTeams.SelectedIndex < 0)
            {
                MessageBox.Show("Takıma renk eklemek için listeden önce takım seçmelisiniz.");
                return;
            }
            if (panel1.Controls.Count == 8)
            {
                MessageBox.Show("Takım rengi 8'e ulaştığından daha fazla renk Ekleyemezsiniz.");
                return;
            }

            Models.Color color = cboColors.SelectedItem as Models.Color;
            Team         team  = lstTeams.SelectedItem as Team;

            if (team.Colors.Contains(color))
            {
                MessageBox.Show("Bu renk zaten mevcut");
                return;
            }
            int selectedIndeks = lstTeams.SelectedIndex;

            team.Colors.Add(color);
            db.SaveChanges();
            lstTeams.DataSource    = db.Teams.ToList();
            lstTeams.SelectedIndex = selectedIndeks;
        }
Beispiel #2
0
        public ColorUpdateForm(ListViewItem lviItem, WACDbContext db)
        {
            InitializeComponent();
            this.listViewItem = lviItem;
            this.db           = db;
            int colorId = (int)lviItem.Tag;

            Models.Color selectedColor = db.Colors.Where(x => x.Id == colorId).FirstOrDefault();
            txtColorName.Text = selectedColor.ColorName;
            nudRed.Value      = selectedColor.Red;
            nudGreen.Value    = selectedColor.Green;
            nudBlue.Value     = selectedColor.Blue;

            //Color Convert İmage https://dyclassroom.com/csharp-project/how-to-convert-a-color-image-into-red-green-blue-image-in-csharp-using-visual-studio
            Bitmap newbmp = new Bitmap(62, 62);

            for (int x = 0; x < newbmp.Height; x++)
            {
                for (int y = 0; y < newbmp.Width; y++)
                {
                    newbmp.SetPixel(x, y, System.Drawing.Color.FromArgb(selectedColor.Red, selectedColor.Green, selectedColor.Blue));
                }
            }
            pboColor.Image = newbmp;
        }
 private void btnRemoveColor_Click(object sender, EventArgs e)
 {
     Models.Color selectedColor = (Models.Color)lstTeamColors.SelectedItem;
     selectedTeam.Colors.Remove(selectedColor);
     db.SaveChanges();
     lstTeamColors.DataSource = selectedTeam.Colors.ToList();
 }
 private void btnAddColor_Click(object sender, EventArgs e)
 {
     foreach (ListViewItem item in lviColors.SelectedItems)
     {
         Models.Color color = db.Colors.Where(x => x.Id == (int)item.Tag).FirstOrDefault();
         selectedTeam.Colors.Add(color);
     }
     lstTeamColors.DataSource = selectedTeam.Colors.ToList();
     db.SaveChanges();
 }
Beispiel #5
0
        private void btnPickColor_Click(object sender, EventArgs e)
        {
            if (txtColorName.Text.Trim() == "")
            {
                MessageBox.Show("You must enter color name!");
                return;
            }

            ColorDialog  cd     = new ColorDialog();
            DialogResult result = cd.ShowDialog();
            int          index;

            if (result == DialogResult.OK)
            {
                System.Drawing.Color pickedColor = cd.Color;

                if (gboColor.Text == "New Color")
                {
                    if (db.Colors.Any(x => x.ColorName == txtColorName.Text.Trim()))
                    {
                        MessageBox.Show("This name is already exists!");
                        ResetVisibles();
                        return;
                    }
                    Models.Color color = new Models.Color {
                        ColorName = txtColorName.Text.Trim(), Red = pickedColor.R, Green = pickedColor.G, Blue = pickedColor.B
                    };
                    db.Colors.Add(color);
                    index = lstColors.Items.Count;
                }
                else
                {
                    if (lstColors.SelectedItems.Count < 1)
                    {
                        return;
                    }


                    var col = (Models.Color)lstColors.SelectedItem;
                    col.ColorName = txtColorName.Text.Trim();
                    col.Red       = pickedColor.R;
                    col.Green     = pickedColor.G;
                    col.Blue      = pickedColor.B;
                    index         = lstColors.SelectedIndex;
                }
                db.SaveChanges();
                ListColors();
                lstColors.SetSelected(index, true);
            }


            gboColor.Text = "New Color";
            ResetVisibles();
        }
Beispiel #6
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            int colorId = (int)listViewItem.Tag;

            Models.Color selectedColor = db.Colors.Where(x => x.Id == colorId).FirstOrDefault();
            selectedColor.Red       = (int)nudRed.Value;
            selectedColor.Green     = (int)nudGreen.Value;
            selectedColor.Blue      = (int)nudBlue.Value;
            selectedColor.ColorName = txtColorName.Text.Trim();
            db.SaveChanges();
            this.Close();
        }
 private void btnRemove_Click(object sender, EventArgs e)
 {
     if (lstTeamColors.SelectedItems.Count < 1)
     {
         lblColor.BackColor = System.Drawing.SystemColors.Control;
         return;
     }
     Models.Color color = (Models.Color)lstTeamColors.SelectedItem;
     selectedTeam.Colors.Remove(color);
     db.SaveChanges();
     ListteamColors();
     lblColor.BackColor = System.Drawing.SystemColors.Control;
 }
Beispiel #8
0
        private void lstAvailableColors_SelectedIndexChanged(object sender, EventArgs e)
        {
            Color selectedColor = lstAvailableColors.SelectedItem as Color;

            if (selectedColor == null)
            {
                return;
            }
            tbRed.Value          = selectedColor.Red;
            tbGreen.Value        = selectedColor.Green;
            tbBlue.Value         = selectedColor.Blue;
            txtColorName.Text    = selectedColor.ColorName;
            panelColor.BackColor = System.Drawing.Color.FromArgb(selectedColor.Red, selectedColor.Green, selectedColor.Blue);
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var colorName = txtColorName.Text.Trim();

            if (colorName == "")
            {
                MessageBox.Show("Please fill all fields correctly.");
                return;
            }
            if (btnAdd.Text == "💾 Save")
            {
                if (colorName == "")
                {
                    MessageBox.Show("Please fill all fields correctly.");
                    return;
                }
                var selectedColor = (Models.Color)lstColors.SelectedItem;
                selectedColor.ColorName = txtColorName.Text;
                if (db.Colors.Any(x => x.ColorName == selectedColor.ColorName))
                {
                    MessageBox.Show("Please enter different color name.");
                    return;
                }
                selectedColor.Red   = Convert.ToByte(lblRed.Text);
                selectedColor.Green = Convert.ToByte(lblGreen.Text);
                selectedColor.Blue  = Convert.ToByte(lblBlue.Text);
                db.SaveChanges();
                ListColors();
                ResetForm();
                return;
            }
            var color = new Models.Color
            {
                ColorName = txtColorName.Text.UpperCaseFirst(),
                Red       = Convert.ToByte(lblRed.Text),
                Green     = Convert.ToByte(lblGreen.Text),
                Blue      = Convert.ToByte(lblBlue.Text)
            };

            if (db.Colors.Any(x => x.ColorName == color.ColorName))
            {
                MessageBox.Show("Please enter different color name.");
                return;
            }
            db.Colors.Add(color);
            db.SaveChanges();
            ListColors();
            ResetForm();
        }
 private void cboColors_SelectedIndexChanged(object sender, EventArgs e)
 {
     Models.Color color = cboColors.SelectedItem as Models.Color;
     if (cboColors.SelectedIndex < 0)
     {
         return;
     }
     if (color == null)
     {
         return;
     }
     if (lstTeams.SelectedIndex >= 0)
     {
         btnAddColorToTeam.Visible = true;
     }
 }
Beispiel #11
0
        private void btnCreateTeam_Click(object sender, EventArgs e)
        {
            Team newTeam = new Team()
            {
                TeamName = txtTeamName.Text.Trim()
            };

            foreach (ListViewItem item in lviWillAddTeamColors.SelectedItems)
            {
                Models.Color color = db.Colors.Where(x => x.Id == (int)item.Tag).FirstOrDefault();
                newTeam.Colors.Add(color);
            }
            db.Teams.Add(newTeam);
            db.SaveChanges();
            LoadTeams();
            txtTeamName.Clear();
        }
        private void btnRemoveFromTeam_Click(object sender, EventArgs e)
        {
            int selectedIndeks = lstTeams.SelectedIndex;

            Models.Color color = cboTeamColors.SelectedItem as Models.Color;
            Team         team  = (Team)lstTeams.SelectedItem;

            team.Colors.Remove(color);
            db.SaveChanges();
            lstTeams.DataSource = db.Teams.ToList();
            var s = team.Colors.ToArray();

            for (int i = 0; i < team.Colors.Count; i++)
            {
                cboTeamColors.Items.Add(s[i]);
            }
            lstTeams.SelectedIndex = selectedIndeks;
        }
Beispiel #13
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            var colorName = txtColorName.Text.UpperCaseFirst().Trim();

            if (colorName == "")
            {
                MessageBox.Show("Please fill all fields correctly.");
                return;
            }
            if (btnAdd.Text == "Save")
            {
                var selectedColor = (Models.Color)lstColors.SelectedItem;
                selectedColor.ColorName = txtColorName.Text.UpperCaseFirst();
                selectedColor.Red       = Convert.ToByte(lblRed.Text);
                selectedColor.Green     = Convert.ToByte(lblGreen.Text);
                selectedColor.Blue      = Convert.ToByte(lblBlue.Text);
                btnAdd.Text             = "Add";
                btnAdd.IconChar         = FontAwesome.Sharp.IconChar.Plus;
                btnAdd.BackColor        = System.Drawing.Color.OrangeRed;
                db.SaveChanges();
                ListColors();
                ResetColorsForm();
                btnDelete.Show();
                btnEdit.Show();
                return;
            }
            var color = new Models.Color
            {
                ColorName = txtColorName.Text.UpperCaseFirst(),
                Red       = Convert.ToByte(lblRed.Text),
                Green     = Convert.ToByte(lblGreen.Text),
                Blue      = Convert.ToByte(lblBlue.Text)
            };

            if (db.Colors.Any(x => x.ColorName == color.ColorName))
            {
                MessageBox.Show("Please enter different color name.");
                return;
            }
            db.Colors.Add(color);
            db.SaveChanges();
            ListColors();
            ResetColorsForm();
        }
        private void btnAddNewTeams_Click(object sender, EventArgs e)
        {
            Team team = new Team();

            team.TeamName = txtTeamName.Text.Trim();
            if (txtTeamName.Text == "")
            {
                MessageBox.Show("Lütfen bir takım adı giriniz");
                return;
            }
            else if (txtTeamName.Text.Contains("closed"))
            {
                MessageBox.Show("closed kelimesi bir takım ismi belirlerken kullanılamaz");
                return;
            }
            if (db.Teams.Any(x => x.TeamName == team.TeamName))
            {
                DialogResult dr = new DialogResult();
                dr = MessageBox.Show("Bu isimde takım mevcut,yeni takım mı oluşturmak istiyorsunuz", "Yeni Takım Oluşturma", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dr == DialogResult.Yes)
                {
                    lstTeams.SelectedIndex = -1;
                    txtTeamName.Text       = "";
                    txtTeamName.Focus();
                    btnAddColorToTeam.Visible = false;
                    panel1.Visible            = false;
                    cboColors.SelectedIndex   = -1;
                }
                else
                {
                    return;
                }
                return;
            }
            if (cboColors.SelectedIndex >= 0)
            {
                Models.Color color = cboColors.SelectedItem as Models.Color;
                team.Colors.Add(color);
            }
            db.Teams.Add(team);
            db.SaveChanges();
            lstTeams.DataSource    = db.Teams.ToList();
            lstTeams.SelectedIndex = lstTeams.Items.Count - 1;
        }
Beispiel #15
0
        private void btnSil_Click(object sender, EventArgs e)
        {
            Color silinecekColor = (Color)lstAvailableColors.SelectedItem;
            int   seciliIndeks   = lstAvailableColors.SelectedIndex;

            db.Colors.Remove(silinecekColor);
            db.SaveChanges();
            lstAvailableColors.DataSource = db.Colors.ToList();
            if (lstAvailableColors.Items.Count > 0)
            {
                if (seciliIndeks == lstAvailableColors.Items.Count)
                {
                    lstAvailableColors.SelectedIndex = seciliIndeks - 1;
                }
                else
                {
                    lstAvailableColors.SelectedIndex = seciliIndeks;
                }
            }
        }
Beispiel #16
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            btnEdit.Visible   = true;
            btnSave.Visible   = false;
            btnCancel.Visible = false;
            Color color        = lstAvailableColors.SelectedItem as Color;
            int   seciliIndeks = lstAvailableColors.SelectedIndex;

            color.Red       = tbRed.Value;
            color.Green     = tbGreen.Value;
            color.Blue      = tbBlue.Value;
            color.ColorName = txtColorName.Text;

            if (txtColorName.Text == "")
            {
                MessageBox.Show("Renk adı boş geçilemez");
                return;
            }
            db.SaveChanges();
            lstAvailableColors.DataSource    = db.Colors.ToList();
            lstAvailableColors.SelectedIndex = seciliIndeks;
        }
Beispiel #17
0
        private void btnDeleteColor_Click(object sender, EventArgs e)
        {
            if (lviColors.SelectedItems.Count <= 0)
            {
                MessageBox.Show("Lütfen Renk Seçiniz.");
                return;
            }
            else if (lviColors.SelectedItems.Count > 1)
            {
                MessageBox.Show("Lütfen 1 adet renk seçiniz.");
                return;
            }
            ListViewItem lviItem = lviColors.SelectedItems[0];
            int          colorId = (int)lviItem.Tag;

            Models.Color willDeleted = db.Colors.Where(x => x.Id == colorId).FirstOrDefault();
            imgList.Images.RemoveByKey(willDeleted.ColorName);
            db.Colors.Remove(willDeleted);
            db.SaveChanges();

            LoadColors();
        }
Beispiel #18
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            Color newColor = new Color();

            newColor.ColorName = txtColorName.Text.Trim();
            if (txtColorName.Text == "")
            {
                MessageBox.Show("Bu aşamada bir renk ismi belirtmek zorundasınız");
                return;
            }
            if (db.Colors.Any(x => x.ColorName == newColor.ColorName))
            {
                DialogResult dr = new DialogResult();
                dr = MessageBox.Show("Bu isimde Renk mevcut,yeni renk mi oluşturmak istiyorsunuz", "Yeni Renk Oluşturma", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (dr == DialogResult.Yes)
                {
                    lstAvailableColors.SelectedIndex = -1;
                    txtColorName.Text = "";
                    tbBlue.Value      = 0;
                    tbGreen.Value     = 0;
                    tbRed.Value       = 0;
                    txtColorName.Focus();
                    panelColor.BackColor = System.Drawing.Color.Black;
                    return;
                }
                else
                {
                    return;
                }
            }
            newColor.Red   = tbRed.Value;
            newColor.Green = tbGreen.Value;
            newColor.Blue  = tbBlue.Value;
            db.Colors.Add(newColor);
            db.SaveChanges();
            lstAvailableColors.DataSource    = db.Colors.ToList();
            lstAvailableColors.SelectedIndex = lstAvailableColors.Items.Count - 1;
        }
Beispiel #19
0
        private void btnAddColor_Click(object sender, EventArgs e)
        {
            DialogResult dr = cdColor.ShowDialog();

            if (dr == DialogResult.OK)
            {
                string promptValue = Prompt.ShowDialog("Renk adı giriniz:", "Renk-Adı");
                if (promptValue == "")
                {
                    promptValue = cdColor.Color.Name;
                }
                Models.Color color = new Models.Color()
                {
                    Red       = cdColor.Color.R,
                    Blue      = cdColor.Color.B,
                    Green     = cdColor.Color.G,
                    ColorName = promptValue
                };
                db.Colors.Add(color);
                db.SaveChanges();
                LoadColors();
            }
        }
        private void lstTeams_SelectedIndexChanged(object sender, EventArgs e)
        {
            label4.Visible            = true;
            cboTeamColors.Visible     = true;
            btnRemoveFromTeam.Visible = true;
            panel1.Visible            = true;
            if (cboColors.SelectedIndex >= 0)
            {
                btnAddColorToTeam.Visible = true;
            }
            if (lstTeams.SelectedIndex < 0)
            {
                return;
            }
            Team team = (Team)lstTeams.SelectedItem;

            txtTeamName.Text = team.TeamName;
            panel1.Controls.Clear();
            cboTeamColors.Items.Clear();
            for (int i = 0; i < team.Colors.Count; i++)
            {
                Label label = new Label();
                panel1.Controls.Add(label);
                label.AutoSize = false;
                label.Width    = 50;
                label.Height   = 50;
                var s = team.Colors.ToArray();
                cboTeamColors.Items.Add(s[i]);
                int red   = s[i].Red;
                int green = s[i].Green;
                int blue  = s[i].Blue;
                label.BackColor = System.Drawing.Color.FromArgb(red, green, blue);
                Point point = new Point();
                label.Left += i * 50;
            }
            Models.Color color = cboTeamColors.SelectedItem as Models.Color;
        }