473,785 Members | 2,363 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to persist color settings in my app?

I want to be able to save the user color settings in my app and restore them
when the app is re-opened. I currently have a config file with different
settings such as:

[App Settings]
UID=jsmith
IP=127.0.0.1
Port=23

I want to be able to save the color settings in the same way, but the I
can't convert from System.Drawing. Color to String. How can I accomplish
this?

Thanks.
Jan 6 '06 #1
5 1155
Terry,

The in my opinion most simple way is the "Color.ToAr gb" and the
Color.FromArgb" methods.

http://msdn2.microsoft.com/en-us/lib...or.toargb.aspx

I hope this helps,

Cor
Jan 6 '06 #2
Thanks! That worked great. Now I can't get my font to persist. I tried
writing out the font as Font.ToHfont and then reading it back in as
Font.FromHfont, but I get an error saying "This only works with TrueType
Fonts. This isn't a TrueType Font." The font actually is a TrueType font,
at least it has the .ttf suffix and has the TT logo next to its name in the
listing.

How can I persist my font?

Thanks.

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:eT******** ******@TK2MSFTN GP12.phx.gbl...
Terry,

The in my opinion most simple way is the "Color.ToAr gb" and the
Color.FromArgb" methods.

http://msdn2.microsoft.com/en-us/lib...or.toargb.aspx

I hope this helps,

Cor

Jan 7 '06 #3
Terry,

You are even able to serialize a font.

\\\first showed to me by Tom Shelton
Private Function SerializeFontOb ject(ByVal fnt As Font) As String
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream
Try
bf.Serialize(me m, fnt)
Return Convert.ToBase6 4String(mem.ToA rray())
Catch
Return String.Empty
Finally
mem.Close()
End Try
End Function
Private Function DeserializeFont Object(ByVal fnt As String) As Font
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream(Co nvert.FromBase6 4String(fnt))
Try
Return DirectCast(bf.D eserialize(mem) , Font)
Finally
If Not mem Is Nothing Then
mem.Close()
End If
End Try
End Function

I hope this helps,

Cor
Jan 7 '06 #4
"Terry Olsen" <to******@hotma il.com> schrieb:
Now I can't get my font to persist. I tried writing out the font as
Font.ToHfont and then reading it back in as Font.FromHfont, but I get an
error saying "This only works with TrueType Fonts. This isn't a TrueType
Font."


In addition to the other replies: The font handle you obtain using
'ToHfont' points to the font object the method is called on. This handle
won't exist any more if you restart the application.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 7 '06 #5
Yup, that did it. Thanks!

"Cor Ligthert [MVP]" <no************ @planet.nl> wrote in message
news:Oh******** ******@TK2MSFTN GP11.phx.gbl...
Terry,

You are even able to serialize a font.

\\\first showed to me by Tom Shelton
Private Function SerializeFontOb ject(ByVal fnt As Font) As String
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream
Try
bf.Serialize(me m, fnt)
Return Convert.ToBase6 4String(mem.ToA rray())
Catch
Return String.Empty
Finally
mem.Close()
End Try
End Function
Private Function DeserializeFont Object(ByVal fnt As String) As Font
Dim bf As New BinaryFormatter
Dim mem As New MemoryStream(Co nvert.FromBase6 4String(fnt))
Try
Return DirectCast(bf.D eserialize(mem) , Font)
Finally
If Not mem Is Nothing Then
mem.Close()
End If
End Try
End Function

I hope this helps,

Cor

Jan 7 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
3648
by: Pack Fan | last post by:
I've noticed that session variables will persist on Mac IE even after all browser windows have been closed. One must quit the program to clear the session variables. This presents a security risk for my session variable based security scheme. Basically, the risk is that a user will login to my site, close the window when done and allow someone else to come up to the machine, go back to my site and be logged into the previous user's...
4
10755
by: Alberto | last post by:
Could you tell me what it's for the "Persist Security Info ..." value in a connection string. Thank you.
2
2558
by: BH | last post by:
I developed a small web app using the FormsAuthentication class to set a cookie (FormsAuthentication.SetAuthCookie(value, isPersist)). The cookie persists fine on my local PC when "isPersist" is true and I can see the cookie file in the cookies folder on my disk. However, after I migrated the application to a server, the cookie is no longer written to the disk. It's still in memory and as long as I don't close the browser instance, the...
1
5434
by: Paul Perot | last post by:
Hi All: I have a DataTable that I have defined Globally. I populate this datatable dynamically with file/folder information that I read directly from the server. I use this datatable information to bind mainly to a DataGrid, but I would also like it to persist for the duration that I have a particular page open. I seem to be losing this data either thru postbacks or by the way I have coded it. Does anyone have any suggestions on how...
3
1518
by: FrzzMan[ | last post by:
Yesterday, all my ASP.NET running fine, at least this error didn't raise. Today, I turned on the PC at the morning and receive this error: Compiler Error Message: CS0016: Could not write to output file 'c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\flexnewsdotnet\36c8c83f\1ce438d6\-ognayiy.dll' -- 'Access is denied.' I checked the permission for the ASPNET account in Temporary ASP.NET Files folder and Temp...
3
2797
by: John Dalberg | last post by:
I am setting the HttpContext.Current.User in the Application_AuthenticateRequest event in global.asax.cs. When I use the IsInRole function in a web page, it works fine. So far so good. (Note that Integrated security is used and anonymous is turned off.) This app will actually work as a child app for an Intranet app so when I remove the application designation in IIS for the child app folder, IsInRole is always null, which is not good. I...
3
1763
by: Matthew | last post by:
I'm a bit new to VB, so please be understanding. I would like to have several variables that are remembered even when the user closes the program and re-opens it. The following seems to describe what I want: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/html/vxtskpersistinginformationinprojectssolutions.asp However, when I tried copying and pasting the example code to my form1.vb I get an error "Type...
5
1413
by: Steve | last post by:
I was dissapointed to see that the new Settings system in 2005 doesn't appear to persist the data between application sessions. I understand that it is used for application initialization, but there is something I read that made me think it would work for user settings as well. Is there an option I need to switch somewhere to get these to persist or is it back to serializing my own options class to XML? Thanks, Steve
0
12889
NeoPa
by: NeoPa | last post by:
Introduction: We get fairly frequent questions on here about why settings (including both values AND formatting) of unbound controls on a form, are not stored for reference later, but instead, each setting seems to be applied to EVERY instance of the control, for all records that show. I will try to lay down all the reasoning and arguments that occur to me. Sometimes, it's harder to explain things when they appear to be self-evident. To...
0
9647
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10161
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9958
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8986
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7506
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4058
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.