当前位置: 首页>>代码示例>>C#>>正文


C# Entry.AddTag方法代码示例

本文整理汇总了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();
        }
开发者ID:gusper,项目名称:Journaley,代码行数:87,代码来源:MainForm.cs


注:本文中的Entry.AddTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。