Save/Load Class
-
I finally made it working!!! I made a test here actually and i made it work. I can save and load from a text file...yeeey. How can I made it more compact? I want to transform it into a stand alone Class that I can call it from anywhere in any situation. Any suggestions? Thanks Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SaveLoadNamespace;
using WarningsNamespace;
using System.Text.RegularExpressions;namespace test7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SaveLoadClass slc = new SaveLoadClass();
WarningsClass wc = new WarningsClass();string tampon; private void buttonSave\_Click(object sender, EventArgs e) { if (checkBox1.Checked) { tampon = "checkBox = true" + "\\r\\n"; } else { tampon = "checkBox = false" + "\\r\\n"; } tampon += "numericUpDown = " + numericUpDown1.Value.ToString() + "\\r\\n"; ; tampon += "comboBox = " + comboBox1.Text + "\\r\\n"; ; slc.file\_SaveFile(tampon); label2.Text = wc.w2; } string buffer, s = ""; int i, j = 0; private void buttonLoad\_Click(object sender, EventArgs e) { //STRING MANIPULATION !!! slc.file\_LoadFile(); label1.Text = buffer = slc.textToLoadInto; label3.Text = wc.w5; #region <\_\_\_\_\_ NumericUpDown \_\_\_\_\_> //NumericUpDown if (buffer.Contains("numericUpDown"))//if that,then should goto there { i = buffer.IndexOf("numericUpDown"); s = buffer.Remove(0, i); //remove the Begining of string if (s.Contains("\\r\\n")) //folowing operations remove the Ending part of the string { i = s.IndexOf("\\r\\n"); j = s.Length - i; s = s.Remove(i, j); } if (s.Contains("=")) { i = s.IndexOf("=") + 1; s = s.Remove(0, i).Trim(); } i = int.Parse(s); numericUpDown1.Value = i; } #endregion >NumericUpDown-END<
-
I finally made it working!!! I made a test here actually and i made it work. I can save and load from a text file...yeeey. How can I made it more compact? I want to transform it into a stand alone Class that I can call it from anywhere in any situation. Any suggestions? Thanks Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SaveLoadNamespace;
using WarningsNamespace;
using System.Text.RegularExpressions;namespace test7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SaveLoadClass slc = new SaveLoadClass();
WarningsClass wc = new WarningsClass();string tampon; private void buttonSave\_Click(object sender, EventArgs e) { if (checkBox1.Checked) { tampon = "checkBox = true" + "\\r\\n"; } else { tampon = "checkBox = false" + "\\r\\n"; } tampon += "numericUpDown = " + numericUpDown1.Value.ToString() + "\\r\\n"; ; tampon += "comboBox = " + comboBox1.Text + "\\r\\n"; ; slc.file\_SaveFile(tampon); label2.Text = wc.w2; } string buffer, s = ""; int i, j = 0; private void buttonLoad\_Click(object sender, EventArgs e) { //STRING MANIPULATION !!! slc.file\_LoadFile(); label1.Text = buffer = slc.textToLoadInto; label3.Text = wc.w5; #region <\_\_\_\_\_ NumericUpDown \_\_\_\_\_> //NumericUpDown if (buffer.Contains("numericUpDown"))//if that,then should goto there { i = buffer.IndexOf("numericUpDown"); s = buffer.Remove(0, i); //remove the Begining of string if (s.Contains("\\r\\n")) //folowing operations remove the Ending part of the string { i = s.IndexOf("\\r\\n"); j = s.Length - i; s = s.Remove(i, j); } if (s.Contains("=")) { i = s.IndexOf("=") + 1; s = s.Remove(0, i).Trim(); } i = int.Parse(s); numericUpDown1.Value = i; } #endregion >NumericUpDown-END<
Hi, you could build a method to which you can pass a form. To get the controls at the passed form use the Controls-Property: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controls.aspx[^] Check the type of each control to get the name like 'checkBox' for your string. Btw: Instead of using the type-name of each control I would suggest using the ID, so that you can store more than one checkbox for example. Hope this helps you a bit. Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
-
Hi, you could build a method to which you can pass a form. To get the controls at the passed form use the Controls-Property: http://msdn.microsoft.com/en-us/library/system.windows.forms.control.controls.aspx[^] Check the type of each control to get the name like 'checkBox' for your string. Btw: Instead of using the type-name of each control I would suggest using the ID, so that you can store more than one checkbox for example. Hope this helps you a bit. Regards Sebastian
It's not a bug, it's a feature! Check out my CodeProject article Permission-by-aspect. Me in Softwareland.
Its a good suggestion and i understand it because i see it some time ago used by others ... But, its too advanced for me for the moment and I wish to make it in some limited way that i can understand what i write there... But,I will look into it and I will strive to understand it how its done and try to use it...but small chance for me to accomplish that kind of maneuverability. Thanks
-
Its a good suggestion and i understand it because i see it some time ago used by others ... But, its too advanced for me for the moment and I wish to make it in some limited way that i can understand what i write there... But,I will look into it and I will strive to understand it how its done and try to use it...but small chance for me to accomplish that kind of maneuverability. Thanks
-
I finally made it working!!! I made a test here actually and i made it work. I can save and load from a text file...yeeey. How can I made it more compact? I want to transform it into a stand alone Class that I can call it from anywhere in any situation. Any suggestions? Thanks Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SaveLoadNamespace;
using WarningsNamespace;
using System.Text.RegularExpressions;namespace test7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SaveLoadClass slc = new SaveLoadClass();
WarningsClass wc = new WarningsClass();string tampon; private void buttonSave\_Click(object sender, EventArgs e) { if (checkBox1.Checked) { tampon = "checkBox = true" + "\\r\\n"; } else { tampon = "checkBox = false" + "\\r\\n"; } tampon += "numericUpDown = " + numericUpDown1.Value.ToString() + "\\r\\n"; ; tampon += "comboBox = " + comboBox1.Text + "\\r\\n"; ; slc.file\_SaveFile(tampon); label2.Text = wc.w2; } string buffer, s = ""; int i, j = 0; private void buttonLoad\_Click(object sender, EventArgs e) { //STRING MANIPULATION !!! slc.file\_LoadFile(); label1.Text = buffer = slc.textToLoadInto; label3.Text = wc.w5; #region <\_\_\_\_\_ NumericUpDown \_\_\_\_\_> //NumericUpDown if (buffer.Contains("numericUpDown"))//if that,then should goto there { i = buffer.IndexOf("numericUpDown"); s = buffer.Remove(0, i); //remove the Begining of string if (s.Contains("\\r\\n")) //folowing operations remove the Ending part of the string { i = s.IndexOf("\\r\\n"); j = s.Length - i; s = s.Remove(i, j); } if (s.Contains("=")) { i = s.IndexOf("=") + 1; s = s.Remove(0, i).Trim(); } i = int.Parse(s); numericUpDown1.Value = i; } #endregion >NumericUpDown-END<
What possessed you to declare a local variable called
tampon
? /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
What possessed you to declare a local variable called
tampon
? /raviMy new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
I was actually thinking on "TRAIN Buffer" ,but in my language "tampon" actually is the word for "TRAIN Buffer"or 1.damper,2. bumper,3. fender, 4. shock, 5. buffer. I was not thinking at all at other meanings other than what i described ... sorry if i mislead you. I will change his name soon.
-
I was actually thinking on "TRAIN Buffer" ,but in my language "tampon" actually is the word for "TRAIN Buffer"or 1.damper,2. bumper,3. fender, 4. shock, 5. buffer. I was not thinking at all at other meanings other than what i described ... sorry if i mislead you. I will change his name soon.
That's OK - it just made me laugh. :) /ravi
My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com
-
I finally made it working!!! I made a test here actually and i made it work. I can save and load from a text file...yeeey. How can I made it more compact? I want to transform it into a stand alone Class that I can call it from anywhere in any situation. Any suggestions? Thanks Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SaveLoadNamespace;
using WarningsNamespace;
using System.Text.RegularExpressions;namespace test7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SaveLoadClass slc = new SaveLoadClass();
WarningsClass wc = new WarningsClass();string tampon; private void buttonSave\_Click(object sender, EventArgs e) { if (checkBox1.Checked) { tampon = "checkBox = true" + "\\r\\n"; } else { tampon = "checkBox = false" + "\\r\\n"; } tampon += "numericUpDown = " + numericUpDown1.Value.ToString() + "\\r\\n"; ; tampon += "comboBox = " + comboBox1.Text + "\\r\\n"; ; slc.file\_SaveFile(tampon); label2.Text = wc.w2; } string buffer, s = ""; int i, j = 0; private void buttonLoad\_Click(object sender, EventArgs e) { //STRING MANIPULATION !!! slc.file\_LoadFile(); label1.Text = buffer = slc.textToLoadInto; label3.Text = wc.w5; #region <\_\_\_\_\_ NumericUpDown \_\_\_\_\_> //NumericUpDown if (buffer.Contains("numericUpDown"))//if that,then should goto there { i = buffer.IndexOf("numericUpDown"); s = buffer.Remove(0, i); //remove the Begining of string if (s.Contains("\\r\\n")) //folowing operations remove the Ending part of the string { i = s.IndexOf("\\r\\n"); j = s.Length - i; s = s.Remove(i, j); } if (s.Contains("=")) { i = s.IndexOf("=") + 1; s = s.Remove(0, i).Trim(); } i = int.Parse(s); numericUpDown1.Value = i; } #endregion >NumericUpDown-END<
Congratulations on getting your code to work :) This approach isnt very dynamic tho and if you add or remove fields you would have to modify your save/load methods. I suggest that you read some articles about Serialization. Start with XML serialization, that way you can open the xml file in your browser and see everything. binary serialization isnt very fun to look at :].
A FOO walked into a BAR, and the horse said..
-
I finally made it working!!! I made a test here actually and i made it work. I can save and load from a text file...yeeey. How can I made it more compact? I want to transform it into a stand alone Class that I can call it from anywhere in any situation. Any suggestions? Thanks Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SaveLoadNamespace;
using WarningsNamespace;
using System.Text.RegularExpressions;namespace test7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SaveLoadClass slc = new SaveLoadClass();
WarningsClass wc = new WarningsClass();string tampon; private void buttonSave\_Click(object sender, EventArgs e) { if (checkBox1.Checked) { tampon = "checkBox = true" + "\\r\\n"; } else { tampon = "checkBox = false" + "\\r\\n"; } tampon += "numericUpDown = " + numericUpDown1.Value.ToString() + "\\r\\n"; ; tampon += "comboBox = " + comboBox1.Text + "\\r\\n"; ; slc.file\_SaveFile(tampon); label2.Text = wc.w2; } string buffer, s = ""; int i, j = 0; private void buttonLoad\_Click(object sender, EventArgs e) { //STRING MANIPULATION !!! slc.file\_LoadFile(); label1.Text = buffer = slc.textToLoadInto; label3.Text = wc.w5; #region <\_\_\_\_\_ NumericUpDown \_\_\_\_\_> //NumericUpDown if (buffer.Contains("numericUpDown"))//if that,then should goto there { i = buffer.IndexOf("numericUpDown"); s = buffer.Remove(0, i); //remove the Begining of string if (s.Contains("\\r\\n")) //folowing operations remove the Ending part of the string { i = s.IndexOf("\\r\\n"); j = s.Length - i; s = s.Remove(i, j); } if (s.Contains("=")) { i = s.IndexOf("=") + 1; s = s.Remove(0, i).Trim(); } i = int.Parse(s); numericUpDown1.Value = i; } #endregion >NumericUpDown-END<
I think I made it how I like it the most and i can proudly name it that is all right ... 2 nights over this but I bring it down right where I want it to be. Phew. Now I am happy with it. I know i must learn and assimilate /the faster the better/ the arrays and lists that you all master them soooo well, and i am angry for that, but... i will. About this matter, some good exercises that cant be done without them(arrays&lists&othersLikeThem) ,and who can be done without make me thinking about what I know already but direct me to learn them well? Thanks,and I appreciate. So, here is my Class:
using System.Windows.Forms;
using SaveLoadNamespace;
namespace ExtractionsNamespace
{//call ALL these methods with :
//using ExtractionsNamespace;
//Extractions ex = new Extractions();
public class ExtractionsClass
{
SaveLoadClass slc = new SaveLoadClass();//STRING MANIPULATION !!! public string tampon; #region <\_\_\_\_\_ AddControl \_\_\_\_\_> //if (checkBox1.Checked) tampon = "checkBox = true" + "\\r\\n"; // else tampon = "checkBox = false" + "\\r\\n"; //tampon += "comboBox = " + comboBox1.Text + "\\r\\n"; //tampon += "numericUpDown = " + numericUpDown1.Value.ToString() + "\\r\\n"; //tampon += "progressBar = " + progressBar1.Value + "\\r\\n"; #endregion >AddControl-END< //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// <summary>call with: ex.AddControl(checkBox1, checkBox1.Checked);</summary> //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public void AddControl(Control c, bool checkToAdd) { if (checkToAdd) tampon += c.Name + " = true" + "\\r\\n"; else tampon += c.Name + " = false" + "\\r\\n"; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// <summary>call with: ex.AddControl(comboBox1, comboBox1.Text);</summary> //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ public void AddControl(Control c, string textToAdd) { tampon += c.Name + " = " + textToAdd + " \\r\\n"; } //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /// <summary>call with: ex.AddControl(numericUpDown1, numericUpDown1.Value.ToString());</summary> //~~~
-
I finally made it working!!! I made a test here actually and i made it work. I can save and load from a text file...yeeey. How can I made it more compact? I want to transform it into a stand alone Class that I can call it from anywhere in any situation. Any suggestions? Thanks Here is the code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SaveLoadNamespace;
using WarningsNamespace;
using System.Text.RegularExpressions;namespace test7
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
SaveLoadClass slc = new SaveLoadClass();
WarningsClass wc = new WarningsClass();string tampon; private void buttonSave\_Click(object sender, EventArgs e) { if (checkBox1.Checked) { tampon = "checkBox = true" + "\\r\\n"; } else { tampon = "checkBox = false" + "\\r\\n"; } tampon += "numericUpDown = " + numericUpDown1.Value.ToString() + "\\r\\n"; ; tampon += "comboBox = " + comboBox1.Text + "\\r\\n"; ; slc.file\_SaveFile(tampon); label2.Text = wc.w2; } string buffer, s = ""; int i, j = 0; private void buttonLoad\_Click(object sender, EventArgs e) { //STRING MANIPULATION !!! slc.file\_LoadFile(); label1.Text = buffer = slc.textToLoadInto; label3.Text = wc.w5; #region <\_\_\_\_\_ NumericUpDown \_\_\_\_\_> //NumericUpDown if (buffer.Contains("numericUpDown"))//if that,then should goto there { i = buffer.IndexOf("numericUpDown"); s = buffer.Remove(0, i); //remove the Begining of string if (s.Contains("\\r\\n")) //folowing operations remove the Ending part of the string { i = s.IndexOf("\\r\\n"); j = s.Length - i; s = s.Remove(i, j); } if (s.Contains("=")) { i = s.IndexOf("=") + 1; s = s.Remove(0, i).Trim(); } i = int.Parse(s); numericUpDown1.Value = i; } #endregion >NumericUpDown-END<
I need a suggestion from you: I want to make a saving program that is for windows only (not for internet) and who can imitate the Forum(in general) type of writing a text , store and display. Like the one i am writing right now. With a list box to display some saved text from a file, a textbox under -to write and save into that file.And a comboBox that can sort all "posts". Basically this is the hard part, the rest are decorations. How do you recommend me to do: Make for every "post" a file (for 100 posts will be 100 files) and the sorting is based on those files-its more intuitive to program it this way for me in my stage. OR - the very hard part: (because i know only the basics in string manipulation)... Make a single file with all the text and sorted it out by manipulating a string who contain the entire file.(a string that can retain in itself 99999999999999 characters-its even possible?-i doubt it. OR Again a single file that can be sorted but with the help of another one that contain some [sortings by address] from that large one. Basically there will be 2 files one with keywords representing addresses and the text attached to them, and the second one with only the keywords address. But This is a little overwhelming for me to think about and i seek help from you, the guru of programming world. Please give me a good solution...and how to think it through(programmatically). Thank you.