|
-
Jun 7th, 2008, 08:59 AM
#1
Thread Starter
PowerPoster
about properties
i have these property in usercontrol:
Code:
Public Property Get StripsActivate() As Boolean
StripsActivate = Strip.Activate
End Property
Public Property Let StripsActivate(ByVal vNewValue As Boolean)
Strip.Activate = vNewValue
If Strip.Activate = True Then
Strip.ActualSubImage = 1
lngActualSubImage = 1
lngTotalSubImages = Strip.ImagesColumn * Strip.ImagesLine
Call UpgradeSubimages
tmrAnimation.Enabled = True
tmrAnimation.Enabled = Ambient.UserMode
Else
tmrAnimation.Enabled = False
lngActualSubImage = 0
End If
PropertyChanged "StripsActivate"
End Property
and i have these in:
Code:
Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
If StripsActivate = True Then
lngActualSubImage = PropBag.ReadProperty("ActualSubImage", 1)
Strip.ActualSubImage = 1
lngTotalSubImages = Strip.ImagesColumn * Strip.ImagesLine
Call UpgradeSubimages
UserControl.Picture = PicAnimation(1).Image
Call Transparent
tmrAnimation.Enabled = True
tmrAnimation.Enabled = Ambient.UserMode
Else
lngActualSubImage = PropBag.ReadProperty("ActualSubImage", 0)
lngTotalSubImages = PicAnimation.Count
UserControl.Picture = PicAnimation(0).Image
Call Transparent
End If
end sub
and i have the same in writeproperties usercontrol event.
my question is why i must repeat 3 times the code for a persistence property?
thanks
-
Jun 8th, 2008, 09:09 AM
#2
Thread Starter
PowerPoster
Re: about properties
if my question is confuse, just tell me...
thanks
-
Jun 8th, 2008, 12:50 PM
#3
Thread Starter
PowerPoster
Re: about properties
these property is to be used in IDE property window. but did i need repeat/call the code 3 times?
thanks
-
Jun 12th, 2008, 03:26 PM
#4
Re: about properties
Yes you can cut these down into 1 method, and both involve using a collection of settings to be retreived or set - otherwise known as a propertybag.
1) You could make a note of the differences between them, and implement these as individual flagged boolean variables stored within a propertybag. I.e. taking this different line:
You could then create a PropertyBag setting of CallTransparentMethod. By accepting a propertybag object as an argument in your property, and evaluating whether this setting had a true or false value, your property/code could then choose to run or skip that line of code.
2) You can have an Enum/Enumeration of the different setting applications possible. I.e.
Code:
Private Enum StripsActivateSettingType
WithTransparency = 0
WithoutTransparency = 1
End Enum
You could then code this into a sub procedure which accepts both a property bag argument of settings to read/write, and a second argument of this enum type. If the Enum value is 1, you can execute the code as in your 2nd posted code there, if the value of the passed in Enum is 2, then you can execute the code similar to the 3rd code sample you posted (which includes the above Call Transparent line).
Last edited by alex_read; Jun 12th, 2008 at 03:30 PM.
-
Jun 13th, 2008, 02:42 PM
#5
Thread Starter
PowerPoster
Re: about properties
 Originally Posted by alex_read
Yes you can cut these down into 1 method, and both involve using a collection of settings to be retreived or set - otherwise known as a propertybag.
1) You could make a note of the differences between them, and implement these as individual flagged boolean variables stored within a propertybag. I.e. taking this different line:
You could then create a PropertyBag setting of CallTransparentMethod. By accepting a propertybag object as an argument in your property, and evaluating whether this setting had a true or false value, your property/code could then choose to run or skip that line of code.
2) You can have an Enum/Enumeration of the different setting applications possible. I.e.
Code:
Private Enum StripsActivateSettingType
WithTransparency = 0
WithoutTransparency = 1
End Enum
You could then code this into a sub procedure which accepts both a property bag argument of settings to read/write, and a second argument of this enum type. If the Enum value is 1, you can execute the code as in your 2nd posted code there, if the value of the passed in Enum is 2, then you can execute the code similar to the 3rd code sample you posted (which includes the above Call Transparent line).
i'm sorry but i wasn't talking about transparent procedure but entire property...
thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|