set value in other class, get value in other - c#

I know its kind of stupid question, but I am beginner in C#.
I want to create start page with settings where user can set a values. How I can relay these values to other page ?
Solution that will give me someone will work with IsolatedStorage?
It does not have, but it's good to know for the future.

This question unfortunately needs a tutorial as answer. Bing has many of these:
Windows Phone 7 Jump Start Sessions (two funny guys show it all!!)
Quick Tutorial Page Navigation (involving a settings page!)
Tutorial Galore
Tips from Stackoverflow for getting started
Your task involves basic UI design, page navigation with parameters and/or data persistence.
And you are even allowed to use Google to find these.

If these settings need to be global, then add a static public member variable to the App.xaml.cs file. Set and Get as required from that property.
IsolatedStorage is useful for persisting data when your application closes, but otherwise in Memory persistence via globally accessible properties could be fine for your requirements.

Related

How to see all registry changes of chosen application in C#

Hi there lovely StackOverFlow helpers, I got into a bit trouble recently.
I need to make an application in WinForm C# as my final programming project. The project is about managing Registry more nicely to make it easier for the user to edit values.
So what I need is; to show all the Registry values of the same type, to show what the value does and to show their build. For instance: the hierarchical build is HKEY_LOCAL_MACHINE\SYSTEM\Keyboard Layout\Preload and the key 1 controls the keyboard loadout when your pc first starts (about presenting it, I'll probably use RichTextBox for the graphical way or something else I'll figure out).
So I assume there's a way the data is placed in the Registry, like all of the setting of the app is here and the prefrences is there..
I hope I was clear enough, thanks for all of your time to read and answer it!! I really REALLY appreciate the effort!

Save Settings in VB.Net or C#

How I can save the settings I want even after I close the program?
Let's say: If I have a Checkbox and I run the program. If I checked it I want to remain that way even when I reopen again the program. I hope you understand what I want.
I'm a newbie, so take me slow. Thank you.
I recommend using Application Settings Property Binding.
There are many options as mrunion mentioned in his good answer, but I think the most simple way in Windows Forms Application is using Application Settings Property Binding. To do so using designer:
Select your CheckBox in design surface
In properties window, at top, expand (ApplicationSettings), open dropdown for Checked property and select (New...) at bottom of dropdown.
Add your desired property with default value.
Save settings in somewhere like Form_Closing event:
C#: Properties.Settings.Default.Save();
VB: My.Settings.Save()
(ApplicationSettings) in property window:
Expanded from above....
To persist settings between different program runs, you will have to store that data somewhere for the user. Assuming since you mentioned VB, I will also assume Windows as your target platform. The best options are the following:
Use the registry to store the persistent data. There are plenty of tutorials on setting and retrieving registry variables.
Use a configuration/INI file for your application. Again, plenty of tutorials exist for this option.
Use a database. This is more advanced, but allows for the most flexibility of storing and retrieving data. I would suggest not using this method at first, and revisit it when you are ready to learn database design/querying/etc.
This should point you in the right direction.

Variables in ASP.NET

I recently switched to ASP.NET Web Forms from Windows Forms and I have an issue with something I would not expect. In good Web Forms I could create a field inside my Form class and assign to it. So if I wanted one control to raise a flag on one event (say user button click) I could declare Boolean and assign to it from my form methods. Then I could check the state of the flag from different methods on different events.
It looks like it's not so much in Web Forms. The value of my fields (or global variables if you will) remains unchanged from the moment I initialized them.
This is probably simple thing but for me it's quite a frustrating problem. I could store my vaues in session but I don't think that it would be a right way to do it. The problem is I need to store a lot of variables since I write code for SQL interface applications. Never had a single problem in Windows Forms and in Web Forms I keep pulling my hair.
Ultimately I need to store objects to reuse them like LINQ to SQL classes objects so I would really appreciate some guidance.
I suggest you review PostBacks, Page life-cycle and how ASP.NET processes client requests . In order to better understand ASP.NET forms, you should take time to read up on the page life-cycle, events and the order in which they are fired. That way you understand why it seems your variables are not being updated.
you should also read about State management like viewstate , session ect...
put your page_load contents that you don't want to execute after button click to the following condition:
if (!IsPostBack)
{
// do something
return;
}

Adding a context menu item to windows explorer

I've been searching for days about this, but haven't found anything.
I am trying to find out how I can add a context menu item to the windows explorer. I do not want it for specific filetypes, BUT I want it to appear on everything inside a specific path.
For example, I want right-click menus of anything inside "C:\folder" to contain this item, but it shouldn't appear outside this folder...
Is that possible?
Any help will be really appreciated!
Thanks in advance,
John.
The normal way this is achieved is to add it to the Registry under:
HKEY_LOCAL_MACHINE/Software/Classes/Folder/Shell
However in your specific case you want to do some preprocessing before it is displayed (eg is it in the specified directory) which wouldn't work with a simple registry alteration.
I think there is a way to force you way into any operation and add a hook to it. I'm talking about old school knowledge now though and I cannot think what the technology would be called. I think its how you would have, for example, forced your way into the rendering engine to put custom skins on normal explorer windows or inject an extra button into the title bar of apps like you used to see back in the day.
It just occurred to me that adding a button to the windows title bar might have given a search starting point, I found this article which refers to subclassing windows components and injecting your own behaviour. I think that is what I'm talking about above:
http://www.codeproject.com/KB/wtl/titlebar.aspx
Hope this gives you a new direction to search in.

How can you store state between screens in SketchFlow?

I'm building a prototype using Expression Blend 3 and SketchFlow (a Silverlight SketchFlow application to be specific) and it consists of multiple screens that I want to share state between.
Take this example:
Screen 1 - 'Login' screen: I want the user to type in a fake user name and password.
Screen 2 - 'Home' screen: I want to display that user name so the user sees that their input is reflected.
This is just a trivial example and not something that most prototypes need to demonstrate, but the same functionality could be used in an application where the selection on one screen needs to be persisted for the next screen.
How can I do this in SketchFlow? I know that I can write Silverlight code to store some data in isolated storage, but I'm trying to go with the 'zero code' approach since this will be a throw-away prototype and would prefer to use some built-in mechanism in SketchFlow if available.
Does Sketchflow offer a way to state data between screens?
If you're doing a throw-away prototype, then my suggestion is the simpliest:
Only provide one path through the prototype. Only allow the person walking through the prototype to navigate through a single path through the different screens. That way, you don't have to worry about state because you always know how the user is going to get to that prototype screen.
It requires no code and gives the user/customer some idea of what the screens are going to look like.
Here is an example showing how to use behaviors to store global state from Christian Schormann:
http://electricbeach.org/?p=349
You might also want to have a look at the demo I gave at PDC last week which contains an example for both preserving global state and a login behavior. Code for this sample is on my blog at electricbeach.org

Categories

Resources