miranda/Speak/Speak/Core/ActionProcessor.cs
2013-05-08 21:39:27 +00:00

87 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Speak.Fork;
namespace Speak.Core
{
internal class ActionProcessor
{
private ContactManager cm;
private Buttons btns;
public ActionProcessor(ContactManager cm, Buttons btns)
{
this.cm = cm;
this.btns = btns;
btns.OnAction += ActionHandler;
cm.OnAction += ActionHandler;
}
private void ActionHandler(object sender, ActionEvent e)
{
string[] actionInfo = e.Action.Split('/');
switch (actionInfo[0])
{
case "autofork":
Settings.Instance.AutoFork = !Settings.Instance.AutoFork;
Settings.Save();
break;
case "forkdel":
DialogResult dr = MessageBox.Show(
"Ты уверен в том, что делаешь?" + Environment.NewLine +
"Хочешь удалить из контакт листа все псевдоконтакты с комментариями?",
"[xJuick] Подтверждение очистки контакт листа",
MessageBoxButtons.YesNoCancel,
MessageBoxIcon.Exclamation);
if (dr == DialogResult.Yes)
cm.ClearContacts();
break;
case "fork":
if (actionInfo.Length == 1)
return;
Match m = Sites.SitesManager.GetContactSite(e.HContact).NumRegex.Match(actionInfo[1]);
if (!m.Success)
return;
cm.ChangeForkState(e.HContact, m.Groups["post"].Value);
break;
case "avatars":
Settings.Instance.ShowAvatars = !Settings.Instance.ShowAvatars;
Settings.Save();
cm.Avatars();
break;
}
}
}
internal class ActionEvent : EventArgs
{
private string action;
private IntPtr hContact;
public ActionEvent(IntPtr hContact, string action)
{
this.hContact = hContact;
this.action = action;
}
public string Action
{
get { return action; }
}
public IntPtr HContact
{
get { return hContact; }
}
}
}