Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Save custom color (.net 2.0)

    Using an open source application that is built on the .NET framework. It uses the Color Picker standard dialog box, which includes the ability to define custom colors. Is there a way to export the color definitions from one computer so they can be transferred to a second (or many...) computers?
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

  2. #2
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Save custom color (.net 2.0)

    You should be able to save the settings to an xml file and then read that into other apps. Caution: The same colors vary on machines depending on the type and brand of monitor and the video cards and settings in the computers, so don't count on the same color on every box. Custom colors are asking for trouble, because a machine wil a different saturation setting might not display that color at all. Laptops now have hi-res monitors, but the color can vary radically between a laptop and a desktop machine due to the video cards, if nothing else.
    Charlotte

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save custom color (.net 2.0)

    Thanks for the tip about colour differences, Charlotte. I will keep that in mind. Not sure what you meant by saving the settings into an xml file -- I don't see any mechanism in the color dialog for doing that.

    I dug around in the Registry, and found what I was looking for. Turns out that the application saves the custom colours into the HKCUSoftwareVB and VBA Settings<applicationName>CustomColors key. I should be able to transfer that key from one computer to another, keeping in mind your caution about colours rendering differently on different computers.

    The application is a mapping program, and it is important to exercise some control over the colour palette. I need a gradient of colours from light to dark in a single shade, so the maps convey the proper relationship when viewed on-screen in colour, as well as to reproduce properly on a monochrome laser printer. Custom colours seems like the only way to accomplish that task.
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Save custom color (.net 2.0)

    There are a variety of ReadXML and WriteXML methods available through datasets, along with a feast of other methods for handling xml files. The problem with using the registry these days is that some companies lock their registries down so tight that you can't do that. We have clients who have made the user permissions so stringent that we no longer rely on registry keys to control our applications. Instead we write settings to xml files in the Document & SettingsAll UsersApplication Data subfolder where we put the application itself. If you're working with something internal to your company and can use registry settings, then there's no barrier to doing it that way. But once the mechanisms are built for storing values in xml and retrieving them, that's even simpler and doesn't run afoul of any registry restrictions.
    Charlotte

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save custom color (.net 2.0)

    If I understand you correctly, there is no built-in method for Windows to persist the custom colors, and that the application itself is writing into the Registry. And since it is becoming less reliable to write into the Registry, the application should change its behaviour, and persist its information in xml files rather than the Registry. Is that correct?

    I had been told (not by the author, but by another user who *seems* to be in the know), that application program was *not* persisting the custom colors, but that Windows was performing that function. I think you are telling me otherwise. I did a quick test using VB .Net 2005 Express by defining a custom color. Closed and restarted the .Net environment, and found that the custom color had disappeared. This supports what I understand you to be saying.

    I appreciate your comments.
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

  6. #6
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save custom color (.net 2.0)

    PS - My original message was written under the assumption that Windows was persisting the colors.
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Save custom color (.net 2.0)

    Ah, I see. No, and I don't recommend that you try to find a way to change the system colors from your application. Changing system settings is invasive and can get you in big trouble with the users and the IT department.

    What you need to do is set the colors for your application only, and that's where the xml file comes in. When the application loads, it can read the xml file and use the settings to create the colors you need IN YOUR APPLICATION. Create a class that handles returning the values for particular color settings and then have your forms and reports call into that class to set their own colors. Then no matter what odd color scheme the user may have selected, your application will display the information in the colors you decide on wherever it's important. For example, we want lines and shading on reports to appear in several shades of gray, although we allow for an override by the application's admin through a xml file we read in when the app launches. If you use System colors, like ControlText, etc., for the rest of your application, it will respond to the user settings for color, while you can control the colors when a specific screen is loaded.
    Charlotte

  8. #8
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Vancouver, Br. Columbia, Canada
    Posts
    632
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save custom color (.net 2.0)

    Thanks for the pointers! I appreciate the time that you have taken.
    --------------------------------------------------
    Jack MacDonald
    Vancouver, Canada

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •