Delphi FMX TCalendar - 禁用周末

时间:2015-11-18 01:54:05

标签: android ios delphi calendar firemonkey

是否可以从FMX TCalendar组件中禁用某些天? 例如周末
如果他们被高举,他们被禁用也是好的,例如第14天和第15天,如下图所示

enter image description here

我可以通过在打开命中测试的情况下在listboxitemstyle上添加一个矩形来禁用它 这就是我为上图所做的事情

startActivity(new Intent(this, SomeModuleAActivity.class));

但我不知道如何在创建项目时访问styleslistbox项目,即使这是我应该这样做的方式

1 个答案:

答案 0 :(得分:2)

经过一段时间的挖掘,这是我发现的快速解释 Source code here

在文件夹中 \ Embarcadero公司\工作室\ 17.0 \源\ FMX 有一个FMX.Calendar.Style.pas文件

我已将该文件复制到与项目相同的位置,并将其重命名为My.FMX.Calendar.Style.pas

我还将TStyledCalendar重命名为TMyStyledCalendar,然后更改了初始化和终结

initialization
  TPresentationProxyFactory.Current.Register(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
finalization
  TPresentationProxyFactory.Current.Unregister(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
end.

initialization
  TPresentationProxyFactory.Current.Unregister(TCalendar, TControlType.Styled, TStyledPresentationProxy<TStyledCalendar>);
  TPresentationProxyFactory.Current.Register(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);
finalization
  TPresentationProxyFactory.Current.Unregister(TCalendar, TControlType.Styled, TStyledPresentationProxy<TMyStyledCalendar>);

还将FMX.Calendar.Style添加到使用部分
中 在FillDays程序中;创建了一个新程序

  procedure ChangeStyle(aDay : TDateTime;Item: TDayItem);
  var wDay : Word;
  begin
    wDay := DayOfWeek(aDay-1);
    if (wDay = DaySaturday) or (wday = DaySunday) then begin
      item.Enabled := false;
      if (Item.StyleLookup <> 'MyListBoxItemstyle') then
        Item.StyleLookup := 'MyListBoxItemstyle';
    end else begin
      if (Item.StyleLookup <> '') then
        Item.StyleLookup := '';
    end;
  end;

并添加了ChangeStyle(Item.Date,Item);到以下FillDaysOfPreviousMonth; FillDaysOfCurrentMonth; FillDaysOfNextMonth;

添加了一个样式以匹配MyListBoxItemstyle

Styled Calendar

玩完样式后让它看起来像这样 Styled Calendar v2

相关问题