本文整理汇总了C#中ObservableCollection.ElementAt方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.ElementAt方法的具体用法?C# ObservableCollection.ElementAt怎么用?C# ObservableCollection.ElementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.ElementAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainViewModel
// This is where you can change the properties of the Shapes and Lines to move them in the View (Window), to play a little with this very simple demo.
public MainViewModel()
{
// Here the list of Shapes is filled with 2 Nodes.
Shapes = new ObservableCollection<Shape>() {
// The "new Type() { prop1 = value1, prop2 = value }" syntax is called an Object Initializer, which creates an object and sets its values.
// This is equivalent to the following:
// Shape shape1 = new Shape();
// shape1.X = 30;
// shape1.Y = 40;
// shape1.Width = 80;
// shape1.Height = 80;
// Also a constructor could be created for the Shape class that takes the parameters (X, Y, Width and Height),
// and the following could be done:
// new Shape(30, 40, 80, 80);
new Shape() { X = 30, Y = 40, Width = 80, Height = 80 },
new Shape() { X = 140, Y = 230, Width = 100, Height = 100 }
};
// Here the list of Lines i filled with 1 Line that connects the 2 Shapes in the Shapes collection.
// ElementAt() is an Extension Method, that like many others can be used on all types of collections.
// It works just like the "Shapes[0]" syntax would be used for arrays.
Lines = new ObservableCollection<Line>() {
new Line() { From = Shapes.ElementAt(0), To = Shapes.ElementAt(1) }
};
}
示例2: GridViewModel
public GridViewModel()
{
ResultData = new ObservableCollection<TestPointDataObject>();
//get the unique test points
var definedTestPoints = _resultValueTags.Where(dt => dt.Name.ToLower().Contains("testpoint")).GroupBy(dt => dt.Name.Split('.').First()).Select(grp => grp.First().Name.Split('.').First());
//var q2 = _resultValueTags.Where(dt => Regex.Match(dt.Name.Split('.').Single((s) => s.Contains("test")), @"(testpoint)[\d+]", RegexOptions.IgnoreCase).Success);
//Add the test point with a header value of it's number.
foreach (string tp in definedTestPoints)
ResultData.Add(new TestPointDataObject(Regex.Match(tp,@"[\d+]").Value));
foreach (DataTag tag in _resultValueTags.Where(dt => dt.Name.ToLower().Contains("testpoint")))
ResultData.ElementAt(Convert.ToInt32(Regex.Match(tag.Name, @"[\d+]").Value) - 1).Results.Add(new ResultDataObject(tag.Name,tag.Double));
foreach (DataTag tag in _results)
{
tag.ValueChanged += Tag_ValueChanged;
tag.ValueSet += Tag_ValueSet;
}
foreach (var v in ResultData)
{
_view = CollectionViewSource.GetDefaultView(v.Results);
_view.GroupDescriptions.Add(new PropertyGroupDescription("Name", new ResultNameGrouper()));
}
}
示例3: OnNavigatedTo
protected override void OnNavigatedTo(NavigationEventArgs e)
{
var op = e.Parameter.ToString();
rankings = Dao.PlacarDao.MontaRanking(Int32.Parse(op));
if (rankings.Count > 0)
{
Colocação.Text = (index + 1) + "º";
Painel.DataContext = rankings.ElementAt(index);
}
}
示例4: BrowseCommandExecute
void BrowseCommandExecute()
{
WellDataRepository dataAccess = new WellDataRepository();
AllWellData = new ObservableCollection<Model.WellData>(_dataRepository.GetXMLData());
WellDataPath = AllWellData.ElementAt(0).FilePath;
}
示例5: DeckPicker
public DeckPicker()
{
InitializeComponent();
_classItems =
new ObservableCollection<DeckPickerClassItem>(
Enum.GetValues(typeof(HeroClassAll)).OfType<HeroClassAll>().Select(x => new DeckPickerClassItem {DataContext = x}));
_archivedClassItem = _classItems.ElementAt((int)HeroClassAll.Archived);
_classItems.Remove(_archivedClassItem);
ListViewClasses.ItemsSource = _classItems;
SelectedClasses = new ObservableCollection<HeroClassAll>();
_displayedDecks = new ObservableCollection<DeckPickerItem>();
ListViewDecks.ItemsSource = _displayedDecks;
DeckTypeItems = new ObservableCollection<string> {"ALL", "ARENA", "CONSTRUCTED"};
}
示例6: MarkSolvedViolations
/// <summary>
/// Marks all solved Violations as marked
/// </summary>
/// <param name="scanTime"></param>
private void MarkSolvedViolations(DateTime scanTime,ObservableCollection<Violation> Violations)
{
try
{
for (int i = Violations.Count - 1; i >= 0; i--)
{
if (Violations.ElementAt(i).FoundAgain)
{
Violations.ElementAt(i).FoundAgain = false;
}
// If it didnt get found again means it didnt appear again ergo its solved
else
{
Violations.ElementAt(i).SolvedTime = scanTime;
Violations.ElementAt(i).ViolationState = ViolationType.SOLVED;
}
}
}
catch (COMException) { }
catch (TargetInvocationException){}
}
示例7: GetTextForecast
/// <summary>
/// Get the long text forecast for all the time periods
/// </summary>
private void GetTextForecast(XElement xmlWeather, ObservableCollection<ForecastPeriod> newForecastList)
{
XElement xmlCurrent;
int elementIndex = 0;
// get a text forecast for each time period
xmlCurrent = xmlWeather.Descendants("wordedForecast").First();
foreach (XElement curElement in xmlCurrent.Elements("text"))
{
try
{
newForecastList.ElementAt(elementIndex).TextForecast =
(string)(curElement.Value);
}
catch (FormatException)
{
newForecastList.ElementAt(elementIndex).TextForecast = "";
}
elementIndex++;
}
}
示例8: GetWeatherIcon
/// <summary>
/// Get the link to the weather icon for all the time periods
/// </summary>
/// <param name="xmlWeather"></param>
/// <param name="newForecastList"></param>
private void GetWeatherIcon(XElement xmlWeather, ObservableCollection<ForecastPeriod> newForecastList)
{
XElement xmlCurrent;
int elementIndex = 0;
// get a link to the weather icon for each time period
xmlCurrent = xmlWeather.Descendants("conditions-icon").First();
foreach (XElement curElement in xmlCurrent.Elements("icon-link"))
{
try
{
newForecastList.ElementAt(elementIndex).ConditionIcon =
(string)(curElement.Value);
}
catch (FormatException)
{
newForecastList.ElementAt(elementIndex).ConditionIcon = "";
}
elementIndex++;
}
}
示例9: CreateSimulatorDomain
public void CreateSimulatorDomain(VAM_Descriptor descriptor)
{
StepCounter = 0;
Addressing = new AddressingExtended(descriptor.Addressing);
Metrics = new Metrics(Addressing.AssociativeMemoryAccessTime, Addressing.MemoryAccessTime);
ObservableCollection<MappingRecordOfProcessAndMemory> addList = new ObservableCollection<MappingRecordOfProcessAndMemory>();
foreach (MappingRecordOfProcessAndMemory record in descriptor.ProcessPageAndMemoryPageMapping)
{
bool addItem = true;
if (record.ProcessPage >= Addressing.NumberOfPages || record.ProcessPage < 0)
{
addItem = false;
continue;
}
if (record.MemoryFrame >= Addressing.QuantityOfPagesStorableInUserMemory || record.MemoryFrame < 0)
{
addItem = false;
continue;
}
for (int i = addList.Count - 1; i > 0; i--)
{
if (record.MemoryFrame == addList.ElementAt(i).MemoryFrame)
{
addItem = false;
break;
}
if (record.ProcessPage == addList.ElementAt(i).ProcessPage)
{
addItem = false;
break;
}
}
if (addItem)
{
addList.Add(record);
}
}
ProcessPageAndMemoryPageMapping = MyCloner.DeepClone<ObservableCollection<MappingRecordOfProcessAndMemory>>(addList);
// associativ memóriába csak azok a page addressek mennek be, akikhez tartozó process lap a memóriában van
AssociativeMemory = new ObservableCollection<FourElementTuple>();
if (descriptor.Addressing.IsAssociativeMemoryInUse)
{
foreach (int processPage in descriptor.AssociativeMemoryInitialContent)
{
AddPageToAssociativeMemory(processPage);
}
}
// ellenőrzéssel kell
ActionSequence = MyCloner.DeepClone<ObservableCollection<ActionBase>>(descriptor.ActionSequence);
ObservableCollection<ActionBase> removeList = new ObservableCollection<ActionBase>();
foreach (ActionBase action in ActionSequence)
{
string fullName = action.GetType().Name;
switch (fullName)
{
case "ResolveVirtualAddress":
break;
case "AddPageToMemory":
if (((AddPageToMemory)action).ProcessPage >= Addressing.NumberOfPages
|| ((AddPageToMemory)action).ProcessPage < 0
|| ((AddPageToMemory)action).MemoryFrame >= Addressing.QuantityOfPagesStorableInUserMemory
|| ((AddPageToMemory)action).MemoryFrame < 0)
{
removeList.Add(action);
}
break;
case "RemovePageFromMemory":
if (((RemovePageFromMemory)action).MemoryFrame >= Addressing.QuantityOfPagesStorableInUserMemory
|| ((RemovePageFromMemory)action).MemoryFrame < 0)
{
removeList.Add(action);
}
break;
case "AddPageToAssociativeMemory":
if (descriptor.Addressing.IsAssociativeMemoryInUse == false)
{
removeList.Add(action);
}
break;
case "RemovePageFromAssociativeMemory":
if (descriptor.Addressing.IsAssociativeMemoryInUse == false)
{
removeList.Add(action);
}
break;
}
}
foreach (ActionBase action in removeList)
{
ActionSequence.Remove(action);
}
}
示例10: GetMinMaxTemperatures
/// <summary>
/// Get the minimum and maximum temperatures for all the time periods
/// </summary>
private void GetMinMaxTemperatures(XElement xmlWeather, ObservableCollection<ForecastPeriod> newForecastList)
{
XElement xmlCurrent;
// Find the temperature parameters. if first time period is "Tonight",
// then the Daily Minimum Temperatures are listed first.
// Otherwise the Daily Maximum Temperatures are listed first
xmlCurrent = xmlWeather.Descendants("parameters").First();
int minTemperatureIndex = 1;
int maxTemperatureIndex = 0;
// If "Tonight" is the first time period, then store Daily Minimum
// Temperatures first, then Daily Maximum Temperatuers next
if (newForecastList.ElementAt(0).TimeName == "Tonight")
{
minTemperatureIndex = 0;
maxTemperatureIndex = 1;
// get the Daily Minimum Temperatures
foreach (XElement curElement in xmlCurrent.Elements("temperature").
ElementAt(0).Elements("value"))
{
newForecastList.ElementAt(minTemperatureIndex).Temperature =
int.Parse(curElement.Value);
minTemperatureIndex += 2;
}
// then get the Daily Maximum Temperatures
foreach (XElement curElement in xmlCurrent.Elements("temperature").
ElementAt(1).Elements("value"))
{
newForecastList.ElementAt(maxTemperatureIndex).Temperature =
int.Parse(curElement.Value);
maxTemperatureIndex += 2;
}
}
// otherwise we have a daytime time period first
else
{
// get the Daily Maximum Temperatures
foreach (XElement curElement in xmlCurrent.Elements("temperature").
ElementAt(0).Elements("value"))
{
newForecastList.ElementAt(maxTemperatureIndex).Temperature =
int.Parse(curElement.Value);
maxTemperatureIndex += 2;
}
// then get the Daily Minimum Temperatures
foreach (XElement curElement in xmlCurrent.Elements("temperature").
ElementAt(1).Elements("value"))
{
newForecastList.ElementAt(minTemperatureIndex).Temperature =
int.Parse(curElement.Value);
minTemperatureIndex += 2;
}
}
}
示例11: CheckIfQuesAreEqual
private bool CheckIfQuesAreEqual(ObservableCollection<string> queue1, ObservableCollection<string> queue2)
{
if (queue1.Count != queue2.Count)
return false;
for (int i = 0; i < queue1.Count; i++)
{
if ( ! queue1.ElementAt(i).Equals(queue2.ElementAt(i)) )
{
return false;
}
}
return true;
}
示例12: CreateCategoryButtons
private ObservableCollection<ScreenCategoryButton> CreateCategoryButtons(ScreenMenu screenMenu)
{
if (screenMenu != null)
{
if (MenuItems != null) MenuItems.Clear();
_currentScreenMenu = screenMenu;
var result = new ObservableCollection<ScreenCategoryButton>();
foreach (var category in screenMenu.Categories.OrderBy(x => x.SortOrder).Where(x => !x.MostUsedItemsCategory))
{
var sButton = new ScreenCategoryButton(category, CategoryCommand);
result.Add(sButton);
}
if (result.Count > 0)
{
var c = result.First();
if (_selectedCategory != null)
c = result.SingleOrDefault(x => x.Category.Name.ToLower() == _selectedCategory.Name.ToLower());
if (c == null && result.Count > 0) c = result.ElementAt(0);
if (c != null) OnCategoryCommandExecute(c.Category);
}
return result;
}
Reset();
return Categories;
}
示例13: initStms
/// <summary>
/// Initialisiert den Pseudocode
/// </summary>
private void initStms()
{
ObservableCollection<Statement> tmpCol = new ObservableCollection<Statement>(_programm.getActualStmNesting());
_stms = new ObservableCollection<Tuple<Statement, string>>();
_stms.Add(new Tuple<Statement,string>(tmpCol.ElementAt(0), Config.TEXT_RED));
for (int i = 1; i < tmpCol.Count; i++)
{
_stms.Add(new Tuple<Statement, string>(tmpCol.ElementAt(i), Config.TEXT_NORMAL));
}
}
示例14: AnalyzeDemo
public Task<Demo> AnalyzeDemo(Demo demo, CancellationToken token)
{
Random random = new Random();
ObservableCollection<PlayerExtended> players = new ObservableCollection<PlayerExtended>();
for (int i = 0; i < 10; i++)
{
PlayerExtended player = new PlayerExtended
{
Name = "player" + (i + 1),
HeadshotCount = random.Next(14),
OnekillCount = random.Next(10, 30),
TwokillCount = random.Next(10, 20),
ThreekillCount = random.Next(0, 10),
FourKillCount = random.Next(0, 5),
FiveKillCount = random.Next(0, 2),
Clutch1V1Count = random.Next(1),
Clutch1V2Count = random.Next(1),
Clutch1V3Count = random.Next(1),
Clutch1V4Count = random.Next(1),
Clutch1V5Count = random.Next(1),
BombDefusedCount = random.Next(0, 2),
BombPlantedCount = random.Next(0, 2),
DeathCount = random.Next(0, 32),
KillsCount = random.Next(30),
AssistCount = random.Next(15),
Score = random.Next(10, 80),
RoundMvpCount = random.Next(6),
RankNumberNew = 5,
RankNumberOld = 4,
RatingHltv = (float)random.NextDouble(),
SteamId = random.Next(1000, 800000),
IsOverwatchBanned = random.Next(100) < 40,
IsVacBanned = random.Next(100) < 40,
TeamKillCount = random.Next(0, 1),
WinCount = random.Next(10, 687),
MolotovThrownCount = random.Next(0, 10),
DecoyThrownCount = random.Next(0, 10),
IncendiaryThrownCount = random.Next(20),
SmokeThrownCount = random.Next(20),
FlashbangThrownCount = random.Next(20),
HeGrenadeThrownCount = random.Next(20),
BombExplodedCount = random.Next(5),
AvatarUrl = string.Empty,
ClutchCount = random.Next(5),
ClutchLostCount = random.Next(5),
KillDeathRatio = (decimal)random.NextDouble(),
MatchCount = random.Next(100),
OpponentClutchCount = random.Next(5),
RoundPlayedCount = random.Next(100)
};
players.Add(player);
}
TeamExtended teamT = new TeamExtended
{
Name = "Team 1",
Players = new ObservableCollection<PlayerExtended>(players.Take(5))
};
TeamExtended teamCt = new TeamExtended
{
Name = "Team 2",
Players = new ObservableCollection<PlayerExtended>(players.Skip(5).Take(5))
};
ObservableCollection<Round> rounds = new ObservableCollection<Round>();
for (int i = 0; i < 32; i++)
{
ObservableCollection<KillEvent> kills = new ObservableCollection<KillEvent>();
for (int j = 0; j < random.Next(1, 9); j++)
{
PlayerExtended killer = players.ElementAt(random.Next(9));
PlayerExtended killed = players.ElementAt(random.Next(9));
kills.Add(new KillEvent(random.Next(1, 10000), random.Next(1, 100))
{
KillerName = killer.Name,
KillerSteamId = killer.SteamId,
KillerSide = killer.Side,
KilledName = killed.Name,
KilledSteamId = killed.SteamId,
KilledSide = killed.Side,
RoundNumber = i,
Weapon = Weapon.WeaponList.ElementAt(random.Next(44))
});
}
// generate open / entry kills for this round
Round round = new Round
{
Number = i + 1,
OneKillCount = random.Next(5),
TwoKillCount = random.Next(2),
ThreeKillCount = random.Next(1),
FourKillCount = random.Next(1),
FiveKillCount = random.Next(1),
EquipementValueTeam1 = random.Next(4200, 30000),
EquipementValueTeam2 = random.Next(4200, 30000),
StartMoneyTeam1 = random.Next(4200, 50000),
StartMoneyTeam2 = random.Next(4200, 50000),
Tick = random.Next(7000, 100000),
//.........这里部分代码省略.........
示例15: GameWork
private void GameWork(ObservableCollection<Content> lvlCountries)
{
Random rnd = new Random();
CurrentCountries = lvlCountries;
int elem_id = rnd.Next(0, lvlCountries.Count);
CurrentCountry = lvlCountries.ElementAt(elem_id);
string namecountry = CurrentCountry.Country;
NameCountryText.Text = namecountry;
nameCapital = CurrentCountry.Capital.ToLower();
var mixedCapital = CurrentCountry.ConvertCapitalName(CurrentCountry.Capital);
//countryLeftText.Text = App.AllCountries.Count.ToString() + " / " + App.LeftCounter.ToString();
// textBlock.Text = lvlCountries.Count.ToString();
ImageBrush brush = new ImageBrush();
string path = "ms-appx:///img/" + CurrentCountry.PathSourceImage + ".jpg";
brush.ImageSource = new BitmapImage(new Uri(path, UriKind.Absolute));
MainImage.Background = brush;
if (App.SettingsGame.HintButton == true)
{
hintbutton.Opacity = 100;
hintbutton.IsEnabled = true;
}
else
{
hintbutton.Opacity = 0;
hintbutton.IsEnabled = false;
}
for (int i = 0; i < gridLetters.Children.Count; i++)
{
if (gridLetters.Children[i].GetType() == textBlock1.GetType())
{
textBlocks.Add((TextBlock)gridLetters.Children[i]);
}
}
for (int i = 0; i < gridCap.Children.Count; i++)
{
if (gridLetters.Children[i].GetType() == textBlock1.GetType())
{
textBlocksCapital.Add((TextBlock)gridCap.Children[i]);
}
}
start = (textBlocksCapital.Count - mixedCapital.Length) / 2;
for (int i = 0; i < mixedCapital.Length; i++)
{
rand = rnd.Next(0, textBlocks.Count);
while (textBlocks[rand].Text != "")
{
rand = rnd.Next(0, textBlocks.Count);
}
textBlocks[rand].Text = mixedCapital[i].ToString();
textBlocksCapital[start + i].Text = ".";
}
foreach (TextBlock txtBlock in textBlocks)
{
if (txtBlock.Text == "") textBlocksTrash.Add(txtBlock);
}
foreach (TextBlock trashBlock in textBlocksTrash)
{
rand = rnd.Next(0, textBlocksTrash.Count);
trashBlock.Text = trashLetters[rand].ToString();
}
}