ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Drag n Drop in the same ImageEn*MView
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

lago

40 Posts

Posted - Mar 29 2016 :  13:25:02  Show Profile  Reply
Hello all, i have a question about drag and drop in the same ImageEn*MView.

As can I move the thumbnails to different positions in the same ImageEn*MView ?

For example, i have four thumbnails like this



... and for example, i want can choose the last thumb (img_4038.jpg) to the first position where are img_4028.jpg with drag method.

Seeing examples i found MultiView sample project, but only work in a single vertical colum. I have multiple horizontal colums, i think its a problem.

Someone can help me? What is the best way to do it?


Thanks alot.

Jorge.

w2m

USA
1990 Posts

Posted - Mar 29 2016 :  15:48:12  Show Profile  Reply
Add the following code to the Horizontal ImageEnMView:
procedure TMainForm.ImageEnMViewHorzontal1AfterEvent(Sender: TObject; Event: TIEAfterEvent);
{ This draws the insert point vertical red line }
var
  imgX, imgY :integer;
begin
  if (Event = ieaePaint) and ImageEnMViewHorzontal1.Dragging and (fDragInsertPos > -1) then
  begin
    if fDragInsertPos >= ImageEnMViewHorzontal1.ImageCount then
    begin
      // Position at end of last thumbnail
      imgX := ImageEnMViewHorzontal1.ImageX[ImageEnMViewHorzontal1.ImageCount - 1] - ImageEnMViewHorzontal1.ViewX;
      imgY := ImageEnMViewHorzontal1.ImageY[ImageEnMViewHorzontal1.ImageCount - 1] - ImageEnMViewHorzontal1.ViewY + ImageEnMViewHorzontal1.ThumbHeight - 2;
    end
    else
    begin
      // Position before current thumbnail
      imgX := ImageEnMViewHorzontal1.ImageX[fDragInsertPos] - ImageEnMViewHorzontal1.ViewX;
      imgY := ImageEnMViewHorzontal1.ImageY[fDragInsertPos] - ImageEnMViewHorzontal1.ViewY + 1;
    end;
    with ImageEnMViewHorzontal1.GetCanvas do
    begin
      Pen.Color := clRed;
      Pen.Width := 3;
      Pen.Style := psSolid;
      MoveTo(ImgX, 0);
      LineTo(ImgX,  ImgY + ImageEnMViewHorzontal1.ThumbHeight);
    end;
  end;
end;

procedure TMainForm.ImageEnMViewHorzontal1DragDrop(Sender, Source: TObject; X, Y: Integer);
{ This moves the selected image to the inserting point }
var
  im:integer;
begin
  ImageEnMViewHorzontal1.MultiSelectSortList;  // selection order is not important
  im := ImageEnMViewHorzontal1.InsertingPoint(X, Y);
  ImageEnMViewHorzontal1.MoveSelectedImagesTo(im);
end;

procedure TMainForm.ImageEnMViewHorzontal1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState;
  var Accept: Boolean);
begin
  fDragInsertPos := -1;
  if Source = ImageEnMViewHorzontal1 then
  begin
    Accept := True;
    fDragInsertPos := ImageEnMViewHorzontal1.InsertingPoint(X, Y);
  end;
  ImageEnMViewHorzontal1.Paint;
end;

procedure TMainForm.ImageEnMViewHorzontal1EndDrag(Sender, Target: TObject; X, Y: Integer);
begin
  ImageEnMViewHorzontal1.IEEndDrag;
  ImageEnMViewHorzontal1.MouseInteract := [mmiSelect];
  ImageEnMViewHorzontal1.Paint;
end;

procedure TMainForm.ImageEnMViewHorzontal1ImageSelect(Sender: TObject; idx: Integer);
begin
  // Copy image
  ImageEnMViewHorzontal1.CopyToIEBitmap( idx, ImageEnVect1.IEBitmap );
  // Copy annotations
  ImageEnVect1.RemoveAllObjects;
  ImageEnMViewHorzontal1.MIO.Params[idx].ImagingAnnot.CopyToTImageEnVect(ImageEnVect1);
  ImageEnVect1.Update;
end;

procedure TMainForm.ImageEnMViewHorzontal1MouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  if (ssLeft in Shift) then
  begin
    ImageEnMViewHorzontal1.MouseInteract := [];
    ImageEnMViewHorzontal1.IEBeginDrag(true, -1);
  end;
end;

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development
Go to Top of Page

lago

40 Posts

Posted - Mar 31 2016 :  22:19:52  Show Profile  Reply
Thanks alot Bill, nice example :) now i will try port to C

Go to Top of Page

lago

40 Posts

Posted - Apr 07 2016 :  05:42:53  Show Profile  Reply
Umm i have some problems with MouseInteract in C++, i found this:
http://www.imageen.com/ieforum/topic.asp?TOPIC_ID=1532&SearchTerms=MouseInteract,C++

ImageEnView1->MouseInteract = TIEMouseInteract()<<mmiSelect;

But not run
[bcc32 Error] Unit1.cpp(1317): E2094 'operator<<' not implemented in type 'TIEMouseInteract' for arguments of type 'TIEMMouseInteractItems'

Someone know where is the problem?

Thanks for all.

Jorge.
Go to Top of Page

aleatprog

122 Posts

Posted - Mar 19 2019 :  02:29:49  Show Profile  Reply
I got a question about Bill's code:

Is it possible to enable drag&drop only if the mouse pointer is on the thumbnail area while clicking, and allow multiple selection if the pointer is outside the thumbnail while clicking?

In short words: the same behaviour as in Windows Explorer.

Using Bill's code, even if I click outside the thumbnail area the drag&drop modus for the thumbnail is active and multiple thumbnail selection is only possible using the shift or ctrl key.
Go to Top of Page

spetric

Croatia
308 Posts

Posted - Mar 19 2019 :  15:41:13  Show Profile  Reply
@largo

One M is missing in your code (if we speak about ImagEnMView):

mView->MouseInteract = TIEMMouseInteract() << mmiSelect;


Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: