本文整理汇总了C#中System.Windows.Documents.List.RemoveRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.RemoveRange方法的具体用法?C# List.RemoveRange怎么用?C# List.RemoveRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.List
的用法示例。
在下文中一共展示了List.RemoveRange方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnExtractImage_Click
private void btnExtractImage_Click(object sender, RoutedEventArgs e)
{
try
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.Title = "Save the extracted BLF Image";
sfd.Filter = "JPEG Image (*.jpg)|*.jpg";
sfd.FileName = lblBLFname.Text.Replace(".blf", "");
if ((bool)sfd.ShowDialog())
{
List<byte> imageToExtract = new List<byte>(_blf.BLFChunks[1].ChunkData);
imageToExtract.RemoveRange(0, 0x08);
File.WriteAllBytes(sfd.FileName, imageToExtract.ToArray<byte>());
MetroMessageBox.Show("Exracted!", "The BLF Image has been extracted.");
}
}
catch (Exception ex)
{
MetroMessageBox.Show("Extraction Failed!", "The BLF Image failed to be extracted: \n " + ex.Message);
}
}
示例2: DoSearch
private void DoSearch()
{
if (Service == null) {
return;
}
string division = null;
if (chkRestrictPlaceType.IsChecked.ValueOrFalse() && !string.IsNullOrEmpty(cmbPlaceType.Text)) {
division = cmbPlaceType.SelectedItem as string;
}
btnCancel.IsEnabled = true;
btnSearch.IsEnabled = false;
Cancelled = false;
var delta = 0.2; // degrees to go out each time...
var latitude = ctlPosition.Latitude;
var longitude = ctlPosition.Longitude;
var info = Service.GetGazetteerInfo();
int maxResults = Int32.Parse(txtMaxResults.Text);
maxResults = Math.Min(maxResults, info.RecordCount);
JobExecutor.QueueJob(() => {
double range = 0;
int count = 0;
try {
double x1, y1, x2, y2;
while (count < maxResults && range < 50 && !Cancelled) {
StatusMessage("Searching for places near {0} (+/- {1} degrees). {2} places found.", GeoUtils.FormatCoordinates(latitude, longitude), range, count);
range += delta;
y1 = latitude - range;
y2 = latitude + range;
x1 = longitude - range;
x2 = longitude + range;
count = Service.CountPlacesInBoundedBox(x1, y1, x2, y2, division);
}
this.InvokeIfRequired(() => {
this.Cursor = Cursors.Wait;
});
StatusMessage("Retrieving places near {0} (+/- {1} degrees). {2} places found.", GeoUtils.FormatCoordinates(latitude, longitude), range, count);
y1 = latitude - range;
y2 = latitude + range;
x1 = longitude - range;
x2 = longitude + range;
var list = Service.GetPlacesInBoundedBox(x1, y1, x2, y2, division);
var model = new List<PlaceNameViewModel>( list.Select((m) => {
var vm = new PlaceNameViewModel(m);
vm.Distance = GeoUtils.GreatCircleArcLength(m.Latitude, m.Longitude, latitude, longitude, DistanceUnits);
string direction = "";
var numPoints = (vm.Distance < 10 ? 16 : 32);
direction = GeoUtils.GreatCircleArcDirection(m.Latitude, m.Longitude, latitude, longitude, numPoints);
vm.Offset = String.Format("{0:0.0} {1} {2}", vm.Distance, "KM", direction);
return vm;
}));
model.Sort(new Comparison<PlaceNameViewModel>((o1, o2) => {
return (int) (o1.Distance - o2.Distance);
}));
if (model.Count > maxResults) {
model.RemoveRange(maxResults, model.Count - maxResults);
}
lstResults.InvokeIfRequired(() => {
lstResults.ItemsSource = model;
CollectionView myView = (CollectionView)CollectionViewSource.GetDefaultView(lstResults.ItemsSource);
myView.SortDescriptions.Add(new SortDescription("Distance", ListSortDirection.Ascending));
});
if (!Cancelled) {
StatusMessage("{0} places retrieved.", model.Count);
} else {
StatusMessage("{0} places retrieved (Cancelled).", model.Count);
}
} finally {
this.InvokeIfRequired(() => {
btnCancel.IsEnabled = false;
btnSearch.IsEnabled = true;
this.Cursor = Cursors.Arrow;
});
}
});
}
示例3: saveEdits_Click
private void saveEdits_Click(object sender, RoutedEventArgs e)
{
if (MessageBox.Show("Save changes to ID3 tags?\nWarning: If you have any tags other than Title, Artist, Album and Genre, they will be removed.", "Save", MessageBoxButton.YesNo, MessageBoxImage.Question) == MessageBoxResult.Yes)
{
TagLib.File temp;
List<Song> remove = new List<Song>();
foreach (Song s in editedSongs)
{
try
{
temp = TagLib.File.Create(searchdir + "\\" + s.getFilename());
temp.Tag.Performers = s.Artist.Split(';');
temp.Tag.Title = s.Title;
temp.Tag.Album = s.Album;
temp.Tag.Genres = s.Genre.Split(';');
temp.Save();
}
catch (IOException err)
{
MessageBox.Show("There was an error while saving the file: " + err.Message, "Save Error", MessageBoxButton.OK, MessageBoxImage.Warning);
}
}
foreach (Song s in remove)
{
editedSongs.Remove(s);
}
remove.RemoveRange(0, remove.Count);
}
else
{
return;
}
}
示例4: mWorker_GetSeries
// Do some live capturing in here...
private void mWorker_GetSeries(object sender, DoWorkEventArgs e)
{
const int windowSize = 400;
List<Tuple<double,double>> y = new List<Tuple<double, double>>(windowSize);
mSerialPort.DiscardInBuffer();
while (!mTestWorker.CancellationPending) {
GetSerialData(ref y);
// continue if not enough input data sampled...
if (y.Count < windowSize)
continue;
// resize captured data to windowSize - default nothing should be removed...
//y.RemoveRange(windowSize, y.Count - windowSize);
var minValue = double.MaxValue;
Int64 ValXIndex = 0;
Int64 ValYIndex = 0;
string Pattern = "";
double[] bufX = y.Select(x => x.Item1).ToArray();
double[] bufY = y.Select(x => x.Item2).ToArray();
ucr_index resultX = new ucr_index();
ucr_index resultY = new ucr_index();
// apply recorded series to all trained
foreach (var item in mTrainedSeries) {
// compare each trained sequence with currently captured one - X values only atm
double[] trainedX = item.Value.Select(x => x.Item1).ToArray();
double[] trainedY = item.Value.Select(x => x.Item2).ToArray();
// compare x and y signals
if ((ucr_query(trainedX, trainedX.Length, 0.5, bufX, bufX.Length, ref resultX) < 0) /*||
(ucr_query(trainedY, trainedY.Length, 0.5, bufY, bufY.Length, ref resultY) < 0)*/) {
continue;
}
double result = resultX.value + resultY.value;
if (result < minValue) {
minValue = result;
ValXIndex = resultX.index;
ValYIndex = resultY.index;
Pattern = item.Key;
}
}
if (minValue < 3.0) {
mDispatcher.Invoke(() => {
TimerLabel.Content = Pattern + " DETECTED" + "\nCost: " + minValue;
if (Pattern == "Serie #0") {
DetectionLight1.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0x00, 0xFF, 0x00));
} else if (Pattern == "Serie #1") {
DetectionLight2.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0x00, 0xFF, 0x00));
} else if (Pattern == "Serie #2") {
DetectionLight3.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0x00, 0xFF, 0x00));
} else {
DetectionLightx.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0x00, 0xFF, 0x00));
}
});
// clear found pattern from sampled signal to ensure that it is only detected once
int cnt = mTrainedSeries[Pattern].Count;
int start = (int)Math.Min(ValXIndex, ValYIndex);
for (int i = start; i < start + cnt; i++) {
y[i] = y[start];
}
//y.RemoveRange(start, cnt);
//y.InsertRange(start, new List<Tuple<double, double>>(cnt));
} else {
// print result
mDispatcher.Invoke(() => {
TimerLabel.Content = Pattern + "\nCost: " + minValue;
DetectionLight1.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0xFF, 0x00, 0x00));
DetectionLight2.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0xFF, 0x00, 0x00));
DetectionLight3.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0xFF, 0x00, 0x00));
DetectionLightx.Fill = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(0xFF, 0x00, 0x00));
});
}
//y.RemoveAt(0);
y.RemoveRange(0, 50); // discard values for a half second
}
e.Cancel = true;
}
示例5: BuildDatasets
/// <summary>
/// Build the datasets and analyze the statistics for each dataset
/// </summary>
/// <returns>An <c>AnalysisStatus</c> enumeration indicating whether the analysis process completed successfuly.</returns>
private Enums.AnalysisStatus BuildDatasets()
{
Enums.AnalysisStatus status = Enums.AnalysisStatus.Success;
DateTime start_step = new DateTime();
DateTime end_step = new DateTime();
TimeSpan time_step = new TimeSpan();
List<double> set;
List<double> diffs;
List<Point> data_set;
TestDataset test_dataset;
_process_log.Add(DateTime.Now.ToString() + ": Build Datasets: Started.");
start_step = DateTime.Now;
_progress.Current = _progress.Minimum;
_background_worker.ReportProgress(_progress.Current);
for (int i = 0; i < _indices.Count; i++)
{
// Build the individual dataset from the full dataset
set = new List<double>();
for (int j = 0; j < _full_data.Count; j++)
{
if (i == _full_data[j].Index)
set.Add(Math.Round(_full_data[j].DatumValue, Constants.StatisticsDecimalPlaces));
_progress.Current = (int)((i * _full_data.Count + j) / (_indices.Count * _full_data.Count) * 100 / 2);
_background_worker.ReportProgress(_progress.Current);
}
// If the individual dataset has a statistically significant number of points, add the dataset to the results
if (set.Count >= Constants.StatisticsThreshholdDefault)
{
data_set = new List<Point>();
diffs = new List<double>();
for (int j = 1; j < set.Count; j++)
{
// Offset the data to the desired number of decimal places and then round-off properly
double d = (set[j] - set[j - 1]) / Math.Pow(10, Constants.StatisticsDecimalOffsetExponentDefault);
d = Math.Round(d, Constants.StatisticsDecimalPlaces + Constants.StatisticsDecimalOffsetExponentDefault);
diffs.Add(d);
}
// Remove the first couple points that tend to have errors relative
// to the rest of the data set
set.RemoveRange(0, Constants.StatisticsRemoveLeadingDefault + 1);
diffs.RemoveRange(0, Constants.StatisticsRemoveLeadingDefault);
for (int j = 0; j < set.Count; j++)
{
data_set.Add(new Point(set[j], diffs[j]));
}
test_dataset = new TestDataset();
test_dataset.Settings = _analysis_settings;
test_dataset.DatasetIdent = _indices[i];
test_dataset.Points = data_set;
test_dataset.JitterStats.Dataset = data_set;
test_dataset.BuildHistogram();
Results.Datasets.Add(test_dataset);
}
}
_progress.Current = _progress.Maximum;
_background_worker.ReportProgress(_progress.Current);
end_step = DateTime.Now;
time_step = TimeSpan.FromTicks(end_step.Ticks - start_step.Ticks);
_process_log.Add(DateTime.Now.ToString() + ": Build Datasets: Completed in " + time_step.TotalSeconds.ToString() + " s");
return status;
}
示例6: parseTmpFile
private void parseTmpFile()
{
// Analysis
List<DateTime> timestamps = new List<DateTime>();
List<string> events = new List<string>();
List<string> targets = new List<string>();
List<int> userID = new List<int>();
List<int> visitors = new List<int>();
foreach (string line in this.TMP_FILE)
{
string tmp_line = line + '\t';
string tmp_element = "";
int tabs = 0;
foreach (char c in tmp_line)
{
if (c != '\t')
tmp_element += c;
else
{
switch (tabs)
{
case 0:
timestamps.Add(parseTmpElementForDateTime(tmp_element));
break;
case 1:
events.Add(parseTmpElementForEvent(tmp_element));
break;
case 2:
targets.Add(parseTmpElementForTarget(tmp_element));
break;
case 3:
userID.Add(parseTmpElementForUserID(tmp_element));
break;
case 4:
visitors.Add(parseTmpElementForUsers(tmp_element));
break;
default:
break;
}
++tabs;
tmp_element = "";
}
}
}
// Cut upper lines
timestamps.RemoveRange(0, 2);
timestamps.RemoveRange((timestamps.Count - 1), 1);
events.RemoveRange(0, 1);
targets.RemoveRange(0, 1);
userID.RemoveRange(0, 1);
visitors.RemoveRange(0, 1);
// Cut to last active event
cutToLastEvent(ref timestamps, ref events, ref targets, ref userID, ref visitors);
this.timestamps.Add(timestamps);
this.events.Add(events);
this.targets.Add(targets);
this.userID.Add(userID);
this.visitors.Add(visitors);
}
示例7: cutToLastEvent
private void cutToLastEvent(ref List<DateTime> timestamps, ref List<string> events, ref List<string> targets, ref List<int> userID, ref List<int> visitors)
{
int cutIndex = getLastEvent(events) + 2;
int cutRange = timestamps.Count - cutIndex;
// Cut to last active event
timestamps.RemoveRange(cutIndex, cutRange);
events.RemoveRange(cutIndex, cutRange);
targets.RemoveRange(cutIndex, cutRange);
userID.RemoveRange(cutIndex, cutRange);
visitors.RemoveRange(cutIndex, cutRange);
}
示例8: loadBLF
private void loadBLF()
{
try
{
_blf = new PureBLF(_blfLocation);
List<byte> imgChunkData = new List<byte>(_blf.BLFChunks[1].ChunkData);
imgChunkData.RemoveRange(0, 0x08);
Dispatcher.Invoke(new Action(delegate
{
BitmapImage image = new BitmapImage();
image.BeginInit();
image.StreamSource = new MemoryStream(imgChunkData.ToArray());
image.EndInit();
imgBLF.Source = image;
// Add Image Info
paneImageInfo.Children.Insert(0, new Components.MapHeaderEntry("Image Width:", image.PixelWidth + "px"));
paneImageInfo.Children.Insert(1, new Components.MapHeaderEntry("Image Height", image.PixelHeight + "px"));
// Add BLF Info
paneBLFInfo.Children.Insert(0, new Components.MapHeaderEntry("BLF Length:", "0x" + _blf.BLFStream.Length.ToString("X")));
paneBLFInfo.Children.Insert(1, new Components.MapHeaderEntry("BLF Chunks:", _blf.BLFChunks.Count.ToString()));
if (Settings.startpageHideOnLaunch)
Settings.homeWindow.ExternalTabClose(Windows.Home.TabGenre.StartPage);
RecentFiles.AddNewEntry(new FileInfo(_blfLocation).Name, _blfLocation, "BLF Image", Settings.RecentFileType.BLF);
}));
}
catch (Exception ex)
{
Dispatcher.Invoke(new Action(delegate
{
MetroMessageBox.Show("Unable to open BLF", ex.Message.ToString());
Settings.homeWindow.ExternalTabClose((TabItem)this.Parent);
}));
}
}
示例9: InsertCard
private void InsertCard(List<Ruban> comers, double xb, double yb)
{
if (comers.Count > ORCHIS_CAP)
{
comers.RemoveRange(0, comers.Count - ORCHIS_CAP);
OrchisAni(onBoards.ToList(), EMPTY_LIST, comers.ToList(), xb, yb);
}
else if (onBoards.Count + comers.Count > ORCHIS_CAP)
{
int diff = onBoards.Count + comers.Count - ORCHIS_CAP;
List<Ruban> take = onBoards.GetRange(0, diff).ToList();
List<Ruban> leave = onBoards.GetRange(diff, onBoards.Count - diff).ToList();
OrchisAni(take, leave, comers.ToList(), xb, yb);
}
else
OrchisAni(EMPTY_LIST, onBoards.ToList(), comers.ToList(), xb, yb);
}
示例10: SelectionChangedAbst
private void SelectionChangedAbst()
{
var wep = (string)weapon.SelectedValue;
var ru = (string)rule.SelectedValue;
var stg = (string)stage.SelectedValue;
NowView = Datas.Where(p =>
{
bool re = true;
if (wep != "すべて")
{
re &= p.Weapon == wep;
}
if (ru != "すべて")
{
if (ru != "ガチマッチ")
{
re &= p.BattleType.ToString() == ru;
}
else
{
re &= p.BattleType.ToString().StartsWith("ガチ");
}
}
if (stg != "すべて")
{
re &= p.Stage == stg;
}
return re;
}).ToList();
switch ((ViewCount)viewCount.SelectedItem)
{
case ViewCount.最近30試合:
if (NowView.Count > 30)
{
NowView.RemoveRange(0, NowView.Count - 30);
}
break;
case ViewCount.最近50試合:
if (NowView.Count > 50)
{
NowView.RemoveRange(0, NowView.Count - 50);
}
break;
case ViewCount.最近100試合:
if (NowView.Count > 100)
{
NowView.RemoveRange(0, NowView.Count - 100);
}
break;
}
if (weapon.SelectedIndex == 0 && rule.SelectedIndex == 0 && stage.SelectedIndex == 0 && viewCount.SelectedIndex == 0)
{
message.Content = "全" + Datas.Count + "件";
}
else
{
message.Content = "全" + Datas.Count + "件中" + NowView.Count + "件";
}
Analysis();
}
示例11: InitializeSlider
public void InitializeSlider()
{
try
{
List<TVMWPFLab.Control.Resolution.DEVMODE> allMode = new List<TVMWPFLab.Control.Resolution.DEVMODE>();
allMode = r.getAllResolution();
List<string> ListSize = new List<string>();
List<string> ListResolutionDesc0 = new List<string>();
ListResolution = new List<ResolutionStruct>();
foreach (Resolution.DEVMODE dm in allMode)
{
ResolutionStruct rs = new ResolutionStruct();
//string sitem = dm.dmPelsWidth + "," + dm.dmPelsHeight + "," + dm.dmDisplayFrequency + "Hz," + dm.dmBitsPerPel + "位";
string sitem = dm.dmPelsWidth + "," + dm.dmPelsHeight;
if (!ListSize.Contains(sitem))
{
ListSize.Add(sitem);
}
}
for (int i = 0; i < ListSize.Count; i++)
{
string size = ListSize[i];
List<string> ListSt = new List<string>();
foreach (Resolution.DEVMODE dm in allMode)
{
string sitem = dm.dmPelsWidth + "," + dm.dmPelsHeight + "," + dm.dmDisplayFrequency + "," + dm.dmBitsPerPel;
if (sitem.Contains(size))
{
ListSt.Add(sitem);
}
}
ListResolutionDesc0.Add(ListSt.Last());
}
List<string> ListResolutionDesc1 = new List<string>();
for (int i = 0; i < ListResolutionDesc0.Count; i++)
{
double width = double.Parse(ListResolutionDesc0[i].Split(',')[0]);
if (width >= 1024)
{
ListResolutionDesc1.Add(ListResolutionDesc0[i]);
}
}
if (ListResolutionDesc1.Count < 6)
{
ListResolutionDesc0.RemoveRange(0, ListResolutionDesc0.Count - 6);
ListResolutionDesc1.Clear();
ListResolutionDesc1 = ListResolutionDesc0;
}
foreach (string item in ListResolutionDesc1)
{
int _width = int.Parse(item.Split(',')[0]);
int _height = int.Parse(item.Split(',')[1]);
int _freq = int.Parse(item.Split(',')[2]);
int _mybit = int.Parse(item.Split(',')[3]);
ResolutionStruct rs = new ResolutionStruct() { width = _width, height = _height, frequence = _freq, bitNum = _mybit };
ListResolution.Add(rs);
}
double gap = (this.Width - ListResolution.Count * traceWidth) / (ListResolution.Count - 1);
List<Image> ListImage = new List<Image>();
for (int i = 0; i < ListResolution.Count; i++)
{
Image img = new Image() { Width = 14, Height = 22 };
img.Source = Utility.GetReleativeImageSource(@"/Assets/刻度.png");
if ((i + 1) != ListResolution.Count)
{
img.Margin = new Thickness(0, 0, gap, 0);
}
else
{
img.Margin = new Thickness(0, 0, 0, 0);
}
ListImage.Add(img);
stack.Children.Add(img);
}
for (int i = 0; i < ListResolution.Count; i++)
{
double sysWidth = SystemParameters.PrimaryScreenWidth;
double sysHeight = SystemParameters.PrimaryScreenHeight;
if (ListResolution[i].width == sysWidth && ListResolution[i].height == sysHeight)
{
SelectedIndex = i;
break;
}
}
DispatcherTimer dt = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(0.2) };
dt.Tick += delegate
{
dt.Stop();
for (int i = 0; i < ListImage.Count; i++)
{
Point pt = ListImage[i].TranslatePoint(new Point(0, 0), this);
ListX.Add(pt.X);
}
//.........这里部分代码省略.........
示例12: m_client_UserSubscribed
void m_client_UserSubscribed(TwitchClient sender, string user)
{
ListItem item = ListItem.CreateFromNewSub(user);
m_eventQueue.Enqueue(new NewSubscriberEvent(item, user));
if (!string.IsNullOrEmpty(m_options.SubscriberFile))
{
List<string> subs = new List<string>();
subs.Add(user);
if (File.Exists(m_options.SubscriberFile))
subs.AddRange(File.ReadAllText(m_options.SubscriberFile).Split(',').Select(s=>s.Trim()));
if (subs.Count > 10)
subs.RemoveRange(10, subs.Count - 10);
File.WriteAllText(m_options.SubscriberFile, string.Join(", ", subs));
}
}