Click here to Skip to main content
15,920,801 members
Home / Discussions / C#
   

C#

 
AnswerRe: Save/Load Class Pin
SeMartens6-Sep-10 20:41
SeMartens6-Sep-10 20:41 
GeneralRe: Save/Load Class Pin
_Q12_6-Sep-10 23:28
_Q12_6-Sep-10 23:28 
GeneralRe: Save/Load Class Pin
_Q12_7-Sep-10 8:10
_Q12_7-Sep-10 8:10 
QuestionRe: Save/Load Class Pin
Ravi Bhavnani7-Sep-10 10:29
professionalRavi Bhavnani7-Sep-10 10:29 
AnswerRe: Save/Load Class Pin
_Q12_7-Sep-10 12:34
_Q12_7-Sep-10 12:34 
GeneralRe: Save/Load Class Pin
Ravi Bhavnani8-Sep-10 4:42
professionalRavi Bhavnani8-Sep-10 4:42 
AnswerRe: Save/Load Class Pin
c0ax_lx8-Sep-10 4:57
c0ax_lx8-Sep-10 4:57 
AnswerRe: Save/Load Class Pin
_Q12_8-Sep-10 20:04
_Q12_8-Sep-10 20:04 
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>
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        public void AddControl(Control c, int valueToAdd)
        {
            tampon += c.Name + " = " + valueToAdd + " \r\n";
        }
        public void EraseAll()
        {
            tampon = "";
        }







        public string buffer; string s = ""; int i, j = 0; bool tf;
        private void Extracttor(string _TextToExtract_)
        {
            i = buffer.IndexOf(_TextToExtract_);
            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();
            }
        }
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /// <summary>call with: numericUpDown1.Value = Extract_int("numericUpDown");</summary>
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        public int Extract_int(string _TextToSearchFor_)
        {
            if (buffer.Contains(_TextToSearchFor_))//if that,then should goto there
            {
                Extracttor(_TextToSearchFor_);
                i = int.Parse(s);
            }
            return i;
        }
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /// <summary>call with: checkBox1.Checked = Extract_bool("checkBox");</summary>
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        public bool Extract_bool(string _TextToSearchFor_)
        {
            if (buffer.Contains(_TextToSearchFor_))//if that,then should goto there
            {
                Extracttor(_TextToSearchFor_);
            }
            if (s.Contains("true"))
            {
                tf = true;
            }
            if (s.Contains("false"))
            {
                tf = false;
            }
            return tf;
        }
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /// <summary>call with: comboBox1.Text = Extract_string("comboBox");</summary>
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        public string Extract_string(string _TextToSearchFor_)
        {
            if (buffer.Contains(_TextToSearchFor_))//if that,then should goto there
            {
                Extracttor(_TextToSearchFor_);
                return s;
            }
            return "string_?";
        }

       



        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /// <summary>call with:  ex.file_SaveFileX();</summary>
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        public void file_SaveFileX()
        {
            slc.file_SaveFile(tampon);              //{ex.AddControl(comboBox1, comboBox1.Text);.....slc.file_SaveFile(ex.tampon);}
        }
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        /// <summary>call with: label1.Text= ex.file_LoadFileX(); </summary>
        //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        public string file_LoadFileX()
        {
            slc.file_LoadFile();
            return buffer = slc.textToLoadInto;     //{ slc.file_LoadFile(); label1.Text = ex.buffer = slc.textToLoadInto;......numericUpDown1.Value = ex.Extract_int("numericUpDown");}
        }


    }
}



And here is the implementation on form:

using System;
using System.Windows.Forms;
using WarningsNamespace;
using ExtractionsNamespace;

namespace test7
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        WarningsClass wc = new WarningsClass();
        ExtractionsClass ex = new ExtractionsClass();


        private void buttonSave_Click(object sender, EventArgs e)
        {
            ex.EraseAll();
            

            ex.AddControl(checkBox1, checkBox1.Checked);
            ex.AddControl(checkBox2, checkBox2.Checked);
            ex.AddControl(checkBox3, checkBox3.Checked);
            ex.AddControl(numericUpDown1, numericUpDown1.Value.ToString());
            ex.AddControl(numericUpDown2, numericUpDown2.Value.ToString());
            ex.AddControl(comboBox1, comboBox1.Text);
            ex.AddControl(progressBar1, progressBar1.Value);

            ex.AddControl(radioButton1, radioButton1.Checked);
            ex.AddControl(radioButton2, radioButton2.Checked);
            ex.AddControl(radioButton3, radioButton3.Checked);
            //------
            
            ex.file_SaveFileX(); label2.Text = wc.w2;
        }


      
        private void buttonLoad_Click(object sender, EventArgs e)
        {
            label1.Text = ex.file_LoadFileX(); label3.Text = wc.w5;
            //------
            checkBox1.Checked = ex.Extract_bool("checkBox1");
            checkBox2.Checked = ex.Extract_bool("checkBox2");
            checkBox3.Checked = ex.Extract_bool("checkBox3");
            numericUpDown1.Value = ex.Extract_int("numericUpDown1");
            numericUpDown2.Value = ex.Extract_int("numericUpDown2");
            comboBox1.Text = ex.Extract_string("comboBox1");
            progressBar1.Value = ex.Extract_int("progressBar1");

            radioButton1.Checked = ex.Extract_bool("radioButton1");
            radioButton2.Checked = ex.Extract_bool("radioButton2");
            radioButton3.Checked = ex.Extract_bool("radioButton3");
        }


        #region <_____ mouseProgressBar _____>
        int somemousecoordonates;
        private void progressBar1_MouseMove(object sender, MouseEventArgs e)
        {
            somemousecoordonates = e.X;
        }
        private void progressBar1_Click(object sender, EventArgs e)
        {
            progressBar1.Value = somemousecoordonates;
            label2.Text = somemousecoordonates.ToString();
        }
        #endregion >mouseProgressBar-END<

BTW, this is what i call a perfect example of [Code Library]. Something like this somewhere, cant be found? Of course for other subjects and matters(not just for savings or loadings).
Smile | :) And the Output is looking like this somewhere in a text file:
checkBox1 = true
checkBox2 = false
checkBox3 = true
numericUpDown1 = 14
numericUpDown2 = 56
comboBox1 = red
progressBar1 = 5
radioButton1 = false
radioButton2 = true
radioButton3 = false

Thanks for all the support.
AnswerRe: Save/Load Class Pin
_Q12_10-Sep-10 19:26
_Q12_10-Sep-10 19:26 
QuestionProblem installing sql server 2005 express through code. Pin
MayukhSen6-Sep-10 18:42
MayukhSen6-Sep-10 18:42 
QuestionreportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) [modified] Pin
amitcoder836-Sep-10 18:00
amitcoder836-Sep-10 18:00 
AnswerRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
Richard MacCutchan6-Sep-10 21:37
mveRichard MacCutchan6-Sep-10 21:37 
GeneralRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
amitcoder836-Sep-10 23:19
amitcoder836-Sep-10 23:19 
GeneralRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
Richard MacCutchan7-Sep-10 1:09
mveRichard MacCutchan7-Sep-10 1:09 
AnswerRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
phil.o6-Sep-10 23:28
professionalphil.o6-Sep-10 23:28 
AnswerRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
amitcoder836-Sep-10 23:39
amitcoder836-Sep-10 23:39 
GeneralRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
Rhys Gravell6-Sep-10 23:43
professionalRhys Gravell6-Sep-10 23:43 
GeneralRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
amitcoder836-Sep-10 23:46
amitcoder836-Sep-10 23:46 
GeneralRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
Rhys Gravell6-Sep-10 23:53
professionalRhys Gravell6-Sep-10 23:53 
GeneralRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) [modified] Pin
phil.o7-Sep-10 0:00
professionalphil.o7-Sep-10 0:00 
AnswerRe: reportAppFactory.OpenDocument throws Invalid Cast exception (No such interfaces supported) Pin
Bernhard Hiller7-Sep-10 0:05
Bernhard Hiller7-Sep-10 0:05 
QuestionHow to write C# struct with array to communicate via IP to C struct device Pin
ejp666-Sep-10 16:12
ejp666-Sep-10 16:12 
AnswerRe: How to write C# struct with array to communicate via IP to C struct device Pin
Luc Pattyn6-Sep-10 16:48
sitebuilderLuc Pattyn6-Sep-10 16:48 
AnswerRe: How to write C# struct with array to communicate via IP to C struct device Pin
DaveyM696-Sep-10 22:18
professionalDaveyM696-Sep-10 22:18 
GeneralRe: How to write C# struct with array to communicate via IP to C struct device Pin
Paul Michalik7-Sep-10 9:42
Paul Michalik7-Sep-10 9:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.