Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC:

Best way to show a picture in an X# VOForm 09 Feb 2022 22:01 #21493

  • ic2
  • ic2's Avatar
  • Topic Author


  • Posts: 1661
  • Hello,

    In a VO datawindow we have a FabPaintLibCtrl which can show a picture with code like this:
    oImg := FabPaintLib{}
    			oImg:CreateFromFile(cJpgFile)
    			SELF:oDCfab:Image := oImg

    For X#, the Fab libs in the download area are all based on the 2.1 Assembly's for the X# files so they are useless in everything above X# 2.6. Besides, if only a few functions are used a .Net solution is preferable I think.

    What is the best solution to do so on a VO style X# window? I assume a Winforms PictureBox control can not be used?

    Dick

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 01:08 #21494

    • vzeljko
    • vzeljko's Avatar


  • Posts: 35
  • Dick,
    I think that Fab libs are based on X# 2.9.1.1 version.
    I prefer .NET classes.

    Zeljko

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 01:52 #21495

    • Chris
    • Chris's Avatar


  • Posts: 3973
  • Hi Dick,

    If the dlls are indeed for X# 2.1, you can ask Fabrice to update them.

    But I think they include source code as well, so I guess you can simply recompile them (unless there's an error compiling them, in which case again Fabrice would need to have a look).
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 10:00 #21498

    • Frank Müßner
    • Frank Müßner's Avatar


  • Posts: 259
  • Hello Dick,

    I use this code when I need a .Netcontrol on a VO window.
        self:pictureEdit1:= DevExpress.XtraEditors.PictureEdit{}
        self:pictureEdit1:Location := System.Drawing.Point{self:size:Width-175, 124} //tt:Height-289}
        self:pictureEdit1:Name := "e""pictureEdit1"
        self:pictureEdit1:Properties:SizeMode := DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom
        self:pictureEdit1:Properties:BorderStyle := DevExpress.XtraEditors.Controls.BorderStyles.NoBorder
        self:pictureEdit1:Properties:ShowMenu := false
        self:pictureEdit1:Size := System.Drawing.Size{162, 162}
        self:pictureEdit1:Visible := True
        self:pictureEdit1:TabIndex := 500
        SetParent(SELF:pictureEdit1:Handle, self:Handle())

    runs without problems until now.

    Maybe it will help you

    Frank

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 14:57 #21504

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1661
  • Hello,

    Thanks for all replies. I've downloaded the zip in the download area of this website and checked the assembly in ILSpy. Also the last update date is 11 March 2020 so they can't be up to date.

    @Frank: what kind of control is self:pictureEdit1 in your VO datawindow?

    We don't have DevExpress but probably we can assign the Winforms PictureEdit the same way as you do for DevExpress?

    Otherwise we need to access the code of Fab Paint. Some (but not all) is on Github.

    Dick

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 15:43 #21505

    • Fabrice
    • Fabrice's Avatar


  • Posts: 366
  • Hi Dick,
    I see my name and FabPaint, so I jump in....

    ALL the source of FabPaint is available on github, int the FabTools repository : github.com/X-Sharp/FabTools
    If you look closely to the Release area, you will find 3 releases : The latest has been build with 2.9a, 23 days ago.

    If it is no young enough, I can rebuild it with 2.10, but as it is all OpenSource code, you can download it and built it yourself...but you will have to use MS Visual Studio for that, sorry... ;)

    HTH,
    Fab

    Please Log in or Create an account to join the conversation.

    Last edit: by Fabrice. Reason: added the link to repository

    Best way to show a picture in an X# VOForm 10 Feb 2022 16:24 #21506

    • Frank Müßner
    • Frank Müßner's Avatar


  • Posts: 259
  • Hi Dick,

    you can take any .Net Control just an example.
    this.pictureBox1 = new System.Windows.Forms.PictureBox();

    look at this X# Help:
    www.xsharp.eu/help/example-4-the-email-client-exa.html

    Frank

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 17:28 #21507

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1661
  • Hello Fabrice,

    Fabrice wrote: ALL the source of FabPaint is available on github, int the FabTools repository : github.com/X-Sharp/FabTools


    Thanks for your reply; we saw that but didn't realize that FabPaint,Zip & More is now part of FabTools. I see it now.
    About the download: I think anyone converting a VO application to X# will look in the download area first. It took us quite some time before we realized this pre-2.6 download was responsible for the exception preventing the program to proceed, because VS isn't really helpful in that and the exception that 2.1 references were used did not occur on calling a Fab function but a few lines in the Start function.

    Maybe the download on www.xsharp.eu/itm-downloads/download?pat...FFabTools4XSharp.zip should be called Fabtools 2.1 with some comments? And another one for 2.6 would be helpful for some too. Or otherwise maybe change the last sentence to something like this?


    All the source can be found at : ... You will need this solution instead of the above download for X# versions from 2.6 and higher (=Assembly version 2.6)

    Dick

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 17:47 #21508

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1661
  • Hello Frank,

    you can take any .Net Control just an example.
    this.pictureBox1 = new System.Windows.Forms.PictureBox();


    The sample says:

    For this method we use a Windows.Forms.Form window as "Host" for the ActiveX control.

    The question is what to use in a VO Form from the Toolbox that appears. I only see FixedBitmap, never used that, but it looks like for that a bitmap should be a predefined resource.

    And as FabPaintLib.prg alone is 1721 lines of code, I was wondering if there's a more efficient way of showing a picture on a VO form, like the included pictureBox of Winforms which can be filled with even 1 line of code.

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    Best way to show a picture in an X# VOForm 10 Feb 2022 17:51 #21509

    • Fabrice
    • Fabrice's Avatar


  • Posts: 366
  • ic2 wrote: And as FabPaintLib.prg alone is 1721 lines of code, I was wondering if there's a more efficient way of showing a picture on a VO form, like the included pictureBox of Winforms which can be filled with even 1 line of code.

    :lol:
    You are right, FabPaintLib is "big", but it does a lot of things.... and you can use it in 2/3 lines to show an image.
    I would be curious to know how long is the PictureBox code in .NET to show images....certainly not only one line ! ;)

    Cheers,
    Fab

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 18:08 #21510

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1661
  • Hello Fabrice,

    As you know I have much more confidence in most of the VO & VO tools code, like yours than in anything Microsoft wrote. So my remarks are not at all to disqualify your products. However, when in a .Net environment, it makes sense not to include external libraries if the job can be done with code already available.

    About the PictureBox it looks like 2 lines would do, and in this sample 4 if you set height & width. That's 100% more than the minimum in in VO with FabPaint, but there's not much at all in C#/.Net which can be done with less code than in VO :unsure:

    Image image = Image.FromFile("BeigeMonitor1.png");
    pictureBox1.Image = image;
    pictureBox1.Height = image.Height;
    pictureBox1.Width = image.Width;

    Dick

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 19:02 #21511

    • Frank Müßner
    • Frank Müßner's Avatar


  • Posts: 259
  • Hi Dick,

    help this ?

    Frank
    Attachments:

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 10 Feb 2022 21:10 #21512

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1661
  • Hello Frank,

    Yes, thank you very much! That's great. It means that you can actually "paint" a Winforms control on a VO style X# window but you have to do it by code, not by using the toolbox, add a control and use the mouse to give it it's position and size.

    To explain to other readers:

    There's no control painted on the VO Windows form, instead this code displays the picture. It places the picture in the given Location of the window with the given Size; I added SizeMode to zoom it, otherwise a large picture only shows that portion of the picture that fits in the assigned Size. Frank has this code in the PostInit of the VO style window.

    Self:pictureBox1:= System.Windows.Forms.PictureBox{}
    Self:pictureBox1:Location := System.Drawing.Point{1, 1}
    Self:pictureBox1:Name := "e""pictureEdit1"
    Self:pictureBox1:Size := System.Drawing.Size{400, 400}
    Self:pictureBox1:SizeMode:= System.Windows.Forms.PictureBoxSizeMode.Zoom
    Self:pictureBox1:Visible := True
    Self:pictureBox1:TabIndex := 700
    Self:pictureBox1:Load("c:\temp\SomePicture.jpg")
    SetParent(Self:pictureBox1:Handle, Self:Handle())
    Return Nil


    But I have 1 issue which is probably a X#/VS issue and maybe someone recognizes . The programs compiles & runs. But of the .xsfrm or .xsmnu open when I double click or right click View Designer. I have checked if any files needed to be set to trusted but no. I added a VO form and that only gives some XML code. No designer.

    I have a converted VO app, SSA, and every form opens the designed in VS. I actually copied the Window1.prg/xsfrm/rc files from Frank's sample and dragged them in the SSA solution. Here I could open it and saw that there were no controls on the window.

    What am I missing here?

    Dick

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 11 Feb 2022 01:34 #21513

    • Chris
    • Chris's Avatar


  • Posts: 3973
  • Hi Dick,

    How did you add the menus and windows to the project? Can you send me the project to have a look?

    About the toolbox, you can choose to add a CustomControl to the window (from the VO toolbox), make it as large as you want and position it accordingly on the window, and then when you use SetParent(), use the handle of that custom control, instead of the handle of the window. That should do the trick.

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 11 Feb 2022 11:49 #21514

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1661
  • Hello Chris,

    Well, you can find the project a little bit higher in this thread. It's the zip download in the post of Frank. It is no my solution.

    I unzipped it and it is not possible to open an editor for the menu's or screens in that solution, in VS 2019.

    And thanks for the customer control info!

    Dick

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 11 Feb 2022 12:07 #21515

    • Chris
    • Chris's Avatar


  • Posts: 3973
  • Hi Dick,

    Ah, sorry, I did not realize this. But I just checked Frank's sample and all menus and windows seem to open fine. Not sure if someone else also sees a problem?

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 11 Feb 2022 12:31 #21516

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1661
  • Hello Chris,

    Hmmm, strange.

    What I did:

    1 I just dragged the VOMDIApp2 dir to my disk from the zip, opened in Windows Explorer
    2 Then doubleclicked VOMDIApp2.xsproj also in Explorer. VS opens it as if I clicked a .sln file
    3 Then I doubleclick Window1.Window1.xsfrm and nothing happens.

    But the application runs fine.

    I retried it to another location with the same result. For me it's not important but it's a bit strange, given that in other projects with VO style forms or menu the editor opens fine. Only difference is that I had to open it using the xsproj file as there was no .sln file in it.

    I also tried it in Xide but I always have trouble opening a project in Xide as I can'open a xsproj file and Xide expects a .viproj file. I never know how to open an existing project like this in Xide.

    Dick

    Please Log in or Create an account to join the conversation.

    Last edit: by ic2.

    Best way to show a picture in an X# VOForm 11 Feb 2022 13:19 #21518

    • Chris
    • Chris's Avatar


  • Posts: 3973
  • Hi Dick,

    Yes indeed, XIDE cannot open VS project files. Sorry, can't think of a reason why the window does not open in your PC unfortunately. But in your own projects, windows openfine, is that right? In which case I would just ignore this, as anyway the window in Frank's sample is completely empty, there's nothing to see there.

    .
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 11 Feb 2022 14:18 #21521

    • leon-ts
    • leon-ts's Avatar


  • Posts: 268
  • Hi all,

    One of my classic Windows applications has a display of staff photos on a VO form. GDI is used for drawing. I recently ported this application to X#. To load images from files, I used classes from the System.Drawing (NET) namespace. Drawing a photo on a VO-form is left on GDI. I cut out an example from the original code and made it into a small test project (archive attached). Maybe someone will find something interesting for themselves.

    Best regards,
    Leonid
    Best regards,
    Leonid
    Attachments:

    Please Log in or Create an account to join the conversation.

    Best way to show a picture in an X# VOForm 11 Feb 2022 20:44 #21529

    • ic2
    • ic2's Avatar
    • Topic Author


  • Posts: 1661
  • Hello Chris,

    Chris wrote: Yes indeed, XIDE cannot open VS project files. Sorry, can't think of a reason why the window does not open in your PC unfortunately. But in your own projects, windows openfine, is that right? In which case I would just ignore this, as anyway the window in Frank's sample is completely empty, there's nothing to see there..


    Yes, in my own projects the editor appears and you should not further spend time on it. Just keep it in mind if it happens for someone else, you can always ask me to open this solution again while you look with Teamviewer, if it helps you solving an issue.

    Dick

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1
    • 2