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


C# ObservableCollection.OrderBy方法代码示例

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


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

示例1: HandleGamesResponse

        private void HandleGamesResponse(ObservableCollection<GameData> gamesCollection, Exception exception)
        {
            if (exception != null)
            {

            }
            else
            {
                ObservableCollection<GameData> temp = new ObservableCollection<GameData>(gamesCollection.OrderBy(g => g.UK_Name.Trim()));

                //var games = from game in temp
                //               group game by game.UK_Name.Trim().ToLower().Substring(0, 1) into c
                //               orderby c.Key
                //               select new Group<GameData>(c.Key, c);



                this.GamesList = temp;
                this.HaveGames = temp.Count() > 0;
            }
        }
开发者ID:Giulio-Ladu,项目名称:GameHub,代码行数:21,代码来源:PlatformGamesViewmodel.cs

示例2: LoadDeviceManagers

        private void LoadDeviceManagers()
        {
            ObservableCollection<DeviceManagerSettings> deviceManagerList = new ObservableCollection<DeviceManagerSettings>();

            XmlElement managers = GetElement("devicemanagerlist");
            if (managers == null)
            {
                managers = GetElement("modbusmanagerlist");  // locate node to be replaced
                if (managers != null)
                {
                    XmlElement managersNew = AddElement(settings, "devicemanagerlist"); // create replacement
                    while(managers.HasChildNodes)  // locate old device manager nodes
                    {
                        XmlElement managerNew = AddElement(managersNew, "devicemanager"); // create new device manager node
                        XmlElement manager = (XmlElement)managers.FirstChild; // select old device manager
                        while (manager.HasChildNodes)
                            managerNew.AppendChild(manager.FirstChild);  // reparent old manager children to new manager
                        managers.RemoveChild(manager); // remove old device manager from old managers list
                    }
                    settings.RemoveChild(managers); // remove old device managers list
                    managers = managersNew; // install new device managers list
                }
            }
            if (managers == null)
                managers = AddElement(settings, "devicemanagerlist");
            else
                foreach(XmlElement manager in managers.ChildNodes)
                    RemoveExtraElements(manager, "serialport", 1);

            foreach (XmlNode e in managers.ChildNodes)
            {
                if (e.NodeType == XmlNodeType.Element && e.Name == "devicemanager")
                {
                    DeviceManagerSettings manager = new DeviceManagerSettings(this, (XmlElement)e);
                    deviceManagerList.Add(manager);
                }
            }

            IEnumerable<DeviceManagerSettings> sorted = deviceManagerList.OrderBy(mms => ((mms.Enabled ? "0" : "1") + mms.Description));

            _DeviceManagerList = new ObservableCollection<DeviceManagerSettings>();
            foreach (DeviceManagerSettings im in sorted)
                _DeviceManagerList.Add(im);

            _AllDevicesList = new ObservableCollection<DeviceManagerDeviceSettings>();
            _AllConsolidationDevicesList = new ObservableCollection<DeviceManagerDeviceSettings>();
            RefreshAllDevices();
            // consolidations must be registered after all devices from all managers are in the list
            foreach (DeviceManagerDeviceSettings dev in _AllDevicesList)
                dev.RegisterConsolidations();
        }
开发者ID:alberthoekstra,项目名称:PVBeanCounter,代码行数:51,代码来源:ApplicationSettings.cs

示例3: OrderItems

        /// <summary>
        /// Order a collection of items by the right sort
        /// </summary>
        /// <param name="items">Collection of items</param>
        /// <returns>Ordered collection</returns>
        private ObservableCollection<Item> OrderItems()
        {
            // create a new collection without any system itemtypes (which are used for section headings)
            var sorted = new ObservableCollection<Item>();
            foreach (var i in list.Items)
                if (i.ItemTypeID != SystemItemTypes.System)
                    sorted.Add(i);

            // order the folder by the correct fields
            switch (OrderBy)
            {
                case FieldNames.DueDate:
                    sorted = sorted.OrderBy(t => t.Complete).ThenBy(t => !t.IsList).ThenBy(t => t.DueSort).ThenBy(t => t.Name).ToObservableCollection();
                    break;
                case FieldNames.Priority:
                    sorted = sorted.OrderBy(t => t.Complete).ThenBy(t => !t.IsList).ThenByDescending(t => t.PrioritySort).ThenBy(t => t.Name).ToObservableCollection();
                    break;
                case FieldNames.Name:
                    sorted = sorted.OrderBy(t => t.Complete).ThenBy(t => !t.IsList).ThenBy(t => t.Name).ToObservableCollection();
                    break;
                case FieldNames.Address:
                    sorted = sorted.OrderBy(t => t.Address).ThenBy(t => !t.IsList).ThenBy(t => t.Name).ToObservableCollection();
                    break;
                case FieldNames.Phone:
                    sorted = sorted.OrderBy(t => t.Phone).ThenBy(t => !t.IsList).ThenBy(t => t.Name).ToObservableCollection();
                    break;
                case FieldNames.Email:
                    sorted = sorted.OrderBy(t => t.Email).ThenBy(t => !t.IsList).ThenBy(t => t.Name).ToObservableCollection();
                    break;
                case FieldNames.Complete:
                    sorted = sorted.OrderBy(t => t.Complete).ThenBy(t => !t.IsList).ThenBy(t => t.Name).ToObservableCollection();
                    break;
                case FieldNames.Category:
                    sorted = sorted.OrderBy(t => t.Complete).ThenBy(t => !t.IsList).ThenBy(t => t.Category).ThenBy(t => t.Name).ToObservableCollection();
                    break;
                case null:
                    sorted = sorted.OrderBy(t => t.Complete).ThenBy(t => !t.IsList).ThenBy(t => t.SortOrder).ToObservableCollection();
                    break;
                default:
                    sorted = sorted.OrderBy(t => t.Complete).ThenBy(t => !t.IsList).ThenBy(t => t.Name).ToObservableCollection();
                    break;
            }

            // if we aren't categorizing then there is no need to create section headings
            if (!Categorize())
                return sorted;

            // insert separators for section headings
            string separator = null;
            var finalList = new ObservableCollection<Item>();
            foreach (var item in sorted)
            {
                ItemType itemType = App.ViewModel.ItemTypes.Single(it => it.ID == item.ItemTypeID);
                string displayType = DisplayTypes.Text;
                string value = null;
                if (itemType.Fields.Any(f => f.Name == OrderBy))
                {
                    Field field = itemType.Fields.Single(f => f.Name == OrderBy);
                    FieldValue fv = item.GetFieldValue(field, false);
                    displayType = field.DisplayType;
                    value = fv != null ? fv.Value : null;
                }
                string currentSectionHeading = item.Complete == true ? "completed" : FormatSectionHeading(displayType, value);
                currentSectionHeading = item.IsList == true ? "lists" : currentSectionHeading;
                if (currentSectionHeading != separator)
                {
                    finalList.Add(new Item() { Name = currentSectionHeading, ItemTypeID = SystemItemTypes.System }); // System itemtype designates separator
                    separator = currentSectionHeading;
                }
                finalList.Add(item);
            }

            return finalList;
        }
开发者ID:ogazitt,项目名称:zaplify,代码行数:79,代码来源:ListHelper.cs

示例4: OrderTasks

 /// <summary>
 /// Order a collection of tasks by the right sort
 /// </summary>
 /// <param name="tasks">Collection of tasks</param>
 /// <returns>Ordered collection</returns>
 private ObservableCollection<Task> OrderTasks(ObservableCollection<Task> tasks)
 {
     // order the list by the correct fields
     switch (OrderBy)
     {
         case "due":
             return tasks.OrderBy(t => t.Complete).ThenBy(t => t.DueSort).ThenBy(t => t.Name).ToObservableCollection();
         case "priority": // by pri
             return tasks.OrderBy(t => t.Complete).ThenByDescending(t => t.PriorityIDSort).ThenBy(t => t.Name).ToObservableCollection();
         case "name": // by name
             return tasks.OrderBy(t => t.Complete).ThenBy(t => t.Name).ToObservableCollection();
     }
     return null;
 }
开发者ID:ogazitt,项目名称:TaskStore,代码行数:19,代码来源:TaskListHelper.cs

示例5: SortData

        private ObservableCollection<string> SortData(ObservableCollection<string> columnDataList, bool IsNumericData)
        {
            ObservableCollection<string> returnedData = new ObservableCollection<string>();
            if (IsNumericData)
            {
                List<double> numberList = new List<double>();
                foreach (string numText in columnDataList)
                {
                    double num = 0;
                    if (double.TryParse(numText, out num))
                    {
                        numberList.Add(num);
                    }
                }

                foreach (double number in numberList.OrderBy(x => x).ToList())
                {
                    returnedData.Add(number.ToString());
                }
            }
            else
            {
                foreach (string text in columnDataList.OrderBy(x=>x).ToList())
                {
                    returnedData.Add(text);
                }
            }
            return returnedData;
        }
开发者ID:EZXInc,项目名称:celera-gui,代码行数:29,代码来源:FilterSelectionView.xaml.cs

示例6: GetSortedClaimDetailDtos

 public override ObservableCollection<ClaimDetailDto> GetSortedClaimDetailDtos(ObservableCollection<ClaimDetailDto> claimDetailDtos)
 {
     return claimDetailDtos.OrderBy(a => (a.Data as IClaimDetailData).ClaimDetailSortOrder)
         .ThenBy(a => int.Parse((a.Data as IClaimDetailData).ClaimDetailReference)).ToObservableCollection();
 }
开发者ID:victorxata,项目名称:261120,代码行数:5,代码来源:AXAClaimModel.cs

示例7: LoadAsync

        private void LoadAsync(string txiFile)
        {
            var doc = XDocument.Load(txiFile);

            var shiftCount = doc.Element("Schichten").Descendants().Count();
            int verarb = 0;

            Schichten = new ObservableCollection<Schicht>();

            // Parallel.ForEach(doc.Element("Schichten").Elements("Schicht"), ig =>
            foreach (var ig in doc.Element("Schichten").Elements("Schicht"))
            {
                var i = ig;
                var schicht = new Schicht()
                                  {
                                      Index = i.AttValue<int>("Index"),
                                      AbrechnungFertig = i.AttValue<bool>("AbrechnungFertig"),
                                      Abgerechnet = i.AttValue<bool>("IstAbgerechnet"),
                                      Anfang = i.AttValue<DateTime>("Anfang"),
                                      Ende = i.AttValue<DateTime>("Ende"),
                                      GeldVorher = i.AttValue<float>("GeldVorher"),
                                      GeldNachher = i.AttValue<float>("GeldNachher"),
                                      GeliehenesWechselgeld = i.AttValue<float>("GeliehenesWechselgeld")
                                  };

                foreach (var j in i.Elements("Sonderausgabe"))
                {
                    schicht.Sonderausgaben.Add(j.AttValue<float>("Wert"));
                }

                foreach (var j in i.Elements("Privatausgabe"))
                {
                    var priv = new Privatausgabe { Index = j.AttValue<int>("Index"), Bemerkung = j.AttValue<string>("Bemerkung") ?? "n/a", Wert = j.AttValue<double>("Wert") };
                    schicht.Privatausgaben.Add(priv);
                }

                foreach (var n in i.Elements("Fahrzeug"))
                {
                    var fzg = new Fahrzeug
                                  {
                                      Index = n.AttValue<int>("Index"),
                                      Nummer = n.AttValue<int>("Nummer"),
                                      TotalAnfang = n.AttValue<Single>("TotalAnfang"),
                                      TotalEnde = n.AttValue<Single>("TotalEnde"),
                                      BesetztAnfang = n.AttValue<Single>("BesetztAnfang"),
                                      BesetztEnde = n.AttValue<Single>("BesetztEnde"),
                                      TourenAnfang = n.AttValue<int>("TourenAnfang"),
                                      TourenEnde = n.AttValue<int>("TourenEnde"),
                                      PreisAnfang = n.AttValue<Single>("EinnahmenAnfang"),
                                      PreisEnde = n.AttValue<Single>("EinnahmenEnde"),
                                  };

                    schicht.Fahrzeuge.Add(fzg);

                    foreach (var p in n.Elements("Fahrt"))
                    {
                        var _kmV = p.Attribute("km").Value;
                        var _km = (int?)p.AttValue<int>("km");
                        var _apesV = p.Attribute("APES").Value;
                        var _apes = (float?)p.AttValue<Single>("APES");
                        var _priceV = p.Attribute("Preis").Value;
                        var _price = (float?)p.AttValue<Single>("Preis");
                        var ft = new Fahrt
                                     {
                                         Index = p.AttValue<int>("Index"),
                                         Description = p.AttValue<string>("Bemerkung"),
                                         KM = (_kmV == "NULL") ? null : _km,
                                         APES = (_apesV == "NULL") ? null : _apes,
                                         Preis = (_priceV == "NULL") ? null : _price,
                                         Rechnungsfahrt = p.AttValue<bool>("IstRechnungsfahrt")
                                     };
                        this.OnProgress(ref verarb, shiftCount);
                        fzg.Fahrten.Add(ft);
                    }
                    this.OnProgress(ref verarb, shiftCount);
                }

                UIDispatcher.Invoke(new Action(() => this.Schichten.Add(schicht)));

                this.OnProgress(ref verarb, shiftCount);
            }
            int uoSIdx = 1;
            foreach (var item in Schichten.OrderBy(p => p.Anfang))
            {
                if (item.Index == 0)
                {
                    while (Schichten.Any(p => p.Index != 0 && p.Index == uoSIdx)) uoSIdx++;
                    item.Index = uoSIdx;
                    item.Parent = this;
                }
                item.ReindexVehicles();
            }
        }
开发者ID:HWiese1980,项目名称:TaxiTaxiWPF,代码行数:93,代码来源:DataDB.cs


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