VBAndCs / sVB-Small-Visual-Basic

Small Visual Basic (sVB) is an educational programming language, created by Eng. Mohammad Hamdy as an evolved version of Microsoft Small Basic (SB). It is meant to be easier and more powerful at the same time, to introduce programming basics to kids and beginners of any age, provided that they can use the English keyboard on the Windows OS.
Other
233 stars 16 forks source link

When an image is replaced by another image with the same name, the label should immediately reflect this change. #88

Closed dynamicboy closed 2 months ago

dynamicboy commented 2 months ago

When an image is replaced by another image with the same name, the label should immediately reflect this change. The truth is the label still display the original image.

I need a way to refresh the cache of the image that the label displays.

I tried this:

Label1.Image = ""
Label1.Image = "E:\1.png"

and

' another different image try to refresh cache
Label1.Image = "E:\2.png" 
Label1.Image = "E:\1.png"

and

Label1.Image = "E:\2.png" 
' try to update cache
Program.Delay(2000)
Label1.Image = "E:\1.png"

but they don't work.

VBAndCs commented 2 months ago

I don't know how to deal with this in WPF, and has no intention to do more digging. You can workaround this by copying the image you want to display to a temp folder with the name image1_edited1 and display it in the lable, and with every edit, advance the name like image1_edited2 and display it. And when you want to save the changes, update the original image1 image by replacing it with the last edited version. And you should delete all temp images when your app is closing.


From: dynamicboy @.> Sent: Monday, September 23, 2024 3:37 PM To: VBAndCs/sVB-Small-Visual-Basic @.> Cc: Subscribed @.***> Subject: [VBAndCs/sVB-Small-Visual-Basic] When an image is replaced by another image with the same name, the label should immediately reflect this change. (Issue #88)

When an image is replaced by another image with the same name, the label should immediately reflect this change. The truth is the label still display the original image.

I need a way to refresh the cache of the image that the label displays.

I tried this:

Label1.Image = "" Label1.Image = "E:\1.png"

and

' another different image try to refresh cache Label1.Image = "E:\2.png" Label1.Image = "E:\1.png"

and

Label1.Image = "E:\2.png" ' try to update cache Program.Delay(2000) Label1.Image = "E:\1.png"

but they don't work.

— Reply to this email directly, view it on GitHubhttps://github.com/VBAndCs/sVB-Small-Visual-Basic/issues/88, or unsubscribehttps://github.com/notifications/unsubscribe-auth/ALQ5MVSNRNTT2HKF7ZICLD3ZYAYVNAVCNFSM6AAAAABOWLQPG6VHI2DSMVQWIX3LMV43ASLTON2WKOZSGU2DGMBSHEZDCMI. You are receiving this because you are subscribed to this thread.Message ID: @.***>

dynamicboy commented 2 months ago

Yes, I insert a timestamp into the filename, such as "name-16_12_08-edited". Each modification has its own timestamp, which I convert back to a date and then calculate the total seconds to compare and determine the latest version to use.

Instead of deleting temporary images when the app closes, I rename the latest version to the normal filename format, effectively overriding the original image.

I previously developed an activities log app, which wrote all activities to a log text file when the app closed. However, I found this approach unreliable and prone to data loss. Therefore, I now choose to log activities at the beginning of the app's launch.