当前位置: 首页>>代码示例>>C#>>正文


C# Animal.import方法代码示例

本文整理汇总了C#中Animal.import方法的典型用法代码示例。如果您正苦于以下问题:C# Animal.import方法的具体用法?C# Animal.import怎么用?C# Animal.import使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Animal的用法示例。


在下文中一共展示了Animal.import方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: btnSort_Click

        private void btnSort_Click(object sender, EventArgs e)
        {
            listView1.Items.Clear();
            listView1.Columns.Clear();
            listView1.Groups.Clear();
            sortedList.Clear();
            if (cmbSortBy.SelectedIndex != 0)
            {
                if (cmbSortBy.SelectedIndex == 1)
                {
                    //sort by points
                    foreach (Animal animal in form1.animalList)
                    {
                        Animal temp = new Animal();
                        temp.import(animal);
                        sortedList.Add(temp);
                    }
                    listView1.Columns.Add(new ColumnHeader("Name"));
                    listView1.Columns.Add(new ColumnHeader("Points"));
                    listView1.Columns[0].Text = "Name";
                    listView1.Columns[1].Text = "Points";
                    listView1.Columns[0].Width = listView1.Width / 2;
                    listView1.Columns[1].Width = listView1.Width / 2 - 10;
                    sortedList.Sort(delegate(Animal first, Animal second)
                    {
                        return second.points.CompareTo(first.points);
                    });
                    foreach (Animal animal in sortedList)
                    {
                        ListViewItem item = new ListViewItem(new string[] { animal.name, animal.points.ToString() });
                        if (chkHighlight.Checked == true && animal.points > nmbLimit.Value)
                        {
                            item.BackColor = Color.PaleVioletRed;
                        }
                        else
                        {
                            item.BackColor = Color.White;
                        }
                        listView1.Items.Add(item);
                    }
                }
                else if (cmbSortBy.SelectedIndex == 2)
                {
                    listView1.Columns.Add(new ColumnHeader("Name"));
                    listView1.Columns.Add(new ColumnHeader("ID"));
                    listView1.Columns[0].Text = "Name";
                    listView1.Columns[1].Text = "ID";
                    listView1.Columns[0].Width = listView1.Width / 2;
                    listView1.Columns[1].Width = listView1.Width / 2 - 10;
                    foreach (Animal animal in form1.animalList)
                    {
                        Boolean added = false;
                        foreach (ListViewGroup group in listView1.Groups)
                        {
                            if (group.Header.Equals(animal.currentReseacher()))
                            {
                                ListViewItem item = new ListViewItem(new[] { animal.name, animal.id.ToString() });
                                item.Group = group;
                                listView1.Items.Add(item);
                                added = true;
                            }
                        }
                        if (!added)
                        {
                            listView1.Groups.Add(new ListViewGroup(animal.currentReseacher()));
                            foreach (ListViewGroup group in listView1.Groups)
                            {
                                if (group.Header.Equals(animal.currentReseacher()))
                                {
                                    ListViewItem item = new ListViewItem(new[] { animal.name, animal.id.ToString() });
                                    item.Group = group;
                                    listView1.Items.Add(item);
                                }
                            }
                        }
                    }
                }
                else if (cmbSortBy.SelectedIndex == 3)
                {
                    int minWeight = (int)nmbMinWeight.Value;
                    foreach (Animal animal in form1.animalList)
                    {
                        if (animal.weight > minWeight)
                        {
                            sortedList.Add(animal);
                        }
                    }
                    listView1.Columns.Add(new ColumnHeader("Name"));
                    listView1.Columns.Add(new ColumnHeader("Weight"));
                    listView1.Columns[0].Text = "Name";
                    listView1.Columns[1].Text = "Weight";
                    listView1.Columns[0].Width = listView1.Width / 2;
                    listView1.Columns[1].Width = listView1.Width / 2 - 10;

                    sortedList.Sort(delegate(Animal first, Animal second)
                    {
                        return second.weight.CompareTo(first.weight);
                    });

                    foreach (Animal animal in sortedList)
//.........这里部分代码省略.........
开发者ID:TornikeNatsvlishvili,项目名称:CAFAnimalDatabase,代码行数:101,代码来源:Form3.cs


注:本文中的Animal.import方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。