本文整理汇总了C#中System.Windows.Documents.List.Sort方法的典型用法代码示例。如果您正苦于以下问题:C# List.Sort方法的具体用法?C# List.Sort怎么用?C# List.Sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.Sort方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs e)
{
WindowPosition.Move(this);
var items = new List<VersionListViewItem>();
var files = new List<string>();
files.AddRange(Directory.GetFiles(Directory.GetCurrentDirectory(), "*.dll", SearchOption.TopDirectoryOnly));
files.AddRange(Directory.GetFiles(Directory.GetCurrentDirectory(), "*.exe", SearchOption.TopDirectoryOnly));
files.Sort((x, y) =>
{
return System.IO.Path.GetFileName(x).CompareTo(System.IO.Path.GetFileName(y));
});
foreach (var path in files)
{
var info = System.Diagnostics.FileVersionInfo.GetVersionInfo(path);
var item = new VersionListViewItem();
item.FileName = System.IO.Path.GetFileName(path);
item.Version = info.FileVersion;
items.Add(item);
}
foreach (var item in items)
{
_versionListView.Items.Add(item);
}
}
示例2: SearchCompleted
private void SearchCompleted(string pattern, List<SearchResult2> results)
{
ContentBox.Items.Clear();
results.Sort();
foreach (SearchResult2 result in results)
ContentBox.Items.Add(new SearchResultListItem2(result));
}
示例3: OpcodeInfoWindow
public OpcodeInfoWindow(NetworkLogViewerBase viewer)
{
InitializeComponent();
m_viewer = viewer;
var window = viewer.InterfaceObject as Window;
if (window != null)
{
this.Owner = window;
this.Style = window.Style;
var styler = window as INotifyStyleChanged;
if (styler != null)
styler.StyleChanged += (o, e) => this.Style = ((Window)m_viewer.InterfaceObject).Style;
}
var fields = typeof(WowOpcodes).GetFields(BindingFlags.Static | BindingFlags.Public);
var list = new List<string>(fields.Length);
foreach (var field in fields)
{
var value = (uint)field.GetRawConstantValue();
if (value != SpecialOpcodes.UnknownOpcode)
list.Add(field.Name);
}
list.Sort();
var items = ui_cbInput.Items;
foreach (var item in list)
items.Add(item);
this.Prepare(WowOpcodes.UNKNOWN_OPCODE);
}
示例4: ctlImportLocation
public ctlImportLocation(ModulePermissions[] MyPermissions)
{
try
{
InitializeComponent();
_MyPermissions = MyPermissions;
DataSet dsTimeZone = clsBusiness.fncGetTimeZone();
for (int i = 0; i < dsTimeZone.Tables[0].Rows.Count; i++)
{ cmbTimeZone.Items.Add(dsTimeZone.Tables[0].Rows[i][0]); }
List<string> xList = new List<string>();
for (int i = 0; i < cmbTimeZone.Items.Count; i++)
{ xList.Add(cmbTimeZone.Items[i].ToString()); }
xList.Sort();
cmbTimeZone.Items.Clear();
for (int j = 0; j < xList.Count; j++)
{ cmbTimeZone.Items.Add(xList[j]); }
this.Loaded += new RoutedEventHandler(ctlImportLocation_Loaded);
}
catch (Exception ex)
{
VMuktiAPI.VMuktiHelper.ExceptionHandler(ex, "ctlImportLocation", "ctlImportLocation.xaml.cs");
}
}
示例5: CalculateConvexHull
/// <summary>
/// Finds the ConvexHull of a series of points. See
/// http://www.cs.princeton.edu/courses/archive/spr10/cos226/demo/ah/GrahamScan.html
/// for further information.
/// </summary>
/// <param name="points">The points to compute the ConvexHull for</param>
/// <returns>a collection of points that represents the polygon
/// of the ConvexHull</returns>
public static ICollection<Point> CalculateConvexHull(ICollection<Point> points)
{
if (points.Count <= 3)
return points;
List<ConvexHullPoint> chPoints = new List<ConvexHullPoint>();
// Get the current anchor point
anchor = new ConvexHullPoint(DetermineAnchorPoint(points), 0, null);
// Loop over the points
foreach (Point currentPoint in points)
{
// Ensure that this point is not the anchor
if (currentPoint != anchor.Point)
{
// Create a new ConvexHUllPoint and save it for later use
ConvexHullPoint newConvexHullPoint = new ConvexHullPoint(currentPoint, CalculateCartesianAngle(currentPoint.X - anchor.Point.X, currentPoint.Y - anchor.Point.Y), anchor);
chPoints.Add(newConvexHullPoint);
}
}
// Sort the points
chPoints.Sort();
// Actually calculate and return the ConvexHull
return GrahamScan(chPoints);
}
示例6: Grid_Loaded
private void Grid_Loaded(object sender, RoutedEventArgs e)
{
if (ctrl.CrmConnectionMgr != null && ctrl.CrmConnectionMgr.CrmSvc != null && ctrl.CrmConnectionMgr.CrmSvc.IsReady)
{
CrmServiceClient svcClient = ctrl.CrmConnectionMgr.CrmSvc;
if (svcClient.IsReady)
{
List<AttributeMetadata> entitiesList = svcClient.GetAllAttributesForEntity(EntityName);
List<string> MyAttributes = new List<string>();
foreach (AttributeMetadata entityinlist in entitiesList)
{
if (entityinlist.IsCustomizable.Value)
{
MyAttributes.Add(entityinlist.LogicalName);
}
}
MyAttributes.Sort();
foreach (string item in MyAttributes)
{
CheckBox chk = new CheckBox();
chk.Content = item;
LB_AttributesList.Items.Add(chk);
}
}
}
}
示例7: MainWindow_Loaded
void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
try
{
string cacheName = ConfigurationManager.AppSettings["CacheName"] ?? "default";
string region = ConfigurationManager.AppSettings["LogRegion"];
DataCacheFactoryConfiguration config = new DataCacheFactoryConfiguration();
DataCacheFactory factory = new DataCacheFactory();
DataCache cache = factory.GetCache(cacheName);
List<KeyValuePair<string, object>> objects = cache.GetObjectsInRegion(region).ToList();
logEntries = new List<KeyValuePair<long, string>>();
for (int i = 0; i < objects.Count; i++)
{
long key;
if (long.TryParse(objects[i].Key, out key))
{
logEntries.Add(new KeyValuePair<long, string>(key, objects[i].Value.ToString()));
}
}
logEntries.Sort((a, b) => a.Key.CompareTo(b.Key));
Grid.ItemsSource = logEntries;
}
catch (Exception ex)
{
MessageBox.Show("Error getting objects from cache: " + ex.Message);
}
}
示例8: salvaScore_Click
private void salvaScore_Click(object sender, RoutedEventArgs e)
{
List<itemRanking> ranking = new List<itemRanking>();
ranking.Capacity = 3;
itemRanking itemRanking = new itemRanking();
itemRanking.nomeJogador = campoJogador.Text;
itemRanking.pontuacao = this.pontuacao;
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
if (settings.Contains("ranking"))
{
ranking = (List<itemRanking>)settings["ranking"];
ranking.Add(itemRanking);
Comparison<itemRanking> comparador = new Comparison<itemRanking>(itemRanking.comparaPontuacao);
ranking.Sort(comparador);
if (ranking.Count > 3)
{
ranking.RemoveAt(3);
}
}
else
{
ranking.Add(itemRanking);
}
settings["ranking"] = ranking;
settings.Save();
NavigationService.Navigate(new Uri("/Ranking.xaml", UriKind.Relative));
}
示例9: UserSettings
public UserSettings(FacebookUserSetting setting)
{
_setting = setting;
//get user
InitializeComponent();
var fb = new FacebookClient(setting.AccessToken);
var picSettings = new List<FacebookPictureSetting>();
dynamic friends = fb.Get("/me/friends");
foreach (var friend in friends.data)
{
picSettings.Add(new FacebookPictureSetting(new FacebookUser(friend.name, friend.id), false));
}
picSettings.Sort((x, y) => string.Compare(x.User.Name, y.User.Name));
picSettings.Insert(0, new FacebookPictureSetting(new FacebookUser(setting.User.Name, setting.User.Id), false));
var selectedPics = picSettings.Where(x => setting.PictureSettings.Any(y => y.User.Id == x.User.Id));
foreach (var sp in selectedPics)
{
sp.Selected = true;
}
lsUsers.ItemsSource = picSettings;
}
示例10: cbEquipes_SelectionChanged
/// <summary>
/// Permet de recuperer l'evenement qui indique qu'on a selectionne un item dans la liste box.
/// </summary>
/// <param name="sender">???</param>
/// <param name="e">???</param>
private void cbEquipes_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// On recupere la liste des joueurs de l'equipe selectionnee, et on les affiches.
var equipe = (sender as ComboBox).SelectedItem as Equipe;
var joueurs = new List<Joueur>();
joueurs = equipe.Joueurs;
joueurs.Sort();
lvJoueurs.ItemsSource = joueurs;
}
示例11: cbCoupes_SelectionChanged
/// <summary>
/// Permet de recuperer l'evenement qui indique qu'on a selectionne un item dans la liste box.
/// </summary>
/// <param name="sender">???</param>
/// <param name="e">???</param>
private void cbCoupes_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// On recupere la liste des matchs de la coupe selectionnee, et on les affiches.
var coupe = (sender as ComboBox).SelectedItem as Coupe;
var matchs = new List<Match>();
matchs = coupe.Matchs;
matchs.Sort();
lvMatchs.ItemsSource = matchs;
}
示例12: SayActionErrors
public void SayActionErrors(List<Pose.JointError> errorList, int nFrames)
{
errorList.Sort((s1, s2) => s1.mag.CompareTo(s2.mag));
errorList.Reverse();
Dictionary<string, int> errorDict = new Dictionary<string, int>();
for (int i = 0; i < errorList.Count; i++)
{
string text = "";
Pose.JointError err = errorList[i];
text += "Your " + getStringFromJointType(err.joint) + " was " + getStringFromErrorType(err.error);
if (err.frame < nFrames / 3)
{
text += " at the beginning. ";
}
else if (err.frame < 2 * nFrames / 3)
{
text += " during the middle. ";
}
else
{
text += " near the end. ";
}
if (errorDict.ContainsKey(text))
{
errorDict[text] += 1;
}
else
{
errorDict[text] = 1;
}
}
List<string> comments = errorDict.Keys.ToList();
comments.Sort((k1, k2) => errorDict[k1].CompareTo(errorDict[k2]));
comments.Reverse();
string speech = "";
for (int i = 0; i < Math.Min(numberErrorsMentioned, comments.Count); i++)
{
if (errorDict[comments[i]] < frameErrorMinimum)
{
break;
}
speech += comments[i];
}
if (speech.Equals(""))
{
speech = "No significant errors found.";
}
Speak(speech);
}
示例13: AddPhoneOptions
public void AddPhoneOptions(IEnumerable<IPhoneDeviceInfo> phoneDevices)
{
List<IPhoneDeviceInfo> phoneDevicesLocal = new List<IPhoneDeviceInfo>(phoneDevices);
phoneDevicesLocal.Sort(ComparePhones);
foreach (IPhoneDeviceInfo phoneDevice in phoneDevicesLocal)
{
Items.Add(new PhoneDeviceListItem(phoneDevice));
}
}
示例14: GetFiles
// Functions
public static string[] GetFiles(string path, string searchPattern, SearchOption searchOption)
{
// Splits the search patterns up so that each can be called individually
string[] searchPatterns = searchPattern.Split(';');
List<string> files = new List<string>();
foreach (string sp in searchPatterns)
files.AddRange(Directory.GetFiles(path, sp, searchOption));
files.Sort();
return files.ToArray();
}
示例15: GestionDesStades
/// <summary>
/// Constructeur de la fenetre de gestion des stades.
/// </summary>
public GestionDesStades()
{
InitializeComponent();
// On recupere la liste des equipes et de l'afficher
var stades = new List<Stade>();
stades = BusinessManager.getStades();
stades.Sort();
lvStades.ItemsSource = stades;
}