Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How do I update *.resx files at runtime?

How do I update *.resx files at runtime?

Scheduled Pinned Locked Moved C#
helpquestionvisual-studiowpfcom
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rudy net
    wrote on last edited by
    #1

    I need some guidance with the following: I am trying to write a button control which will have certain properties to set styles such as aqua type. I looked into aqua button samples here in CP and the one I liked the most is "The Aqualizer"[^] which creates a bitmap image of aqua buttons. The problem is that it takes a long time to create the image, so what I would like to do is create the image at design time and store the image in the ResourceManager, then at runtime I should be able to load the image for the current button state. Where I need most guidance is storing the bitmap image into a resx file. By default, VS creates a resx file for my class derived from ButtonBase but I don't know how to access it at design time. The only way I could think was to read the resx file, then modify it as needed by adding the elements myself with the data for the bitmap files. However, I don't like this method because I depend on the location of the resx file. Since this is the first time I try using resource managers, I am kind of lost. I did read about it and getting the image seems straight forward, but storing it at design time is another story. Thanks in advance for any help you can give me.

    C 1 Reply Last reply
    0
    • R rudy net

      I need some guidance with the following: I am trying to write a button control which will have certain properties to set styles such as aqua type. I looked into aqua button samples here in CP and the one I liked the most is "The Aqualizer"[^] which creates a bitmap image of aqua buttons. The problem is that it takes a long time to create the image, so what I would like to do is create the image at design time and store the image in the ResourceManager, then at runtime I should be able to load the image for the current button state. Where I need most guidance is storing the bitmap image into a resx file. By default, VS creates a resx file for my class derived from ButtonBase but I don't know how to access it at design time. The only way I could think was to read the resx file, then modify it as needed by adding the elements myself with the data for the bitmap files. However, I don't like this method because I depend on the location of the resx file. Since this is the first time I try using resource managers, I am kind of lost. I did read about it and getting the image seems straight forward, but storing it at design time is another story. Thanks in advance for any help you can give me.

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      You're on the wrong track. What you can do is add the bitmap to your application as a resource, then you can load it from there and apply it to your bitmap in code. The resx file does not *exist* at runtime, it's just part of the files the compiler uses to know what to shove into your exe. Christian Graus - Microsoft MVP - C++

      R 1 Reply Last reply
      0
      • C Christian Graus

        You're on the wrong track. What you can do is add the bitmap to your application as a resource, then you can load it from there and apply it to your bitmap in code. The resx file does not *exist* at runtime, it's just part of the files the compiler uses to know what to shove into your exe. Christian Graus - Microsoft MVP - C++

        R Offline
        R Offline
        rudy net
        wrote on last edited by
        #3

        Humm, I guess I could save the image in a memory stream, then add the image to an ImageList and return the index of the image added so the button can redraw itself. I guess the solution above will work although I am still puzzled if we can make changes to the resx file just like Visual Studio does it at design time. Thanks, Rudy.

        C 1 Reply Last reply
        0
        • R rudy net

          Humm, I guess I could save the image in a memory stream, then add the image to an ImageList and return the index of the image added so the button can redraw itself. I guess the solution above will work although I am still puzzled if we can make changes to the resx file just like Visual Studio does it at design time. Thanks, Rudy.

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          rudy.net wrote:

          Humm, I guess I could save the image in a memory stream, then add the image to an ImageList and return the index of the image added so the button can redraw itself.

          You can store it as a Bitmap in your exe, and pull it out as a Bitmap.

          rudy.net wrote:

          I am still puzzled if we can make changes to the resx file just like Visual Studio does it at design time.

          What part of 'no' did you not understand ? The resx files do not exist on your client machine, therefore they are not used, therefore you cannot change them. Christian Graus - Microsoft MVP - C++

          R 1 Reply Last reply
          0
          • C Christian Graus

            rudy.net wrote:

            Humm, I guess I could save the image in a memory stream, then add the image to an ImageList and return the index of the image added so the button can redraw itself.

            You can store it as a Bitmap in your exe, and pull it out as a Bitmap.

            rudy.net wrote:

            I am still puzzled if we can make changes to the resx file just like Visual Studio does it at design time.

            What part of 'no' did you not understand ? The resx files do not exist on your client machine, therefore they are not used, therefore you cannot change them. Christian Graus - Microsoft MVP - C++

            R Offline
            R Offline
            rudy net
            wrote on last edited by
            #5

            My mistake, the subject should say "How do I update *.resx files at design time.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups