本文整理汇总了C#中Entry.AddTag方法的典型用法代码示例。如果您正苦于以下问题:C# Entry.AddTag方法的具体用法?C# Entry.AddTag怎么用?C# Entry.AddTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Entry
的用法示例。
在下文中一共展示了Entry.AddTag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddNewEntry
/// <summary>
/// Adds a new entry.
/// </summary>
private void AddNewEntry()
{
Entry newEntry = null;
if (this.IsInCalendarView() && this.monthCalendar.SelectedDates.Count == 1)
{
DateTime now = DateTime.Now;
DateTime selected = this.monthCalendar.SelectedDates[0];
// Overwrite the "Date" portion of the entry with the currently selected date.
DateTime date = new DateTime(
selected.Year,
selected.Month,
selected.Day,
now.Hour,
now.Minute,
now.Second,
now.Millisecond,
DateTimeKind.Local);
do
{
newEntry = new Entry(date.ToUniversalTime());
}
while (this.Entries.ContainsKey(newEntry.UUID));
}
else if (this.IsInTagsView() && this.listBoxTags.SelectedIndex != -1)
{
do
{
newEntry = new Entry();
}
while (this.Entries.ContainsKey(newEntry.UUID));
if (this.listBoxTags.SelectedItem is StarredCountEntry)
{
newEntry.Starred = true;
}
else if (this.listBoxTags.SelectedItem is TagCountEntry)
{
newEntry.AddTag(((TagCountEntry)this.listBoxTags.SelectedItem).Tag);
}
}
else
{
do
{
newEntry = new Entry();
}
while (this.Entries.ContainsKey(newEntry.UUID));
}
this.Entries.Add(newEntry.UUID, newEntry);
this.SelectedEntry = newEntry;
// Check if there are any "empty" entries on the same day.
var entriesToDelete = this.Entries.Values
.Where(x => x != newEntry)
.Where(x => x.LocalTime.Date == newEntry.LocalTime.Date)
.Where(x => x.IsEmptyEntry())
.ToList(); // Make it a list to avoid concurrent modification exception.
// Delete those, if any.
foreach (var entryToDelete in entriesToDelete)
{
// Protect against the occasional exception dialog. (GitHub Issue #40).
try
{
entryToDelete.Delete(this.Settings.EntryFolderPath);
}
catch (IOException e)
{
Logger.Log(e.Message);
Logger.Log(e.StackTrace);
}
this.Entries.Remove(entryToDelete.UUID);
}
this.UpdateAllEntryLists();
this.UpdateStats();
this.spellCheckedEntryText.Focus();
}