Click here to Skip to main content

djdynamix asked:

Open original thread
I wonder if anyone can help me figure this out?
 
I have a Marquee which scrolls text on TV screens and is working ok. Thing is that I need the end user to be able to change certain aspects of it through a Windows Form. I've been trying to use the Visual Studio Settings (which save to an AppConfig.XML file) to save the users' settings.
 
The text, font name and font size all save and restore perfectly, but for some reason the font colour, which is a System.Drawing.Color type, is always wrong.
 
When I open the AppConfig.XML or AppConfig.EXE.XML files in an external editor, the colour variable is correct, but the program seems to be getting its data from somewhere else for only this one object....
 
This is the code I'm using on the form:
 
        Dim FontName As String = My.Settings.ScrollFontName
        Dim FontSize As Integer = My.Settings.ScrollFontSize
        Dim FS As New Font(FontName, CInt(FontSize / 2), FontStyle.Regular)
        Dim FontColour As System.Drawing.Color = My.Settings.ScrollColour
 
        ScrollerSetupLbl.ForeColor = FontColour
        ScrollerSetupLbl.Font = FS
        ScrollerSetupLbl.ScrollLeftToRight = False
        ScrollerSetupLbl.MarqueeText = My.Settings.ScrollText
 
(In case you're wondering about why I'm dividing the font size in half, the scrollbar on the setup form is half the height of the scrollbar on the main screen.)
 
This is the AppConfig XML file:
 
<?xml version="1.0" encoding="utf-8"?>
 
<configuration>
  <configSections>
    <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
      <section name="Secure_Kiosk.My.MySettings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
    </sectionGroup>
  </configSections>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
  </startup>
  <userSettings>
    <Secure_Kiosk.My.MySettings>
      <setting name="ScrollFontName" serializeAs="String">
        <value>Arial</value>
      </setting>
      <setting name="ScrollFontSize" serializeAs="String">
        <value>36</value>
      </setting>
      <setting name="ScrollColour" serializeAs="String">
        <value>DarkBlue</value>
      </setting>
      <setting name="ScrollText" serializeAs="String">
        <value>Test text here</value>
      </setting>
    </Secure_Kiosk.My.MySettings>
  </userSettings>
</configuration>
 
Note that the "ScrollColour" value is "DarkBlue". I've also tried "Black", "Gold" and "White", all of which are recognised colours for the System.Drawing.Color type, but it always just displays "Red", which was the first colour I tried when I was testing it. For some reason it seems "stuck" on that one regardless.
 
I've also tried saving a String type variable in the settings, and converting to a System.Drawing.Color type in the form code and got exactly the same thing. The first colour I set "sticks" and won't change. Even manually editing the config files doesn't work.
 
Any ideas?
 
Thanks.
Tags: VB.NET, VisualStudio2012

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web02 | 2.8.141022.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100