unit uSymbolStyle;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, Buttons, ExtCtrls, OleCtrls, MapXLib_TLB;
type
TfSymbolStyle = class(TForm)
panel: TScrollBox;
private
{ Private declarations }
lftr:CMapxFeature;//操作的对象;
procedure imageClick(sender:TObject);
Procedure FreeControls;
public
{ Public declarations }
procedure Enter(ftr:CMapXFeature);
end;
var
fSymbolStyle: TfSymbolStyle;
implementation
uses uMain, uInter, uFtrsList, uInfoFun;
{$R *.dfm}
procedure TfSymbolStyle.Enter(Ftr:CMapxFeature);
Const
ColCount: integer=10;
//每排10个图标
iSpace=1;//间隙
var
Bitmaps: BitmapSymbols;
i,j: Integer;
imageArr: Array of TSpeedButton;
iRow,iCol,RowCount,iCount: integer;
f, ftr:CMapxFeature;
sl:TStringList;
Ldata :Tfeature;
sel:Variant;
s:string;
begin
//===========================================================
sl:=TStringList.create;
fftrsList:=TfFtrsList.Create(application);
lftr:=ftr;
//===========================================================
{ Fill the ListBox with all of the names of the bitmap symbols
then
, the application could respond to ado
uble click in the
listbox by changing the style of some object on the map }
freeControls;
Bitmaps := CoBitmapSymbols.Create;
ShowMessage(inttostr(bitmaps.Count));
RowCount:=Round((Bitmaps.Count)/ColCount)+1;
showmessage(inttostr(rowcount));
SetLength(imageArr,Bitmaps.Count);
fSymbolStyle.width:=8+ColCount*32+ispace*2;
fSymbolStyle.Height:=27+RowCount*32+ispace*2;
For i := 1 to Bitmaps.Countdo
begin
// ListBox1.Items.Add(Bitmaps.Item(i).Name);
iRow:=Round(i/RowCount);
iCol:=Round(i mod RowCount);
imageArr[i-1]:=TSpeedButton.create(Panel);
imageArr[i-1].Name:='image'+inttostr(i);
imageArr[i-1].Parent:=TWinControl(Panel);
imageArr[i-1].Hint:=bitmaps.item(i).Name;
imageArr[i-1].ShowHint:=true;
imageArr[i-1].Glyph.LoadFromFile(CUSTOMSYMBOL_PATH+Bitmaps.Item(i).Name);
imageArr[i-1].Height:=32;
imageArr[i-1].Width:=32;
imageArr[i-1].top:=iSpace+(iRow)*32;
imageArr[i-1].Left:=iSpace+(iCol)*32;
imageArr[i-1].Cursor:=crHandPoint;
imageArr[i-1].onClick:=imageClick;
end;
self.show;
end;
procedure TfSymbolStyle.imageClick(sender:TObject);
var
Lyr:CMapxLayer;
begin
if MessageDlg('是否选择当前图标?',mtconfirmation,[mbyes,mbno],0)=mryes then
begin
if lFtr.Style.SupportsBitmapSymbols=true then
begin
try
lFtr.Style.SymbolType:=miSymbolTypeBitmap;
lFtr.Style.SymbolBitmapName:=TImage(sender).Hint;
lFtr.Style.SymbolBitmapTransparent:=true;
lFtr.Update(EmptyParam ,EmptyParam);
showmessage(lFtr.Name+'图标更新成功!');
except
showmessage('图标更新失败!');
end;
end
else
showmessage('该对象不支持图标!');
self.close;
end;
end;
Procedure TfSymbolStyle.freeControls;
var
i,iCount:Integer;
begin
iCount:=fSymbolStyle.panel.Controlcount;
for i:=iCount-1do
wnto 0do
fSymbolStyle.panel.Controls[0].Free;
end;
end.