87 lines
2.7 KiB
C#
87 lines
2.7 KiB
C#
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; }
|
||
}
|
||
}
|
||
}
|