FMXPlanner background items

Great to see the FMXPlanner, been waiting ages for it! :)


I can't find in the documentation how to add custom background items, e.g. Lunch etc
e.g. http://www.tmssoftware.com/site/img/plan16_1.png

Plus, different start and end times for each resource on a single day.

Any help appreciated.

Richard

Hi, 


Fixed background items are currently not supported, but you can accomplish this with custom drawing:

procedure TForm1.TMSFMXPlanner1AfterDrawCell(Sender: TObject; ACanvas: TCanvas;
  ARect: TRectF; ACol, ARow: Integer; AStartTime, AEndTime: TDateTime;
  APosition: Integer; AKind: TTMSFMXPlannerCacheItemKind);
begin
  if (HourOf(AStartTime) = 12) and (HourOf(AEndTime) = 13) then
  begin
    ACanvas.Fill.Color := claWhite;
    ACanvas.Font.Size := 20;
    ACanvas.FillText(ARect, 'LUNCH', False, 1, [], TTextAlign.Center, TTextAlign.Center);
  end;
end;

procedure TForm1.TMSFMXPlanner1BeforeDrawCell(Sender: TObject; ACanvas: TCanvas;
  ARect: TRectF; ACol, ARow: Integer; AStartTime, AEndTime: TDateTime;
  APosition: Integer; AKind: TTMSFMXPlannerCacheItemKind; var AAllow,
  ADefaultDraw: Boolean);
begin
  if (HourOf(AStartTime) = 12) and (HourOf(AEndTime) = 13) then
  begin
    ACanvas.Fill.Color := claSteelBlue;
    ACanvas.Fill.Kind := TBrushKind.Solid;
  end;
end;

If you mean different visual active start and end times for each resource that are still selectable you need to override the OnIsDateTimeInactive event and return different values depending on the position.

procedure TForm1.TMSFMXPlanner1IsDateTimeInActive(Sender: TObject;
  ADateTime: TDateTime; APosition: Integer; var AInActive: Boolean);
begin
  case APosition of
    0: AInactive := not ((HourOf(ADateTime) >= 8) and (HourOf(ADateTime) <= 18));
    1: AInactive := not ((HourOf(ADateTime) >= 10) and (HourOf(ADateTime) <= 20));
    2: AInactive := not ((HourOf(ADateTime) >= 9) and (HourOf(ADateTime) <= 15));
  end;
end;

If you meant to disable dates then you can change the event handler to OnIsDateTimeDisabled.



Kind Regards, 
Pieter

Thanks Pieter, that's plenty to keep me busy!

:)