mcpField
S
syncfusion-winforms-scheduler

syncfusion-winforms-scheduler

github.com/syncfusion开发260 次安装1 周前更新
代码仓库

关于 syncfusion-winforms-scheduler

面向 Windows Forms 开发者的 Syncfusion Scheduler 技能,介绍日历视图、预约管理与自定义方法,适用于构建桌面排程界面。

主要功能

  1. 01月、日、周及自定义周视图
  2. 02预约增删改查与数据绑定
  3. 03重复预约规则
  4. 04拖放与触控交互
  5. 05外观和主题定制

适用场景

  1. 01开发 Outlook 风格日历
  2. 02构建资源排程系统
  3. 03管理事件与重复预约

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/syncfusion/winforms-ui-components-skills --skill syncfusion-winforms-scheduler

安装后在 Claude Code 中输入/syncfusion-winforms-scheduler确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

references/
appointments-and-data.md
customizing-appearance.md
data-provider-xml-implementation.md
getting-started.md
recurrence-appointments.md
touch-and-interaction.md
views-and-navigation.md

详细介绍

实现 Windows Forms Scheduler(日历事件)

Syncfusion Windows Forms Scheduler 是一款全面的日历控件,提供类似于 Microsoft Outlook 的日程安排功能。用户可以通过多种视图类型(月、日、周、工作周、自定义周)创建、查看和管理约会,并支持重复约会、拖放操作、触控手势和丰富的自定义选项。

何时使用此技能

在以下情况下使用此技能:

  • 在 Windows Forms 应用程序中构建日历和日程安排界面
  • 在月、日、周、工作周或自定义周视图中显示约会
  • 实现重复约会(按日、周、月、年重复,或按时间间隔重复)
  • 启用约会 CRUD 操作(创建、读取、更新、删除),并持久化数据
  • 添加拖放功能,用于安排和重新安排约会
  • 自定义日历外观(颜色、主题、标题、导航、黄金时段)
  • 支持触控交互(滑动、缩放、平移),适用于现代设备
  • 将日程数据绑定到自定义数据提供程序或数据库
  • 创建 Outlook 风格的日历应用程序,带有导航日历和时段
  • 管理时间间隔,支持秒/分钟精度,满足详细的日程安排需求

组件概述

Windows Forms Scheduler 控件以 Grid 控件为基础,并提供:

  • **多种视图类型:**月、日、周、工作周和自定义周视图
  • **导航日历:**用于选择日期的多月日历
  • **约会管理:**全面支持 CRUD 操作,并可通过对话框编辑
  • **重复规则引擎:**支持基于时间间隔的复杂重复模式
  • **数据架构:**通过接口(IScheduleAppointment、IScheduleDataProvider)灵活绑定数据
  • **交互功能:**拖放、调整大小、上下文菜单、工具提示
  • **触控支持:**滑动滚动、缩放和基于手势的导航
  • **外观自定义:**可全面设置所有 UI 元素的样式
  • **主题支持:**Office 2003/2007/2010、Metro 和自定义主题

主要组件:

  • **ScheduleControl:**包含所有日程安排功能的主用户控件
  • **ScheduleAppointment:**表示单个约会的数据对象
  • **ScheduleDataProvider:**用于数据管理和持久化的基类
  • **NavigationCalendar:**用于日期导航的多月日历
  • **标题面板:**导航按钮和标题显示
  • **导航面板:**包含导航日历和自定义控件的侧边栏

命名空间:Syncfusion.Windows.Forms.Schedule

程序集依赖项:

  • Syncfusion.Grid.Base.dll
  • Syncfusion.Grid.Windows.dll
  • Syncfusion.Schedule.Base.dll
  • Syncfusion.Schedule.Windows.dll
  • Syncfusion.Shared.Base.dll
  • Syncfusion.Tools.Windows.dll

NuGet 指南:

  • 安装最新可用版本的 Syncfusion.Schedule.Windows
Install-Package Syncfusion.Schedule.Windows -Version *

文档与导航指南

入门

📄 阅读: references/getting-started.md

  • 安装和程序集部署
  • 通过设计器或代码创建 ScheduleControl
  • 使用 ArrayListDataProvider(内置解决方案)绑定数据
  • 基本约会 CRUD 操作(插入、编辑、删除)
  • 使用 XML 序列化保存和加载约会数据
  • 设置约会文本颜色
XML 数据提供程序实现

📄 阅读: references/data-provider-xml-implementation.md

  • 使用内置 ArrayListDataProvider 管理数据
  • 数据提供程序提供集成的 SaveXML 和 LoadXML 方法
  • 使用 XML 文件持久化管理内存中的数据
  • 使用 FileName 和 IsDirty 属性跟踪文件状态
  • 完整的代码示例和模式
  • 无需自定义类的生产就绪解决方案
视图和导航

📄 阅读: references/views-and-navigation.md

  • 日程视图类型(Month、Day、Week、WorkWeek、CustomWeek)
  • 通过编程方式和上下文菜单更改视图
  • 导航日历配置和属性
  • 导航面板和标题面板自定义
  • 周数显示和日历布局
  • 日期导航和选择事件
预约和数据管理

📄 阅读: references/appointments-and-data.md

  • ScheduleAppointment 类属性(StartTime、EndTime、Subject、Content 等)
  • ScheduleAppointmentList 集合方法
  • ScheduleDataProvider 基类实现
  • 数据接口(IScheduleAppointment、IScheduleAppointmentList、IScheduleDataProvider)
  • 创建自定义数据提供程序
  • 下拉列表数据(标签、标记、提醒、位置、所有者)
  • CommitChanges 和 SaveOnCloseBehavior
  • NewScheduleAppointment、AddItem、RemoveItem 方法
重复预约

📄 阅读: references/recurrence-appointments.md

  • 重复规则语法和格式
  • 规则类型(Every DAY、WEEKDAY、WEEKEND、WEEK、MONTH、QUARTER、YEAR)
  • 基于时间的重复(Every SEC、Every MIN、Every HR)
  • 用于小于小时的间隔的 AllowSecondsInAppointment 属性
  • 通过预约对话框 UI 添加重复
  • 通过 RecurrenceRule 属性以编程方式添加重复
  • IRecurringScheduleAppointment 和 IRecurringScheduleDataProvider 接口
  • 带有结束日期和间隔的复杂重复模式
自定义外观

📄 阅读: references/customizing-appearance.md

  • Appearance 属性和 ScheduleAppearance 对象
  • 边框自定义(ClickItemBorderColor、DragColor、SolidBorderColor)
  • 标题和标头自定义
  • 日期和时间的显示项格式字符串
  • 导航日历外观(颜色、选择、今天标记)
  • 黄金时段配置(开始/结束时间和颜色)
  • 时间列自定义(24 小时制、字体大小、颜色)
  • 视觉样式和 Metro 主题支持
  • ThemesEnabled 属性
  • ThemeChanged 事件: 通过 scheduleControl1.GetScheduleHost().ThemeChanged 订阅 ThemeChanged(不在 ScheduleControl 上直接订阅)
触摸和交互

📄 阅读: references/touch-and-interaction.md

  • 用于支持触摸的 EnableTouchMode 属性
  • 触摸滑动(垂直滚动和水平导航)
  • 触摸缩放以更改视图
  • 拖动和调整预约大小
  • ItemChanging 事件和 ItemDragHitContext
  • 在 ItemChanging 事件处理程序中使用 e.ProposedItem 获取预约详细信息
  • 检测拖动上下文(Schedule 区域与 Calendar 区域)
  • 根据放置位置取消拖动操作
  • ItemAction 枚举

快速入门示例

using System;
using System.Windows.Forms;
using Syncfusion.Schedule;
using Syncfusion.Windows.Forms.Schedule;

namespace SchedulerApp
{
    public partial class Form1 : Form
    {
        private ScheduleControl scheduleControl1;
        
        public Form1()
        {
            InitializeComponent();
            InitializeScheduler();
        }
        
        private void InitializeScheduler()
        {
            // Create ScheduleControl
            scheduleControl1 = new ScheduleControl();
            scheduleControl1.Location = new Point(20, 20);
            scheduleControl1.Size = new Size(800, 600);
            
            // Set up built-in data provider
            ArrayListDataProvider data = new ArrayListDataProvider();
            data.MasterList = new ArrayListAppointmentList();
            
            // Configure view and data binding
            scheduleControl1.ScheduleType = ScheduleViewType.Month;
            scheduleControl1.DataSource = data;
            
            // Add to form
            this.Controls.Add(scheduleControl1);
        }
    }
}

常见模式

创建和添加预约
// Get the data provider
ArrayListDataProvider dataProvider = scheduleControl1.DataSource as ArrayListDataProvider;

// Create new appointment
IScheduleAppointment appointment = dataProvider.NewScheduleAppointment();
appointment.StartTime = DateTime.Now.AddHours(1);
appointment.EndTime = DateTime.Now.AddHours(2);
appointment.Subject = "Team Meeting";
appointment.Content = "Discuss project milestones";
appointment.LabelValue = 2; // Business category
appointment.ForeColor = Color.Blue;

// Add to data provider
dataProvider.AddItem(appointment);

// Refresh to display
scheduleControl1.Refresh();

// Save to XML file
dataProvider.SaveXML(dataProvider.FileName);
创建重复预约
IScheduleDataProvider dataProvider = scheduleControl1.DataSource as IScheduleDataProvider;
IScheduleAppointment app = dataProvider.NewScheduleAppointment();
IRecurringScheduleDataProvider recurringProvider = scheduleControl1.DataSource as IRecurringScheduleDataProvider;

IRecurringScheduleAppointment recurringItem = app as IRecurringScheduleAppointment;

if (recurringItem != null)
{
    recurringItem.StartTime = new DateTime(2026, 03, 24, 9, 0, 0);
    recurringItem.EndTime = new DateTime(2026, 03, 24, 10, 0, 0);
    recurringItem.Subject = "Daily Standup";
    
    // Recurrence rule: Every weekday
    recurringItem.RecurrenceRule = "03/24/2026;06/30/2026;Every WEEKDAY";
    
    // Add recurring appointments
    recurringProvider.AddNewRecurringAppointments(recurringItem, new DateTime(2026, 12, 31));
}
以编程方式更改视图
// Switch to Day view
scheduleControl1.ScheduleType = ScheduleViewType.Day;

// Switch to Week view
scheduleControl1.ScheduleType = ScheduleViewType.Week;

// Switch to WorkWeek view (Monday-Friday)
scheduleControl1.ScheduleType = ScheduleViewType.WorkWeek;

// Switch to Month view
scheduleControl1.ScheduleType = ScheduleViewType.Month;
自定义外观
// Access appearance object
ScheduleAppearance appearance = scheduleControl1.Appearance;

// Customize colors
appearance.CaptionBackColor = Color.FromArgb(0, 114, 198);
appearance.PrimeTimeCellColor = Color.LightBlue;
appearance.NonPrimeTimeCellColor = Color.White;

// Set prime time hours (9 AM to 5 PM)
appearance.PrimeTimeStart = 9;
appearance.PrimeTimeEnd = 17;

// Apply Metro theme
appearance.VisualStyle = Syncfusion.Windows.Forms.GridVisualStyles.Metro;

// Customize navigation calendar
appearance.NavigationCalendarBackColor = Color.White;
appearance.NavigationCalendarSelectionColor = Color.Blue;
appearance.NavigationCalendarTodayColor = Color.Red;
启用触摸支持
// Enable touch mode for swipe, zoom, and pan gestures
scheduleControl1.EnableTouchMode = true;

// Users can now:
// - Swipe vertically to scroll in Day/WorkWeek views
// - Swipe horizontally to navigate previous/next
// - Zoom to change view types (like Outlook)
处理预约拖动事件
// Subscribe to ItemChanging event
scheduleControl1.ItemChanging += ScheduleControl1_ItemChanging;

private void ScheduleControl1_ItemChanging(object sender, ScheduleAppointmentCancelEventArgs e)
{
    if (e.Action == ItemAction.ItemDrag)
    {
        // Get drag context (Calendar or Schedule area)
        Console.WriteLine($"Dropped in: {e.ItemDragHitContext}");
        
        // Cancel drops to calendar area
        if (e.ItemDragHitContext == ItemDragHitContext.Calendar)
        {
            MessageBox.Show("Cannot drop appointments in calendar area");
            e.Cancel = true;
        }
    }
}

关键类和接口

ScheduleControl

提供日程安排功能的主要控件:

  • DataSource:IScheduleDataProvider - 预约的数据源
  • ScheduleType:ScheduleViewType - 当前视图(Month/Day/Week/WorkWeek/CustomWeek)
  • Appearance:ScheduleAppearance - 外观自定义对象
  • Calendar:NavigationCalendar - 导航日历控件
  • EnableAlerts:bool - 启用预约提醒
  • EnableTouchMode:bool - 启用触摸手势
ScheduleAppointment (IScheduleAppointment)

表示单个预约:

  • StartTime、EndTime:DateTime - 预约时间范围
  • Subject:string - 预约标题
  • Content:string - 详细说明
  • AllDay:bool - 是否为全天预约
  • LabelValue:int - 类别/标签标识符
  • MarkerValue:int - 状态标记(空闲、忙碌、暂定、外出)
  • ReminderValue:int - 提醒时间间隔
  • LocationValue:int - 位置标识符
  • ForeColor:Color - 文本颜色
  • UniqueID:int - 唯一标识符
  • Owner:int - 多用户场景中的所有者标识符
ScheduleDataProvider (IScheduleDataProvider)

用于数据管理的基类:

  • GetScheduleForDay(DateTime day):获取指定日期的预约
  • GetSchedule(DateTime start, DateTime end):获取日期范围内的预约
  • NewScheduleAppointment():创建新的预约对象
  • AddItem(IScheduleAppointment):添加预约
  • RemoveItem(IScheduleAppointment):移除预约
  • CommitChanges():保存修改
  • SaveOnCloseBehaviorAction:控件释放时的自动保存行为

常见用例

  1. Outlook 风格的日历应用

    • 带导航日历的月视图
    • 双击创建预约
    • 拖放更改预约时间
    • 支持定期会议
  2. 资源调度系统

    • 使用日视图/周视图分配资源
    • 按资源类型为预约设置颜色
    • 拖动以分配资源
    • 使用自定义间隔管理时间段
  3. 活动管理应用

    • 在月视图中显示多日活动
    • 支持全天活动
    • 使用标签为活动分类
    • 自定义位置和提醒设置
  4. 医疗预约系统

    • 使用工作周视图显示医生排班
    • 15 分钟时间间隔
    • 跟踪患者预约
    • 定期预约模式(每周检查)
  5. 时间跟踪与记录

    • 使用 AllowSecondsInAppointment 实现分钟/秒级精度
    • 使用自定义数据提供程序集成数据库
    • 按时间重复(每 N 分钟/小时)
    • 自定义详细时间列
  6. 支持触控的平板设备日程安排

    • 为平板设备启用 EnableTouchMode
    • 在不同日期之间滑动导航
    • 使用缩放手势切换视图
    • 便于触控操作的预约编辑

相关技能

后续步骤

从 入门指南 开始,安装并配置 Scheduler 控件,然后根据应用需求,通过上方的导航指南了解具体功能。

评论

支持 Markdown