DÉMARRAGE RAPIDE
A Team Scheduler in a Few Lines
The same API in Delphi, C++ Builder and C#: two people, a daily stand-up from a recurrence rule, and a week view that lets users drag new meetings.
A VCL week Scheduler: two people as resources, a daily stand up from a recurrence rule, drag to create.
unit frmTeam;
interface
uses
Classes, Controls, Forms, SysUtils,
sgcUICore_Theme, sgcPlanner_Data, sgcPlanner_Scheduler,
sgcPlanner_Scheduler_VCL;
type
TFormTeam = class(TForm)
procedure FormCreate(Sender: TObject);
private
FData: TsgcPlannerData;
FScheduler: TsgcVCLScheduler;
procedure DoItemCreate(Sender: TObject; const aStart, aFinish: TDateTime;
const aResourceId: string; var aTitle: string; var aAccept: Boolean);
end;
implementation
procedure TFormTeam.FormCreate(Sender: TObject);
var
vItem: TsgcPlannerItem;
vMonday: TDateTime;
begin
vMonday := Date - DayOfWeek(Date) + 2;
FData := TsgcPlannerData.Create(Self);
FData.Resources.AddResource('ana', 'Ana').Color := $FF2563EB;
FData.Resources.AddResource('luis', 'Luis').Color := $FF0F766E;
// a daily stand-up from an iCalendar recurrence rule
vItem := FData.AddItem('standup');
vItem.Title := 'Daily stand-up';
vItem.Start := vMonday + EncodeTime(9, 0, 0, 0);
vItem.Finish := vMonday + EncodeTime(9, 15, 0, 0);
vItem.RecurrenceRule := 'FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR';
vItem.Resources := 'ana,luis';
vItem := FData.AddItem('review');
vItem.Title := 'Design review';
vItem.Start := vMonday + 1 + EncodeTime(14, 0, 0, 0);
vItem.Finish := vMonday + 1 + EncodeTime(15, 30, 0, 0);
vItem.Resources := 'ana';
FScheduler := TsgcVCLScheduler.Create(Self);
FScheduler.Parent := Self;
FScheduler.Align := alClient;
FScheduler.Data := FData;
FScheduler.Theme := utDark;
FScheduler.View := psvWeek;
FScheduler.Options.DayStartHour := 8;
FScheduler.Options.DayEndHour := 18;
FScheduler.Options.GroupByResource := True;
FScheduler.OnItemCreate := DoItemCreate;
FScheduler.ScrollToTime(vMonday + EncodeTime(8, 0, 0, 0));
end;
procedure TFormTeam.DoItemCreate(Sender: TObject; const aStart,
aFinish: TDateTime; const aResourceId: string; var aTitle: string;
var aAccept: Boolean);
begin
// the user dragged an empty slot: name the new meeting
aTitle := 'New meeting';
aAccept := True;
end;
end.
Lire la rubrique d'aide →
The same scheduler in C++ Builder.
#include <vcl.h>
#pragma hdrstop
#include <System.DateUtils.hpp>
#include "sgcUICore_Theme.hpp"
#include "sgcPlanner_Data.hpp"
#include "sgcPlanner_Scheduler.hpp"
#include "sgcPlanner_Scheduler_VCL.hpp"
class TTeamHandlers : public TObject
{
public:
// the user dragged an empty slot: name the new meeting
void __fastcall ItemCreate(TObject *Sender, const TDateTime aStart,
const TDateTime aFinish, const UnicodeString aResourceId,
UnicodeString &aTitle, bool &aAccept)
{
aTitle = "New meeting";
aAccept = true;
}
};
void __fastcall BuildTeamScheduler(TForm *Form)
{
static TTeamHandlers *vHandlers = new TTeamHandlers();
TDateTime vMonday = Date() - DayOfWeek(Date()) + 2;
TsgcPlannerData *vData = new TsgcPlannerData(Form);
vData->Resources->AddResource("ana", "Ana")->Color = 0xFF2563EB;
vData->Resources->AddResource("luis", "Luis")->Color = 0xFF0F766E;
// a daily stand-up from an iCalendar recurrence rule
TsgcPlannerItem *vItem = vData->AddItem("standup");
vItem->Title = "Daily stand-up";
vItem->Start = vMonday + EncodeTime(9, 0, 0, 0);
vItem->Finish = vMonday + EncodeTime(9, 15, 0, 0);
vItem->RecurrenceRule = "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR";
vItem->Resources = "ana,luis";
vItem = vData->AddItem("review");
vItem->Title = "Design review";
vItem->Start = vMonday + 1 + EncodeTime(14, 0, 0, 0);
vItem->Finish = vMonday + 1 + EncodeTime(15, 30, 0, 0);
vItem->Resources = "ana";
TsgcVCLScheduler *vScheduler = new TsgcVCLScheduler(Form);
vScheduler->Parent = Form;
vScheduler->Align = alClient;
vScheduler->Data = vData;
vScheduler->Theme = utDark;
vScheduler->View = psvWeek;
vScheduler->Options->DayStartHour = 8;
vScheduler->Options->DayEndHour = 18;
vScheduler->Options->GroupByResource = true;
vScheduler->OnItemCreate = vHandlers->ItemCreate;
vScheduler->ScrollToTime(vMonday + EncodeTime(8, 0, 0, 0));
}
Lire la rubrique d'aide →
The C# version for WinForms.
using System;
using System.Windows.Forms;
using esegece.sgcPlanner;
using esegece.sgcUICore;
namespace TeamPlanner
{
internal class MainForm : Form
{
public MainForm()
{
Text = "Team scheduler";
DateTime monday = DateTime.Today.AddDays(-(((int)DateTime.Today.DayOfWeek + 6) % 7));
var data = new TsgcPlannerData();
data.Resources.AddResource("ana", "Ana").Color = 0xFF2563EB;
data.Resources.AddResource("luis", "Luis").Color = 0xFF0F766E;
// a daily stand-up from an iCalendar recurrence rule
var item = data.AddItem("standup");
item.Title = "Daily stand-up";
item.Start = monday.AddHours(9);
item.Finish = monday.AddHours(9).AddMinutes(15);
item.RecurrenceRule = "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR";
item.Resources = "ana,luis";
item = data.AddItem("review");
item.Title = "Design review";
item.Start = monday.AddDays(1).AddHours(14);
item.Finish = monday.AddDays(1).AddHours(15.5);
item.Resources = "ana";
var scheduler = new TsgcWinFormsScheduler { Dock = DockStyle.Fill, Data = data, Theme = TsgcUITheme.utDark };
scheduler.View = TsgcPlannerSchedulerViewKind.psvWeek;
scheduler.Options.DayStartHour = 8;
scheduler.Options.DayEndHour = 18;
scheduler.Options.GroupByResource = true;
// the user dragged an empty slot: name the new meeting
scheduler.OnItemCreate = (object sender, DateTime start, DateTime finish, string resourceId,
ref string title, ref bool accept) => { title = "New meeting"; accept = true; };
Controls.Add(scheduler);
scheduler.ScrollToTime(monday.AddHours(8));
}
[STAThread]
static void Main() { Application.EnableVisualStyles(); Application.Run(new MainForm()); }
}
}
dotnet add package esegece.sgcPlanner.WinForms
Lire la rubrique d'aide →
Gantt in Delphi
Three tasks, two links, a baseline, the critical path and the schedule engine (the Gantt features here are Registered edition features).
Recurrence rules and the Gantt Schedule and SetBaseline calls are Registered edition features. The free Community edition shows a recurring item once.