Emuforums.com

Go Back   Emuforums.com > General Discussion > Web development / Programming
Home Register Downloads FAQ Members List Calendar Arcade Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
Old June 7th, 2009   #1 (permalink)
 
S.T.A.R.S.'s Avatar
 
Join Date: Jan 2006
Location: Planet Earth...
Posts: 593
Exclamation YOUR way of saving changes in the C# application...

Hey guys.Well for the past 3 years I was always interested WHAT KIND OF THE WAY the C# programmers use to save the changes in the application.Whether is that the check state of the check box control or radio button control or whatever......and then how to execute the function in the application when the state of the check box,(or any other control),is checked or unchecked.You know those popular buttons in Windows like OK,CANCEL and APPLY?Well my question is what way do you use for that APPLY button.So for example:

-You have the C# application with the check box and button whos text is
APPLY THE CHANGE
-You want to make that when the user clicks the APPLY button,the that
change in the check box is saved.Wether is the check box checked or
unchecked
-Also you want to make that after the user quits the application and then
turn it on again,the that change is automatically loaded in the C#
application and automatically shows that change--->CHECKED or
UNCHECKED check box control

So my question is...what kind of the way do YOU use to do something like
this???

Honestly I hate doing something like this using the XML,SQL or any other way that saves the changes in the Windows registry...
I made my own way which seems to work prefectly

But anyway...I would like to know YOUR way of doing something like this in C#.Wether is the version 2002,2003,2005 or 2008...
__________________
GOODBYE FOREVER EVERYONE...
S.T.A.R.S. is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old June 8th, 2009   #2 (permalink)
Global Moderator
 
cooliscool's Avatar
 
Join Date: Jul 2001
Location: South Carolina, USA
Posts: 6,824
.... ugh.
cooliscool is offline   Reply With Quote
Old June 8th, 2009   #3 (permalink)
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Post-Apocalyptic Earth
Posts: 3,900
you can save an ini file with the options you want, and then load it at application boot-up.
that's my favorite way, since i think ini files are cool xD

there's also some very easy way to do this stuff in VB, but i don't remember how xD
__________________

Quote:
Eccentricity is often associated with genius, giftedness, or creativity. The individual's eccentric behavior is perceived to be the outward expression of his or her unique intelligence or creative impulse. In this vein, the eccentric's habits are incomprehensible not because they are illogical or the result of madness, but because they stem from a mind so original that it cannot be conformed to societal norms.
check out my blog
cottonvibes is offline   Reply With Quote
Old June 8th, 2009   #4 (permalink)
Mobile Fanatic
 
runawayprisoner's Avatar
 
Join Date: Nov 2006
Location: Santa Cruz, CA
Posts: 6,198
Yeah, I second the ini file option. Simple, and effective.
__________________
cChip interpreter WIP - current status: Release Candidate
LRx Filter RC - current performance rating: 9/10
runawayprisoner is offline   Reply With Quote
Old June 8th, 2009   #5 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 373
it depends on the application i am designing, but the main thing is that i do it like an ini file even though 99% of the time i do not work with straight ini files lol.

but when my app boots up i load the settings from where ever the file i am working with is saved and i apply the changes to my controls.
Hatorijr is offline   Reply With Quote
Old June 8th, 2009   #6 (permalink)
Emu author
 
@ruantec's Avatar
 
Join Date: Nov 2002
Location: Austria (originally from Dominican Republic)
Posts: 2,378
XML can be a good way to that.. there´s a class for it.
__________________

Current development tools:

Visual C++.net, Visual C#.net
Visual VB.net, Visual Webdeveloper.net
Bloodshed Dev C++, Borland C++
Visual Basic 6
@ruantec is offline   Reply With Quote
Old June 8th, 2009   #7 (permalink)
 
S.T.A.R.S.'s Avatar
 
Join Date: Jan 2006
Location: Planet Earth...
Posts: 593
Lol this will maybe sound funny,but I am using the simple rich text box to save the changes for ANY control I want.I do not use the XML,INI files or Windows registry.
My way of saving changes is a little bit strange lol,but it works perfectly.If you are interested,I can make a 5 minute video to show you how I did it.Of course if that's ok with you guys?
__________________
GOODBYE FOREVER EVERYONE...
S.T.A.R.S. is offline   Reply With Quote
Old June 9th, 2009   #8 (permalink)
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Post-Apocalyptic Earth
Posts: 3,900
Quote:
Originally Posted by S.T.A.R.S. View Post
I am using the simple rich text box to save the changes for ANY control I want.
i'm not sure i understand what you're doing.

do you mean write the settings to a hidden rich text box, and then save/load it to some file using a function?


oh wait....
are you even talking about saving/loading settings between application startup?
or are you just talking about saving settings while running the application?

in either case, a rich-text-box control seems like overkill.
at the very-least, you can use a String instead.
but one of the nicest ways (and the common way to do it) is to have a struct with the different application setting's data.

something like:

Code:
struct appData {
    bool option1;
    bool option2;
    int  option3;
}

appData mySettings; // Global Struct with the App's Settings
__________________

Quote:
Eccentricity is often associated with genius, giftedness, or creativity. The individual's eccentric behavior is perceived to be the outward expression of his or her unique intelligence or creative impulse. In this vein, the eccentric's habits are incomprehensible not because they are illogical or the result of madness, but because they stem from a mind so original that it cannot be conformed to societal norms.
check out my blog
cottonvibes is offline   Reply With Quote
Old June 9th, 2009   #9 (permalink)
 
S.T.A.R.S.'s Avatar
 
Join Date: Jan 2006
Location: Planet Earth...
Posts: 593
Quote:
Originally Posted by cottonvibes View Post
i'm not sure i understand what you're doing.

do you mean write the settings to a hidden rich text box, and then save/load it to some file using a function?


oh wait....
are you even talking about saving/loading settings between application startup?
or are you just talking about saving settings while running the application?
[/code]
I just recorded the video so everything will make all clear.In an hour I will give you guys the link to download the video.The damn upload process on the sendspace takes forever xD
__________________
GOODBYE FOREVER EVERYONE...
S.T.A.R.S. is offline   Reply With Quote
Old June 9th, 2009   #10 (permalink)
No sir. I don't like it.
 
masta.g.86's Avatar
 
Join Date: Oct 2008
Location: Alabama
Posts: 2,455
Can't wait...
__________________
Quote:
The truth is there for those who choose to see it.
Phenom II X4 @ 3.6GHz | 4GB OCZ Dominator DDR3 @ 1600MHz
Sapphire Vapor-X Radeon HD4850 | Samsung TOC 24" 1920x1200
Auzentech X-Fi Forte 7.1 | Klipsch Promedia 5.1 THX
LG H20L BD-RE | WD Caviar Black 1TB 7200RPM
GIGABYTE GA-MA790FXT-UD5P | Windows 7 x64 Ultimate

Join the NGEmu Folding@Home Team! Info
Download the standard client here OR preferably download the GPU or SMP client here.
Set your team ID to: 161326
NGEmu Stats Page: Here
masta.g.86 is offline   Reply With Quote
Old June 9th, 2009   #11 (permalink)
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Post-Apocalyptic Earth
Posts: 3,900
s.t.a.r.s.:

can't you just post the source-code? xD

but yeah... can't wait for the video
__________________

Quote:
Eccentricity is often associated with genius, giftedness, or creativity. The individual's eccentric behavior is perceived to be the outward expression of his or her unique intelligence or creative impulse. In this vein, the eccentric's habits are incomprehensible not because they are illogical or the result of madness, but because they stem from a mind so original that it cannot be conformed to societal norms.
check out my blog
cottonvibes is offline   Reply With Quote
Old June 9th, 2009   #12 (permalink)
 
S.T.A.R.S.'s Avatar
 
Join Date: Jan 2006
Location: Planet Earth...
Posts: 593
Hehe lol nice try xD
Well the video isn't anything special lol.I just showed the main way of how I usually do that.Lol I bet that nobody is not saving changes on the way like I do xD xD xD
The uploading is at 63%...so slow
__________________
GOODBYE FOREVER EVERYONE...
S.T.A.R.S. is offline   Reply With Quote
Old June 9th, 2009   #13 (permalink)
 
S.T.A.R.S.'s Avatar
 
Join Date: Jan 2006
Location: Planet Earth...
Posts: 593
Hehe anyone recognizes the picture bellow?
Ohh btw the uploading is finished.To download the video,click the link bellow:
Send big files the easy way. Files too large for email attachments? No problem!

Please comment the video xD
Attached Images
File Type: jpg MVS 2002.JPG (118.0 KB, 18 views)
__________________
GOODBYE FOREVER EVERYONE...
S.T.A.R.S. is offline   Reply With Quote
Old June 9th, 2009   #14 (permalink)
No sir. I don't like it.
 
masta.g.86's Avatar
 
Join Date: Oct 2008
Location: Alabama
Posts: 2,455
Quote:
Originally Posted by S.T.A.R.S. View Post
Hehe anyone recognizes the picture bellow?
Memories of college and screwing around with XP come flooding back to me.

EDIT: 89.3MBs? I really need to make a thread explaining how to create optimized video encodes.

EDIT2: You're a really slow typer, S.T.A.R.S. Would've been better to just use record your own voice as you go along.

EDIT3: Ctrl-A is the keyboard shortcut for 'select all'.
__________________
Quote:
The truth is there for those who choose to see it.
Phenom II X4 @ 3.6GHz | 4GB OCZ Dominator DDR3 @ 1600MHz
Sapphire Vapor-X Radeon HD4850 | Samsung TOC 24" 1920x1200
Auzentech X-Fi Forte 7.1 | Klipsch Promedia 5.1 THX
LG H20L BD-RE | WD Caviar Black 1TB 7200RPM
GIGABYTE GA-MA790FXT-UD5P | Windows 7 x64 Ultimate

Join the NGEmu Folding@Home Team! Info
Download the standard client here OR preferably download the GPU or SMP client here.
Set your team ID to: 161326
NGEmu Stats Page: Here

Last edited by masta.g.86; June 9th, 2009 at 03:40..
masta.g.86 is offline   Reply With Quote
Old June 9th, 2009   #15 (permalink)
 
S.T.A.R.S.'s Avatar
 
Join Date: Jan 2006
Location: Planet Earth...
Posts: 593
Quote:
Originally Posted by masta.g.86 View Post
Memories of college and screwing around with XP come flooding back to me.

EDIT: 89.3MBs? I really need to make a thread explaining how to create optimized video encodes.

EDIT2: You're a really slow typer, S.T.A.R.S. Would've been better to just use record your own voice as you go along.

EDIT3: Ctrl-A is the keyboard shortcut for 'select all'.
Lol if I was talking,you wouldn't understand a word xD I am a slow typer,but fast in talking xD

So was the video good except of my typing and the video file size?
__________________
GOODBYE FOREVER EVERYONE...
S.T.A.R.S. is offline   Reply With Quote
Old June 9th, 2009   #16 (permalink)
No sir. I don't like it.
 
masta.g.86's Avatar
 
Join Date: Oct 2008
Location: Alabama
Posts: 2,455
A lot better than previous videos.

Though the use of text typing instead of a voice-over makes it boring to watch. I would say add some music, but your tastes in music may differ radically with someone else's causing them to mute the video or stop watching it completely. I fired up Winamp and started playing from a good playlist so I could watch it through.
__________________
Quote:
The truth is there for those who choose to see it.
Phenom II X4 @ 3.6GHz | 4GB OCZ Dominator DDR3 @ 1600MHz
Sapphire Vapor-X Radeon HD4850 | Samsung TOC 24" 1920x1200
Auzentech X-Fi Forte 7.1 | Klipsch Promedia 5.1 THX
LG H20L BD-RE | WD Caviar Black 1TB 7200RPM
GIGABYTE GA-MA790FXT-UD5P | Windows 7 x64 Ultimate

Join the NGEmu Folding@Home Team! Info
Download the standard client here OR preferably download the GPU or SMP client here.
Set your team ID to: 161326
NGEmu Stats Page: Here
masta.g.86 is offline   Reply With Quote
Old June 9th, 2009   #17 (permalink)
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Post-Apocalyptic Earth
Posts: 3,900
stars:

dude you could have just posted the source-code instead of a 45 minute video

but i actually learned something from that video.
msvc#'s form builder is very-very similar to VB.net. it also handles events like VB.
i just wish it supported macros and templates (especially macros, they're terribly useful).

anyways stars,
while that method does work, it is horribly inefficient and could get very messy if you have a lot of options.
__________________

Quote:
Eccentricity is often associated with genius, giftedness, or creativity. The individual's eccentric behavior is perceived to be the outward expression of his or her unique intelligence or creative impulse. In this vein, the eccentric's habits are incomprehensible not because they are illogical or the result of madness, but because they stem from a mind so original that it cannot be conformed to societal norms.
check out my blog
cottonvibes is offline   Reply With Quote
Old June 9th, 2009   #18 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 373
c# i believe does have some form of templates or something extremely close to it. i am unsure of macros and for me macros are not really needed since they are just about like functions in a way and i never used macros in any c/c++ code i ever wrote though i do know what they are and how to use them if i did need them(i got that from reading a nice and very detailed book on stuff like that before, nice reading). but yea c# is nice when given a chance to be worked with well. i never got to far into learning vb, the book i used to learn it turned me away since when i tried to make a notepad like app going by the instructions by the letter, it did not work at all like the book claimed which turned me away to another language which ironically i think was c/c++ lol.
Hatorijr is offline   Reply With Quote
Old June 9th, 2009   #19 (permalink)
You're already dead...
 
cottonvibes's Avatar
 
Join Date: Sep 2007
Location: Post-Apocalyptic Earth
Posts: 3,900
c# has generics, but they're more limited than templates. you can't do "template metaprogramming" for example.
C# Frequently Asked Questions : How do C# generics compare to C++ templates?
Template metaprogramming - Wikipedia, the free encyclopedia

and functions aren't as nice as macros for some situations, and not everything a macro does can be done by functions.
also, even if you can do the job with a function, many times it will be less optimized since macros are compile-time generated code.

one time i used macros to generate some opcode tables that pointed to template-functions which needed multiple instances.
i reduced the tables from ~1000 lines to ~260 lines using macros.

Diff of microVU_Tables.inl r1166 - pcsx2 - Google Code

this would not have been possible using functions.
in fact, ~90% of the times i use macros, it can't be done with a function.

what if you have some really nested struct var that you use frequently like:
house.door.knob.keyhole = 1;
you can just do:
#define hKeyhole house.door.knob.keyhole
and use 'hKeyhole' instead, like:
hKeyhole = 1;

i also do stuff like that a lot too, although some people don't like it because its harder to understand the code at first glance.

there's a lot of other useful things macros are good for (too much to go into detail here). they're one big reason i like c++ so much.
before i learned the language, i didn't know there was something so powerful.
and i still didn't understand how powerful they could be till i looked at some of the different ways people used them xD
__________________

Quote:
Eccentricity is often associated with genius, giftedness, or creativity. The individual's eccentric behavior is perceived to be the outward expression of his or her unique intelligence or creative impulse. In this vein, the eccentric's habits are incomprehensible not because they are illogical or the result of madness, but because they stem from a mind so original that it cannot be conformed to societal norms.
check out my blog
cottonvibes is offline   Reply With Quote
Old June 9th, 2009   #20 (permalink)
Emu Author
 
Hatorijr's Avatar
 
Join Date: Dec 2004
Location: North Carolina
Posts: 373
like i said i understand the usefulness of macros, i read a giant amount of info on them and i know c# has nothing as powerful as macros, i never intended to bash them in anyway .

as i told @ruantec earlier, i like using c# right now for the emus i am doing but if a time comes that i feel c# just wont do the job the way i need, i will attempt to modify and pull in as much c++ code to use in my c# code as i can but if i really need to i will without a doubt switch back to c++, both languages(well all 3 if you do not count c and c++ as about the same in a sense) are great languages, both have pros and cons. but i will use c++ where i need it without hesitation as i do realize how nice c/c++ can be as i started out on c/c++ and it can be nice, my only main issue is that working with window creation and directx is a royal pain and is one reason why i switched to c# when i started learning it.

i do know c++ macros can selectively do a lot of things just like normal functions can and at the same time cut down on a lot of code as well where as to achieve the same functionality just is not as readily possible with standard functions which is what makes macros so powerful but yes they can cause other issues in terms of readability too. but i suppose thats why you should use proper naming and comments for those cases too i guess.
Hatorijr is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 10:03.

© 2006 - 2008 Emu Forums | About Emu Forums | Legal | A member of the Crowdgather Forum Community


Powered by vBulletin® Version 3.7.6
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0 RC5