delphi 预览图片2 (MouseUP)
这个是自己项目在使用的,所以带有些业务功能的代码。
逻辑上使用的大多是 mouseup ,MouseMove,Mousedown。使用recttangle容器实现滑动。网上有这个下载demo。
另外移动端要注意线程的异步同步的控制。
unit UShowPictureZoomIn;
interface
uses
System.SysUtils,
System.Types,
System.UITypes,
System.IOUtils,
System.Classes,
System.Variants,
System.Messaging ,
System.Generics.Collections,
FMX.Types,
FMX.Graphics,
FMX.Controls,
FMX.Forms,
FMX.Dialogs,
FMX.StdCtrls,
FMX.Objects,
FMX.Effects,
FMX.Ani,
FMX.Controls.Presentation,
FMX.Layouts,DRCommonEvent,
DRFormClass,PublicVariables,ParentFrm,UDM,MSFileCLass,
GetData,Common,Datasnap.DBClient,DataRec,CDSHelper ,
{$IFNDEF MSWINDOWS}
FMX.Gestures,
{$ENDIF}
FMX.Edit;
type
// TArray = array of string;
TArrays = array of array of string;
TFrmShowPictureZoomIn = class(TParentform)
LayoutContainer: TLayout;
Image1: TImage;
Image2: TImage;
RectBottom: TRectangle;
AChkType: TCheckBox;
lblSelectOK: TLabel;
RectTop: TRectangle;
ImgReturn: TImage;
procedure FormCreate(Sender: TObject);
procedure FormResize(Sender: TObject);
//
procedure RectOnMouseDown(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Single);
procedure RectOnMouseMove(Sender: TObject; Shift: TShiftState; X,Y: Single);
procedure RectOnMouseUP(Sender: TObject; Button: TMouseButton;Shift : TShiftState; X, Y: Single);
procedure FormGesture(Sender: TObject; const EventInfo: TGestureEventInfo;
var Handled: Boolean);
procedure FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Single);
procedure lblSelectOKClick(Sender: TObject);
procedure ImgReturnClick(Sender: TObject);
procedure FormTap(Sender: TObject; const Point: TPointF);
procedure RectTopClick(Sender: TObject);
private
{ Private declarations }
{$IFNDEF MSWINDOWS}
GestureManager1 : TGestureManager ;
{$ENDIF}
ARectOK : TRectangle;
ARectCancel : TRectangle ;
ARectChk : TRectangle ;
ARectIsCreate : boolean ;
AImage : Array of TImage ;
ARect : Array of TRectangle ;
//
FLastPosition : TPointF;
FLastDIstance : integer ;
FOriginalWidth : Array of Single ;
FOriginalHeight : Array of Single ;
FOriginalX : Array of single ;
FOriginalY : Array of Single ;
FZoomWidth : Single ;
FZoomHeight : Single ;
//
BMSCarrierObject_ID:string;
// AImgGuIDRelationship:TImgGuIDRelationship;
ArrayOfGuID :TArrays;
firstHit : integer;
AGuIDlist:Tstringlist;
// ArrayOfGuID :array of array of string;
FBitmapList : TList<TBitmap>;
FImgListPath : TList<string>;
FCurrentIndex : integer ;
PageCount,PageCountA : integer ;
pageIndex : Integer;
tapDownPos : TPointF;
tapDownPosF : TPointF;
FX : single ;
tapIsDown: Boolean; // This is needed, since the tap can happend outside control and then moved inside it to release
procedure ScrollMainView(page: Integer);
procedure InitFormInfo ;
//
procedure InitImageList();
procedure InitCurrentImage ;
procedure InitFormInfoA ;
//
procedure InitImageListPath ;
procedure InitCurrentImgPath ;
//
procedure InitImageStrPath ;
Procedure InitCurrentPath ;
procedure ARectCancelOnClick(Sender :TObject);
procedure ARectOnClick(Sender :TObject);
procedure LblOkClick(Sender: TObject);
procedure LoadImgGuIDInfo; //下载小图guid和大图guid对应表 暂时不用
procedure LoadZoomImg(AIndex:integer);
public
{ Public declarations }
//缩约图list,缩约图idlist,点击的第几张图,载体id,缩约图和原图对应的id 2维表
class Procedure ShowForm(AList:TList<TBitmap>;BGuIDlist:Tstringlist;AIndex
:integer;AMSCarrierObject_ID:string; AArrayOfGuID:TArrays); overload;
class Procedure ShowForm(AListPath : TList<string> ; AIndex :Integer );overload;
end;
var
FrmShowPictureZoomIn: TFrmShowPictureZoomIn;
implementation
{$R *.fmx}
procedure TFrmShowPictureZoomIn.ARectCancelOnClick(Sender: TObject);
begin
TDRForm.Create(TFrmShowPictureZoomIn).Release ;
end;
procedure TFrmShowPictureZoomIn.ARectOnClick(Sender: TObject);
var
ABitmap : TBitmap ;
AList : TList<TBitmap>;
begin
if Sender is TRectangle then
begin
try
AList := TList<TBitmap>.Create;
ABitmap := TBitmap.Create;
ABitmap.Assign(AImage[pageindex].bitmap);
if AChkType.IsChecked <> true then
ABitmap.CreateThumbnail(40,40);
AList.Add(ABitmap);
TMessageManager.DefaultManager.SendMessage(self,TImageCallBack.Create(AList));
//image2.Bitmap.Assign(AImage[pageindex-1].bitmap);
finally
ABitmap.DisposeOf ;
end;
end;
end;
procedure TFrmShowPictureZoomIn.FormCreate(Sender: TObject);
begin
pageIndex := 0;
tapIsDown := false;
LayoutContainer.Position.Y := 60;
ARectIsCreate := false;
end;
procedure TFrmShowPictureZoomIn.FormGesture(Sender: TObject;
const EventInfo: TGestureEventInfo; var Handled: Boolean);
var
LObj : IControl;
LImage : TImage;
LImageCenter : TPointF;
ATag : integer ;
begin
INHERITED;
{$IFNDEF MSWINDOWS}
if Sender is TImage then
ATag := TImage(Sender).Tag ;
if Sender is TRectangle then
ATag := TRectangle(Sender).Tag;
if EventInfo.GestureID = igiZoom then
begin
tapIsDown := false;
LObj := Self.ObjectAtPoint(ClientToScreen(EventInfo.Location));
if LObj is TImage then
begin
if (not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags)) and
(not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags)) then
begin
LImage := TImage(LObj.GetObject);
LImageCenter := LImage.Position.Point + PointF(LImage.Width / 2,
LImage.Height / 2);
LImage.Width := LImage.Width + (EventInfo.Distance - FLastDistance);
LImage.Height := LImage.Height + (EventInfo.Distance - FLastDistance);
LImage.Position.X := LImageCenter.X - LImage.Width / 2;
LImage.Position.Y := LImageCenter.Y - LImage.Height / 2;
//
if LImage.Width < FOriginalWidth[PageIndex] then
begin
FZoomWidth := LImage.Width ;
end;
if LImage.height < FOriginalHeight[PageIndex] then
begin
FZoomheight := LImage.height ;
end;
end;
FLastDistance := EventInfo.Distance;
Handled := true ;
end;
end;
{$ENDIF}
end;
procedure TFrmShowPictureZoomIn.FormMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
if FZoomWidth< FOriginalWidth[PageIndex] then
begin
AImage[PageIndex].Position.X := FOriginalX[PageIndex];
AImage[PageIndex].Position.Y := FOriginalY[PageIndex] ;
AImage[PageIndex].Width := FOriginalWidth[PageIndex] ;
AImage[PageIndex].Height := FOriginalHeight[PageIndex] ;
end;
end;
procedure TFrmShowPictureZoomIn.FormResize(Sender: TObject);
var
i :integer ;
begin
LayoutContainer.Height := Self.ClientHeight;
LayoutContainer.Width := self.ClientWidth ;
RectTop.Width := trunc(self.ClientWidth / 3 );
if ARectIsCreate then
begin
if Assigned(FBitmapList) then
for i :=0 to FBitmapList.Count -1 do
begin
ARect[i].Width := self.ClientWidth ;
if i>0 then
ARect[i].Position.X :=ARect[i-1].Width *I;
ScrollMainView(FCurrentIndex);
end;
if Assigned(FImgListPath) then
for i :=0 to FImgListPath.Count -1 do
begin
ARect[i].Width := self.ClientWidth ;
if i>0 then
ARect[i].Position.X :=ARect[i-1].Width *I;
ScrollMainView(FCurrentIndex);
end;
end;
end;
procedure TFrmShowPictureZoomIn.FormTap(Sender: TObject; const Point: TPointF);
begin
TDRForm.Create(self).Release ;
end;
procedure TFrmShowPictureZoomIn.ImgReturnClick(Sender: TObject);
begin
TDRForm.Create(self).Release ;
end;
procedure TFrmShowPictureZoomIn.InitCurrentImage;
begin
ScrollMainView(FCurrentIndex);
end;
procedure TFrmShowPictureZoomIn.InitCurrentImgPath;
begin
end;
procedure TFrmShowPictureZoomIn.InitCurrentPath;
begin
TAnimator.AnimateFloat(LayoutContainer, 'Position.X', (50 * 2) * -1, 0.5, TAnimationType.Out, TInterpolationType.Exponential);
end;
procedure TFrmShowPictureZoomIn.InitFormInfo;
begin
//PageCount := FBitmapList.Count ;
if Assigned(FBitmapList) then
begin
PageCount := FBitmapList.Count -1 ;
setLength(ArrayOfGuID,FBitmapList.Count,2);
end;
if Assigned(FImgListPath) then
begin
PageCount := FImgListPath.Count -1 ;
setLength(ArrayOfGuID,FImgListPath.Count,2);
end;
{$IFNDEF MSWINDOWS}
GestureManager1 := TGestureManager.Create(SELF) ;
{$ENDIF}
end;
procedure TFrmShowPictureZoomIn.InitFormInfoA;
begin
PageCount := FBitmapList.Count -1 ;
end;
procedure TFrmShowPictureZoomIn.InitImageList;
var
i : integer ;
ARect : Array of TRectangle ;
ARectBottom : TRectangle;
ARectTop : TRectangle;
ALblOk : TLabel ;
begin
setLength(ARect,FBitmapList.Count);
setLength(AImage,FBitmapList.Count);
setLength(FOriginalWidth,FBitmapList.Count);
setLength(FOriginalHeight,FBitmapList.Count);
setLength(FOriginalX,FBitmapList.Count);
setLength(FOriginalY,FBitmapList.Count);
for i := 0 to FBitmapList.Count-1 do
begin
ARect[i] := TRectangle.Create(nil);
ARect[i].Width := self.ClientWidth ;
ARect[i].Height := self.Height ;
ARect[i].Parent := LayoutContainer ;
//ARect[i].Align := TAlignLayout.Left ;
if i>0 then
ARect[i].Position.X :=ARect[i-1].Width *I;
ARect[i].Tag := i+1 ;
ARect[i].Fill.Color :=$FF000000;
{$IFNDEF MSWINDOWS}
ARect[i].Touch.GestureManager := GestureManager1 ;
ARect[i].Touch.InteractiveGestures :=[TInteractiveGesture.Zoom,TInteractiveGesture.Pan,TInteractiveGesture.Rotate,
TInteractiveGesture.TwoFingerTap,TInteractiveGesture.PressAndTap];
ARect[i].OnGesture := FormGesture ;
{$ENDIF}
ARect[i].OnMouseDown := RectOnMouseDown ;
ARect[i].OnMouseUp := RectOnMouseUp ;
ARect[i].OnMouseMove := RectOnMouseMove ;
AImage[i] := FMX.Objects.TImage.Create(nil);
AImage[i].Parent := ARect[i] ;
AImage[i].Tag := i+1 ;
AImage[i].Width := self.ClientWidth -20 ;
AImage[i].Height := 400 ;
AImage[i].Margins.Left :=10;
AImage[i].Margins.Right :=10;
AImage[i].Align :=TAlignLayout.Center ;
// if FileExists(FBitmapList[i]) then
// begin
// AImage[i].Bitmap.LoadFromFile(FBitmapList[i]);
// end
// else
AImage[i].Bitmap.Assign(FBitmapList[i]);
AImage[i].WrapMode :=TImageWrapMode.Stretch ;
AImage[i].HitTest := true ;
AImage[i].OnMouseDown := RectOnMouseDown ;
AImage[i].OnMouseUp := RectOnMouseUp ;
AImage[i].OnMouseMove := RectOnMouseMove ;
ARectBottom := TRectangle.Create(nil);
ARectBottom.Width := self.ClientWidth ;
ARectBottom.Height := 60;
ARectBottom.Parent := ARect[i] ;
ARectBottom.StrokeThickness := 0;
ARectBottom.Fill.Color := $FF000000;
ARectBottom.Opacity := 0.5 ;
ARectBottom.Align := TAlignLayout.Bottom ;
ARectOK := TRectangle.Create(nil);
ARectOK.Parent := ARectBottom ;
ARectOK.Width := 120;
ARectOK.Align := TAlignLayout.Right ;
ARectOK.HitTest := true;
ARectOK.Margins.Top :=8;
ARectOK.Margins.Right :=16;
ARectOK.Margins.Bottom :=8;
ARectOK.Sides :=[];
ARectOK.XRadius := 8;
ARectOK.YRadius := 8;
ARectOK.Fill.Color := $FF4acfd6;
ARectOK.OnClick := ARectOnClick ;
ALblOk := TLabel.Create(nil) ;
ALblOk.Text :='选 取';
ALblOk.AutoSize := true;
ALblOk.Parent := ARectOK ;
ALblOk.Font.Size := 18;
ALblOk.FontColor := $FFFFFF;
ALblOk.Align := TAlignLayout.Center ;
ALblOk.HitTest := false;
//
ARectTop := TRectangle.Create(nil);
ARectTop.Width := self.ClientWidth ;
ARectTop.Height := 60;
ARectTop.Parent := ARect[i] ;
ARectTop.StrokeThickness := 0;
ARectTop.Fill.Color := $FF000000;
ARectTop.Opacity := 0.5 ;
ARectTop.Align := TAlignLayout.Top ;
//
FOriginalWidth[i] := AImage[i].Width ;
FOriginalHeight[i] := AImage[i].Height ;
FOriginalX[i] := AImage[i].Position.X ;
FOriginalY[i] := AImage[i].Position.Y ;
end;
end;
procedure TFrmShowPictureZoomIn.InitImageListPath;
var
i : integer ;
ARectBottom : TRectangle;
ARectTop : TRectangle;
ALblOk : TLabel ;
ALblCancel : TLabel ;
AStream : TMemoryStream ;
begin
setLength(ARect, FImgListPath.Count);
setLength(AImage,FImgListPath.Count);
setLength(FOriginalWidth, FImgListPath.Count);
setLength(FOriginalHeight,FImgListPath.Count);
setLength(FOriginalX,FImgListPath.Count);
setLength(FOriginalY,FImgListPath.Count);
ARectIsCreate := true ;
for i := 0 to FImgListPath.Count-1 do
begin
ARect[i] := TRectangle.Create(nil);
ARect[i].Width := self.ClientWidth ;
ARect[i].Height := self.Height;
ARect[i].Parent := LayoutContainer ;
ARect[i].HitTest:= true ;
if i>0 then
ARect[i].Position.X :=ARect[i-1].Width *I;
ARect[i].Margins.Left :=20 ;
ARect[i].Margins.Right :=20 ;
ARect[i].Tag := i+1 ;
ARect[i].Fill.Color :=$FF000000;
{$IFNDEF MSWINDOWS}
ARect[i].Touch.GestureManager := GestureManager1 ;
ARect[i].Touch.InteractiveGestures :=[TInteractiveGesture.Zoom,TInteractiveGesture.Pan,TInteractiveGesture.Rotate,
TInteractiveGesture.TwoFingerTap,TInteractiveGesture.PressAndTap];
ARect[i].OnGesture := FormGesture ;
{$ENDIF}
ARect[i].OnMouseDown := RectOnMouseDown ;
ARect[i].OnMouseUp := RectOnMouseUp ;
ARect[i].OnMouseMove := RectOnMouseMove ;
AImage[i] := FMX.Objects.TImage.Create(nil);
AImage[i].Parent := ARect[i] ;
AImage[i].Tag := i+1 ;
AImage[i].Align :=TAlignLayout.Client ;
AImage[i].WrapMode :=TImageWrapMode.Fit;
//AImage[i].Align:=TAlignLayout.Contents;
//AImage[i].Width := self.ClientWidth ;
//AImage[i].Height :=self.Height;
AStream:= TMemoryStream.Create ;
{$IFDEF MSWINDOWS}
if FileExists(FImgListPath[i]) then
begin
try
AStream.LoadFromFile(FImgListPath[i]);
AImage[i].Bitmap.LoadFromStream(AStream);
finally
AStream.DisposeOf ;
end;
end
else
AImage[i].Bitmap.Assign(Image2.Bitmap);
{$ELSE}
if TFile.Exists(FImgListPath[i]) then
begin
try
AStream.LoadFromFile(FImgListPath[i]);
AImage[i].Bitmap.LoadFromStream(AStream);
Finally
AStream.DisposeOf ;
end;
end
else
AImage[i].Bitmap.Assign(Image2.Bitmap);
{$ENDIF}
//AImage[i].WrapMode :=TImageWrapMode.Stretch ;
AImage[i].HitTest := true ;
AImage[i].OnMouseDown := RectOnMouseDown ;
AImage[i].OnMouseUp := RectOnMouseUp ;
AImage[i].OnMouseMove := RectOnMouseMove ;
//
FOriginalWidth[i] := AImage[i].Width ;
FOriginalHeight[i] := AImage[i].Height ;
FOriginalX[i] := AImage[i].Position.X ;
FOriginalY[i] := AImage[i].Position.Y ;
ARectIsCreate := true ;
end;
end;
procedure TFrmShowPictureZoomIn.InitImageStrPath;
var
i : integer ;
ARect : Array of TRectangle ;
ALabel : TLabel ;
ARectBottom : TRectangle;
ARectTop : TRectangle;
ALblOk : TLabel ;
begin
setLength(ARect,7);
setLength(AImage,FBitmapList.Count);
setLength(FOriginalWidth,FBitmapList.Count);
setLength(FOriginalHeight,FBitmapList.Count);
setLength(FOriginalX,FBitmapList.Count);
setLength(FOriginalY,FBitmapList.Count);
for i := 0 to 2 do
begin
ARect[i] := TRectangle.Create(nil);
ARect[i].Width := 50;
ARect[i].height := self.ClientHeight ;
ARect[i].Parent := LayoutContainer ;
//ARect[i].Align := TAlignLayout.Left ;
if i>0 then
begin
ARect[i].Position.X :=ARect[i-1].Width *I ;
end;
ARect[i].Tag := i+1 ;
ARect[i].Fill.Color :=$FF33aadd;
ALabel := TLabel.Create(nil);
ALabel.Parent := ARect[i] ;
ALabel.text := 'aa'+inttostr(i);
ALabel.Align := TAlignLayout.Left ;
end;
end;
procedure TFrmShowPictureZoomIn.LblOkClick(Sender: TObject);
begin
//
end;
procedure TFrmShowPictureZoomIn.lblSelectOKClick(Sender: TObject);
begin
ARectOnClick(Sender);
end;
procedure TFrmShowPictureZoomIn.LoadImgGuIDInfo;
var
getdata1: TGetData;
str,devicetype,ANameList: string;
Atag: string;
cds1: TClientDataSet;
AList :TStringList;
i,j:integer;
begin
if not IsWebConnected then
begin
ShowTips(NoAvailableNetwork);
Exit;
end;
// StartLoading(Self);
ASYNCStart(
procedure
begin
try
// showmessage('P_DEC_getIMGDetail'+','+BMSCarrierObject_ID);
getdata1 := TGetData.Create(['P_DEC_getIMGDetail',
BMSCarrierObject_ID]);
str := getdata1.GetResult;
cds1 := getdata1.GetClientDataSet;
finally
getdata1.DisposeOf;
end;
SYNCStart(
procedure
begin
try
i:=0;
cds1.First;
while not cds1.Eof do
begin
ArrayOfGuID[i,0]:= cds1.FieldByName('ID_SL').AsString;
ArrayOfGuID[i,1]:=cds1.FieldByName('ID').AsString;
inc(i);
cds1.Next;
end;
finally
// LoadZoomImg(FCurrentIndex);
cds1.disposeof;
end;
end);
end);
end;
procedure TFrmShowPictureZoomIn.LoadZoomImg(AIndex: integer);
var
i,j:integer;
ABitmap:Tbitmap;
errmsg:string;
begin
//if firstHit<>0 then
ScrollMainView(AIndex);
ASYNCStart(
procedure
var
j:integer;
begin
i:=AIndex;
ABitmap:= Tbitmap.Create;
for j := 0 to AGuIDlist.Count-1 do
begin
if ArrayOfGuID[j,0]=AGuIDlist[i] then
begin
TBitmapManager.DownLoadSingleBitMap(ArrayOfGuID[j,1],ABitmap,errmsg);
end;
end;
SYNCStart(
procedure
begin
AImage[i].Bitmap.Assign(ABitmap);
// firstHit:=1;
end);
end);
end;
procedure TFrmShowPictureZoomIn.RectOnMouseDown(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Single);
begin
tapDownPos := TPointF.Create(X, Y);
tapIsDown := true;
end;
procedure TFrmShowPictureZoomIn.RectOnMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Single);
begin
if tapIsDown then
begin
FX := LayoutContainer.Position.X ;
if (PageIndex>=0) and (PageIndex<=PageCount) then
begin
if X - tapDownPos.X < 0 then
begin
TAnimator.AnimateFloat(LayoutContainer, 'Position.X', LayoutContainer.Position.X + (X - tapDownPos.x), 0.5, TAnimationType.InOut, TInterpolationType.Linear );
end
else
begin
TAnimator.AnimateFloat(LayoutContainer, 'Position.X', LayoutContainer.Position.X + (X - tapDownPos.x), 0.5, TAnimationType.InOut, TInterpolationType.Linear );
end;
end;
end;
end;
procedure TFrmShowPictureZoomIn.RectOnMouseUP(Sender: TObject;Button: TMouseButton; Shift: TShiftState; X, Y: Single);
var
AMidX,AMidX1 :single ;
ATag : integer ;
begin
if FZoomWidth< FOriginalWidth[PageIndex] then
begin
AImage[PageIndex].Position.X := FOriginalX[PageIndex];
AImage[PageIndex].Position.Y := FOriginalY[PageIndex] ;
AImage[PageIndex].Width := FOriginalWidth[PageIndex] ;
AImage[PageIndex].Height := FOriginalHeight[PageIndex] ;
end;
if tapIsDown then
begin
if Sender is TImage then
ATag := TImage(Sender).Tag ;
if Sender is TRectangle then
ATag := TRectangle(Sender).Tag;
tapIsDown := false;
if (pageIndex =0) then
begin
if (X - tapDownPos.X + FX >0) then
TAnimator.AnimateFloat(LayoutContainer, 'Position.X', 0, 0.5, TAnimationType.InOut, TInterpolationType.Circular )
else
if (X - tapDownPos.X + FX < -10) and (X - tapDownPos.X + FX > -80) then
TAnimator.AnimateFloat(LayoutContainer, 'Position.X', 0, 0.5, TAnimationType.InOut, TInterpolationType.Linear )
else
begin
Inc(pageIndex);
// ScrollMainView(pageIndex);
// sleep(500);
LoadZoomImg(pageIndex);
end;
end
else
begin
if (pageIndex = PageCount) then
begin
if X - tapDownPos.X + FX < 0 then
begin ///1111111111111
if (X - tapDownPos.X + FX) + (self.ClientWidth * (pageindex)) <0 then
TAnimator.AnimateFloat(LayoutContainer, 'Position.X', (self.ClientWidth*(PageCount))*-1, 0.5, TAnimationType.InOut, TInterpolationType.Linear )
else
begin
if ((X - tapDownPos.X + FX) + (self.ClientWidth * (pageindex ))>0) and
((X - tapDownPos.X + FX) + (self.ClientWidth * (pageindex ))<100) then
begin
TAnimator.AnimateFloat(LayoutContainer, 'Position.X', (self.ClientWidth*(PageCount))*-1, 0.5, TAnimationType.InOut, TInterpolationType.Linear );
end
else
begin
Dec(pageIndex);
// ScrollMainView(pageIndex);
// sleep(500);
LoadZoomImg(pageIndex);
end;
end;
end;
end
else
begin
// swipe left
AMidX := X - tapDownPos.X + FX ;
AMidX1 := -(Self.ClientWidth*(pageIndex));
if AMidX - AMidX1 < 0 then
begin
if ((AMidX - AMidx1) < 0) and
((AMidX - AMidx1) > -120) then
begin
TAnimator.AnimateFloat(LayoutContainer, 'Position.X', -(Self.ClientWidth*(pageIndex)), 0.5, TAnimationType.InOut, TInterpolationType.Linear );
end
else
begin
Inc(pageIndex);
// ScrollMainView(pageIndex);
// sleep(500);
LoadZoomImg(pageIndex);
end;
end
// swipe right
else
begin
if ((AMidX - AMidx1) > 0) and
((AMidX - AMidx1) < 80) then
begin
ScrollMainView(pageIndex);
end
else
begin
dec(pageIndex);
// ScrollMainView(pageIndex);
// sleep(500);
LoadZoomImg(pageIndex);
end;
end;
end;
end;
end;
end;
procedure TFrmShowPictureZoomIn.RectTopClick(Sender: TObject);
begin
TDRForm.Create(self).Release ;
end;
procedure TFrmShowPictureZoomIn.ScrollMainView(page: Integer);
begin
//showmessage(pageIndex.ToString);
pageIndex := page;
Dec(page);
TAnimator.AnimateFloat(LayoutContainer, 'Position.X', (ClientWidth * (page+1)) * -1, 0.5, TAnimationType.Out, TInterpolationType.Exponential);
end;
class procedure TFrmShowPictureZoomIn.ShowForm(AListPath: TList<string>;
AIndex: Integer);
begin
with TDRForm.Create(TFrmShowPictureZoomIn).TCCF as TFrmShowPictureZoomIn do
begin
FImgListPath := AListPath ;
FCurrentIndex := AIndex ;
InitFormInfo ;
Show ;
InitImageListPath ;
InitCurrentImage ;
end;
end;
class procedure TFrmShowPictureZoomIn.ShowForm(AList: TList<TBitmap>;BGuIDlist:Tstringlist;
AIndex: integer;AMSCarrierObject_ID:string; AArrayOfGuID:TArrays);
var
i,j:integer;
ABitmap:Tbitmap;
errmsg:string;
begin
with TDRForm.Create(TFrmShowPictureZoomIn).TCCF as TFrmShowPictureZoomIn do
begin
firstHit:=0;
FBitmapList := AList ;
FCurrentIndex := AIndex ;
BMSCarrierObject_ID:=AMSCarrierObject_ID;
InitFormInfo;
Show ;
AGuIDlist:=Tstringlist.Create;
AGuIDlist:=BGuIDlist;
ArrayOfGuID:=AArrayOfGuID;
//LoadImgGuIDInfo;
InitImageList ;
//InitCurrentImage ;
LoadZoomImg(FCurrentIndex);
// ABitmap:= Tbitmap.Create;
// for j := 0 to AGuIDlist.Count-1 do
// begin
// if ArrayOfGuID[j,0]=AGuIDlist[FCurrentIndex] then
// begin
// //showmessage(ArrayOfGuID[j,0]+','+ArrayOfGuID[j,1]);
// TBitmapManager.DownLoadSingleBitMap(ArrayOfGuID[j,1],ABitmap,errmsg);
// // image3.Bitmap.Assign(ABitmap);
// AImage[FCurrentIndex].Bitmap.Assign(ABitmap);
// firstHit:=1;
// end;
// end;
end;
end;
end.
delphi 预览图片2 (MouseUP)的更多相关文章
- hTML5实现表单内的上传文件框,上传前预览图片,针刷新预览images
hTML5实现表单内的上传文件框,上传前预览图片,针刷新预览images, 本例子主要是使用HTML5 的File API,建立一個可存取到该file的url, 一个空的img标签,ID为img0,把 ...
- [js/jquery]移动端手势拖动,放大,缩小预览图片
摘要 有这样的需求需要在手机端预览图片的时候,实现图片的手势拖动,放大缩小功能.最终通过touch.js这个插件实现了效果. touch.js Touch.js是移动设备上的手势识别与事件库, 由百度 ...
- ftp如何预览图片 解决方案
下载使用 server-U ,开启 HTTP 服务,输入 http://ip:端口 后,登录ftp账号密码,可选使用 基于java的应用 web client 或 FTP Voyager JV,来预览 ...
- 本地预览图片html和js例子
本地预览图片html和js例子,直接上代码吧. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ...
- js矩阵菜单或3D立体预览图片效果
js矩阵菜单或3D立体预览图片效果 下载地址: http://files.cnblogs.com/elves/js%E7%9F%A9%E9%98%B5%E8%8F%9C%E5%8D%95%E6%88% ...
- [.ashx檔?泛型处理例程?]基础入门#2....FileUpload上传前,预览图片(两种作法--ashx与JavaScript)
原文出處 http://www.dotblogs.com.tw/mis2000lab/archive/2013/08/20/ashx_beginner_02_fileupload_picture_p ...
- input file 模拟预览图片。
首先申明,接下来内容只是单纯的预览图片,最多选择九张,并没有和后台交互,交互的话需要自己另外写js. 本来想写一个调用摄像头的demo,意外的发现input file 在手机端打开的话,ios可以调用 ...
- Html5选择图片并及时预览图片
以往想要实现图片预览基本都是先传至服务器后等返回链接地址才能进行预览,使用Html5选择图片并及时预览图片的代码如下,使用起来更爽了. <!DOCTYPE html> <html l ...
- 巧用weui.gallery(),点击图片后预览图片
要在页面需要加载的JS文件: <script src="../js/libs/weui.min.js"></script> 可以去weui的文档中下载,这是 ...
随机推荐
- 转 linux目录介绍
以下用一个表格来罗列linux默认的目录或文件及其用途: 目录/文件 用途 来源 / /处于Linux文件系统树形结构的最顶端,它是Linux文件系统的入口,所有的目录.文件.设备都在/之下. - / ...
- 17.4.3 使用MulticastSocket实现多点广播(2)
// 让该类实现Runnable接口,该类的实例可作为线程的target public class MulticastSocketTest implements Runnable { // 使用常量作 ...
- php 依赖注入容器
原文: http://blog.csdn.net/realghost/article/details/35212285 https://my.oschina.net/cxz001/blog/53316 ...
- Cocos2dx 学习笔记整理----在项目中使用图片(二)
之前了解了一种比较简单的图片的使用方式, 今次来了解稍微复杂一点的图片使用方式,plist+png. 这里要用到之前提到的Texture Packer. Texture Packer是一款图片打包工具 ...
- ComboBox值排序
ComboBox值排序先是想通过冒泡排序,但是冒泡排序是int类型,又打算通过下标,进行字符串排序,然后想到了一个简单的办法……先存入ArrayList排序Sort清空ComboBox再遍历存入 ...
- [转]ASP.NET Core 1 Deploy to IIS
本文转自: http://webmodelling.com/webbits/aspnet/aspnet-deploy-iis.aspx 15 Sep 2016. This tutorial will ...
- HDU 5620 KK's Steel
想了一下发现是斐波那契数列.....水题 #include <stdio.h> #include <algorithm> #include <string.h> # ...
- mysql数据库中间件研究
随着互联网的发展,数据量的不断增大. 单台实例已经远远无法满足业务的需要. 对数据库分库分表的需求不断的增加随之而来的就是数据库中间件的开发. 一. 单台实例主要面临下面几个问题: 1. 数据量太大 ...
- CocoaPods安装和使用教程 分类: ios技术 ios相关 2015-03-11 21:53 48人阅读 评论(0) 收藏
目录 CocoaPods是什么? 如何下载和安装CocoaPods? 如何使用CocoaPods? 场景1:利用CocoaPods,在项目中导入AFNetworking类库 场景2:如何正确编译运行一 ...
- vuejs 子组件传递父组件的第一种方式
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...