本文整理汇总了C#中System.Windows.Documents.List.FindAll方法的典型用法代码示例。如果您正苦于以下问题:C# List.FindAll方法的具体用法?C# List.FindAll怎么用?C# List.FindAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.FindAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btn_delete_Click
private void btn_delete_Click(object sender, RoutedEventArgs e)
{
int recv;
byte[] rdata = new byte[1024*1024];
List<UserData> Delete_list = LUserdata.FindAll(p => { if (p.user.Ischecked) { return true; } return false; });
Delete_list.FindAll(p => { p.Count = Delete_list.Count; return true; });
Delete_list.FindAll(p => { p.Ischeckedcount = LUserdata.Count(t => t.user.Ischecked == true); return true; });
if (Delete_list.Count != 0)
{
string post_data = "&#D" + Delete_list.Count.ToString();
foreach (UserData item in Delete_list)
{
post_data = post_data + "&#" + item.user.Id + "::" +
item.user.Password + "::" +
((int)item.user.Power).ToString() + "::" +
((int)item.user.State).ToString();
}
byte[] tmp_data = Encoding.UTF8.GetBytes(post_data);
client.Send(tmp_data);
recv = client.Receive(rdata);
if (Encoding.UTF8.GetString(rdata, 0, recv) == "1")
{
LUserdata = LUserdata.FindAll(p => { if (p.user.Ischecked) { p.user.Ischecked = false; return p.user.Id != p.user.Id; } return true; });
LUserdata.FindAll(p => { p.Count = LUserdata.Count; return true; });
LUserdata.FindAll(p => { p.Ischeckedcount = LUserdata.Count(t => t.user.Ischecked == true); return true; });
if (LUserdata.Count == 0)
Tb_SelectCount.Text = "0";
UserInfo.DataContext = LUserdata;
Grid_Data.DataContext = LUserdata;
}
else
{
MessageBox.Show("删除用户失败!", "警告");
}
}
}
示例2: TwitterSampleStream
private void TwitterSampleStream()
{
ListWordsByFrequency frequencyList = new ListWordsByFrequency();
var logFile = System.IO.File.ReadAllLines(@"C:\Users\Daniel\Source\Repos\TwitterCrawl\positive-words.txt");
List <string> StringList = new List<string>(logFile);
Globals.Stream = Stream.CreateSampleStream();
int incomming = 0;
int success = 0;
Globals.Stream.TweetReceived += (sender, args) =>
{
Dispatcher.BeginInvoke(new Action(() =>
{
incomming++;
label.Content = incomming;
label1.Content = success;
string tweet = args.Tweet.ToString();
bool test = StringList.Any(tweet.Contains);
if (test)
{
success++;
txtBxTwitterFeed.Clear();
txtBxTwitterFeed.Text = tweet;
var matchingvalues = StringList.FindAll(tweet.Contains);
StringBuilder builder = new StringBuilder();
foreach (string v in matchingvalues) // Loop through all strings
{
builder.Append(v).Append(" "); // Append string to StringBuilder
}
frequencyList.split(builder.ToString());
rTxtBxFrequency.Document.Blocks.Clear();
rTxtBxFrequency.Document.Blocks.Add(new Paragraph(new Run(frequencyList.output)));
}
}));
};
}
示例3: Window_Loaded
private void Window_Loaded(object sender, RoutedEventArgs e)
{
standList = standBLL.GetModelList("");
List<Model.TB_StandardInfo> standListLevel1 = standList.FindAll(x => x.Stand_Level == 1);
lbLevel1.ItemsSource = standListLevel1;
//lbLevel1.SelectedIndex = 0;
lbLevel1.SelectedIndex = -1;
if (selectStandInfo1 != null) {
for (int i = 0; i < standListLevel1.Count; i++)
{
if (standListLevel1[i].ID == selectStandInfo1.ID)
{
lbLevel1.SelectedIndex = i;
break;
}
}
}
//lbLevel1.SelectedValue = selectStandInfo1;
}
示例4: lbxVisits_SelectionChanged
/* populates selected visit details */
private void lbxVisits_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (lbxVisits.SelectedIndex != -1)
{
/* If User clicks on previous visits while creating a visit
* ui needs to be updated for updating */
if (mode == Mode.create)
{
CreateNewVisitComplete();
}
if(TempVisitMedia!=null)
CleanupMedia.AddRange(TempVisitMedia.FindAll(m => m.Id == 0).Select(m => m.Path));
SelectedVisit = (Domain.Visit)lbxVisits.SelectedItem;
acbReferredBy.Text = SelectedVisit.ReferredBy;
acbDoctors_Email.Text = SelectedVisit.Doctors_Email;
acbDoctor.Text = SelectedVisit.Doctor;
dtDate_of_Examination.Text = SelectedVisit.Date_of_Examination.Date.ToString();
acbDiagnosis.Text = SelectedVisit.Diagnosis;
acbTreatment.Text = SelectedVisit.Treatment;
TempVisitSymptoms = SelectedVisit.Symptoms.ToList();
lbxSymptoms.ItemsSource = TempVisitSymptoms;
TempVisitTags = SelectedVisit.Tags.ToList();
lbxTags.ItemsSource = TempVisitTags;
TempVisitMedia = SelectedVisit.Media.ToList();
lbxVideos.ItemsSource = TempVisitMedia.FindAll(n => n.Type == Domain.MediumType.Video);
lbxImages.ItemsSource = TempVisitMedia.FindAll(n => n.Type == Domain.MediumType.Image);
acbSymptom.Text = "";
acbTag.Text = "";
UpdateVisit();
}
}
示例5: calcOverlappingDateTimeOfAllMusicians
private AvailableTime calcOverlappingDateTimeOfAllMusicians(AvailableTime timeToFit, List<AvailableTime> possibleTimes)
{
Boolean hadOneFit;
foreach (Musician m in currentBand.Musicians)
{
hadOneFit = false;
foreach (AvailableTime aT in possibleTimes.FindAll(time => time.Id == m.Id))
{
if (timeToFit.StartTime >= aT.StartTime && timeToFit.EndTime <= aT.EndTime
|| (timeToFit.EndTime >= aT.StartTime && timeToFit.EndTime <= aT.EndTime)
|| (timeToFit.StartTime <= aT.StartTime && timeToFit.EndTime >= aT.StartTime)
|| (timeToFit.StartTime <= aT.StartTime && timeToFit.EndTime >= aT.EndTime))
{
timeToFit.StartTime = new DateTime(Math.Max(timeToFit.StartTime.Ticks, aT.StartTime.Ticks));
timeToFit.EndTime = new DateTime(Math.Min(timeToFit.EndTime.Ticks, aT.EndTime.Ticks));
hadOneFit = true;
break;
}
}
if (hadOneFit == false)
{
timeToFit = null;
break;
}
}
return timeToFit;
}
示例6: GetXiaPanCounts
//下盘个数
List<string> GetXiaPanCounts(int Min, int Max, List<string> ListR)
{
List<string> ListStr = new List<string>();
ListStr = ListR.FindAll(t =>
{
string[] arry = t.Split(new char[] { '0', '1', '2' }, StringSplitOptions.None);
int count = arry.Length - 1;
return (Min <= count && count <= Max);
});
return ListStr;
}
示例7: FillGridWithInfo
private void FillGridWithInfo()//Fetching info for each cell of Info grid and placing it there
{
int rows = WeekGrid.Rows;//we will need row and column number to properly placing info into the grid;
int columns = WeekGrid.Columns;
List<Group> searchresult = new List<Group>();
foreach (ListView listView in WeekGrid.Children)
{
int index = WeekGrid.Children.IndexOf(listView);
int row = index / columns;
int column = index % columns;
searchresult = groups.FindAll(delegate(Group group)//Looking up if there are ny group for at this date;
{
DateTime weekday = GetStartOfCurrentWeek().AddDays(column);
return group.Date == weekday;
});
if (!searchresult.Any())//If there are none - setting empty labels.
{
for (int i = 0; i < listView.Items.Count; i++)
{
((Label)listView.Items[i]).Content = " ";
((Label)listView.Items[i]).Tag = null;
((Label)listView.Items[i]).Background = Brushes.White;
}
}
else if (searchresult.Any())//If there are any - we narrow search further to timeperiod.
{
searchresult = searchresult.FindAll(delegate(Group gp)
{
timeperiod time = (timeperiod)row;
return gp.Time == time;
});
if (!searchresult.Any())//If there are none, we again set all to empty;
{
for (int i = 0; i < listView.Items.Count; i++)
{
((Label)listView.Items[i]).Content = " ";
((Label)listView.Items[i]).Tag = null;
((Label)listView.Items[i]).Background = Brushes.White;
}
}
else if (searchresult.Any())//And if there are any we set them to appropriate posistions in list;
{
for (int i = 0; i < listView.Items.Count; i++)//we go through all labels on Listview
{
Group target = searchresult.Find(delegate(Group gp)//And see if there is group for this label
{//to be displayed
return gp.Room.Id == i + 1;//We check it by room id, because each label corresponds to unique room;
});
if (target != null)//If we get some result
{
((Label)listView.Items[target.Room.Id - 1]).Tag = target;//We place this group there
((Label)listView.Items[target.Room.Id - 1]).Content = target.Room.Type + ": " +target.Name;
((Label)listView.Items[i]).Background = Brushes.LightSeaGreen;//And display with text and color;
}
else
{
((Label)listView.Items[i]).Content = " ";//Again if there is nothing - setting all to empty;
((Label)listView.Items[i]).Tag = null;
((Label)listView.Items[i]).Background = Brushes.White;
}
}
}
}
}
}
示例8: GetTwitterNewsAPI11
public void GetTwitterNewsAPI11(string url)
{
TwitterStatuses.Clear();
if (string.IsNullOrEmpty(url)) {
TwitterStatuses.Add(new TwitterItemViewModel(LanguageManager) {
Title = LanguageManager.Model.NewsTwitterError + ": [ERRCODE 4 - No URL specified]",
Date = DateTime.Now
});
return;
}
Uri link = new Uri(url);
string response;
using (WebClient wc = new WebClientEx()) {
try {
response = wc.DownloadString(link);
} catch (Exception e) {
TwitterStatuses.Add(new TwitterItemViewModel(LanguageManager) {
Title = LanguageManager.Model.NewsTwitterError + ": " + e.Message + " [ERRCODE 3 - Remote Error]",
Date = DateTime.Now
});
return;
}
}
JArray tList;
try {
tList = JArray.Parse(System.Web.HttpUtility.HtmlDecode(response));
} catch {
TwitterStatuses.Add(new TwitterItemViewModel(LanguageManager) {
Title = LanguageManager.Model.NewsTwitterError + " [ERRCODE 1 - Parse Error]",
Date = DateTime.Now
});
return;
}
List<UserStatus> statuses = new List<UserStatus>();
List<ProfileImage> profileImages = new List<ProfileImage>();
List<ProfileImage> currentImage;
ProfileImage profileImage;
for (int i = 0; i < tList.Count(); i++) {
JObject tweet = JObject.Parse(tList[i].ToString());
UserStatus status = new UserStatus();
status.UserName = tweet["user"]["name"].ToString();
status.UserScreenName = tweet["user"]["screen_name"].ToString();
status.ProfileImageUrl = tweet["user"]["profile_image_url"].ToString();
var retweet = tweet["retweeted_status"];
if (retweet != null) {
status.UserScreenName = retweet["user"]["name"].ToString();
status.UserName = retweet["user"]["screen_name"].ToString();
status.RetweetImageUrl = retweet["user"]["profile_image_url"].ToString();
}
status.Status = tweet["text"].ToString();
status.StatusId = tweet["id"].ToString();
status.StatusDate = ParseDateTime(tweet["created_at"].ToString());
string profile_image;
if (status.RetweetImageUrl != null) {
profile_image = status.RetweetImageUrl;
} else {
profile_image = status.ProfileImageUrl;
}
currentImage = profileImages.FindAll(im => (im.url == profile_image));
if (currentImage.Count == 0) {
profileImage = new ProfileImage();
profileImage.url = profile_image;
profileImage.bitmap = GetImage(profile_image);
if (profileImage.bitmap != null) {
profileImages.Add(profileImage);
}
} else {
profileImage = currentImage[0];
}
status.ProfileImageBitmap = profileImage.bitmap;
statuses.Add(status);
}
foreach (UserStatus status in statuses) {
TwitterStatuses.Add(new TwitterItemViewModel(LanguageManager) {
Title = status.Status,
Date = status.StatusDate,
Image = status.ProfileImageBitmap,
StatusLink = "https://twitter.com/statuses/" + status.StatusId,
UserLink = "https://twitter.com/" + status.UserScreenName,
UserName = status.UserName
});
}
}
示例9: MenuItem_Click_2
private void MenuItem_Click_2(object sender, RoutedEventArgs e)
{
List<card> MissingCards = new List<card>();
foreach (card item in card.cardList)
{
int numberOfCard = getNumberOfCardInCollection(item.CardId);
int numberToHave;
if (item.Rarity == "Legendary")
{
numberToHave = 1;
}
else
{
numberToHave = 2;
}
for (int i = 0; i < numberToHave - numberOfCard; i++)
{
MissingCards.Add(item);
}
}
int missingDust = 0;
int missingDustClassic = 0;
int missingDustGvG = 0;
int missingDustTgT = 0;
unsafe
{
int* dust = null;
foreach (card item in MissingCards.FindAll(c => c.CardSet == "Classic" || c.CardSet == "Goblins vs Gnomes" || c.CardSet == "The Grand Tournament"))
{
switch (item.CardSet)
{
case "Classic":
dust = &missingDustClassic;
break;
case "Goblins vs Gnomes":
dust = &missingDustGvG;
break;
case "The Grand Tournament":
dust = &missingDustTgT;
break;
default:
break;
}
switch (item.Rarity)
{
case "Common":
*dust += 40;
break;
case "Rare":
*dust += 100;
break;
case "Epic":
*dust += 400;
break;
case "Legendary":
*dust += 1600;
break;
default:
break;
}
}
}
missingDust = missingDustClassic + missingDustGvG + missingDustTgT;
MessageBox.Show(missingDust.ToString());
}
示例10: lv_dropdetails_SelectionChanged
private void lv_dropdetails_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
try
{
if (e.AddedItems.Count > 0)
{
GetUndeclaredVaultDrops vd_select = e.AddedItems[0] as GetUndeclaredVaultDrops;
if (vd_select != null)
{
if (vd_select.Cassettes != null && vd_select.Cassettes.Count > 0)
{
lst_cassettes = vd_select.Cassettes;
if (Settings.AutoFillDeclaredAmount)
{
foreach (CassetteDropsResult casette in vd_select.Cassettes)
{
casette.DeclaredBalance = casette.VaultBalance.Value;
if (casette.EnableControls)
{
casette.Quantity = Convert.ToInt32(Math.Truncate(casette.DeclaredBalance / Convert.ToDecimal(casette.Denom.Value)));
}
}
}
p_cassette = lst_cassettes.Find(obj => obj.CassetteType_ID == (int)CassetteTypes.Cassette && !obj.EnableControls);
p_hopper = lst_cassettes.Find(obj => obj.CassetteType_ID == (int)CassetteTypes.Hopper && !obj.EnableControls);
if (lst_cassettes.FindAll(obj => obj.CassetteType_ID == (int)CassetteTypes.Cassette).Count == 0)
{
btnStart.Visibility = Visibility.Hidden;
}
else
{
btnStart.Visibility = Visibility.Visible;
}
lv_CassetteDetails.ItemsSource = lst_cassettes;
if (!vd_select.IsEmptyCassette)
{
vd_select.IsEmptyCassette = false;
}
vd_select.Declared_Balance = (p_cassette != null ? p_cassette.DeclaredBalance : 0) + (p_hopper != null ? p_hopper.DeclaredBalance : 0);
}
else
{
LoadEmptyCassette(vd_select);
if (lst_cassettes.FindAll(obj => obj.CassetteType_ID == (int)CassetteTypes.Cassette).Count == 0)
{
btnStart.Visibility = Visibility.Hidden;
}
else
{
btnStart.Visibility = Visibility.Visible;
}
vd_select.Declared_Balance = 0;
vd_select.IsEmptyCassette = true;
}
if (!vd_select.ToDeclared)
{
lblcounterWarning.Text = Application.Current.FindResource("Vault_MessageID16") as string;
}
else
{
lblcounterWarning.Text = "";
}
if (e.RemovedItems.Count > 0)
{
GetUndeclaredVaultDrops vd_removeselect = e.RemovedItems[0] as GetUndeclaredVaultDrops;
if (vd_removeselect != null)
{
if (vd_removeselect.Declared_Balance > 0 && vd_removeselect.ToDeclared)
{
if ((Settings.ShowVaultConfirmMessage) && MessageBox.ShowBox("Vault_MessageID15", BMC_Icon.Information, BMC_Button.YesNo) == System.Windows.Forms.DialogResult.Yes)
{
lv_dropdetails.SelectionChanged -= lv_dropdetails_SelectionChanged;
lv_dropdetails.SelectedItem = vd_removeselect;
bool IsValidAmount = false;
SaveVaultDeclaration(ref IsValidAmount);
lv_dropdetails.SelectionChanged += lv_dropdetails_SelectionChanged;
return;
}
else
{
foreach (CassetteDropsResult casette in vd_removeselect.Cassettes)
{
casette.Quantity = 0;
casette.DeclaredBalance = 0;
}
}
}
else
{
foreach (CassetteDropsResult casette in vd_removeselect.Cassettes)
{
//.........这里部分代码省略.........
示例11: CheckCopyDataGridContents
/// <summary>
/// DataGridの異なる行異なる列を選択したコピーの禁止処理
/// </summary>
/// <returns></returns>
bool CheckCopyDataGridContents()
{
List<System.Windows.Point> rowAndColList = new List<System.Windows.Point>();
List<int> copyRowList = new List<int>();
List<int> copyColumnList = new List<int>();
var cells = upperdatagrid.SelectedCells;
foreach (DataGridCellInfo cell in cells)
{
rowAndColList.Add(
new System.Windows.Point(upperdatagrid.Items.IndexOf(cell.Item), cell.Column.DisplayIndex));
int b = copyColumnList.Find(s => s == cell.Column.DisplayIndex);
if (copyColumnList.Count == 0 || !copyColumnList.Contains(cell.Column.DisplayIndex))
{
copyColumnList.Add(cell.Column.DisplayIndex);
}
if (copyRowList.Count == 0 || !copyRowList.Contains(upperdatagrid.Items.IndexOf(cell.Item)))
{
copyRowList.Add(upperdatagrid.Items.IndexOf(cell.Item));
}
}
int copyRangeColumn = copyColumnList.Count;
int copyRangeRow = copyRowList.Count;
bool validCopyFlag = true;
//複数コピーの禁止
//全てのXがコピーした列数分だけ存在するか、すべてのYがコピーした行数分だけ存在する
foreach (var y in copyColumnList)
{
validCopyFlag = true;
if (rowAndColList.FindAll(s => s.Y == y).Count != copyRangeRow)
{
validCopyFlag = false;
break;
}
}
foreach (var x in copyRowList)
{
validCopyFlag = true;
if (rowAndColList.FindAll(s => s.X == x).Count != copyRangeColumn)
{
validCopyFlag = false;
break;
}
}
if (!validCopyFlag)
{
System.Windows.Forms.MessageBox.Show(AnimeCheckerByXaml.Properties.Settings.Default.E0004,
"エラー", System.Windows.Forms.MessageBoxButtons.OK,
System.Windows.Forms.MessageBoxIcon.Error);
return false;
}
return true;
}
示例12: btn_show_Click
private void btn_show_Click(object sender, RoutedEventArgs e)
{
int recv;
byte[] rdata = new byte[1024 * 1024];
LUserdata = new List<UserData>();
LUser = new List<User>();
Edit_list = new List<string>();
byte[] tmp_data = Encoding.UTF8.GetBytes("&#GET");
client.Send(tmp_data);
recv = client.Receive(rdata);
string[] get_info = (Encoding.UTF8.GetString(rdata, 0, recv)).Split(new string[] { "&#" }, StringSplitOptions.RemoveEmptyEntries);
foreach (string item in get_info)
{
string[] user = item.Split(new string[] { "::" }, StringSplitOptions.RemoveEmptyEntries);
Power p = (Power)Int32.Parse(user[2]);
State s = (State)Int32.Parse(user[3]);
string Online = "";
switch (user[6])
{
case "0":
Online = "离线";
break;
case "1":
Online = "在线";
break;
default:
break;
}
LUser.Add(new User
{
Id = user[0],
Password = user[1],
Power = p,
State = s,
Lastlogin = user[4],
Tcount = Int32.Parse(user[5]),
Isonline = Online,
Ischecked = false
});
}
foreach (var item in LUser)
{
UserData Udata = new UserData();
Udata.user = item;
Udata.Count = LUser.Count;
Udata.Ischeckedcount = LUser.Count(p => p.Ischecked == true);
LUserdata.Add(Udata);
}
//bind
UserInfo.DataContext = LUserdata;
LUserdata = LUserdata.FindAll(p => { if (p.user.Ischecked) { p.user.Ischecked = false; return p.user.Id != p.user.Id; } return true; });
LUserdata.FindAll(p => { p.Count = LUserdata.Count; return true; });
LUserdata.FindAll(p => { p.Ischeckedcount = LUserdata.Count(t => t.user.Ischecked == true); return true; });
if (LUserdata.Count == 0)
Tb_SelectCount.Text = "0";
Grid_Data.DataContext = LUserdata;
}
示例13: GetGoupSum
//分组和值
List<string> GetGoupSum(string terms, List<string> ListR)
{
List<string> ListStr = new List<string>();
string[] arrTerms = terms.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string term in arrTerms)
{
string nums = term.Split('|')[0];
string nums2 = term.Split('|')[1];
string[] strs = nums.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
List<int> number = new List<int>();
for (int i = 0; i < strs.Length; i++)
{
if (strs[i] == "Y")
{
number.Add(i);
}
}
double Min = double.Parse(nums2.Split('-')[0]);
double max = double.Parse(nums2.Split('-')[1]);
ListR = ListR.FindAll(t =>
{
bool isOK = false;
int sum = 0;
foreach (int i in number)
{
if (t[i].ToString() != "*")
{
sum += int.Parse(t[i].ToString());
}
else
{
isOK = true;
}
}
return isOK || (Min <= sum && sum <= max);
});
}
ListStr = ListR;
return ListStr;
}
示例14: GetSumCounts
//号码和值
List<string> GetSumCounts(int Min, int Max, List<string> ListR)
{
List<string> ListStr = new List<string>();
ListStr = ListR.FindAll(t =>
{
t = t.Replace("*", "");
int sum = 0;
foreach (char c in t)
{
sum += int.Parse(c.ToString());
}
return (Min <= sum && sum <= Max);
});
return ListStr;
}
示例15: GetThreeCounts
//3的个数/1的个数/0的个数
private List<string> GetThreeCounts(int Min, int Max, string Num, List<string> ListR)
{
List<string> ListStr = new List<string>();
string Reg1 = "";//匹配最小值正则
string Reg = "";//匹配最大值正则
if (Min == 0)
{
Reg1 = @"(\d|\*)*";
}
else
{
for (int i = 0; i < Min; i++)
{
Reg1 += @"(\d|\*)*" + Num + @"(\d|\*)*";
}
}
if (Max == 0)
{
Reg = @"(\d|\*)*" + Num + @"(\d|\*)*";
}
else
{
for (int j = 0; j < Max; j++)
{
Reg += @"(\d|\*)*" + Num + @"(\d|\*)*";
}
Reg += @"(\d|\*)*" + Num + @"(\d|\*)*";
}
ListStr = ListR.FindAll(t => Regex.Match(t, Reg1).Success);
ListStr = ListStr.FindAll(t => !Regex.Match(t, Reg).Success);
return ListStr;
}