c# - .NET Google Calendar API 获取事件的颜色

标签 c# .net google-calendar-api

我正在学习 .NET Google Calendar API,但我不知道如何获取事件的颜色(而不是日历的颜色)。这是谷歌添加的一个相对较新的功能。在这段代码的最后,我试图打印出每个事件的标题、开始时间和颜色

    {
        CalendarService myService = new CalendarService("calService");
        myService.setUserCredentials("me@gmail.com", "password");
        EventQuery myQuery = new EventQuery("https://www.google.com/calendar/feeds/me@gmail.com/private/full");
        myQuery.StartTime = new DateTime(2011, 10, 5);
        myQuery.EndTime = new DateTime(2011, 10, 7);

        EventFeed myResultsFeed = myService.Query(myQuery);
        Console.WriteLine("events:\n");
        foreach (EventEntry entry in myResultsFeed.Entries)
        {

            Console.WriteLine(entry.Title.Text + entry.Times[0].StartTime "\n");
        }
    }

我在哪里可以找到颜色?

以撒。

最佳答案

通过快速阅读 Google 的 API 文档,颜色似乎与 CalendarEntry 类相关联。例如,这是一个设置 CalendarEntry 并设置颜色的示例:

CalendarEntry calendar = new CalendarEntry();
calendar.Title.Text = "Little League Schedule";
calendar.Summary.Text = "This calendar contains the practice schedule and game times.";
calendar.TimeZone =  "America/Los_Angeles";
calendar.Hidden = false;
calendar.Color = "#2952A3";
calendar.Location = new Where("", "", "Oakland");

从阅读有关插入事件的文章来看,当您插入一个事件时,您似乎指定了一个日历提要,例如 allcalendars feed并且该事件将插入到您通过 URL 指定的任何日历中,这让我假设您的事件将采用的颜色将是为该日历设置的颜色。

因此,假设这是正确的,如果您希望事件具有某种颜色,则必须首先创建一个该颜色的日历,然后将事件添加到该日历。浏览 .NET API Documentation应该会为您提供完成此操作所需的其余信息。

关于c# - .NET Google Calendar API 获取事件的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7693592/

相关文章:

c# - 带有叠加项目控件的图像

.net - 使用 Azure 应用程序配置 -> 希望允许本地配置覆盖开发人员

javascript - 如何循环遍历 Google 表格中的事件 ID 以检索附件 ID?

python - 使用 Python 访问 Google Calendar API

c# - foreach 中的多项选择到 LINQ

属性辅助方法的 c# 泛型

c# - 如何从 .NET 桌面应用程序安装没有 [DefaultInstall] 部分的 INF 驱动程序?

c# - 如何就地对 Collection<T> 进行排序?

c# - 为什么我需要用这个简单的 LINQ 表达式来引用 System.Numerics?

java - Javascript 中未终止的字符串常量错误