AdvancedHMI Software

General Category => Support Questions => Topic started by: oqapsking on May 08, 2017, 02:42:39 PM

Title: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 08, 2017, 02:42:39 PM
i am trying to stretch the background image from image list when using with ImageDisplayByValue component

so i add this property to the ImageDisplayByValue class code


Code: [Select]
Public Property BackgroundImageLayou As ImageLayout
        Get
            Return BackgroundImageLayout
        End Get
        Set(ByVal value As ImageLayout)

            BackgroundImageLayout = value



        End Set
    End Property


after i add the code

the property appears in  ImageDisplayByValue1 properties and i choose stretch but nothing happens

any ideas ?

with thanks
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Archie on May 08, 2017, 03:55:56 PM
What you have done is merely create a property that stores a value in a variable that Visual Studio implicitly created. You stored value then goes no where, therefore does nothing.

I think what you are trying to do is fill you ImageDisplayByValue with your images from the ImageList. To do this, simply set the ImageSize property of your ImageList to the same dimensions as the Size property of your ImageDisplayByValue.

In other words get the Size of your ImageDisplayByValue, then select the ImageList and copy that size into the ImageSize property.
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 08, 2017, 04:44:57 PM
Yes but i still need my image to be biger than 256;256
And that is why i need to make it strech
So it would fit good with my design
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Archie on May 08, 2017, 10:05:47 PM
I don't think this is possible with this control. It looks like it will be necessary to create a custom control that does not use the ImageList, but instead uses a collection of images.
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 09, 2017, 06:52:39 AM
can you tell me  how to make an image colliction ?

i tried to make this class

but it is not user friendly

i put the pictures i needed in the project resorces with a seqal name

then i use this code


the user class has picturebox and basiclabel

Code: [Select]




Public Class curt1
    Dim listpic As String
    Dim defealtpic As String



    Private Sub BasicLabel1_ValueChanged(sender As Object, e As EventArgs) Handles BasicLabel1.ValueChanged
        Dim object_name_as_string = listpic
        Dim es As String = BasicLabel1.Value.ToString

        defealtpic = Label1.Text + "1"

        If BasicLabel1.Value > 0 Then
            listpic = defealtpic + es

            PictureBox2.Image = Global.MfgControl.AdvancedHMI.My.Resources.Resources.ResourceManager.GetObject(listpic)
        Else
            PictureBox2.Image = Global.MfgControl.AdvancedHMI.My.Resources.Resources.ResourceManager.GetObject(defealtpic)
        End If
    End Sub

    Private Sub curt1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

       
    End Sub
    Public Property ComComponent As MfgControl.AdvancedHMI.Drivers.IComComponent
        Get
            Return BasicLabel1.ComComponent
        End Get
        Set(value As MfgControl.AdvancedHMI.Drivers.IComComponent)
            BasicLabel1.ComComponent = value

        End Set
    End Property
    Public Property firstchar As String
        Get
            Return Label1.Text
        End Get
        Set(value As String)
            Label1.Text = value

        End Set
    End Property
 

    Public Property firstimage As Bitmap
        Get
            Return PictureBox2.Image
        End Get
        Set(value As Bitmap)
            PictureBox2.Image = value

        End Set
    End Property

    Public Property PLCAddressValue As String
        Get
            Return BasicLabel1.PLCAddressValue
        End Get
        Set(value As String)
            BasicLabel1.PLCAddressValue = value

        End Set
    End Property

   
End Class


Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Archie on May 09, 2017, 07:46:05 AM
This is a bit more complex than I initially thought because of the design time editor for the Image Collection. I'll see what I can come up with over the next few days.
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 09, 2017, 07:52:58 AM
OK AND THANKS FOR YOUR HELP : )
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Godra on May 09, 2017, 11:38:45 AM
You could also try adding these 2 properties to the original ImageDisplayByValue control:

Code: [Select]
    <System.ComponentModel.Browsable(False)> _
    Public Shadows Property ImageIndex As Integer
        Get
            Return -1
        End Get
        Set(ByVal value As Integer)
            If ImageList IsNot Nothing AndAlso ImageList.Images.Count > 0 Then
                If value > -1 AndAlso value < ImageList.Images.Count Then
                    Me.BackgroundImage = ImageList.Images(value)
                End If
            End If
        End Set
    End Property

    Public Property ImageLayout As ImageLayout
        Get
            Return MyBase.BackgroundImageLayout
        End Get
        Set(ByVal value As ImageLayout)
            MyBase.BackgroundImageLayout = value
        End Set
    End Property

Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 09, 2017, 04:21:13 PM
You could also try adding these 2 properties to the original ImageDisplayByValue control:

Code: [Select]
    <System.ComponentModel.Browsable(False)> _
    Public Shadows Property ImageIndex As Integer
        Get
            Return -1
        End Get
        Set(ByVal value As Integer)
            If ImageList IsNot Nothing AndAlso ImageList.Images.Count > 0 Then
                If value > -1 AndAlso value < ImageList.Images.Count Then
                    Me.BackgroundImage = ImageList.Images(value)
                End If
            End If
        End Set
    End Property

    Public Property ImageLayout As ImageLayout
        Get
            Return MyBase.BackgroundImageLayout
        End Get
        Set(ByVal value As ImageLayout)
            MyBase.BackgroundImageLayout = value
        End Set
    End Property


thanks godra but it gave the same result i can chose stretch but nothing happens






























Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Godra on May 09, 2017, 05:22:43 PM
That property is designed to have all images stretch to fit the size of the control.

If you resize the control and/or change the layout to "Tile", does it look any different?


If your intention is to have the control resize itself and show images in their original size then you might need to wait for Archie's new solution.
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 10, 2017, 12:32:05 AM
That property is designed to have all images stretch to fit the size of the control.

If you resize the control and/or change the layout to "Tile", does it look any different?


If your intention is to have the control resize itself and show images in their original size then you might need to wait for Archie's new solution.

What i want is the image to strech as the sizrle of the control
But when i nothing happens when i chose strech or tile or zoom
It stays as the size of the imagelist in my case 256;256
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Godra on May 10, 2017, 06:58:09 AM
To show how those 2 properties work, I have attached the picture of a motor being used in 2 differently sized controls.
The original motor picture is attached as well.

Is that what you are looking to have?
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 10, 2017, 09:12:59 AM
yes that is what i need but when i used ur code

i can choose strech but the image stays the same size no matter what is the imagedisplaybyvalues control size is

Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Godra on May 10, 2017, 08:50:14 PM
I have attached the control I am using.

Try it and see if it makes a difference (add it as existing item to the "Controls" folder and replace the existing control).

Once you use the control make sure that its AutoSize property is set to False (this since it might show as True).
I also set the ImageSize property to 256, 256.
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 11, 2017, 04:17:16 PM
I have attached the control I am using.

Try it and see if it makes a difference (add it as existing item to the "Controls" folder and replace the existing control).

Once you use the control make sure that its AutoSize property is set to False (this since it might show as True).
I also set the ImageSize property to 256, 256.

i did what you said but the same thing the ImageLayout have no effect look at the attachment

and thanks

Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Godra on May 12, 2017, 01:13:21 AM
Is your picture from Design Mode or Runtime?
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 12, 2017, 02:50:03 PM
both the same thing
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Godra on May 12, 2017, 07:18:37 PM
Did you rebuild the solution after you added the control?

The ImageIndex property is currently set to be invisible and also not to show any image in Design Mode.
I am not sure how come that you can see the image.
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: oqapsking on May 14, 2017, 09:56:33 AM
how can i enable them so i can see the changes
Title: Re: ImageDisplayByValue and BackgroundImageLayout
Post by: Godra on May 14, 2017, 10:47:15 AM
Just comment out the first line of code above the ImageIndex property:

Code: [Select]
    '<System.ComponentModel.Browsable(False)> _
This will allow you to test all the images by using the ImageIndex property.

Your image selection will not be memorized since the current modification is intended to prevent images from showing in the image frame.
The image layout will be memorized.