Exemplo n.º 1
0
 public Contestant(Contestant c)
 {
     this.id = c.Id;
     this.FirstName = c.FirstName;
     this.LastName = c.LastName;
     this.Seura = c.Seura;
     this.Sarja = c.Sarja;
     this.Team = c.Team;
 }
Exemplo n.º 2
0
        public ContestantRowEditForm(ContestantListForm f, Contestant c)
        {
            InitializeComponent();
            contestant = c;
            clf = f;

            List<string> sarjaList = clf.getSarjaList();
            List<string> seuraList = clf.getSeuraList();
            List<string> joukkueList = clf.getJoukkueList();

            sarjaComboBox.Items.AddRange(sarjaList.ToArray());
            seuraComboBox.Items.AddRange(seuraList.ToArray());
            joukkueComboBox.Items.Add("");
            joukkueComboBox.Items.AddRange(joukkueList.ToArray());

            firstNameTextBox.Text = contestant.FirstName;
            lastNameTextBox.Text = contestant.LastName;

            joukkueComboBox.Text = contestant.Team;
            sarjaComboBox.Text = contestant.Sarja;
            seuraComboBox.Text = contestant.Seura;
        }
Exemplo n.º 3
0
        private void objectListView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Point cursor = Cursor.Position;
            cursor = PointToClient(cursor);

            int x = cursor.X - objectListView1.Location.X - 2;
            int y = cursor.Y - objectListView1.Location.Y - 2;

            ListViewItem clickedItem = objectListView1.GetItemAt(x, y);
            ContestantListLine clickedModelItem = (ContestantListLine)objectListView1.GetModelObject(clickedItem.Index);
            Contestant selectedContestant = null;

            if (!(clickedModelItem is RoundDivider))

                for (int i = 0; i < contestantList.Count; i++)
                {
                    if (!(contestantList[i] is RoundDivider) && contestantList[i].Id == clickedModelItem.Id)
                    {
                        selectedContestant = new Contestant((Contestant)contestantList[i]);
                        break;
                    }
                }

            if (selectedContestant != null)
                new ContestantRowEditForm(this, selectedContestant).ShowDialog();
        }
Exemplo n.º 4
0
        private void objectListView1_Click(object sender, EventArgs e)
        {
            ContestantListLine clickedModelItem = null;
            Point cursor = Cursor.Position;
            cursor = PointToClient(cursor);

            int x = cursor.X - objectListView1.Location.X - 2;
            int y = cursor.Y - objectListView1.Location.Y - 2;

            OLVColumn hitColumn;
            ListViewItem clickedItem = objectListView1.GetItemAt(x, y, out hitColumn);

            if(clickedItem != null)
                clickedModelItem = (ContestantListLine)objectListView1.GetModelObject(clickedItem.Index);

            Contestant selectedContestant = null;

            if (hitColumn != null && hitColumn.Tag != null && clickedItem != null)
            {
                if (hitColumn.Tag.ToString() == "buttonColumn1")
                {
                    if (clickedModelItem is RoundDivider && clickedModelItem.HotRound)
                    {
                        foreach (ContestantListLine line in contestantList)
                        {
                            if (line is RoundDivider && (line.Id == clickedModelItem.Id))
                            {
                                line.HotRound = false;
                            }
                        }
                        refreshContestantListView();
                    }
                    else if (clickedModelItem is RoundDivider && !clickedModelItem.HotRound)
                    {
                        foreach (ContestantListLine line in contestantList)
                        {
                            if (line is RoundDivider && (line.Id == clickedModelItem.Id))
                            {
                                line.HotRound = true;
                            }
                        }

                        refreshContestantListView();
                    }
                    else
                    {
                        for (int i = 0; i < contestantList.Count; i++)
                        {
                            if (!(clickedModelItem is RoundDivider) && contestantList[i].Id == clickedModelItem.Id)
                            {
                                selectedContestant = new Contestant((Contestant)contestantList[i]);
                                break;
                            }
                        }

                        if (selectedContestant != null)
                            new ContestantRowEditForm(this, selectedContestant).ShowDialog();
                    }
                }
                else if (hitColumn.Tag.ToString() == "buttonColumn2")
                {
                    if (!(clickedModelItem is RoundDivider) || (clickedModelItem.Id > 1))
                    {
                        Console.WriteLine("Poistonappi");
                        deleteLine(clickedItem);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private void addEmptyRowsButton_Click(object sender, EventArgs e)
        {
            tallennettu = false;
            for (int i = 0; i < roundContestantCounts.Count; i++)
            {
                if (roundContestantCounts[i] < MaximumRoundSize)
                {
                    int emptySlots = MaximumRoundSize - roundContestantCounts[i];

                    while (emptySlots > 0)
                    {
                        int id = generateId();

                        if (i < roundDividerIndices.Count - 1)
                        {
                            contestantList.Insert(roundDividerIndices[i + 1], new Contestant(id, "", "", "", "", ""));
                            object[] temp = new object[1];
                            temp[0] = new Contestant(id, "", "", "", "", "");
                            objectListView1.InsertObjects(roundDividerIndices[i + 1], temp);
                        }
                        else
                        {
                            contestantList.Add(new Contestant(id, "", "", "", "", ""));
                            objectListView1.AddObject(new Contestant(id, "", "", "", "", ""));
                        }

                        emptySlots--;
                    }
                    updateDividerIndicesAndContestantCounts();
                    countRoundSizes();
                }
            }
        }
Exemplo n.º 6
0
        internal void UpdateContestantLine(Contestant updatedContestant)
        {
            for (int i = 0; i < contestantList.Count; i++)
            {
                if (contestantList[i].Id == updatedContestant.Id)
                {
                    contestantList[i].FirstName = updatedContestant.FirstName;
                    contestantList[i].LastName = updatedContestant.LastName;
                    contestantList[i].Seura = updatedContestant.Seura;
                    contestantList[i].Sarja = updatedContestant.Sarja;
                    contestantList[i].Team = updatedContestant.Team;

                    break;
                }
            }

            for (int i = 0; i < objectListView1.Items.Count; i++)
            {
                if (objectListView1.Items[i].SubItems[0].Text == updatedContestant.Id.ToString())
                {
                    objectListView1.Items[i].SubItems[2].Text = updatedContestant.FullName;
                    objectListView1.Items[i].SubItems[3].Text = updatedContestant.Seura;
                    objectListView1.Items[i].SubItems[4].Text = updatedContestant.Sarja;
                    objectListView1.Items[i].SubItems[5].Text = updatedContestant.Team;

                    break;
                }
            }
            refreshContestantListView();
        }