这个是自己项目在使用的,所以带有些业务功能的代码。

逻辑上使用的大多是 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)的更多相关文章

  1. hTML5实现表单内的上传文件框,上传前预览图片,针刷新预览images

    hTML5实现表单内的上传文件框,上传前预览图片,针刷新预览images, 本例子主要是使用HTML5 的File API,建立一個可存取到该file的url, 一个空的img标签,ID为img0,把 ...

  2. [js/jquery]移动端手势拖动,放大,缩小预览图片

    摘要 有这样的需求需要在手机端预览图片的时候,实现图片的手势拖动,放大缩小功能.最终通过touch.js这个插件实现了效果. touch.js Touch.js是移动设备上的手势识别与事件库, 由百度 ...

  3. ftp如何预览图片 解决方案

    下载使用 server-U ,开启 HTTP 服务,输入 http://ip:端口 后,登录ftp账号密码,可选使用 基于java的应用 web client 或 FTP Voyager JV,来预览 ...

  4. 本地预览图片html和js例子

    本地预览图片html和js例子,直接上代码吧. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" ...

  5. js矩阵菜单或3D立体预览图片效果

    js矩阵菜单或3D立体预览图片效果 下载地址: http://files.cnblogs.com/elves/js%E7%9F%A9%E9%98%B5%E8%8F%9C%E5%8D%95%E6%88% ...

  6. [.ashx檔?泛型处理例程?]基础入门#2....FileUpload上传前,预览图片(两种作法--ashx与JavaScript)

    原文出處  http://www.dotblogs.com.tw/mis2000lab/archive/2013/08/20/ashx_beginner_02_fileupload_picture_p ...

  7. input file 模拟预览图片。

    首先申明,接下来内容只是单纯的预览图片,最多选择九张,并没有和后台交互,交互的话需要自己另外写js. 本来想写一个调用摄像头的demo,意外的发现input file 在手机端打开的话,ios可以调用 ...

  8. Html5选择图片并及时预览图片

    以往想要实现图片预览基本都是先传至服务器后等返回链接地址才能进行预览,使用Html5选择图片并及时预览图片的代码如下,使用起来更爽了. <!DOCTYPE html> <html l ...

  9. 巧用weui.gallery(),点击图片后预览图片

    要在页面需要加载的JS文件: <script src="../js/libs/weui.min.js"></script> 可以去weui的文档中下载,这是 ...

随机推荐

  1. STM32开发指南-跑马灯实验

    简单对I/O口的控制,主要通过对寄存器的读写控制.主要通过I/O的寄存器来控制:1. 控制I/O的方向2. 控制I/O的输出电平或上下来电阻3. 存储I/O口当前的输入状态(高低电平) 对使用LED灯 ...

  2. Struts2--中文问题

    有中文的情况下, form method都要用post: 如果jsp输入中文返回到后台action输出时会显示乱码, struts.xml已经设置 <constant name="st ...

  3. armstrong's programming erlang 2nd

    Re: json handling map functions in erlang 17 I have not read Joes final book on the matter (several ...

  4. RAD Studio 2010 环境设置(转)

    源:RAD Studio 2010 环境设置 最近在使用RAD Studio 2010做一些开发和实验,但在安装了自定义的控件及第三方下载的控件后,在我的工程里经常会提示找不到DCU,为了以后忘记这一 ...

  5. 浏览器加载外部js 的顺序,以及处理顺序。

    问题, 有事候按F12打开 google的调试台后,查看network下面加载过来的资源是, 有些资源的状态处于 pending.. 个人理解: 浏览器是可以同时开启多个http 请求去加载外部的资源 ...

  6. String类的两种赋值

    java.lang包是java的默认引入包,所以我们不需显式地导包. String s1 = new String("字符串");//创建2个字符串对象,堆中一个,字符串常量池中一 ...

  7. 屌爆了的两个在线编辑网站runjs和jsbin

    作者:zccst HTML5+css3做的小游戏 http://timelineapp.pointstone.org/coreball/game.html 切图工具:http://kuaiqie.co ...

  8. 我对hibernate的对象的3种状态的理解

    老师的说法 Hibernate中对象的状态    在Hibernate使用中,对象的状态有以下三种    a.临时对象 : 在程序中使用new方式创建的对象    b.持久对象 : 在程序中与sess ...

  9. eclipse java生成exe

    eclipse导出jar文件再将它转换成exe可执行文件详解 关键字: 欢迎光临 此文章是为了帮助刚接触j2se或不懂如何打包jar文件的人而着笔,同时也是让自己的知识以文章的形式保存起来. 一.导出 ...

  10. /etc/profile文件

    导读:Linux /etc/profile文件的改变会涉及到系统的环境,也就是有关Linux环境变量的东西,学习Linux要了解Linux profile文件的相关原理,这里对则以文件进行具体分析.这 ...