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

逻辑上使用的大多是 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. Swift中的异常处理

    swift中的异常处理 如果在调用系统某一个方法时,该方法最后有一个throws.说明该方法会抛出异常.如果一个方法会抛出异常,那么需要对该异常进行处理 *在swift中提供三种处理异常的方式 方式一 ...

  2. 数据恢复软件Extundelete

    数据恢复软件Extundelete介绍 一.概述 作为一名运维人员,保证数据的安全是根本职责,所以在维护系统的时候,要慎重和细心,但是有时也难免发生出现数据被误删除的情况,这个时候该如何快速.有效地恢 ...

  3. Java 8新特性探究(八)精简的JRE详解

    http://www.importnew.com/14926.html     首页 所有文章 资讯 Web 架构 基础技术 书籍 教程 Java小组 工具资源 - 导航条 - 首页 所有文章 资讯 ...

  4. 2014非专业知识学习---be smart

    非专业部分--构建人生 以书籍和网易公开课为主 (1)理财&投资 基金投资相关,好的书籍? (2)哲学总览 <公正>这个看了大半,需要总结归纳.  (必选) 同时结合哲学史,归纳西 ...

  5. 用Quick Cocos2dx做一个连连看(二)

    今天完成了以下内容: 1 成对生成SpriteItem 2 重排接口制作完成 3 SpriteItem的选择逻辑 主要代码如下: function MainScene:onEnter() local ...

  6. 自动安装脚本-------------基于LVMP搭建Nagios 监控

    Mysql初始化参数(mysql-5.6.31) /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local ...

  7. 必须熟悉的vim快捷键操作

    转载请表明出处http://www.dabu.info/?p=801 Vim/Vi 没有菜单,只有命令 Vim/Vi 工作模式介绍:插入模式 和  命令模式 是vi的两个基本模式.——插入模式 ,是用 ...

  8. kvm学习小计

    1.Kvm安装 安装方法两种方式,一种是直接下载源码编译安装,一种是直接使用yum install kvm/apt-get install kvm,这部分就不详细说明了,我使用的是第二种方法,待后 续 ...

  9. Windows录音API学习笔记(转)

    源:Windows录音API学习笔记 Windows录音API学习笔记 结构体和函数信息  结构体 WAVEINCAPS 该结构描述了一个波形音频输入设备的能力. typedef struct { W ...

  10. 详解Objective-C的meta-class 分类: ios相关 ios技术 2015-03-07 15:41 51人阅读 评论(0) 收藏

    比较简单的一篇英文,重点是讲解meta-class.翻译下,加深理解. 原文标题:What is a meta-class in Objective-C? 原文地址:http://www.cocoaw ...