unit PCFillDlg; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, FillForm,DlgBase,PCTypesUtils,DrawObjects,Powercad; type TPCFillDlg = class(TDlgBase) private { Private declarations } Syncing: Boolean; Dial : TfrmFill; Procedure Apply(Sender:TObject); Function GetVisible:boolean; protected { Protected declarations } Procedure SetControl(value: TPowerCad);override; public { Public declarations } constructor create(Aowner: TComponent);override; procedure show;override; Procedure SyncronizeContext; Procedure Syncronize;override; Procedure Locate(px,py:Integer);override; published { Published declarations } Property CadControl; Property Visible: Boolean read GetVisible; end; procedure EventBack(Client:TObject; EventId: Integer; NumVal:Integer; Strval:String; DblVal:Double;Enabled:Boolean);stdcall; implementation {$R *.DCR} uses PCDrawing; constructor TPCFillDlg.create(Aowner: TComponent); begin inherited create(Aowner); dial := TfrmFill.create(self); OnApply := Apply; DlgName := 'Fill Dialog'; Syncing := False; end; Procedure TPCFillDlg.SyncronizeContext; var a: integer; Info : TLayerInfo; Count : Integer; Figure: TFigure; Begin if syncing then exit; Syncing := True; If assigned(CadControl) then Dial.SetControl(CadControl); If assigned(CadControl) and (CadControl.Selection.Count > 0) then begin Figure := TFigure(CadControl.Selection[0]); if Figure.RegHandle <> 0 then begin Dial.SelFigure := Figure; Dial.Sync; end; end; Syncing := False; end; Procedure TPCFillDlg.Show; begin SyncronizeContext; dial.show; if CadControl = nil then begin ShowMessage('The Fill Dialog is not related with any Powercad control!'); end; end; Procedure TPCFillDlg.Locate(px,py:Integer); begin Dial.Left := px; Dial.Top := py; end; Function TPCFillDlg.GetVisible: Boolean; begin Result := Dial.Visible; end; Procedure TPCFillDlg.Syncronize; begin If Dial.Visible then SyncronizeContext; end; procedure TPCFillDlg.Apply(Sender: TObject); begin if CadControl <> nil then begin if dial.FillType = fsHatch then begin CadControl.SetSelectionHatch(Dial.HatchStyle,Dial.ForeColor,Dial.BackColor,Dial.FillSize); end else if dial.FillType = fsGradient then begin CadControl.SetSelectionGradient(Dial.GradStyle,Dial.ForeColor,Dial.BackColor); end else if dial.FillType = fsTexture then begin CadControl.SetSelectionTexture(Dial.TextureStyle,Dial.TextureSize); end; SyncronizeContext; end else begin ShowMessage('The Fill Dialog is not related with any Powercad control!'); end; end; procedure TPCFillDlg.SetControl(value: TPowerCad); begin inherited; if assigned(Value) then begin Value.RegisterEvent(cBrushStyle,Self,EventBack); end; end; procedure EventBack(Client:TObject; EventId: Integer; NumVal:Integer; Strval:String; DblVal:Double;Enabled:Boolean);stdcall; begin TPCFillDlg(Client).SyncronizeContext; end; end.