本文整理汇总了C#中System.Windows.Documents.List.OrderByDescending方法的典型用法代码示例。如果您正苦于以下问题:C# List.OrderByDescending方法的具体用法?C# List.OrderByDescending怎么用?C# List.OrderByDescending使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.OrderByDescending方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParseJsonToQuakes
public IEnumerable<Earthquake> ParseJsonToQuakes(string json)
{
try
{
JObject o = JObject.Parse(json);
List<Earthquake> quakes = new List<Earthquake>(30);
foreach (var q in o["features"].Children())
{
Earthquake quake = new Earthquake
{
Location = new GeoCoordinate(q["geometry"]["coordinates"].Values<double>().ElementAt(1),
q["geometry"]["coordinates"].Values<double>().ElementAt(0)),
Depth = (double)q["properties"]["depth"],
Magnitude = (double)q["properties"]["magnitude"],
Reference = (string)q["properties"]["publicid"],
/* origintime=2012-08-13 05:25:24.727000 (that's in UTC) */
Date = DateTime.Parse((string)q["properties"]["origintime"] + "Z"),
Agency = (string)q["properties"]["agency"],
Status = (string)q["properties"]["status"]
};
quakes.Add(quake);
}
return quakes.OrderByDescending(q => q.Date);
}
catch (Exception e)
{
throw new JsonException("Problem with JSON data", e);
}
}
示例2: button2_Click
private void button2_Click(object sender, RoutedEventArgs e)
{
string[] inputStrings = textBox1.Text.Split(new char[] { '\n', ',', '.'}, StringSplitOptions.RemoveEmptyEntries);
textBox3.Text = string.Empty;
string output = string.Empty;
List<SimilirityAndString> unSortedOutput = new List<SimilirityAndString>();
string lookupString = textBox2.Text.ToLower();
foreach (var item in inputStrings)
{
string candidate = item.Trim().ToLower();
double sIndex = FuzzyString.FuzzyString.GetSimilarIndex(lookupString, candidate);
if (sIndex > 30)
unSortedOutput.Add(
new SimilirityAndString()
{
simIndex = sIndex,
inputString = item
});
}
var sortedOutput = unSortedOutput.OrderByDescending(item => item.simIndex);
foreach (var item in sortedOutput)
{
output += string.Format("Similarity:{0:0.00} ---- {1}\r\n", item.simIndex, item.inputString);
}
textBox3.Text = output;
}
示例3: WriteAll
public static void WriteAll(List<HistoryItem> items)
{
IsolatedStorageSettings.ApplicationSettings["HistoryItems"] = items.OrderByDescending(a => a.Date).Take(MAX_TO_KEEP).ToList();
IsolatedStorageSettings.ApplicationSettings.Save();
//App.HistoryViewModel.IsValid = false;
}
示例4: Highscore
public Highscore()
{
InitializeComponent();
try
{
int length = (int)DataManager.userSettings["taille"];
this.scores = new List<HighscoreElement>();
for(int i=1; i <= length; i++)
this.scores.Add(new HighscoreElement((int)DataManager.userSettings["highscore"+i]));
listeDesScores.ItemsSource = scores.OrderByDescending(e => e.Score).Select(e => new HighscoreElement(e.Score,ObtientImage(e.Score)));
}
catch (System.Collections.Generic.KeyNotFoundException)
{
MessageBox.Show("No Key");
}
}
示例5: Test4
/// <summary>
/// Test2 takes an original point, and chooses the nearest X items from the new positions.
///
/// Say two of those original points had a link. Now you could have several new points that correspond to one
/// of the originals, linked to several that correspond to the second original
///
/// This method creates links from one set to the other
/// </summary>
public static LinkResult3[] Test4(LinkResult2[] from, LinkResult2[] to, int maxReturn)
{
// Find the combinations that have the highest percentage
List<Tuple<int, int, double>> products = new List<Tuple<int, int, double>>();
for (int fromCntr = 0; fromCntr < from.Length; fromCntr++)
{
for (int toCntr = 0; toCntr < to.Length; toCntr++)
{
products.Add(new Tuple<int, int, double>(fromCntr, toCntr, from[fromCntr].Percent * to[toCntr].Percent));
}
}
// Don't return too many
IEnumerable<Tuple<int, int, double>> topProducts = null;
if (products.Count <= maxReturn)
{
topProducts = products; // no need to sort or limit
}
else
{
topProducts = products.
OrderByDescending(o => o.Item3).
Take(maxReturn).
ToArray();
}
// Normalize
double totalPercent = topProducts.Sum(o => o.Item3);
LinkResult3[] retVal = topProducts.
Select(o => new LinkResult3(from[o.Item1], to[o.Item2], o.Item3 / totalPercent)).
ToArray();
return retVal;
}
示例6: refreshDataGrid
/// <summary>
/// Füllt das DataGrid
/// </summary>
private void refreshDataGrid(List<BookingDataGridModel> bookingModels)
{
// Sortiere absteigend
bookingModels = bookingModels.OrderByDescending(t => t.bookingID).ToList();
this.dataGridPaging = new DataGridPaging<BookingDataGridModel>(bookingModels);
AccountingRecordDataGrid.ItemsSource = this.dataGridPaging.FirstSide();
AccountingRecordDataGrid.Items.Refresh();
this.ChangePagingBar();
}
示例7: readRanking
// Showing ranking
private List<int> readRanking()
{
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
//List<int> listaPontos = new List<int>();
List<int> resultList = new List<int>();
if (settings.Contains("pointing"))
{
pointList = (List<int>)settings["pointing"];
var result = pointList.OrderByDescending(n => n).Take(3);
foreach (var i in result)
{
resultList.Add(i);
}
}
else {
MessageBox.Show("Nenhum dado cadastrado!");
pivotGame.SelectedIndex = 0;
}
return resultList;
}
示例8: Sort
public static void Sort(this DataGrid dg, Type cTypeOfElement, string sFieldName, bool bBackward)
{
System.Reflection.PropertyInfo cHeader = (System.Reflection.PropertyInfo)cTypeOfElement.GetMember(sFieldName)[0];
List<ObjectForSort> aOFS = new List<ObjectForSort>();
foreach (object oOFS in dg.ItemsSource)
aOFS.Add(new ObjectForSort() { o = oOFS, oValue = cHeader.GetValue(oOFS, null) });
if (bBackward)
dg.ItemsSource = aOFS.OrderByDescending(o => o.oValue).Select(o => o.o).ToList();
else
dg.ItemsSource = aOFS.OrderBy(o => o.oValue).Select(o => o.o).ToList();
}
示例9: CategorySort
public void CategorySort(ClusteringResult baseResult)
{
List<Category> list = new List<Category>();
List<Category> list2 = new List<Category>(this.Categories);
foreach (var item in baseResult.Categories)
{
if (list2.Count > 0)
{
var idList = item.GetComuity().Select(n => n.Id);
var c = list2.OrderByDescending(n => n.GetComuity().Select(m => m.Id).Intersect(idList).Count()).First();
list2.Remove(c);
list.Add(c);
}
else
{
list.Add(new Category());
}
}
this.Categories.Clear();
foreach (var item in list)
{
this.Categories.Add(item);
}
var layerNames = this.LayerGroup.Select(n => n.Key).Distinct().ToArray();
LayerGroup.Clear();
foreach (var item in layerNames)
{
LayerGroup lg = new LayerGroup() { Name = item, Items = new System.Collections.ObjectModel.ObservableCollection<Layer>() };
LayerGroup.Add(item, lg);
foreach (var item2 in Categories)
{
lg.Items.Add(item2.GetLayer(item));
}
}
}
示例10: parse_ConsumerList
private void parse_ConsumerList(object sender, HtmlDocumentLoadCompleted e)
{
IList < ProductViewModel > tmpItems = new List<ProductViewModel>();
IList<HtmlNode> hnc = e.Document.DocumentNode.DescendantNodes().ToList();
String currentCategory = "Consumer Product Recalls";
foreach (HtmlNode node in hnc)
{
if (node.Name.ToLower() == "table")
{
foreach (HtmlAttribute att in node.Attributes)
{
if (att.Name.ToLower() == "summary" && att.Value == "Search results")
{
foreach (HtmlNode table in node.DescendantNodes().ToList())
{
if (table.Name.ToLower() == "tr")
{
ProductViewModel po = new ProductViewModel();
po.Category = currentCategory;
foreach (HtmlNode tr in table.DescendantNodes().ToList())
{
if (tr.Name.ToLower() == "th")
{
break;
}
else if(tr.Name.ToLower() == "td")
{
String datetest = tr.InnerText;
DateTime test;
datetest = datetest.Replace(",", "");
datetest = datetest.Replace("Sept", "Sep");
datetest = datetest.Replace("y 008", "2008");
if (DateTime.TryParse(datetest, out test))
{
po.RecallDateString = datetest;
}
else
{
po.ShortDescription = ConvertWhitespacesToSingleSpaces( this.getTitleFromURLNode(tr) ).Trim();
po.Href = Url_HealthCanadaConsumerPrefix + this.getURLFromNode(tr);
break;
}
}
}
if (po.Href != null && po.Href != "")
{
tmpItems.Add(po);
}
}
}
}
}
}
}
foreach (ProductViewModel p in tmpItems.OrderByDescending(x => x._dateRecall))
{
this.Items.Add(p);
}
tmpItems.Clear();
this.IsDataLoaded = true;
NotifyPropertyChanged("WebDataRetrived");
}
示例11: parse_RecallListByCategory
private void parse_RecallListByCategory(object sender, HtmlDocumentLoadCompleted e)
{
IList < ProductViewModel > tmpItems = new List<ProductViewModel>();
IList<HtmlNode> hnc = e.Document.DocumentNode.DescendantNodes().ToList();
String currentCategory = null;
Boolean flag_comment = false;
foreach (HtmlNode node in hnc)
{
if (!flag_comment && node.Name.ToLower() == "#comment")
{
flag_comment = true;
}
else if (flag_comment && node.PreviousSibling != null && node.PreviousSibling.Name == "#comment")
{
flag_comment = false;
}
if (!flag_comment && node.Name.ToLower() == "h3")
{
currentCategory = node.InnerText;
}
else if (!flag_comment && node.Name.ToLower() == "li")
{
if (node.ParentNode.Name == "ul" && node.ParentNode.Attributes.Count == 0)
{
ProductViewModel po = new ProductViewModel();
po.Category = currentCategory;
foreach (HtmlNode li in node.DescendantNodes().ToList())
{
if (li.Name.ToLower() == "a")
{
foreach (HtmlAttribute at in li.Attributes)
{
if (at.Name.ToLower() == "href")
{
po.Href = at.Value;
}
}
po.ShortDescription = ConvertWhitespacesToSingleSpaces(li.InnerText.Replace("�", "'"));
}
else if (li.Name.ToLower() == "span")
{
po.RecallDateString = li.InnerText;
}
else if (li.Name.ToLower() == "#text")
{
if (li.ParentNode.Name.ToLower() == "li" && li.InnerText.Contains("20"))
{
String date = "";
if (li.PreviousSibling != null && li.PreviousSibling.Name.ToLower() == "abbr")
{
date += li.PreviousSibling.InnerText + " ";
}
date += li.InnerText;
po.RecallDateString = date;
}
}
}
tmpItems.Add(po);
}
}
}
foreach (ProductViewModel p in tmpItems.OrderByDescending(x => x._dateRecall))
{
this.Items.Add(p);
}
this.IsDataLoaded = true;
NotifyPropertyChanged("WebDataRetrived");
}
示例12: load_FoodSafety
private void load_FoodSafety(object sender, HtmlDocumentLoadCompleted e)
{
IList<ProductViewModel> tmpItems = new List<ProductViewModel>();
IList<HtmlNode> hnc = e.Document.DocumentNode.DescendantNodes().ToList();
String currentCategory = "Food Recalls and Allergy Alerts";
Boolean content_flag = false;
foreach (HtmlNode node in hnc)
{
if (node.Name.ToLower() == "#comment" && node.InnerText.Contains("start - recall index links"))
{
content_flag = true;
}
else if(node.Name.ToLower() == "#comment" && node.InnerText.Contains("FOOTER BEGINS") )
{
content_flag = false;
}
else if (content_flag && node.Name.ToLower() == "ul")
{
foreach (HtmlNode li in node.DescendantNodes().ToList())
{
if (li.Name.ToLower() == "li")
{
ProductViewModel po = new ProductViewModel();
po.Category = currentCategory;
foreach (HtmlNode ee in li.DescendantNodes().ToList())
{
if (ee.Name.ToLower() == "strong")
{
po.RecallDateString = ee.InnerText;
}
else if (ee.Name.ToLower() == "a")
{
foreach (HtmlAttribute at in ee.Attributes)
{
if (at.Name.ToLower() == "href")
{
po.Href = "http://www.inspection.gc.ca"+ at.Value;
}
}
po.ShortDescription = ConvertWhitespacesToSingleSpaces(ee.InnerText.Replace("�", "'").Replace("’", "'"));
}
}
tmpItems.Add(po);
}
}
}
}
foreach (ProductViewModel p in tmpItems.OrderByDescending(x => x._dateRecall))
{
this.Items.Add(p);
}
tmpItems.Clear();
this.IsDataLoaded = true;
NotifyPropertyChanged("WebDataRetrived");
}
示例13: parse_RecallListCurrent
//Because current contains uncategorized items
private void parse_RecallListCurrent(object sender, HtmlDocumentLoadCompleted e)
{
IList<ProductViewModel> tmpItems = new List<ProductViewModel>();
IList<HtmlNode> hnc = e.Document.DocumentNode.DescendantNodes().ToList();
String currentCategory = "Advisories, Warnings and Recalls";
foreach (HtmlNode node in hnc)
{
if (node.Name.ToLower() == "div")
{
if (node.Attributes.Count == 1 && node.Attributes[0].Name.ToLower() == "class"
&& node.Attributes[0].Value.ToLower() == "date")
{
foreach (HtmlNode child in node.DescendantNodes().ToList())
{
if (child.Name.ToLower() == "li")
{
if (child.ParentNode.Name == "ul" && child.ParentNode.Attributes.Count == 0)
{
ProductViewModel po = new ProductViewModel();
po.Category = currentCategory;
foreach (HtmlNode li in child.DescendantNodes().ToList())
{
if (li.Name.ToLower() == "a")
{
foreach (HtmlAttribute at in li.Attributes)
{
if (at.Name.ToLower() == "href")
{
po.Href = at.Value;
}
}
po.ShortDescription = ConvertWhitespacesToSingleSpaces(li.InnerText.Replace("�", "'"));
}
else if (li.Name.ToLower() == "span")
{
po.RecallDateString = li.InnerText;
}
else if (li.Name.ToLower() == "#text")
{
if (li.ParentNode.Name.ToLower() == "li" && li.InnerText.Contains("20"))
{
String date = "";
if (li.PreviousSibling != null && li.PreviousSibling.Name.ToLower() == "abbr")
{
date += li.PreviousSibling.InnerText + " ";
}
date += li.InnerText;
po.RecallDateString = date;
}
}
}
//if (po.RecallDateString == "Jun 7, 2011")
//{
// goto EndParse;
//}
tmpItems.Add(po);
}
}
}
}
}
} //EndParse:
foreach (ProductViewModel p in tmpItems.OrderByDescending(x => x._dateRecall))
{
this.Items.Add(p);
}
tmpItems.Clear();
this.IsDataLoaded = true;
NotifyPropertyChanged("WebDataRetrived");
}
示例14: NotifyPropertyChanged
private void NotifyPropertyChanged(String propertyName)
{
if (propertyName == "WebDataRetrived")
{
IList<ProductViewModel> tmpItems = new List<ProductViewModel>(Items);
Items.Clear();
foreach (ProductViewModel p in tmpItems.OrderByDescending(x => x._dateRecall))
{
this.Items.Add(p);
}
tmpItems.Clear();
foreignProductAlerts = null;
advisoriesWarningsRecalls = null;
Spinnner.ShowSpinner = false;
}
PropertyChangedEventHandler handler = PropertyChanged;
if (null != handler)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
示例15: Button_Click_1
private void Button_Click_1(object sender, RoutedEventArgs e)
{
OpenFileDialog ofd = new OpenFileDialog();
if (ofd.ShowDialog() == true)
{
TextBox_InputName.Text = ofd.FileName;
FFTW fftw = new FFTW();
_input = DataLoader.Load(ofd.FileName);
double[] inputCopy = new double[_input.Length];
_input.CopyTo(inputCopy, 0);
_frequencyDomain = fftw.Forward(inputCopy);
_frequencyDomainLinkedToCheckboxes = new Complex[_frequencyDomain.Length];
_frequencyDomain.CopyTo(_frequencyDomainLinkedToCheckboxes, 0);
DataSeries<double, double> points = new DataSeries<double, double>("Magnitudes");
TheList = new ObservableCollection<CheckBoxBinder>();
List<CheckBoxBinder> mags = new List<CheckBoxBinder>();
for (int c = 0; c < _frequencyDomain.Length; c++)
{
points.Add(new DataPoint<double, double> { X = c, Y = _frequencyDomain[c].Magnitude });
mags.Add(new CheckBoxBinder { TheValue = _frequencyDomain[c].Magnitude, Index = c });
}
foreach (CheckBoxBinder d in mags.OrderByDescending(m => m.TheValue))
{
TheList.Add(d);
}
exampleChart.Series[0].DataSeries = points;
this.DataContext = this;
DataSeries<double, double> data = new DataSeries<double, double>("Data");
for (int c = 0; c < _input.Length; c++)
{
data.Add(new DataPoint<double, double> { X = c, Y = _input[c] });
}
dataChart.Series[0].DataSeries = data;
return;
}
}