Click here to Skip to main content
15,916,042 members
Home / Discussions / C#
   

C#

 
AnswerRe: Image corruption in picturebox Pin
OriginalGriff7-Sep-10 1:16
mveOriginalGriff7-Sep-10 1:16 
GeneralRe: Image corruption in picturebox Pin
Sauce!7-Sep-10 2:10
Sauce!7-Sep-10 2:10 
AnswerRe: Image corruption in picturebox Pin
Luc Pattyn7-Sep-10 1:48
sitebuilderLuc Pattyn7-Sep-10 1:48 
GeneralRe: Image corruption in picturebox Pin
Sauce!7-Sep-10 2:12
Sauce!7-Sep-10 2:12 
GeneralRe: Image corruption in picturebox Pin
Luc Pattyn7-Sep-10 2:27
sitebuilderLuc Pattyn7-Sep-10 2:27 
QuestionHow to Unhide the Hidden form Pin
Ravindra Bisen6-Sep-10 23:36
Ravindra Bisen6-Sep-10 23:36 
AnswerRe: How to Unhide the Hidden form Pin
OriginalGriff6-Sep-10 23:44
mveOriginalGriff6-Sep-10 23:44 
AnswerRe: How to Unhide the Hidden form Pin
Luc Pattyn7-Sep-10 1:52
sitebuilderLuc Pattyn7-Sep-10 1:52 
GeneralRe: How to Unhide the Hidden form Pin
DaveyM697-Sep-10 2:04
professionalDaveyM697-Sep-10 2:04 
GeneralRe: How to Unhide the Hidden form Pin
OriginalGriff7-Sep-10 2:18
mveOriginalGriff7-Sep-10 2:18 
AnswerRe: How to Unhide the Hidden form Pin
DaveyM697-Sep-10 2:01
professionalDaveyM697-Sep-10 2:01 
GeneralRe: How to Unhide the Hidden form Pin
Hum Dum8-Sep-10 0:25
Hum Dum8-Sep-10 0:25 
GeneralRe: How to Unhide the Hidden form Pin
DaveyM698-Sep-10 1:53
professionalDaveyM698-Sep-10 1:53 
GeneralRe: How to Unhide the Hidden form Pin
DaveyM698-Sep-10 1:57
professionalDaveyM698-Sep-10 1:57 
AnswerRe: How to Unhide the Hidden form Pin
Luc Pattyn7-Sep-10 2:32
sitebuilderLuc Pattyn7-Sep-10 2:32 
QuestionSave/Load Class Pin
_Q12_6-Sep-10 19:05
_Q12_6-Sep-10 19:05 
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<

            #region <_____ checkBox _____>
            //checkBox
            if (buffer.Contains("checkBox"))//if that,then should goto there
            {
                i = buffer.IndexOf("checkBox");
                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(); 
                }

                if (s.Contains("true"))//s.Contains here is for: in case of whitespaces
                {
                    checkBox1.Checked = true;
                }
                if (s.Contains("false"))
                {
                    checkBox1.Checked = false;
                }
            }
            #endregion >checkBox-END<

            #region <_____ comboBox _____>
            //comboBox
            if (buffer.Contains("comboBox"))//if that,then should goto there
            {
                i = buffer.IndexOf("comboBox");
                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();
                }

                comboBox1.Text = s;
            }
            #endregion >comboBox-END<


        }
    }
}



The output is like this:
checkBox = true
numericUpDown = 24
comboBox = red
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 
AnswerRe: Save/Load Class Pin
_Q12_10-Sep-10 19:26
_Q12_10-Sep-10 19:26 

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.