2007-11-14 01:23:27 +03:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Text;
|
|
|
|
using System.Windows.Forms;
|
2008-05-19 01:07:21 +04:00
|
|
|
using System.Resources;
|
|
|
|
using System.Threading;
|
|
|
|
using System.Globalization;
|
2007-11-14 01:23:27 +03:00
|
|
|
|
|
|
|
namespace webImTray {
|
|
|
|
class Options {
|
|
|
|
|
2008-03-27 00:46:01 +03:00
|
|
|
public const string DEFAULT_SERVER = "http://localhost/webim";
|
|
|
|
public const string PENDING_USERS_PAGE = "/operator/users.php";
|
|
|
|
public const string SETTINGS_PAGE = "/operator/operators.php";
|
2007-11-14 01:23:27 +03:00
|
|
|
private const string HTTP_PREFIX = "http://";
|
|
|
|
|
|
|
|
public static string WebIMServer {
|
|
|
|
get {
|
2008-03-27 00:46:01 +03:00
|
|
|
String server = Application.UserAppDataRegistry.GetValue("server", DEFAULT_SERVER).ToString();
|
|
|
|
while (server.EndsWith("/")) {
|
2007-11-14 01:23:27 +03:00
|
|
|
server = server.Substring(0, server.Length - 1);
|
2008-03-27 00:46:01 +03:00
|
|
|
}
|
|
|
|
if (!server.StartsWith(HTTP_PREFIX)) {
|
|
|
|
return DEFAULT_SERVER;
|
|
|
|
}
|
2007-11-14 01:23:27 +03:00
|
|
|
return server;
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
if (!value.StartsWith(HTTP_PREFIX))
|
|
|
|
return;
|
|
|
|
Application.UserAppDataRegistry.SetValue("server", value.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static decimal ForceRefreshTime {
|
|
|
|
get {
|
|
|
|
return Decimal.Parse(Application.UserAppDataRegistry.GetValue("refreshtime", "15").ToString());
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
Application.UserAppDataRegistry.SetValue("refreshtime", value.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-28 00:30:36 +03:00
|
|
|
public static bool DisconnectOnLock {
|
|
|
|
get {
|
|
|
|
return Application.UserAppDataRegistry.GetValue("disconnectonlock", "true").ToString().ToLower().Equals("true");
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
Application.UserAppDataRegistry.SetValue("disconnectonlock", value.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-14 01:23:27 +03:00
|
|
|
public static bool ShowInTaskBar {
|
|
|
|
get {
|
|
|
|
return Application.UserAppDataRegistry.GetValue("showintaskbar", "false").ToString().ToLower().Equals("true");
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
Application.UserAppDataRegistry.SetValue("showintaskbar", value.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool HideAfterStart {
|
|
|
|
get {
|
|
|
|
return Application.UserAppDataRegistry.GetValue("hideafterstart", "false").ToString().ToLower().Equals("true");
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
Application.UserAppDataRegistry.SetValue("hideafterstart", value.ToString());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private const string autoRunUserRegistry = "Software\\Microsoft\\Windows\\CurrentVersion\\Run";
|
|
|
|
private const string autoRunRegistry = "HKEY_CURRENT_USER\\" + autoRunUserRegistry;
|
|
|
|
private const string autoRunKey = "webimtray.exe";
|
|
|
|
|
|
|
|
public static bool AutoStart {
|
|
|
|
get {
|
|
|
|
return Microsoft.Win32.Registry.GetValue(autoRunRegistry, autoRunKey, "").ToString().Length > 0;
|
|
|
|
}
|
|
|
|
set {
|
|
|
|
if (value) {
|
|
|
|
Microsoft.Win32.Registry.SetValue(autoRunRegistry, autoRunKey, Application.ExecutablePath);
|
|
|
|
} else {
|
|
|
|
try {
|
|
|
|
Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(autoRunUserRegistry, true);
|
|
|
|
key.DeleteValue(autoRunKey, false);
|
|
|
|
key.Close();
|
|
|
|
}
|
|
|
|
catch (Exception) {
|
|
|
|
Microsoft.Win32.Registry.SetValue(autoRunRegistry, autoRunKey, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static bool HideMainWindow {
|
|
|
|
get {
|
|
|
|
if (forceShowWindow)
|
|
|
|
return false;
|
|
|
|
return HideAfterStart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static bool forceShowWindow = false;
|
|
|
|
|
|
|
|
internal static void parseParameters(string[] args) {
|
|
|
|
if (args.Length == 1 && args[0].Equals("/show"))
|
|
|
|
forceShowWindow = true;
|
|
|
|
}
|
2008-05-18 23:36:55 +04:00
|
|
|
|
|
|
|
public static bool RussianLocale {
|
|
|
|
get {
|
2008-05-21 01:37:54 +04:00
|
|
|
return Application.UserAppDataRegistry.GetValue("isrussianlocale", "true").ToString().ToLower().Equals("true");
|
2008-05-18 23:36:55 +04:00
|
|
|
} set {
|
|
|
|
Application.UserAppDataRegistry.SetValue("isrussianlocale", value.ToString());
|
|
|
|
}
|
|
|
|
}
|
2008-05-19 01:07:21 +04:00
|
|
|
|
|
|
|
public static ResourceManager resourceManager = new ResourceManager("webImTray.webImTray", System.Reflection.Assembly.GetExecutingAssembly());
|
|
|
|
public static CultureInfo englishCulture = new CultureInfo("en-US");
|
|
|
|
public static CultureInfo russianCulture = new CultureInfo("ru-RU");
|
2007-11-14 01:23:27 +03:00
|
|
|
}
|
|
|
|
}
|