Author Topic: ImageDisplayByValue and BackgroundImageLayout  (Read 2392 times)

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
ImageDisplayByValue and BackgroundImageLayout
« 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

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5260
    • View Profile
    • AdvancedHMI
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #1 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.

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #2 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

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5260
    • View Profile
    • AdvancedHMI
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #3 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.

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #4 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



Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5260
    • View Profile
    • AdvancedHMI
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #5 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.

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #6 on: May 09, 2017, 07:52:58 AM »
OK AND THANKS FOR YOUR HELP : )

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #7 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


oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #8 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































Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #9 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.
« Last Edit: May 09, 2017, 06:19:07 PM by Godra »

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #10 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

Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #11 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?

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #12 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


Godra

  • Hero Member
  • *****
  • Posts: 1436
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #13 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.
« Last Edit: May 10, 2017, 09:22:58 PM by Godra »

oqapsking

  • Full Member
  • ***
  • Posts: 178
    • View Profile
Re: ImageDisplayByValue and BackgroundImageLayout
« Reply #14 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