本文整理汇总了C#中System.Windows.Documents.List.Where方法的典型用法代码示例。如果您正苦于以下问题:C# List.Where方法的具体用法?C# List.Where怎么用?C# List.Where使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.Where方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DetectRotation
public override List<TableObject> DetectRotation(List<TableObject> ObjectList)
{
DateTime start = DateTime.Now;
//No bitmaps -> no rotation detection
if (ObjectList.Where(o => o.ExtractedBitmap != null).Count() == 0)
return ObjectList;
List<TableObject> ObjectsWithBitmap = ObjectList.Where(o => o.ExtractedBitmap != null).ToList();
int objects = ObjectsWithBitmap.Count();
int index = 0;
int _threadcount = 0;
ManualResetEvent[] resetEvents;
//Start 4 threads, only if >= 4 threads
if (objects >= 4)
{
_threadcount = 4;
resetEvents = new ManualResetEvent[4];
for (int i=4; i > 0; i--)
{
Thread t1 = new Thread(new ParameterizedThreadStart(Work));
t1.Name = "ObjectTable RotationDetection Thread #" + i.ToString();
//Copy 1/i*objectcount of the objects to the new thread
int amount = (int) Math.Round((1.0/i)*objects);
TableObject[] threadobjects = new TableObject[amount];
ObjectsWithBitmap.CopyTo(index, threadobjects, 0, amount);
objects -= amount;
index += amount;
resetEvents[i-1] = new ManualResetEvent(false);
t1.Start(new object[] {threadobjects,resetEvents[i-1]});
}
WaitHandle.WaitAll(resetEvents);
}
else
{
//Single thread
_threadcount = 1;
ManualResetEvent manualReset = new ManualResetEvent(false);
Thread t = new Thread(new ParameterizedThreadStart(Work));
t.Name = "ObjectTable RotationDetection Thread -";
t.Start(new object[] {ObjectsWithBitmap.ToArray(),manualReset});
manualReset.WaitOne();
}
//Performance
this.RotationDetectionDuration = (int) Math.Round((DateTime.Now - start).TotalMilliseconds);
return ObjectList;
}
示例2: ChuZhuangControl
public ChuZhuangControl(List<ChuZhuangTable> list,HeroInfoTable singHero)
{
InitializeComponent();
this.tbl_Title.Text = "英雄出装路线";
if (list != null||list.Count==0)
{
List<ChuZhuangTable> list1 = list.Where(c => c.Index == 1).ToList();
List<ChuZhuangTable> list2 = list.Where(c => c.Index == 2).ToList();
List<ChuZhuangTable> list3 = list.Where(c => c.Index == 3).ToList();
foreach (ChuZhuangTable item in list1)
{
Image image = new Image();
image.Width = 60;
image.Height = 60;
image.Margin = new Thickness(5, 5, 5, 5);
image.Source = new BitmapImage() { UriSource = new Uri(item.ItemUri, UriKind.Relative) };
wp_ChuMen.Children.Add(image);
}
tb1_ChuMenContent.Text = singHero.ChuMen;
foreach (ChuZhuangTable item in list2)
{
Image image = new Image();
image.Width = 60;
image.Height = 60;
image.Margin = new Thickness(5, 5, 5, 5);
image.Source = new BitmapImage() { UriSource = new Uri(item.ItemUri, UriKind.Relative) };
this.wp_ZhongQi.Children.Add(image);
}
tb1_ZhongQiContent.Text= singHero.ZhongQi;;
foreach (ChuZhuangTable item in list3)
{
Image image = new Image();
image.Width = 60;
image.Height = 60;
image.Margin = new Thickness(5, 5, 5, 5);
image.Source = new BitmapImage() { UriSource = new Uri(item.ItemUri, UriKind.Relative) };
wp_HouQi.Children.Add(image);
}
// tb1_ChuMenContent.Text = singHero.ChuMen;
tb1_HouQiContent.Text = singHero.HuoQi;
}
else
{
this.tbl_Title.Text = "没有相关信息,请等待更新.....";
}
}
示例3: 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;
}
示例4: AttackWithLandCombatUnits
private static List<LandCombatUnit> AttackWithLandCombatUnits(List<LandCombatUnit> landCombatUnits)
{
landCombatUnits = landCombatUnits.Where(lcu => lcu.CanAttack || lcu.CanMove).ToList();
foreach (LandCombatUnit landCombatUnit in landCombatUnits)
{
Tile currentTile = Game.BoardFactory.Tiles.Where(t => t.GroundUnit == landCombatUnit).FirstOrDefault();
Game.TileFactory.SetAttackableTiles(landCombatUnit, currentTile);
if (landCombatUnit.AttackableTiles.Count > 0)
{
Tile targetTile = null;
if (landCombatUnit.EquipmentClassEnum == EquipmentClassEnum.AntiAir)
{
targetTile = DetermineTarget(landCombatUnit.AttackableTiles,TargetTypeEnum.Air);
}
else
{
targetTile = DetermineTarget(landCombatUnit.AttackableTiles, TargetTypeEnum.SoftGround);
}
Game.BoardFactory.ActiveTile = currentTile;
Game.BoardFactory.ActiveUnit = landCombatUnit;
Game.BoardFactory.CalculateBattleForComputerPlayer(targetTile);
}
}
return landCombatUnits;
}
示例5: GetCurrency
public static List<Currency> GetCurrency()
{
List<Currency> wCurrency = new List<Currency>();
XmlDocument xmlDoc = new XmlDocument();
string path = System.AppDomain.CurrentDomain.BaseDirectory + "Currencies.xml";
if(System.IO.File.Exists(path)) {
xmlDoc.Load(path);
XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/ISO_4217/CcyTbl/CcyNtry");
foreach (XmlNode node in nodeList) {
if (node.SelectSingleNode("Ccy") != null) {
bool isExist = wCurrency.Where(c => c.code == node.SelectSingleNode("Ccy").InnerText &&
c.description == node.SelectSingleNode("CcyNm").InnerText).Any();
if(!isExist) {
wCurrency.Add(new Currency {
code = node.SelectSingleNode("Ccy").InnerText,
description = node.SelectSingleNode("CcyNm").InnerText,
createdAt = DateTime.Now,
updateAt = DateTime.Now
});
}
} else {
var d = node;
}
}
} else {
MessageBox.Show("Currency file could not be found.", "Missing file", MessageBoxButton.OK, MessageBoxImage.Warning);
}
wCurrency = wCurrency.OrderBy(x => x.description).ToList();
return wCurrency;
}
示例6: Editor
private bool vueMode = false; // false = ortho, true = orbite
#endregion Fields
#region Constructors
internal Editor(EditorController _controller)
{
InitializeComponent();
controller = _controller;
// Ne pas enlever Forms : c'est pour éviter l'ambiguïté.
KeyDown += controller.KeyPressed;
KeyUp += controller.KeyUnPressed;
GamePanel.MouseDown += new Forms.MouseEventHandler(controller.MouseButtonDown);
GamePanel.MouseUp += new Forms.MouseEventHandler(controller.MouseButtonUp);
GamePanel.MouseEnter += new EventHandler(GamePanel_MouseEnter);
GamePanel.MouseLeave -= new EventHandler(GamePanel_MouseExit);
GamePanel.MouseWheel += new Forms.MouseEventHandler(controller.RouletteSouris);
GamePanel.MouseMove += new Forms.MouseEventHandler(controller.MouseMove);
/// Resize on resize only
Application.Current.MainWindow.SizeChanged += new SizeChangedEventHandler(ResizeGamePanel);
settings = (new ConfigPanelData()).LoadSettings();
profiles = (new ConfigPanelData()).LoadProfiles();
var defaultProfile = profiles.Where(x => settings != null && x.CompareTo(settings.DefaultProfile) == 0);
if (defaultProfile.Count() > 0)
{
selectedProfile = defaultProfile.First();
controller.ChangeProfile(selectedProfile);
}
else
{
selectedProfile = profiles[0];
controller.ChangeProfile(selectedProfile);
}
}
示例7: viewModel_ControlTypeChanged
/// <summary>
/// 当出现控件类型变化时,刷新整个Tab
/// </summary>
/// <param name="prompts"></param>
private void viewModel_ControlTypeChanged(List<PromptItem> prompts)
{
TabItem tab = tabAll.SelectedItem as TabItem;
if (tab == null)
{
return;
}
//如果有prompt的ControlType发生了变化,那么就刷新页面
int index = (int)tab.Tag;
var numbers = prompts.Where(it => it.TabIndex == index);
if (prompts.Where(it => it.TabIndex == index).Count() > 0)
{
RefreshTabContent(tab);
}
}
示例8: BindLists
public void BindLists(List<CodeITBL.FileFromDB> files, bool SearchByUploadDate = false)
{
lvItemsContainer.ItemsSource = null;
lvItemsContainer3Days.ItemsSource = null;
lvItemsContainer7Days.ItemsSource = null;
lvItemsContainer.Items.Clear();
lvItemsContainer3Days.Items.Clear();
lvItemsContainer7Days.Items.Clear();
if (!SearchByUploadDate)
{
lvItemsContainer.ItemsSource = files.Where(x => x.OriginalFileDate.Date == DateTime.Now.Date).ToList();
lvItemsContainer3Days.ItemsSource = files.Where(x => x.OriginalFileDate.Date >= DateTime.Now.Date.AddDays(-2) && x.OriginalFileDate.Date <= DateTime.Now.Date.AddHours(23).AddMinutes(59)).ToList();
lvItemsContainer7Days.ItemsSource = files.Where(x => x.OriginalFileDate.Date >= DateTime.Now.Date.AddDays(-6) && x.OriginalFileDate.Date <= DateTime.Now.Date.AddHours(23).AddMinutes(59)).ToList();
}
else
{
lvItemsContainer.ItemsSource = files.Where(x => x.CreatedOn.Date == DateTime.Now.Date).ToList();
lvItemsContainer3Days.ItemsSource = files.Where(x => x.CreatedOn.Date >= DateTime.Now.Date.AddDays(-2) && x.CreatedOn.Date <= DateTime.Now.Date.AddHours(23).AddMinutes(59)).ToList();
lvItemsContainer7Days.ItemsSource = files.Where(x => x.CreatedOn.Date >= DateTime.Now.Date.AddDays(-6) && x.CreatedOn.Date <= DateTime.Now.Date.AddHours(23).AddMinutes(59)).ToList();
}
txtTodayNoItems.Visibility = lvItemsContainer.Items.Count == 0 ? Visibility.Visible : Visibility.Hidden;
txt3DaysNoItems.Visibility = lvItemsContainer3Days.Items.Count == 0 ? Visibility.Visible : Visibility.Hidden;
txt7DaysNoItems.Visibility = lvItemsContainer7Days.Items.Count == 0 ? Visibility.Visible : Visibility.Hidden;
}
示例9: SelectionRoute
public SelectionRoute(List<string> original, string route)
{
original.Where(it => !String.IsNullOrEmpty(it)).ToList().ForEach(it => this.original.Add(new RouteEntity(it)));
if (!String.IsNullOrEmpty(route))
{
route.Split(' ').ToList().ForEach(it => this.route.Add(new RouteEntity(it)));
}
InitializeComponent();
OriginalList.ItemsSource = this.original;
RouteList.ItemsSource = this.route;
}
示例10: HorarioProximo
private void HorarioProximo(List<string> saidasDiretas, TextBlock tb)
{
string proxSaida;
try
{
proxSaida = saidasDiretas.Where(x => String.Compare(x, DateTime.Now.ToShortTimeString()) > 0).First();
}
catch (Exception)
{
proxSaida = saidasDiretas.First();
}
tb.Text = proxSaida;
}
示例11: btn_simulate_Click
private void btn_simulate_Click(object sender, RoutedEventArgs e)
{
int nbrSim = Convert.ToInt32(txt_nbrsim.Text);
double initWealth = Properties.Settings.Default.InitWealth;
List<double> finalEarnings = new List<double>();
List<int> counts = new List<int>();
for (int i = 0; i < nbrSim; i++)
{
MartStrategy MStrat = new MartStrategy(5, 250, initWealth);
double bid = MStrat.Bet();
Number res;
double payoff;
int count = 0;
while (bid <= MStrat.Wealth)
{
MStrat.PlaceBet(bid);
res = _RGame.Play();
payoff = _RGame.GetPayoffColor(NumberColor.Red, bid, res);
MStrat.Setup(payoff);
bid = MStrat.Bet();
count++;
}
finalEarnings.Add(MStrat.Earnings-initWealth);
counts.Add(count);
}
txt_earnings.Text = finalEarnings.Average().ToString();
txt_plays.Text = counts.Average().ToString();
txt_maxEarnings.Text = finalEarnings.Max().ToString();
txt_maxLosses.Text = finalEarnings.Min().ToString();
txt_totEarnings.Text = finalEarnings.Where(x => x > 0).Sum().ToString();
txt_totLosses.Text = finalEarnings.Where(x => x < 0).Sum().ToString();
txt_balance.Text = finalEarnings.Sum().ToString();
}
示例12: AnalysisResultsPage
public AnalysisResultsPage(List<AlgorithmResult> algorithmResults)
{
InitializeComponent();
foreach (var algRes in algorithmResults.Where(result => result.Results != null))
{
algRes.Results = algRes.Results.Select(_preprocessAlgResults).ToList();
}
foreach (
var finalRes in algorithmResults.SelectMany(result => result.FinalResults))
{
finalRes.WritableHelperData = _preprocessAlgResults(finalRes.HelperData);
}
_presenter = new ResultsPresenter(algorithmResults);
DataContext = _presenter;
}
示例13: PlayerSelectionDialog
public PlayerSelectionDialog( string selector, List<Player> playerList )
{
InitializeComponent();
List<Player> modifiedPlayerList = new List<Player>(playerList.Where(player => player.Name != selector));
// Load the listbox with the players and select the first player on the list.
if ( modifiedPlayerList.Count > 0 )
{
PlayerListBox.ItemsSource = modifiedPlayerList;
PlayerListBox.SelectedIndex = 0;
}
else
{
MessageBox.Show("No other players!");
this.enoughPlayers = false;
}
}
示例14: btn_MentionUsers_UseScrapedData_Save_Click
private void btn_MentionUsers_UseScrapedData_Save_Click(object sender, RoutedEventArgs e)
{
try
{
if(!string.IsNullOrEmpty(cmbBox_MentionUser_UseScrapedUrl_LstOfUrls.Text))
{
List<CheckBox> temp = new List<CheckBox>();
foreach (CheckBox item in cmbBox_MentionUser_UseScrapedUrl_LstOfUrls.Items)
{
temp.Add(item);
}
if (temp.Where(x => x.IsChecked == true).ToList().Count == 0)
{
GlobusLogHelper.log.Info("Please Select Atleast One Account ");
return;
}
if (temp.Count > 0)
{
foreach (CheckBox item in temp)
{
if (item.IsChecked == true)
{
GlobalDeclration.objMentionUser.listOfUrlToMentionUser.Add(item.Content.ToString());
}
}
}
//GlobalDeclration.objMentionUser.listOfUrlToMentionUser.Add(cmbBox_MentionUser_UseScrapedUrl_LstOfUrls.Text);
ModernDialog.ShowMessage("Your Data Has Been Saved Succefully", "Select Url", MessageBoxButton.OK);
}
else
{
GlobusLogHelper.log.Info("Please Select Url From Dropdown List");
ModernDialog.ShowMessage("Please Select Url From Dropdown List", "Select Url", MessageBoxButton.OK);
cmbBox_MentionUser_UseScrapedUrl_LstOfUrls.Focus();
return;
}
}
catch(Exception ex)
{
GlobusLogHelper.log.Error("Error ==> " + ex.Message);
}
}
开发者ID:sumitglobussoft,项目名称:instagram-dominator-2.0,代码行数:44,代码来源:UserControlMentionUsersUseScrapedUrl.xaml.cs
示例15: buttonPrikazi_Click
private void buttonPrikazi_Click(object sender, RoutedEventArgs e)
{
if (datePickerDatumOd.SelectedDate != null || datePickerDatumDo.SelectedDate != null)
{
ObservableCollection<StampaBrojIzdatihPonuda> _lista = dBProksi.DajBrojIzdatihPonudaPoRadnicima((DateTime)datePickerDatumOd.SelectedDate, (DateTime)datePickerDatumDo.SelectedDate);
List<StampaBrojIzdatihPonuda> _s = new List<StampaBrojIzdatihPonuda>();
switch (((ComboBoxItem)comboBoxSortirajPo.SelectedItem).Content.ToString())
{
case "Šifra":
_s = _lista.OrderBy(o => o.Sifra).ToList();
break;
case "Nadimak":
_s = _lista.OrderBy(o => o.Nadimak).ToList();
break;
case "Broj ponuda":
_s = _lista.OrderByDescending(o => o.BrojPonuda).ToList();
break;
}
reportViewerIzvestaj.LocalReport.ReportEmbeddedResource = "Servis.Izvestaji.BrojIzdatihPonudaStampa.rdlc";
reportViewerIzvestaj.ProcessingMode = ProcessingMode.Local;
ReportDataSource _reportDataSource = new ReportDataSource("DS_StampaBrojIzdatihPonuda", (bool)checkBoxVeceOdNule.IsChecked ? _s.Where(f => f.BrojPonuda > 0) : _s);
reportViewerIzvestaj.LocalReport.DataSources.Clear();
reportViewerIzvestaj.LocalReport.DataSources.Add(_reportDataSource);
reportViewerIzvestaj.SetDisplayMode(DisplayMode.PrintLayout);
reportViewerIzvestaj.ZoomMode = ZoomMode.PageWidth;
reportViewerIzvestaj.RefreshReport();
}
else
{
Dijalog _dialog = new Dijalog("Obavezan podatak", "Odaberi vremenski opseg.");
//_dialog.WindowStyle = WindowStyle.ToolWindow;
_dialog.Owner = Window.GetWindow(this);
_dialog.WindowStartupLocation = WindowStartupLocation.CenterOwner;
_dialog.ShowDialog();
return;
}
}