aclreg.pas

来自「delphi编程控件」· PAS 代码 · 共 427 行

PAS
427
字号
unit aclreg;
(*
 COPYRIGHT (c) RSD Software 1997 - 98
 All Rights Reserved.
*)

{$I aclver.inc}

interface

uses   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  DsgnIntf;

procedure Register;

implementation
{$IFNDEF AOB_PS}
{$R aclexreg.dcr}
{$ENDIF}
uses aimctrls, aimpredt, asimpred, aoutlbar, adatectl,
aoutlsed, aoutlbed, autostrs, aprstore, aprstped, aurllabl, ATimeCtl
{$IFNDEF AOB_PS}{$IFDEF DELPHI3_0},ARichEd, AREProEd, ARERuler {$ENDIF}{$ENDIF};

{TAutoOutLookStoreEditor}
type
  TAutoOutLookBarStoreEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure TAutoOutLookBarStoreEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: ShowAutoOutLookBarStoreEditor(TAutoOutLookBarStore(Component));
  end;
  Designer.Modified;
end;

function TAutoOutLookBarStoreEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := LoadStr(AEL_STOREDITEMS);
  end;
end;

function TAutoOutLookBarStoreEditor.GetVerbCount: Integer;
begin
  Result := 1;
end;

{TAutoOutLookBarEditor}
type
  TAutoOutLookBarEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure TAutoOutLookBarEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: if ShowAutoOutLookBarEditor(TAutoOutLookBar(Component)) then   Designer.Modified;
  end;
end;

function TAutoOutLookBarEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := LoadStr(AEL_GROUPS);
  end;
end;

function TAutoOutLookBarEditor.GetVerbCount: Integer;
begin
  Result := 1;
end;

{TAutoPropertiesStoreEditor}
type
  TAutoPropertiesStoreEditor = class(TComponentEditor)
    procedure ExecuteVerb(Index: Integer); override;
    function GetVerb(Index: Integer): string; override;
    function GetVerbCount: Integer; override;
  end;

procedure TAutoPropertiesStoreEditor.ExecuteVerb(Index: Integer);
begin
  case Index of
    0: if AutoPropertiesStoreComponentEdit(TAutoPropertiesStore(Component)) then   Designer.Modified;
  end;
end;

function TAutoPropertiesStoreEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0: Result := LoadStr(AEC_PROPERTIESSTORE);
  end;
end;

function TAutoPropertiesStoreEditor.GetVerbCount: Integer;
begin
  Result := 1;
end;

{TAutoOutLookBarStoreGroupsPropertyEditor}
type
TAutoOutLookBarStoreGroupsPropertyEditor = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoOutLookBarStoreGroupsPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TStrings.ClassName]);
end;

function TAutoOutLookBarStoreGroupsPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paMultiSelect, paDialog];
end;

procedure TAutoOutLookBarStoreGroupsPropertyEditor.Edit;
begin
  ShowAutoOutLookBarStoreEditor(GetComponent(0) as TAutoOutLookBarStore);
end;

{TAutoOutLookBarGroupsPropertyEditor}
type
TAutoOutLookBarGroupsPropertyEditor = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoOutLookBarGroupsPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TAutoOutLookGroups.ClassName]);
end;

function TAutoOutLookBarGroupsPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paMultiSelect, paDialog];
end;

procedure TAutoOutLookBarGroupsPropertyEditor.Edit;
begin
  if ShowAutoOutLookBarEditor(GetComponent(0) as TAutoOutLookBar) then
    Modified;
end;

{TAutoPropertiesStoreItemsPropertyEditor}
type
TAutoPropertiesStoreItemsPropertyEditor = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoPropertiesStoreItemsPropertyEditor.GetValue: string;
begin
  Result := Format('(%s)', [TAutoPropertiesStore.ClassName]);
end;

function TAutoPropertiesStoreItemsPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paMultiSelect, paDialog];
end;

procedure TAutoPropertiesStoreItemsPropertyEditor.Edit;
begin
  if AutoPropertiesStoreComponentEdit(GetComponent(0) as TAutoPropertiesStore) then
    Modified;
end;

{TAutoPropertiesFilesPropertyEditor}
type
TAutoPropertiesFilesPropertyEditor = class(TStringProperty)
protected
  function GetFileName : String; virtual;
  function GetFilter : String; virtual;
  procedure SetFileName(Value : String); virtual; 
public
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoPropertiesFilesPropertyEditor.GetFileName : String;
begin
end;

function TAutoPropertiesFilesPropertyEditor.GetFilter : String;
begin
end;

procedure TAutoPropertiesFilesPropertyEditor.SetFileName(Value : String);
begin
end;

function TAutoPropertiesFilesPropertyEditor.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog];
end;

procedure TAutoPropertiesFilesPropertyEditor.Edit;
Var
  SaveDialog : TSaveDialog;
begin
   SaveDialog := TSaveDialog.Create(Nil);
   SaveDialog.Filter := GetFilter;
   SaveDialog.Options := [ofOverwritePrompt,ofHideReadOnly];   
   SaveDialog.FileName := GetFileName;
   if SaveDialog.Execute then begin
     SetFileName(SaveDialog.FileName);
     Modified;
   end;
   SaveDialog.Free;
end;

{TAutoPropertiesIniFilePropertyEditor}
type
TAutoPropertiesIniFilePropertyEditor = class(TAutoPropertiesFilesPropertyEditor)
protected
  function GetFileName : String; override;
  function GetFilter : String; override;
  procedure SetFileName(Value : String); override;
end;

function TAutoPropertiesIniFilePropertyEditor.GetFileName : String;
begin
  Result := TAutoPropertiesStore(GetComponent(0)).IniFileName;
end;

function TAutoPropertiesIniFilePropertyEditor.GetFilter : String;
begin
  Result := '*.ini|*.ini*.*|*.*|';
end;

procedure TAutoPropertiesIniFilePropertyEditor.SetFileName(Value : String);
begin
  TAutoPropertiesStore(GetComponent(0)).IniFileName := Value;
end;

{TAutoPropertiesBinFilePropertyEditor}
type
TAutoPropertiesBinFilePropertyEditor = class(TAutoPropertiesFilesPropertyEditor)
protected
  function GetFileName : String; override;
  function GetFilter : String; override;
  procedure SetFileName(Value : String); override;
end;

function TAutoPropertiesBinFilePropertyEditor.GetFileName : String;
begin
  Result := TAutoPropertiesStore(GetComponent(0)).BinaryFileName;
end;

function TAutoPropertiesBinFilePropertyEditor.GetFilter : String;
begin
  Result := '*.bin|*.bin*.*|*.*|';
end;

procedure TAutoPropertiesBinFilePropertyEditor.SetFileName(Value : String);
begin
  TAutoPropertiesStore(GetComponent(0)).BinaryFileName := Value;
end;

type
TAutoImageControlItemProperties = class(TPropertyEditor)
public
  function GetValue: string; override;
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoImageControlItemProperties.GetValue: string;
begin
  Result := Format('(%s)', [TStrings.ClassName]);
end;

function TAutoImageControlItemProperties.GetAttributes: TPropertyAttributes;
begin
  Result := [paMultiSelect, paDialog];
end;

procedure TAutoImageControlItemProperties.Edit;
begin
  if(AutoImageItemsPropEditor(GetComponent(0) as TWinControl)) then
    Modified;
end;

type
TAutoSpinImageItemsProperties = class(TClassProperty)
public
  function GetAttributes: TPropertyAttributes; override;
  procedure Edit; override;
end;

function TAutoSpinImageItemsProperties.GetAttributes: TPropertyAttributes;
begin
  Result := [paDialog, paReadOnly];
end;

procedure TAutoSpinImageItemsProperties.Edit;
begin
  if(AutoSpinImageItemsPropEditor(GetComponent(0) as TAutoCustomSpinImage)) then
    Modified;
end;

{ TDateProperty }
type
TDateProperty = class(TPropertyEditor)
  function GetAttributes: TPropertyAttributes; override;
  function GetValue: string; override;
  procedure SetValue(const Value: string); override;
end;

function TDateProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paMultiSelect, paRevertable];
end;

function TDateProperty.GetValue: string;
var
  DT: TDateTime;
begin
  DT := GetFloatValue;
  if DT = 0.0 then Result := '' else
  Result := FormatDateTime(DateFormat, DT);
end;

procedure TDateProperty.SetValue(const Value: string);
var
  DT: TDateTime;
begin
  if Value = '' then DT := 0.0
  else DT := StrToDate(Value);
  SetFloatValue(DT);
end;

{ TTimeProperty }

type
  TTimeProperty = class(TPropertyEditor)
    function GetAttributes: TPropertyAttributes; override;
    function GetValue: string; override;
    procedure SetValue(const Value: string); override;
  end;

function TTimeProperty.GetAttributes: TPropertyAttributes;
begin
  Result := [paMultiSelect, paRevertable];
end;

function TTimeProperty.GetValue: string;
begin
  Result := FormatDateTime(TimeFormat, GetFloatValue);
end;

procedure TTimeProperty.SetValue(const Value: string);
var
  DT: TDateTime;
begin
  if Value = '' then DT := 0.0
  else DT := StrToTime(Value);
  SetFloatValue(DT);
end;


procedure Register;
begin
  RegisterComponents('Auto Controls',
  [TAutoImageListBox, TAutoImageComboBox, TAutoSpinImage]);

  RegisterComponents('Auto Controls', [TAutoOutLookBarStore, TAutoOutLookBar, TAutoOutLookPopupMenu]);
  RegisterNoIcon([TAutoOutLookStoredItem]);

  RegisterComponents('Auto Tools', [TAutoPropertiesStore]);
  RegisterComponents('Auto Controls', [TAutoURLLabel]);
  RegisterComponents('Auto Controls', [TAutoDateControl{$IFNDEF AOB_PS}, TAutoDateEdit{$ENDIF}]);
  RegisterComponents('Auto Controls', [TAutoTimeControl, TAutoTimeEdit]);

 {$IFNDEF AOB_PS}{$IFDEF DELPHI3_0}
   RegisterPropertyEditor(TypeInfo(TStrings), TAutoRichEdit,
    'Lines', TAREStringsProperty);
   RegisterComponents('Auto Controls', [TAutoRichEdit, TAutoRichEditRuler]);
 {$ENDIF}{$ENDIF}

  RegisterPropertyEditor(TypeInfo(TStrings), TAutoCustomImageListBox, 'Items',
  TAutoImageControlItemProperties);
  RegisterPropertyEditor(TypeInfo(TStrings), TAutoImageComboBox, 'Items',
  TAutoImageControlItemProperties);
  RegisterPropertyEditor(TypeInfo(TAutoSpinImageItems), TAutoCustomSpinImage, 'Items',
  TAutoSpinImageItemsProperties);
  RegisterPropertyEditor(TypeInfo(TStrings), TAutoOutLookBarStore, 'Groups',
                         TAutoOutLookBarStoreGroupsPropertyEditor);
  RegisterPropertyEditor(TypeInfo(TAutoOutLookGroups), TAutoOutLookBar, 'Groups',
                         TAutoOutLookBarGroupsPropertyEditor);
  RegisterPropertyEditor(TypeInfo(TAutoObjectsStore), TAutoPropertiesStore, 'Items',
                         TAutoPropertiesStoreItemsPropertyEditor);
  RegisterPropertyEditor(TypeInfo(String), TAutoPropertiesStore, 'IniFileName',
                         TAutoPropertiesIniFilePropertyEditor);
  RegisterPropertyEditor(TypeInfo(String), TAutoPropertiesStore, 'BinaryFileName',
                         TAutoPropertiesBinFilePropertyEditor);

  RegisterPropertyEditor(TypeInfo(TDateTime), TCustomAutoDateControl, 'Date', TDateProperty);
  RegisterPropertyEditor(TypeInfo(TDateTime), TCustomAutoDateControl, 'BeginDate', TDateProperty);
  RegisterPropertyEditor(TypeInfo(TDateTime), TCustomAutoDateControl, 'EndDate', TDateProperty);
  {$IFNDEF AOB_PS}
  RegisterPropertyEditor(TypeInfo(TDateTime), TCustomAutoDateEdit, 'Date', TDateProperty);
  RegisterPropertyEditor(TypeInfo(TDateTime), TCustomAutoDateEdit, 'BeginDate', TDateProperty);
  RegisterPropertyEditor(TypeInfo(TDateTime), TCustomAutoDateEdit, 'EndDate', TDateProperty);
  {$ENDIF}  
  RegisterPropertyEditor(TypeInfo(TDateTime), TCustomAutoTimeControl, 'Time', TTimeProperty);
  RegisterPropertyEditor(TypeInfo(TDateTime), TCustomAutoTimeEdit, 'Time', TTimeProperty);
  RegisterComponentEditor(TAutoOutLookBarStore, TAutoOutLookBarStoreEditor);
  RegisterComponentEditor(TAutoOutLookBar, TAutoOutLookBarEditor);
  RegisterComponentEditor(TAutoPropertiesStore, TAutoPropertiesStoreEditor);

end;


end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?