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


C# ObservableCollection.ToList方法代码示例

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


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

示例1: InitFilteredData

        public void InitFilteredData(string columnName, ObservableCollection<string> filterStringList)
        {
            FilterItemList = new ObservableCollection<FilterItem>();
            FilterItemList.Add(new FilterItem() { Data = EZXWPFLibrary.Properties.Resources.FILTER_SELECTALL, IsSelected = true});
            FilterItemList.Add(new FilterItem() { Data = EZXWPFLibrary.Properties.Resources.FILTER_UNSELECTALL, IsSelected = false});

            foreach (string item in filterStringList.ToList())
            {
                FilterItemList.Add(new FilterItem() { Data = item, IsSelected = true });
            }

            if (this.SelectedFilterColumn != null)
            {
                this.SelectedFilterColumn.ConditionList = new List<Condition>();
                this.SelectedFilterColumn.FilterType = FilterSelectionType.NA;
            }
            this.RaisePropertyChanged(p => p.SelectedFilterColumn);
        }
开发者ID:EZXInc,项目名称:celera-gui,代码行数:18,代码来源:FilterSelectionVM.cs

示例2: SubmitCommandExecuted

        private async void SubmitCommandExecuted()
        {
            var OriginalResources = new ObservableCollection<GolfModel>(Golf.Golf.GolfFollowResources.Select(x => new GolfModel(AvailableGolfResources.Where(p => p.Golf.ID == x.FollowResourceID).FirstOrDefault().Golf)));
            var DeletedObjects = OriginalResources.ToList().Except(GolfFollowResources.ToList(), new GolfFollowResourcesComparer()).ToList();
            var AddedObjects = GolfFollowResources.ToList().Except(OriginalResources.ToList(), new GolfFollowResourcesComparer()).ToList();

            var OrginalFollowGolfResources = await _adminDataUnit.GolfFollowResourceRepository.GetAllAsync(x => x.GolfID == Golf.Golf.ID);

            DeletedObjects.ForEach(deletedResources =>
            {
                _adminDataUnit.GolfFollowResourceRepository.Delete(OrginalFollowGolfResources.Where(p => p.FollowResourceID == deletedResources.Golf.ID).FirstOrDefault());
            });

            AddedObjects.ForEach(addedObject =>
            {
                var obj = new GolfFollowResource()
                       {
                           ID = Guid.NewGuid(),
                           GolfID = Golf.Golf.ID,
                           FollowResourceID = addedObject.Golf.ID
                       };

                _adminDataUnit.GolfFollowResourceRepository.Add(obj);

            });
            //await _adminDataUnit.SaveChanges();
        }
开发者ID:syatin003,项目名称:Wpf,代码行数:27,代码来源:GolfFollowResourceViewModel.cs

示例3: LoadTracks

        private async Task LoadTracks(CancellationToken token)
        {
            if (SelectedAlbum == null)
                return;

            IsWorking = true;
            OnTaskStarted("audio");

            try
            {
                var response = await DataService.GetUserTracks(0, 0, SelectedAlbum.Id != 0 ? SelectedAlbum.Id : 0);
                if (response.Items != null && response.Items.Count > 0)
                {
                    if (token.IsCancellationRequested)
                    {
                        Debug.WriteLine("Tracks load cancelled");
                        return;
                    }

                    Tracks = new ObservableCollection<Audio>(response.Items);

                    if (AudioService.CurrentAudio == null)
                    {
                        AudioService.SetCurrentPlaylist(Tracks.ToList());
                        AudioService.CurrentAudio = Tracks.First();
                        AudioService.CurrentAudio.IsPlaying = true;
                    }
                }
                else
                {
                    OnTaskError("audio", ErrorResources.LoadAudiosErrorEmpty);
                    Tracks = null;
                }
            }
            catch (Exception ex)
            {
                LoggingService.Log(ex);

                OnTaskError("audio", ErrorResources.LoadAudiosErrorCommon);
            }

            IsWorking = false;
            OnTaskFinished("audio");
        }
开发者ID:kostyatab,项目名称:meridian,代码行数:44,代码来源:MusicViewModel.cs

示例4: bw_DoWork

        /// <summary>
        /// Using background worker to build collection of game objects from XML
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            XmlDocument xdoc = new XmlDocument();
            xdoc.Load(HyperspinDatabaseXml);
            DatabaseGameCollection = new ObservableCollection<DatabaseGame>();
            string name = string.Empty, image = string.Empty, desc = string.Empty, cloneof = string.Empty, crc = string.Empty,
                manu = string.Empty, genre = string.Empty, rating = string.Empty;
            int enabled = 0;
            int year = 0;
            string index = string.Empty;
            int i = 0;
            string lastRom = string.Empty;

            DatabaseGameCollection.Add(new DatabaseGame("_Default", "_Default"));
            foreach (XmlNode node in xdoc.SelectNodes("menu/game"))
            {
                if (bw.CancellationPending)
                {
                    e.Cancel = true;
                    return;
                }

                name = node.SelectSingleNode("@name").InnerText;

                char s = name[0];
                char t;

                if (lastRom != string.Empty)
                {
                    t = lastRom[0];
                    if (char.ToLower(s) == char.ToLower(t))
                    {
                        index = string.Empty;
                        image = string.Empty;
                    }
                    else
                    {
                        index = "true";
                        image = char.ToLower(s).ToString();
                    }
                }

                if (SystemName != "Main Menu")
                {
                    if (node.SelectSingleNode("@enabled") != null)
                    {
                        if (node.SelectSingleNode("@enabled").InnerText != null)
                        {
                            enabled = Convert.ToInt32(node.SelectSingleNode("@enabled").InnerText);
                        }
                    }
                    else
                        enabled = 1;

                    desc = node.SelectSingleNode("description").InnerText;

                    if (node.SelectSingleNode("cloneof") != null)
                        cloneof = node.SelectSingleNode("cloneof").InnerText;
                    if (node.SelectSingleNode("crc") != null)
                        crc = node.SelectSingleNode("crc").InnerText;
                    if (node.SelectSingleNode("manufacturer") != null)
                        manu = node.SelectSingleNode("manufacturer").InnerText;
                    if (node.SelectSingleNode("year") != null)
                        if (!string.IsNullOrEmpty(node.SelectSingleNode("year").InnerText))
                            Int32.TryParse(node.SelectSingleNode("year").InnerText, out year);

                    if (node.SelectSingleNode("genre") != null)
                        genre = node.SelectSingleNode("genre").InnerText;
                    if (node.SelectSingleNode("rating") != null)
                        rating = node.SelectSingleNode("rating").InnerText;

                }

                DatabaseGameCollection.Add(new DatabaseGame(name, index, image, desc, cloneof, crc, manu, year, genre, rating, enabled));

                lastRom = name;
                i++;
            }

            /// Scan the favorites text, set the hspath and systemname
            Favorites f = new Favorites();
            f.HSPath = HSPath;
            f.SystemName = SystemName;
            Favorites.dbPath = HSPath + "\\Databases\\";
            List<string> faveText = Favorites.GetFavoritesFromText(f.SystemName);
            Favorites.updateGameListFavorites(DatabaseGameCollection.ToList(), faveText);

            // Return the new collection to the backgroundworker
            e.Result = DatabaseGameCollection;
        }
开发者ID:horseyhorsey,项目名称:HyperMint,代码行数:95,代码来源:Database.cs

示例5: CheckData

        public bool CheckData(ObservableCollection<FBEntity> listSaveNew)
        {
            bool pass = true;
            #region old
            //listSaveNew.ToList().ForEach(item =>
            //    {
            //        // 要删除的实体
            //        if (item.FBEntityState == EntityState.Deleted)
            //        {
            //            return;
            //        }
            //        T_FB_SUBJECTTYPE entitySubjectType = item.Entity as T_FB_SUBJECTTYPE;

            //        pass &= SetErrorFlag(entitySubjectType, CheckSubjectType(entitySubjectType));
                    
            //        var subjects = item.GetRelationFBEntities(typeof(T_FB_SUBJECT).Name);
            //        subjects.ToList().ForEach(fbEntitySubject =>
            //            {
            //                // 要删除的实体
            //                if (fbEntitySubject.FBEntityState == EntityState.Deleted)
            //                {
            //                    return;
            //                }
            //                T_FB_SUBJECT entitySubject = fbEntitySubject.Entity as T_FB_SUBJECT;
            //                pass &= SetErrorFlag(entitySubject, CheckSubject(entitySubject));
            //            });
            //    });
            #endregion 

            #region beyond
            listSaveNew.ToList().ForEach(item =>
            {
                // 要删除的实体
                if (item.FBEntityState == FBEntityState.Deleted)
                {
                    return;
                }
                T_FB_SUBJECTTYPE entitySubjectType = item.Entity as T_FB_SUBJECTTYPE;

                pass &= SetErrorFlag(entitySubjectType, CheckSubjectType(entitySubjectType));
                if (!pass)
                {
                    return;
                }
                var subjects = item.GetRelationFBEntities(typeof(T_FB_SUBJECT).Name);
                subjects.ToList().ForEach(fbEntitySubject =>
                {
                    // 要删除的实体
                    if (fbEntitySubject.FBEntityState == FBEntityState.Deleted)
                    {
                        return;
                    }
                    T_FB_SUBJECT entitySubject = fbEntitySubject.Entity as T_FB_SUBJECT;
                    pass &= SetErrorFlag(entitySubject, CheckSubject(entitySubject));
                    if (!pass)
                    {
                        return;
                    }
                });
            });

            #endregion 
            return pass;
        }
开发者ID:JuRogn,项目名称:OA,代码行数:64,代码来源:SubjectManagement.xaml.cs

示例6: RefreshFilteredData

        public void RefreshFilteredData(string columnName, ObservableCollection<string> filterStringList, FilterColumn filterColumn)
        {
            FilterItemList = new ObservableCollection<FilterItem>();

            FilterItemList.Add(new FilterItem() { Data = EZXWPFLibrary.Properties.Resources.FILTER_SELECTALL, IsSelected = true });
            FilterItemList.Add(new FilterItem() { Data = EZXWPFLibrary.Properties.Resources.FILTER_UNSELECTALL, IsSelected = false });

            if (filterColumn == null || filterColumn.FilterType == FilterSelectionType.NA)
            {
                if (filterColumn == null)
                {
                    foreach (string item in filterStringList.ToList())
                    {
                        FilterItemList.Add(new FilterItem() { Data = item, IsSelected = true });
                    }
                }
                else
                {
                    foreach (string item in filterStringList.ToList())
                    {
                        if (filterColumn.ColumnSelectedDataList.Any(x => x == item))
                        {
                            FilterItemList.Add(new FilterItem() { Data = item, IsSelected = true });
                        }
                        else
                        {
                            FilterItemList.Add(new FilterItem() { Data = item, IsSelected = false });
                            FilterItemList[0].IsSelected = false;
                        }
                    }
                }

                if (this.SelectedFilterColumn != null)
                {
                    this.SelectedFilterColumn.ConditionList = new List<Condition>();
                    this.SelectedFilterColumn.FilterType = FilterSelectionType.NA;
                }
            }
            else
            {
                FilterItemList[0].IsSelected = false;
                FilterItemList[1].IsSelected = false;
                foreach (string item in filterStringList.ToList())
                {
                    FilterItemList.Add(new FilterItem() { Data = item, IsSelected = false });
                }
            }
            this.RaisePropertyChanged(p => p.SelectedFilterColumn);
        }
开发者ID:EZXInc,项目名称:celera-gui,代码行数:49,代码来源:FilterSelectionVM.cs

示例7: OnQueueItemsChanged

 /// <summary>
 /// Triggers QueueItemsChanged event.
 /// </summary>
 /// <param name="items">List of items currently in the queue</param>
 protected static void OnQueueItemsChanged(object sender, ObservableCollection<OrgItem> queueItems)
 {
     if (QueueItemsChanged != null)
         QueueItemsChanged(sender, new QueueItemsChangedArgs(queueItems.ToList()));
 }
开发者ID:Garreye,项目名称:meticumedia,代码行数:9,代码来源:QueueControlViewModel.cs

示例8: MainPage_Loaded

        // Load data for the ViewModel Items
        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            this.Items = new ObservableCollection<ItemViewModel>();

            using (var ctx = new wp7ShareWordsDataContext(conn))
            {
                Random rnd = new Random();

                var frases = ctx.Frases.OrderBy(x => rnd.Next()).ToList().Take(8);

                foreach (var item in frases.ToList())
                {
                    this.Items.Add(new ItemViewModel()
                {
                    LineId = item.Id,
                    LineOne = item.Titulo,
                    LineTwo = item.Autor
                });
                }
            }

            if (!App.ViewModel.IsDataLoaded)
            {

                App.ViewModel.LoadData(Items.ToList());
            }
        }
开发者ID:programadriano,项目名称:shareWords,代码行数:28,代码来源:MainPage.xaml.cs

示例9: IsExist

 //检查列表中有没有特定的建筑牌
 public bool IsExist(ObservableCollection<Building> buildings, int id)
 {
     List<Building> Bs = buildings.ToList<Building>();
     if (Bs.FindIndex(s => s.Id == id) > -1)
     { return true; }
     else { return false; }
 }
开发者ID:div8ivb,项目名称:Citadels151010,代码行数:8,代码来源:GameVM.cs

示例10: Button_Click

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // Open file system to select file(s)
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Multiselect = true;

            Nullable<bool> result = dlg.ShowDialog();  // Display OpenFileDialog by calling ShowDialog method
            byte[] rawData;
            List<Tuple<string, byte[]>> dataList = new List<Tuple<string, byte[]>>();
            string ext = "";
            string filename = "";

            // Add all files selected into the the db. If multiple files added, project destination is the same.
            foreach (String file in dlg.FileNames)
            {
                // Get the selected file name and display in a TextBox
                if (result.HasValue == true && result.Value == true)
                {
                    rawData = File.ReadAllBytes(file);
                    dataList.Add(Tuple.Create(file, rawData));
                    ext = Path.GetExtension(file);
                    filename = file;
                }
            }

            AnalysisMsgPrompt a = new AnalysisMsgPrompt(new DataGridLoader(), null);

            if (a.ShowDialog() == true)
            {
                dgl.loadSpeakers(a.PID);
                rowS = dgl.getCollection("S");
                foreach (var elem in rowS.ToList())
                {

                    ((dynamic)rowS).Add((Speaker)elem);
                }

                foreach (var dataItem in dataList)
                {
                    var comm = new MySqlCommand();
                    filename = Path.GetFileName(dataItem.Item1);

                    using (DBConnection db = new DBConnection())
                    {

                        comm.CommandText = "INSERT INTO Analysis (AID, Description, FileData, FileType) VALUES(@AID, @Desc, @FileAsBlob, @FileType)";
                        comm.Parameters.AddWithValue("@AID", filename);
                        if (a.Desc.Equals(""))
                        {
                            comm.Parameters.AddWithValue("@Desc", "No description");
                        }
                        else
                        {

                            //Add to analysis table
                            comm.CommandText = "create table if not exists analysis (AID varchar(150) primary key, File mediumblob, Description varchar(500))";
                            comm.ExecuteNonQuery();

                            comm.CommandText = "INSERT INTO analysis (AID, File, Description) VALUES(@AID, @FileAsBlob, @Desc)";
                            comm.Parameters.AddWithValue("@AID", dataItem.Item1);
                            comm.Parameters.AddWithValue("@FileAsBlob", dataItem.Item2);
                            if (a.Desc.Equals(""))
                            {
                                comm.Parameters.AddWithValue("@Desc", "No description");
                            }
                            else
                            {

                                comm.Parameters.AddWithValue("@Desc", a.Desc);
                            }
                            comm.ExecuteNonQuery();

                            //Add to the mapping table(to link with speaker)
                            List<Row> startsWithAge = rowS.Where(s => ((Speaker)s).SpeakerName.StartsWith(a.Age)).ToList();

                            MessageBox.Show(a.Age);
                            foreach (var row in rowS)
                            {

                                //comm.CommandText = "create table if not exists files2analysis (AID varchar(150) primary key, ID varchar(150) primary key)";
                                //comm.ExecuteNonQuery();
                                if (((Speaker)row).SpeakerName.StartsWith(a.Age))
                                {

                                    db.insertIntoDB(comm);
                                }

                                comm.CommandText = "INSERT IGNORE INTO files2analysis (ID, AID) VALUES (@ID2, @AID2)";
                                comm.Parameters.Clear();
                                comm.Parameters.AddWithValue("@ID2", ((Speaker)row).ID);
                                comm.Parameters.AddWithValue("@AID2", dataItem.Item1);
                                comm.ExecuteNonQuery();
                            }

                            HashSet<Tuple<String, String>> uniqueAnalysis = new HashSet<Tuple<String, String>>();
                            HashSet<Tuple<String, String>> uniqueRowName = new HashSet<Tuple<String, String>>();
                            string previous = "";
                            foreach (var row in rowS)
                            {
                                if (!((Speaker)row).Name.Equals(previous))
//.........这里部分代码省略.........
开发者ID:RodelJasper,项目名称:p4p,代码行数:101,代码来源:MainWindow.xaml.cs


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