XR2


can anybody explain me how can I do to use this statement in my Add-In, because I don't understand it

using this statement can I save more than one variable

I need to save 10 variables, and don't know if this is posible using that thing




Re: how to use the SavedState property of the MessengerClient in my Add-In

David_ES


It's simple;

messenger.SavedState = MyStringToGetOrSet;

Format your string to save 10 variables, For example:


string MyStringToGetOrSet = FirstConfig + "," + SecondfConfig + ...
messenger.SavedState = MyStringToGetOrSet;





Re: how to use the SavedState property of the MessengerClient in my Add-In

XR2

Ok thanks

I have auto reply addin

public void Client_IncomingTextMessage(Object Sender, IncomingTextMessageEventArgs e)

{

String Reply = String.Empty;

switch (this.client.LocalUser.Status)

{

case UserStatus.Away:

Reply += FirstConfig;

break;

}

case UserStatus.Busy:

Reply += SecondfConfig;

break;

} // and for all the UserStatus...

User userFrom = e.UserFrom;

Client.SendTextMessage(Reply, userFrom);

}

how would you apply that to this






Re: how to use the SavedState property of the MessengerClient in my Add-In

David_ES

Do you want to save the answer to send

I think

messenger.SavedState = Reply;




Re: how to use the SavedState property of the MessengerClient in my Add-In

XR2

what I need to save are the variables ( Ausente, No_Disponible, Vuelvo_enseguida, Sali_a_comer, Al_telefono) this is all the code that was given to me.

Code Block

namespace Auto

{

public class reply: IMessengerAddIn

{

//public Label Label0, Label1, Label2, Label3, Label4, Label5;

public Button Button1, Button2;

public TextBox textBox1, textBox2, textBox3, textBox4, textBox5;

public Microsoft.Messenger.MessengerClient messenger2 = new Microsoft.Messenger.MessengerClient();

private MessengerClient client = null;

public void Initialize(MessengerClient messenger)

{

Client = messenger;

Client.IncomingTextMessage += new EventHandler<IncomingTextMessageEventArgs>(Client_IncomingTextMessage);

Client.ShowOptionsDialog += new EventHandler(Client_ShowOptionsDialog);

Client.Shutdown += new EventHandler(Client_Shutdown);

}

public string Ausente, No_Disponible, Vuelvo_enseguida, Sali_a_comer, Al_telefono;

public void Client_Shutdown(object sender, EventArgs e)

{

/////////////////

}

public void Client_IncomingTextMessage(Object Sender, IncomingTextMessageEventArgs e)

{

String Msgr = String.Empty;

switch (this.client.LocalUser.Status)

{

case UserStatus.Away:

Msgr += Ausente;

break;

case UserStatus.Busy:

Msgr += No_Disponible;

break;

case UserStatus.BeRightBack:

Msgr += Vuelvo_enseguida;

break;

case UserStatus.OutToLunch:

Msgr += Sali_a_comer;

break;

case UserStatus.OnThePhone:

Msgr += Al_telefono;

break;

}

User userFrom = e.UserFrom;

Client.SendTextMessage(Msgr, userFrom);

}

public void Client_ShowOptionsDialog(object sender, EventArgs e)

{

Form Settings = new Form(); Settings.Size = new Size(475, 195);

textBox1 = new TextBox();

textBox1.Location = new Point(100, 20); textBox1.Size = new Size(360, 20);

textBox2 = new TextBox(); textBox2.Location = new Point(100, 40);

textBox2.Size = new Size(360, 20); textBox3 = new TextBox();

textBox3.Location = new Point(100, 60); textBox3.Size = new Size(360, 20);

textBox4 = new TextBox(); textBox4.Location = new Point(100, 80);

textBox4.Size = new Size(360, 20); textBox5 = new TextBox();

textBox5.Location = new Point(100, 100); textBox5.Size = new Size(360, 20);

Button1 = new Button(); Button1.Location = new Point(305, 130);

Button2 = new Button(); Button2.Location = new Point(385, 130);

Settings.StartPosition = FormStartPosition.CenterScreen;

Settings.FormBorderStyle = FormBorderStyle.FixedDialog;

Button1.DialogResult = DialogResult.OK;

Settings.AcceptButton = Button1;

Settings.CancelButton = Button2;

textBox1.Text = Ausente;

textBox2.Text = No_Disponible;

textBox3.Text = Vuelvo_enseguida;

textBox4.Text = Sali_a_comer;

textBox5.Text = Al_telefono;

Button1.Text = "Aceptar";

Button2.Text = "Cancelar";

Settings.Controls.AddRange(new Control[] { textBox1, textBox2, textBox3, textBox4, textBox5, Button1, Button2 });

Settings.ShowDialog();

if (Settings.DialogResult == DialogResult.OK)

{

Ausente = textBox1.Text;

No_Disponible = textBox2.Text;

Vuelvo_enseguida = textBox3.Text;

Sali_a_comer = textBox4.Text;

Al_telefono = textBox5.Text;}

}

public MessengerClient Client

{

get { return client; }

set { client = value; }

}

}

}





Re: how to use the SavedState property of the MessengerClient in my Add-In

David_ES

//Set
Msgr = Ausente + '*' + No_Disponible + '*' + Vuelvo_enseguida + '*' + Sali_a_comer + '*' + Al_telefono;
messenger.SavedState = Msgr;

//Get
string[] v = Messenger.SavedState.Split('*');

//First pos = ausente
//Second pos = No_Disponible
//...




Re: how to use the SavedState property of the MessengerClient in my Add-In

XR2

thanks man, but I can't make it works

somethig like this I thought that would work, but, it didn't

public void Client_Shutdown(object sender, EventArgs e)

{

Client.SavedState = Ausente;

Client.SavedState = No_Disponible;

Client.SavedState = Vuelvo_enseguida;

Client.SavedState = Sali_a_comer;

Client.SavedState = Al_telefono;

}

edited {

on the first run, the first time the addin get loaded the variables (Ausente, No_Disponible, Vuelvo_enseguida, Sali_a_comer and Al_telefono) has a null value

so I (the user) press de Setting Button and set any text to those variables.

Now Ausente = "bla, bla" etc.

when the I close the MSN and reopen it the add get reloaded I want Ausente to get back the value that I have written before "bla, bla" and the rest of the variables

}

I'm going to give up on this one





Re: how to use the SavedState property of the MessengerClient in my Add-In

Jeroen Bransen - J-Thread

Code Block

public void Client_Shutdown(object sender, EventArgs e)

{

Client.SavedState = Ausente;

Client.SavedState += "|"+No_Disponible;

Client.SavedState += "|"+Vuelvo_enseguida;

Client.SavedState += "|"+Sali_a_comer;

Client.SavedState += "|"+Al_telefono;

}

Else you will overwrite the Client.SavedState property by Al_telefono. Now I used "|" as a separator, if people enter the | in the text, it will go wrong.
To retrieve the values on load, you have to do:
Code Block
string[] parts = Client.SavedState.Split('|');
if(parts.Length > 4)
{
Ausente = parts[0];
No_Disponible = parts[1];
Vuelvo_enseguida = parts[2];
Sali_a_comer = parts[3];
Al_telefono = parts[4];
}





Re: how to use the SavedState property of the MessengerClient in my Add-In

XR2

David_ES, Jeroen Bransen - J-Thread Thanks for your help and your time.

in this way its worked for me, I think.

Code Block

public void Initialize(MessengerClient messenger)

{Client = messenger;

Client.IncomingTextMessage += new EventHandler<IncomingTextMessageEventArgs>(Client_IncomingTextMessage);

Client.ShowOptionsDialog += new EventHandler(Client_ShowOptionsDialog);

Client.Shutdown += new EventHandler(Client_Shutdown);

string[] parts = Client.SavedState.Split('|');

if (parts.Length > 4)

{ Ausente = parts[0];

No_Disponible = parts[1];

Vuelvo_enseguida = parts[2];

Sali_a_comer = parts[3];

Al_telefono = parts[4];

}

}

public void Client_Shutdown(object sender, EventArgs e)

{

Client.SavedState = Ausente;

Client.SavedState += '|' + No_Disponible;

Client.SavedState += '|' + Vuelvo_enseguida;

Client.SavedState += '|' + Sali_a_comer;

Client.SavedState += '|' + Al_telefono;

}

Sorry for my bad English

Saludos desde Argentina