本文整理汇总了C#中System.Windows.Documents.List.GetRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.GetRange方法的具体用法?C# List.GetRange怎么用?C# List.GetRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.GetRange方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PackageRecords
public List<RecordPackage> PackageRecords(List<Record> records)
{
var packages = new List<RecordPackage>();
int groupCount = records.Count / RecordPackage.PackageSize + 1;
for (int i = 0; i < groupCount; i++) {
int index = i * RecordPackage.PackageSize;
int count = index + RecordPackage.PackageSize < records.Count ?
RecordPackage.PackageSize : records.Count - index;
var group = records.GetRange(index, count);
packages.Add(new RecordPackage(group));
}
return packages;
}
示例2: GetStartCorrectedFrames
public static List<Skeleton> GetStartCorrectedFrames(List<Skeleton> test, List<Skeleton> action)
{
test = KinectFrameUtils.AlignFrames(test, action.Count);
double dist = GetTotalDistTraveled(action);
int frameStart = -1;
int rawStart = -1;
for (int i = 0; i < action.Count; i++)
{
if (KinectFrameUtils.GetTotalDistTraveled(action.GetRange(0, i)) > (dist / 5) && frameStart < 0)
{
frameStart = i;
}
if (KinectFrameUtils.GetTotalDistTraveled(test.GetRange(0, i)) > (dist / 5) && rawStart < 0)
{
rawStart = i;
}
}
int diff = frameStart - rawStart;
if (diff > 0)
{
for (int i = 0; i < diff; i++)
{
test = AlignFrames(test, test.Count - 1);
test.Insert(0, test[0]);
}
}
else
{
for (int i = 0; i < -diff; i++)
{
test.RemoveAt(0);
test.Add(test[test.Count - 1]);
}
}
return test;
}
示例3: UpdateCompositeFeed
public void UpdateCompositeFeed()
{
CompositeFeed composite = this.Feeds[3] as CompositeFeed;
List<FeedItem> items = new List<FeedItem>();
foreach (Feed feed in this.Feeds)
{
items.AddRange(feed.Items);
// items.AddRange(feed.Items.ToList().GetRange(0, composite.MaxItems));
}
// on classe du plus recent au plus vieux, donc on inverse item1 et item2 dans la comparaison
items.Sort((item1, item2) => item2.PublicationDate.CompareTo(item1.PublicationDate));
composite.Items = new ObservableCollection<FeedItem>(items.GetRange(0, composite.MaxItems));
}
示例4: btn_eval_click
private void btn_eval_click(object sender, RoutedEventArgs e)
{
var reader = new StreamReader(new FileStream(outputFile, FileMode.Open));
var calculatedSequence = new List<string>();
var calculatedLatency = new List<KeyValuePair<string,int>>();
float countAll = 0;
float countHit = 0;
int latency = 0;
while (!reader.EndOfStream)
{
var line = reader.ReadLine();
if (line.Contains("==="))
{
calculatedSequence.Clear();
latency = 0;
}
if (line.Contains("%"))
{
int sequenceHit = 0;
countAll++;
calculatedSequence.Add(line.Split('%')[0].Trim());
var originalLabel = line.Split('%')[1].Substring(1).Trim();
foreach (string lbl in calculatedSequence)
{
if (!lbl.Equals(originalLabel) && sequenceHit == 0)
latency++;
else
sequenceHit++;
}
// EVALUATION: berechnete Werte entsprechen zu einem drittel des erwarteten Labels und das ziellabel ist mindestens einmal in den letzten 5 Frames enthalten
if (sequenceHit >= calculatedSequence.Count*0.33 && calculatedSequence.GetRange(calculatedSequence.Count-6,5).Contains(originalLabel))
countHit++;
else
latency = -1;
calculatedLatency.Add(new KeyValuePair<string,int>(originalLabel,latency));
}
else
{
if (!String.IsNullOrWhiteSpace(line))
calculatedSequence.Add(line.Trim());
}
}
reader.Close();
float q = countHit / countAll;
double latOverall = calculatedLatency.Sum(i => i.Value) / calculatedLatency.Count;
box_eval.Document.Blocks.Add(new Paragraph(new Run(String.Format("Gesamt:\t{0}\nTreffer:\t{1}\nQuote:\t{2} %\n=================================\n",
countAll, countHit, q * 100, latOverall*100))));
var latencyOutput = "";
var latencySum = 0.0;
var latencyCount = 0;
foreach (var lat in calculatedLatency)
{
if (lat.Value >= 0)
{
latencyOutput += String.Format("'{0}' erkannt nach {1} Frames. (= {2} ms)\n", lat.Key, lat.Value, lat.Value * 100);//100ms (3*33ms bei 30 fps)
latencySum += lat.Value;
latencyCount++;
}
else
latencyOutput += String.Format("'{0}' nicht erkannt!\n", lat.Key);
}
box_eval.Document.Blocks.Add(new Paragraph(new Run(String.Format("{0}\nDurchschnittliche Latenz aller erkannten Labels: {1:000.0} ms",latencyOutput, (latencySum/latencyCount)*100))));
}
示例5: GetFullFeed
/*************************************************************
*
* GetFullFeed
*
*************************************************************/
private async void GetFullFeed ()
{
FeedDict fd = FetchLocalFeedAsDictionary ();
Feed feed = await FetchTastyTradeFeed ();
foreach (FeedItem fi in feed)
{
if (!fd.ContainsKey (fi.PubDate))
{
fd[fi.PubDate] = fi;
}
}
m_DomainFeed = (from pair in fd
orderby pair.Key descending
select pair.Value).ToList ();
m_FavouriteFeed = (from fi in m_DomainFeed where Favourited (fi) select fi).ToList ();
m_DisplayedFeed = m_DomainFeed.GetRange (CurrentOffset, Math.Min (m_DomainFeed.Count, 50));
CurrentOffset = 0;
FeedGrid.DataContext = m_DisplayedFeed;
}
示例6: btnLocalFiles_Click
/***************************************************************************
*
* LocalFiles only
*
***************************************************************************/
private void btnLocalFiles_Click (object sender, RoutedEventArgs e)
{
if (btnLocalFiles.IsChecked == true)
{
m_DomainFeed = new List<FeedItem> ();
string path = RootDir; // (string) App.Current.Resources["PodcastPath"];
var folders = Directory.EnumerateDirectories (path);
foreach (var folder in folders)
{
string f = new DirectoryInfo (folder).Name;
try
{
DateTime dt = DateTime.ParseExact (f, "yyyy-MMM-dd HHmm", CultureInfo.InvariantCulture);
using (StreamReader sr = new StreamReader (folder + "\\feed.xml"))
{
XmlSerializer xr = new XmlSerializer (typeof (FeedItem));
FeedItem fi = (FeedItem) xr.Deserialize (sr);
/* Update Image and Movie nodes
---------------------------- */
fi.Image = ConvertToUrlForm (fi.LocalImage);
fi.Movie = ConvertToUrlForm (fi.LocalMovie);
m_DomainFeed.Add (fi);
}
}
catch (Exception )
{
// skip. could be irrelevant folder
}
}
m_DomainFeed = m_DomainFeed.OrderByDescending ((s) => s.PubDate).ToList ();
CurrentOffset = 0;
m_FavouriteFeed = (from fi in m_DomainFeed where Favourited (fi) select fi).ToList ();
m_DisplayedFeed = m_DomainFeed.GetRange (CurrentOffset, Math.Min (m_DomainFeed.Count, 50));
FeedGrid.DataContext = m_DisplayedFeed;
}
else
{
GetFullFeed ();
}
}
示例7: InputTextBox_KeyUp
private void InputTextBox_KeyUp(object sender, KeyEventArgs e)
{
try
{
if (e.Key == Key.Enter)
{
if (InputTextBox.Text.Length > 0)
{
PacketHelper packetHelper = new PacketHelper((byte)Convert.ToInt16("01111110", 2), InputTextBox.Text.ToCharArray(), 19, 1, 1, 1);
List<Packet> packets = packetHelper.GetPackets();
List<bool> data = new List<bool>();
StringBuilder stringBuilder = new StringBuilder();
int n = 1;
foreach (Packet packet in packets)
{
data.AddRange(packet.EncodedData);
// stringBuilder.AppendLine(string.Format("Packet #{0}", n++));
// stringBuilder.AppendLine(PacketHelper.BinDataToString(packet.EncodedData));
}
// PacketInfoTextBox.Text = stringBuilder.ToString();
int numOfBits = data.Count;
int numOfCycles = numOfBits % 8 == 0 ? numOfBits : numOfBits + 1;
List<byte> dataToSend = new List<byte>();
for (int i = 0; i < numOfCycles / 8; i++)
{
if (i != numOfCycles / 8 - 1)
{
dataToSend.Add((byte)Convert.ToInt16(PacketHelper.BinDataToString(data.GetRange(i * 8, 8)), 2));
}
else
{
dataToSend.Add((byte)Convert.ToInt16(PacketHelper.BinDataToString(data.GetRange(i * 8, numOfBits - i * 8)), 2));
}
}
_serialPortCOM1.RtsEnable = true;
_serialPortCOM1.Write(dataToSend.ToArray(), 0, dataToSend.Count);
Thread.Sleep(100);
_serialPortCOM1.RtsEnable = false;
//InputTextBox.Clear();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
示例8: GetFriendList
private void GetFriendList(int page)
{
m_progressIndicatorHelper.PushTask();
String myID = PreferenceHelper.GetPreference("Douban_ID");
if (String.IsNullOrEmpty(myID))
return;
if (!m_bAllListLoaded)
{
m_doubanAPI.GetFollowingUserList(myID, (GetFollowingUserListEventArgs e) =>
{
if (e.errorCode == DoubanSdkErrCode.SUCCESS && e.userList != null)
{
m_allList = e.userList;
m_pageCount = (int)Math.Ceiling((double)m_allList.Count / (double)MAX_PER_PAGE);
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
FriendList.Clear();
int lengthLeft = m_allList.Count - page * MAX_PER_PAGE;
int cutLength = lengthLeft < MAX_PER_PAGE ? lengthLeft : MAX_PER_PAGE;
List<FollowingUserInfo> tempList = m_allList.GetRange(page * MAX_PER_PAGE, cutLength);
foreach (FollowingUserInfo user in tempList)
{
FriendList.Add(user);
}
m_progressIndicatorHelper.PopTask();
});
}
else
{
m_progressIndicatorHelper.PopTask();
}
});
}
else
{
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
FriendList.Clear();
int lengthLeft = m_allList.Count - page * MAX_PER_PAGE;
int cutLength = lengthLeft < MAX_PER_PAGE ? lengthLeft : MAX_PER_PAGE;
List<FollowingUserInfo> tempList = m_allList.GetRange(page * MAX_PER_PAGE, cutLength);
foreach (FollowingUserInfo user in tempList)
{
FriendList.Add(user);
}
m_progressIndicatorHelper.PopTask();
});
}
}