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


C# List.Contains方法代码示例

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


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

示例1: EditDrinksPage

        public EditDrinksPage()
        {
            InitializeComponent();
            DataContext = App.ViewModel;

            Drink TapToAdd = new Drink() { Name = "Tap to add a drink", Size = 0, mg = 0, drinkId = 1, IsActive = false };
            Drink AddedDrinks = new Drink() { Name = "------ Added Drinks ------", Size = 0, mg = 0 };

            var drinkList = new List<Drink>(App.ViewModel.drinkList);

            int i;
            for (i = 0; i < drinkList.Count; i++)
            {
                if ((drinkList[i] as Drink).Name == "Tap to add a drink")
                {
                    var drink = (drinkList[i] as Drink);

                    if (drinkList.Contains(drink))
                        drinkList.Remove(drink);
                }
                else if ((drinkList[i] as Drink).Name == "------ Added Drinks ------")
                {
                    var drink = (drinkList[i] as Drink);

                    if (drinkList.Contains(drink))
                        drinkList.Remove(drink);
                }
            }
            drinkList.Remove(TapToAdd);

            if (drinkList.Contains(AddedDrinks))
                drinkList.Remove(AddedDrinks);

            drinksListBox.ItemsSource = drinkList;
        }
开发者ID:griffinfujioka,项目名称:CaffeineCalculator,代码行数:35,代码来源:EditDrinksPage.xaml.cs

示例2: UserControl_Loaded

        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                t = Utils.Utils.GetTscDataByApplicationCurrentProperties();
                if (t == null)
                {
                    return;
                }
                //t.ListPlan;
                List<Schedule> ls = t.ListSchedule;
                List<int> li = new List<int>();
                foreach (Schedule s in ls)
                {
                    if (!li.Contains(s.ucId) && s.ucId != 0)
                        li.Add(s.ucId);
                }

                cbxScheduleId.ItemsSource = li;
                List<Plan> lp = t.ListPlan;
                foreach (Plan p in lp)
                {
                    if (p.ucId >= 1 && p.ucId <= 20)
                    {
                        sldPlanId.Value = p.ucId;
                        cbxScheduleId.SelectedItem = Convert.ToInt32(p.ucScheduleId);
                        ushort month = p.usMonthFlag;
                        uint day = p.ulDayFlag;
                        DateTime datetime = DateTime.Now;
                        //for (int i = 1; i <= 12; i++)
                        //{
                        //    if (((month >> i) & 0x01) == 0x01)
                        //    {
                        //        for (int j = 1; j <= 31; j++)
                        //        {
                        //            if (((day >> j) & 0x01) == 0x01)
                        //            {
                        //                try
                        //                {
                        //                    calendar.SelectedDates.Add(new DateTime(datetime.Year, i, j));
                        //                }
                        //                catch (Exception ex)
                        //                {
                        //                    continue;
                        //                }

                        //            }
                        //        }
                        //    }
                        //}
                        //break;
                    }
                }
            }
            catch(Exception ex )
            {

            }
            
        }
开发者ID:renhualu,项目名称:tsccui32,代码行数:60,代码来源:CalendarView.xaml.cs

示例3: ComboBox_Loaded

         private void ComboBox_Loaded(object sender, RoutedEventArgs e)
         {
             List<string> maat = new List<string>();
 
             try
             {
                 //maat comboboxiin, ei lisätä duplikaatteja      
                 foreach (XElement maa in xe.Descendants("maa"))
                 {
                     if (!maat.Contains(maa.Value))
                     {
                         maat.Add(maa.Value);
                     }
                 }
 
                 // ... Get the ComboBox reference.
                 var comboBoxMaa = sender as ComboBox;
 
                 // ... Assign the ItemsSource to the List.
                 comboBoxMaa.ItemsSource = maat;
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
开发者ID:tatureijonen,项目名称:IIO11300,代码行数:26,代码来源:MainWindow.xaml.cs

示例4: convert

 private void convert(int i)
 {
     List<int> listy = new List<int>();
     int t = 0;
     while (t < i)
     {
         int a = f();
         if (listy.Contains(a))
         {
             a = f();
             listy.Add(a);
         }
         else
         {
             listy.Add(a);
         }
         t++;
     }
     StringBuilder builder = new StringBuilder();
     foreach (int list in listy)
     {
         builder.Append(list).Append(" ");
     }
     string result = builder.ToString();
     label.Content = result;
 }
开发者ID:OliPicard,项目名称:LotterydotNET,代码行数:26,代码来源:MainWindow.xaml.cs

示例5: InitMyStuff

        private void InitMyStuff()
        {
            try
            {
                cities = new List<string>();
                /*cities.Add("Jyväskylä");
                cities.Add("Helsinki");
                cities.Add("New York");*/
                string kaupunki = "";
                foreach (DataRow item in table.Rows)
                {
                    kaupunki = item[3].ToString();
                    if (!cities.Contains(kaupunki))
                    {
                        cities.Add(kaupunki);
                    }
                    
                }
                // VE3 LINQ:lla voi tehdä kyselyn tyypitettyyn datatableen, huom ei kaikille datatablella
             //   var result = (from c in table select c.City).Distinct();
                // databindaus
                cbCities.ItemsSource = cities;

                            
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
开发者ID:Prome-,项目名称:IIO11300,代码行数:30,代码来源:MainWindow.xaml.cs

示例6: CreateMeasurementsJson

        public string CreateMeasurementsJson(string fileName, string resourceid)
        {
            XDocument doc = XDocument.Load(fileName);
              var str = new StringBuilder();

              var res2 = (from measure in doc.Root.Elements("resource").Elements("measurements").Elements("measurement")
                      where
                          measure.Attribute("resource_id").Value.Equals(resourceid, StringComparison.OrdinalIgnoreCase)
                      select measure).ToList();

              str.Append("[");
              var elemsList = new List<string>();
              foreach (var el in res2)
              {
              var basicInfo = new List<string> { "resource_id", "resource_name", "measurement_id", "measurement_time" };
              var tmp = new StringBuilder();
              tmp.Append("{");
              tmp.Append(string.Format("\"{0}\":\"{1}\"", "measurement_id", el.Attribute("measurement_id").Value));
              tmp.Append(",");
              tmp.Append(string.Join(",", (from att in el.Attributes() where !basicInfo.Contains(att.Name.ToString()) select string.Format("\"{0}\":\"{1}\"", "measurement_name", att.Name)).ToArray()));
              tmp.Append("}");

              elemsList.Add(tmp.ToString());
              }
              str.Append(string.Join(",", elemsList));
              str.Append("]");

              return (!str.ToString().Equals("[]")) ? str.ToString() : string.Empty;
        }
开发者ID:pz-agh,项目名称:pz-monitor,代码行数:29,代码来源:MainWindow.xaml.cs

示例7: IniMyStuff

        private void IniMyStuff()
        {
            cities = new List<string>();
            //cities.Add("Jyväskylä");
            //cities.Add("Helsinki");
            //cities.Add("New York");
            // VE2 käydään loopilla DataTable läpi
            string kaupunki = "";
            foreach (DataRow item in dt.Rows)
            {
                kaupunki = item[3].ToString();
                if (!cities.Contains(kaupunki))
                {
                    cities.Add(kaupunki);
                }
                
            }
            // VE3 LINQ:lla voi tehdä kyselyn tyypitettyyn DataTableen, huom ei kaikille DataTableille
            // joten ei toimi tässä
            // databindaus
            // var result = (from c in dt select c.City).Distinct();

            // databindaus
            cbCities.ItemsSource = cities;
        }
开发者ID:Sakaauti,项目名称:IIO11300,代码行数:25,代码来源:MainWindow.xaml.cs

示例8: HaeMaat

        private void HaeMaat()
        {
            List<string> maalista = new List<string>();

        // Loading from a file, you can also load from a stream       
        // Z:\Github\IIO13200_NET_15S\Tehtävä4\Viinit1.xml
         var xml = XDocument.Load(@"Z:\Github\IIO13200_NET_15S\Tehtävä4\Viinit1.xml");

            var result = from r in xml.Descendants("wine")
                            select new
                            {
                                Maa = r.Element("maa").Value
                            };

            foreach (var r in result)
            {
                string uusi = r.Maa;
                if (!maalista.Contains(uusi))
                    {
                    maalista.Add(uusi);
                    } 
            }

            cbMaat.ItemsSource = maalista;
            cbMaat.SelectedIndex = 0;

        }
开发者ID:jussiheikkinen,项目名称:IIO13200_NET_15S,代码行数:27,代码来源:MainWindow.xaml.cs

示例9: IniMyStuff

        private void IniMyStuff()
        {
            // Asetetaan kaupunkien nimet ComboBoxiin.
            cities = new List<string>();
            // VE1 kaupungin nimet "kovakoodattuna".
            //cities.Add("Jyväskylä");
            //cities.Add("Helsinki");
            //cities.Add("New York");

            // VE2 käydään loopittamalla DataTable läpi.
            string kaupunki = "";

            foreach (DataRow item in dt.Rows)
            {
                kaupunki = item[3].ToString();

                // Lisätään kaupunki vain kerran listaan.
                if(!cities.Contains(kaupunki))
                    cities.Add(item[3].ToString());
            }

            // VE3 LINQ:lla voi tehdä kyselyn tyypitettyyn DataTableen, huom. ei kaikille DataTableille.
            // var result = (from c in dt select c.City).Distinct();

            // Databindaus.
            cbCities.ItemsSource = cities;
        }
开发者ID:jani-kahkonen,项目名称:IIO11300,代码行数:27,代码来源:MainWindow.xaml.cs

示例10: CheckRoomFree

        private bool CheckRoomFree()
        {
            bool check = false;
            ClassSchedule = new List<string>();
            ClassSchedule = database.getAllweekPlan();
            tempSplitArray = new string[6];
            roomClassSetup.Clear();
            List<string> tempList = new List<string>();
            foreach (var item in ClassSchedule)
            {
                tempSplitArray = item.Split(';');

                if (!roomClassSetup.Contains(tempSplitArray[3]))
                    roomClassSetup.Add(tempSplitArray[3]);

                if (dayOfWeekID.ToString() == tempSplitArray[0] && periodID.ToString() == tempSplitArray[1])
                {
                    if (tempSplitArray[3] != null && !tempList.Contains(tempSplitArray[3]))
                    {
                        tempList.Add(tempSplitArray[3]);
                        check = true;
                    }
                }
            }
            roomClassSetup = roomClassSetup.Except(tempList).ToList();
            return check;
        }
开发者ID:jamiees2,项目名称:GRU2L4U-Lokaverkefni,代码行数:27,代码来源:tab1.xaml.cs

示例11: AllProductProvinceGroupings_Loaded

        private void AllProductProvinceGroupings_Loaded(LoadOperation<ProductProvinceGrouping> result)
        {
            List<int> alreadySetProducts = new List<int>();
            if (Utils.LoadOperation_Error_Handled(result.Error, "SmartMap"))
                foreach (ProductProvinceGrouping ppg in result.Entities)
                    alreadySetProducts.Add(ppg.ProductMapID);

            List<string> productNames = new List<string>();
            foreach (ProductMap pm in DBUtils.GetAllProducts())
            {
                if (productNames.Contains(pm.CD_BrandDIName) || pm.CD_BrandDIName == null || pm.CD_BrandDIName.Trim() == "")
                    continue;
                productNames.Add(pm.CD_BrandDIName);
                SolidColorBrush foreground = new SolidColorBrush(Colors.Black);
                if (alreadySetProducts.Contains(pm.ProductMapID))
                    foreground = new SolidColorBrush(Colors.Gray);
            
                
                if (_selectedProductMapIds != null && _selectedProductMapIds.Contains(pm.ProductMapID))
                    SelectedProductsList.Items.Add(new ListBoxItem() { Content = pm.CD_BrandDIName, Tag = pm.ProductMapID, Foreground = foreground });
                else
                    ProductsList.Items.Add(new ListBoxItem() { Content = pm.CD_BrandDIName, Tag = pm.ProductMapID, Foreground = foreground });
            }
            if (ProductsLoading != null)
                ProductsLoading.Visibility = System.Windows.Visibility.Collapsed;
            else
                _hideLoading = true;
        }
开发者ID:naimheshmati,项目名称:Sanofi,代码行数:28,代码来源:SelectProductWindow.xaml.cs

示例12: ProvincesList_Loaded

        private void ProvincesList_Loaded(object sender, RoutedEventArgs e)
        {
            ProvincesList = (sender as ListBox);
            List<string> names = new List<string>();
            foreach (RegionMap rm in DBUtils.GetAllDatRegions())
            {
                if (!Utils.String_Trim_ToLower_Equals(rm.GroupName, C.PROVINCE_DB_REGIONGROUP))
                    continue;
                if (_groupRegionMapIds != null)
                {
                    bool var = false;
                    foreach (ProvinceGroupRegionMap pgrm in _groupRegionMapIds)
                        if (pgrm.RegionMapID == rm.RegionMapID)
                        {
                            var = true;
                            break;
                        }
                    if (var)
                        continue;
                }
                if (names.Contains(rm.DAT_EnREGIONNAME.Trim().ToLower()))
                    continue;
                names.Add(rm.DAT_EnREGIONNAME.Trim().ToLower());
                ProvincesList.Items.Add(rm);
            }
            if (_groups != null)
            {

            }
        }
开发者ID:naimheshmati,项目名称:Sanofi,代码行数:30,代码来源:CreateGroups.xaml.cs

示例13: Behaviors

        public Behaviors(World world)
        {
            this.world = world;

            BehaviorList = new Dictionary<int, string>();

            ranGen = new Random();

            moveMod = 1;

            turnMod = 0.04;

            energyMod = 0.5;

            blacklistMethods = new List<String>();
            createMethodBlacklist();

            int index = 0;
            //Constructing the dictionary of possible actions
            foreach (var method in GetType().GetMethods())
            {
                //Ignore operations that aren't related to an organism.
                if (!blacklistMethods.Contains(method.Name))
                {
                    BehaviorList.Add(index, method.Name);
                    index++;
                }
            }
        }
开发者ID:Spadar,项目名称:MachineLearning,代码行数:29,代码来源:Behaviors.cs

示例14: IniMyStuff

 private void IniMyStuff()
 {
   //asetetaan kaupunkien nimet ComboBoxiin
   cities = new List<string>();
   //VE1 kaupungin nimet "kovakoodattu"
   //cities.Add("Jyväskylä");
   //cities.Add("Helsinki");
   //cities.Add("New York");
   //VE2 käydään loopittamalla DataTable läpi
   string kaupunki = "";
   foreach (DataRow item in dt.Rows)
   {
     kaupunki = item["City"].ToString();
     //tai
     kaupunki = item[3].ToString();
     //lisätään kukin kaupunki vain kerran listaan
     if (!cities.Contains(kaupunki))
       cities.Add(kaupunki);
   }
   //VE3 LINQ:lla voi tehdä kyselyn tyypitettyyn DataTableen, huom ei kaikille DataTablella
   //joten ei toimi tässä
   //var result = (from c in dt
   //              select c.City).Distinct();
   //databindaus
   cbCities.ItemsSource = cities;
 }
开发者ID:EsaSalmik,项目名称:IIO11300Keskiviikko,代码行数:26,代码来源:MainWindow.xaml.cs

示例15: Started

        public int[] Started()
        {
            List<int> ar;
            List<int> buf_ar;
            do
            {
                ar = new List<int>();
                Random rand = new Random();
                int buf = rand.Next(0, 16);
                buf_ar = new List<int>(new int[16] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 });
                while (buf_ar.Count != 0)
                {

                    if (!buf_ar.Contains(buf))
                    {
                        buf = rand.Next(0, 16);
                    }
                    else
                    {
                        ar.Add(buf);
                        buf_ar.Remove(buf);
                    }

                }

            } while (!IDA.DoHaveResolve(ar.ToArray()));
            return ar.ToArray();
        }
开发者ID:densem-2013,项目名称:FifteenImage,代码行数:28,代码来源:MainWindow.xaml.cs


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