本文整理汇总了C#中ObservableCollection.LastOrDefault方法的典型用法代码示例。如果您正苦于以下问题:C# ObservableCollection.LastOrDefault方法的具体用法?C# ObservableCollection.LastOrDefault怎么用?C# ObservableCollection.LastOrDefault使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObservableCollection
的用法示例。
在下文中一共展示了ObservableCollection.LastOrDefault方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddVirtualEnvironmentView
public AddVirtualEnvironmentView(
PythonProjectNode project,
IInterpreterRegistryService interpreterService,
IPythonInterpreterFactory selectInterpreter
) {
_interpreterService = interpreterService;
_project = project;
VirtualEnvBasePath = _projectHome = project.ProjectHome;
Interpreters = new ObservableCollection<InterpreterView>(InterpreterView.GetInterpreters(project.Site, project));
var selection = Interpreters.FirstOrDefault(v => v.Interpreter == selectInterpreter);
if (selection == null) {
selection = Interpreters.FirstOrDefault(v => v.Interpreter == project.GetInterpreterFactory())
?? Interpreters.LastOrDefault();
}
BaseInterpreter = selection;
_project.InterpreterFactoriesChanged += OnInterpretersChanged;
var venvName = "env";
for (int i = 1; Directory.Exists(Path.Combine(_projectHome, venvName)); ++i) {
venvName = "env" + i.ToString();
}
VirtualEnvName = venvName;
CanInstallRequirementsTxt = File.Exists(PathUtils.GetAbsoluteFilePath(_projectHome, "requirements.txt"));
WillInstallRequirementsTxt = CanInstallRequirementsTxt;
}
示例2: GetForumCategoryMainPage
public async Task<ObservableCollection<ForumCategoryEntity>> GetForumCategoryMainPage()
{
var forumGroupList = new ObservableCollection<ForumCategoryEntity>();
var result = await _webManager.GetData(Constants.FORUM_LIST_PAGE);
HtmlDocument doc = result.Document;
HtmlNode forumNode =
doc.DocumentNode.Descendants("select")
.FirstOrDefault(node => node.GetAttributeValue("name", string.Empty).Equals("forumid"));
if (forumNode != null)
{
try
{
IEnumerable<HtmlNode> forumNodes = forumNode.Descendants("option");
foreach (HtmlNode node in forumNodes)
{
string value = node.Attributes["value"].Value;
int id;
if (!int.TryParse(value, out id) || id <= -1) continue;
if (node.NextSibling.InnerText.Contains("--"))
{
string forumName =
WebUtility.HtmlDecode(node.NextSibling.InnerText.Replace("-", string.Empty));
bool isSubforum = node.NextSibling.InnerText.Count(c => c == '-') > 2;
var forumSubCategory = new ForumEntity
{
Name = forumName.Trim(),
Location = string.Format(Constants.FORUM_PAGE, value),
IsSubforum = isSubforum
};
forumSubCategory.SetForumId();
forumGroupList.LastOrDefault().ForumList.Add(forumSubCategory);
}
else
{
string forumName = WebUtility.HtmlDecode(node.NextSibling.InnerText);
var forumGroup = new ForumCategoryEntity(forumName,
string.Format(Constants.FORUM_PAGE, value));
forumGroupList.Add(forumGroup);
}
}
}
catch (Exception ex)
{
throw new Exception("Main Forum Parsing Error: " + ex.StackTrace);
}
}
#if DEBUG
if (forumGroupList.Any())
forumGroupList[3].ForumList.Add(AddDebugForum());
#endif
return forumGroupList;
}
示例3: ParseResult
private void ParseResult(string response)
{
try
{
var collection = new ObservableCollection<Hilite>();
var result = JObject.Parse(response);
if (!bool.Parse(result["success"].ToString()))
{
Dispatcher.BeginInvoke(() => MessageBox.Show(result["errorMessage"].ToString(), AppResources.ErrorTitle, MessageBoxButton.OK));
}
else
{
if (!bool.Parse(result["isNextFetch"].ToString()))
{
IsolatedStorageSettings.ApplicationSettings["LastHiliteFetch"] = result["currentTimestamp"].ToString();
}
else
{
collection = HiliteCollection;
var last = collection.LastOrDefault();
if (last != null)
{
last.IsLast = false;
}
}
var messages = JArray.Parse(result["messages"].ToString());
foreach (var hilite in messages.Select(hiliteRow => JObject.Parse(hiliteRow.ToString())))
{
var hiliteObj = new Hilite
{
Channel = hilite["channel"].ToString(),
Nick = hilite["nick"].ToString(),
Message = hilite["message"].ToString(),
TimestampString = hilite["timestamp"].ToString(),
Id = long.Parse(hilite["id"].ToString())
};
collection.Add(hiliteObj);
}
if (result["nextMessage"].Type != JTokenType.Null)
{
var nextHilite = JObject.Parse(result["nextMessage"].ToString());
_nextHilite = new Hilite
{
Channel = nextHilite["channel"].ToString(),
Nick = nextHilite["nick"].ToString(),
Message = nextHilite["message"].ToString(),
TimestampString = nextHilite["timestamp"].ToString(),
Id = long.Parse(nextHilite["id"].ToString())
};
var last = collection.LastOrDefault();
if (last != null)
{
last.IsLast = true;
}
}
else
{
_nextHilite = null;
var last = collection.LastOrDefault();
if (last != null)
{
last.IsLast = false;
}
}
HiliteCollection = collection;
}
}
catch (Exception e)
{
Dispatcher.BeginInvoke(() => MessageBox.Show(string.Format(AppResources.ErrorFetchingMessagesEx, e), AppResources.ErrorTitle, MessageBoxButton.OK));
}
IsBusy = false;
}
示例4: GetDataSourceForUpdateDepreciationScreen
/// <summary>
/// The get data source for update depreciation screen.
/// </summary>
/// <returns>
/// The <see cref="Task"/>.
/// </returns>
private async Task GetDataSourceForUpdateDepreciationScreen()
{
if (this.DynamicMainGridViewModel.SelectedItems != null)
{
// Get Type name for UpdateDepreciation screen
string updateDepreciationName = default(string);
var allItemsSelected = new ObservableCollection<AssetClassesTypeRowItem>(this.DynamicMainGridViewModel.SelectedItems.Cast<AssetClassesTypeRowItem>());
foreach (var item in allItemsSelected)
{
var assetClassesTypeRowItem = allItemsSelected.FirstOrDefault();
var classesTypeRowItem = allItemsSelected.LastOrDefault();
if (classesTypeRowItem != null && (assetClassesTypeRowItem != null && (item.EquipTypeId == assetClassesTypeRowItem.EquipTypeId || item.EquipTypeId == classesTypeRowItem.EquipTypeId)))
{
updateDepreciationName = updateDepreciationName + item.TypeDescription;
}
else
{
updateDepreciationName = updateDepreciationName + ", " + item.TypeDescription;
}
}
await this.TypeUpdateDepreciationViewModel.GenerateUserControlForDetailScreen();
await this.TypeUpdateDepreciationViewModel.GetUpdateDepreciationDataSource(updateDepreciationName, await AssetClassesTypeFunctions.GetDefaultDataForDetail());
this.TypeUpdateDepreciationViewModel.ContentItemChanged = this.AssetClassesTypeDetailViewModel_PropertyChanged;
}
}
示例5: UnifiedMapViewModel
//.........这里部分代码省略.........
_changeMapTypeCommand =
new Command<MapType>(m => MapDisplayType = m);
_addPinCommand =
new Command(AddPin, o => _allPins.Any());
_removePinCommand =
new Command(RemovePin, o => Pins.Any());
_moveToRegionCommand =
new Command(() => Map.MoveToRegion(animated: true));
_addPolylineCommand =
new Command(AddPolyline, o => _allPolylines.Any());
_removePolylineCommand =
new Command(RemovePolyline, o => Overlays.Any());
_selectCommand =
new Command<int>(SetSelectedItem, (arg) => Pins.Count > 0);
_allPins = new LinkedList<IMapPin> (
new []
{
new MapPin
{
Title = "Brändlen",
Location = new Position(46.904829, 8.409724),
Color = Color.Red
},
new MapPin
{
Title = "Wolfenschiessen",
Snippet = "... nothing to see here",
Location = new Position(46.905180, 8.398110),
Color = Color.Blue
},
new MapPin
{
Title = "Klewenalp",
Location = new Position(46.939898, 8.475217),
Color = Color.Fuchsia,
},
new MapPin
{
Title = "Beckenried NW",
Location = new Position(46.963876, 8.482078),
Color = Color.Green,
},
new MapPin
{
//Title = "Zürich",
//Snippet = "It's awesome",
Location = new Position(47.3667, 8.5500),
Image = "pin_icon",
SelectedImage = "pin_icon_active",
Anchor = new Point(0.5, 1)
},
new MapPin
{
Title = "fivenine",
Snippet = "fivenine GmbH",
Location = new Position(47.389097, 8.517756),
Image = "pin_icon",
SelectedImage = "pin_icon_active",
Anchor = new Point(0.5, 1)
},
});
Pins = new ObservableCollection<IMapPin> ();
_allPolylines = new LinkedList<IMapOverlay> ();
var polyline = new PolylineOverlay ();
foreach (var pin in _allPins) {
polyline.Add (pin.Location);
}
_allPolylines.AddLast (polyline);
Overlays = new ObservableCollection<IMapOverlay> ();
Overlays.Add(new CircleOverlay
{
Location = new Position(47.389097, 8.517756),
Radius = 400,
Color = Color.Navy.MultiplyAlpha(0.2),
FillColor = Color.Blue.MultiplyAlpha(0.2)
});
// Add some sample pins
AddPin (null);
AddPin (null);
// Add some polylines
AddPolyline (null);
SelectedItem = Pins.LastOrDefault();
}
示例6: setLineData
private void setLineData(int days)
{
DateTime start = DateTime.Today.AddDays(-days);
_LineData = new ObservableCollection<LData>(
(from p in APPDB.Outgoing
where p.Time > start
group p by p.Time into g
select new LData
{
// time = g.Key.ToShortDateString(),
time="",
value = g.Sum(p => p.Money)/100
}
)
);
if (_LineData.Count != 0)
{
_LineData[0].time = start.ToShortDateString();
_LineData.LastOrDefault().time = DateTime.Today.ToShortDateString();
}
//int count = _LineData.Count;
//if (count < 3)
// return;
//int step = count / 3;
//int index = 0;
//foreach (var i in _LineData)
//{
// if (index % step != 0)
// i.time = "";
// index++;
//}
}
示例7: initHomePage
/**
* 返回_pieData,_lineData,_RecentData,homeinfo
*/
private void initHomePage(object sender, DoWorkEventArgs e)
{
YingDB DB = App.APPDB;
Home_info HomeInfo = DB.Home_info.FirstOrDefault();
DateTime today = DateTime.Today;
initResult result = new initResult();
//获取首页信息
if (HomeInfo.Date.Year == today.Year)
{
if (HomeInfo.Date.Month != today.Month)
{
HomeInfo.Mouthsum = 0;
HomeInfo.Daysum = 0;
}
else
{
if (HomeInfo.Date != today)
HomeInfo.Daysum = 0;
}
}
else
{
HomeInfo.Weeksum = 0;
HomeInfo.Daysum = 0;
}
HomeInfo.Date = today;
if ((today - HomeInfo.Weekstart).Days > 7)
{
HomeInfo.Weeksum = 0;
HomeInfo.Weekstart = today.AddDays(-(int)today.DayOfWeek);
}
result.HomeInfo = HomeInfo;
//最近数据
ObservableCollection<HData> recentData = new ObservableCollection<HData>(
(
from p in APPDB.Outgoing
join g in APPDB.Sub_type on p.Sub_id equals g.Id
orderby p.Id descending
select new HData { Name=g.Name,value=p.Money}
).Take(7)
);
result.RecentData = recentData;
//7天饼图数据
DateTime start = DateTime.Today.AddDays(-7);
ObservableCollection<PData> PieData = new ObservableCollection<PData>(
(from p in APPDB.Outgoing
where p.Time > start
group p by p.Main_id into g
join m in APPDB.Main_type on g.Key equals m.Id
select new PData { title = m.Name, value = g.Sum(p => p.Money) / 100 }
)
);
result.pieData = PieData;
//30天线图数据
start = DateTime.Today.AddDays(-30);
ObservableCollection<LData> LineData = new ObservableCollection<LData>(
(from p in APPDB.Outgoing
where p.Time > start
group p by p.Time into g
select new LData
{
// time = g.Key.ToShortDateString(),
time = "",
value = g.Sum(p => p.Money) / 100
}
)
);
if (LineData.Count != 0)
{
LineData[0].time = start.ToShortDateString();
LineData.LastOrDefault().time = DateTime.Today.ToShortDateString();
}
result.LineData = LineData;
e.Result = result;
}
示例8: AddAbstract
private void AddAbstract()
{
var abs = DefaultManager.Instance.DefaultAbstract;
abs.PersonConferenceId = CurrentPersonConference.PersonConferenceId;
DataManager.Instance.AddAbstract(abs);
AllAbstracts = new ObservableCollection<Abstract>(DataManager.Instance.GetAbstractsByPersonConferenceID(CurrentPersonConference.PersonConferenceId));
CurrentAbstract = AllAbstracts.LastOrDefault();
OnPropertyChanged("CurrentAbstract");
OnPropertyChanged("AllAbstracts");
}