android - Delphi FMX TCalendar - 禁用周末

标签 android ios delphi calendar firemonkey

是否可以从 FMX TCalendar 组件禁用某些日期? 例如周末
如果能够强调他们是残疾人,例如残疾人,那就太好了。下图中的第 14 天和第 15 天

enter image description here

我可以通过在打开 HitTest 的情况下将矩形添加到列表框项目样式上来禁用它
这就是我对上图所做的

procedure TForm1.cal1DayClick(Sender: TObject);
var sTemp : String;
begin
  cal1.StylesData['days.Selected.StyleLookup'] := 'ListBoxItemstyleCust';
end;

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

最佳答案

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

在文件夹中 \Embarcadero\Studio\17.0\source\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;填充当前月份的天数;下个月的填充天数;

添加了一个样式来匹配 MyListBoxItemstyle

Styled Calendar

使用样式后,它看起来像这样 Styled Calendar v2

关于android - Delphi FMX TCalendar - 禁用周末,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33770484/

相关文章:

android - 如果 Android 应用程序不在中国 Android 手机的堆栈中,推送通知将不起作用

arrays - 查找两个数组中的公共(public)元素

Pie 中的 Android vndk

android - Android Oreo 中所有应用的通知设置 Activity

ios - 如何在 Swift 中进行轻量级核心数据迁移

ios - 使用标签栏 Controller-> Nav controller -> View Hierarchy 从 app delegate 呈现 View - iOS Swift

delphi - 如何确保 RTTI 可用于某个类而不实例化它?

delphi - 从delphi中的纯文本+私钥获取sha1消息摘要

java - 自动完成 map Activity 中的搜索地点

ios - -[UIImage _imageByUnpremultiplying] : unrecognized selector sent to instance