private void ApplyConfig(Config config) { if (config.InterfaceStyle == 0) //System toolStrip1.RenderMode = ToolStripRenderMode.System; else if (config.InterfaceStyle == 1) //Office 2003 toolStrip1.RenderMode = ToolStripRenderMode.ManagerRenderMode; //rtbIMText.BackColor = instance.Config.CurrentConfig.BgColour; if (instance.Config.CurrentConfig.EnableSpelling) { dicfile = instance.Config.CurrentConfig.SpellLanguage; // "en_GB.dic"; this.instance.AffFile = afffile = dicfile + ".aff"; this.instance.DictionaryFile = dicfile + ".dic"; dic = dir + dicfile; dicfile += ".dic"; if (!System.IO.File.Exists(dic + ".csv")) { //System.IO.File.Create(dic + ".csv"); using (StreamWriter sw = File.CreateText(dic + ".csv")) { sw.Dispose(); } } hunspell.Dispose(); hunspell = new Hunspell(); hunspell.Load(dir + afffile, dir + dicfile); ReadWords(); } else { hunspell.Dispose(); } }
private void ApplyConfig(Config config) { if (config.InterfaceStyle == 0) //System tstTabs.RenderMode = ToolStripRenderMode.System; else if (config.InterfaceStyle == 1) //Office 2003 tstTabs.RenderMode = ToolStripRenderMode.ManagerRenderMode; stopnotify = config.DisableNotifications; if (config.DisableTrayIcon) { if (stopnotify) { notifyIcon1.Visible = false; config.HideMeta = false; } else { if (!config.HideMeta) { notifyIcon1.Visible = false; } else { notifyIcon1.Visible = true; } } } else { notifyIcon1.Visible = true; } // Menu positions Control control; //bool topofscreen = false; switch (instance.Config.CurrentConfig.FnMenuPos) { case "Top": control = toolStripContainer1.TopToolStripPanel; //topofscreen = true; break; case "Bottom": control = toolStripContainer1.BottomToolStripPanel; break; case "Left": control = toolStripContainer1.LeftToolStripPanel; break; case "Right": control = toolStripContainer1.RightToolStripPanel; break; default: control = toolStripContainer1.TopToolStripPanel; break; } tstTabs.Parent = control; //topofscreen = false; }
private void ApplyConfig(Config config, bool doingInit) { if (doingInit) this.WindowState = (FormWindowState)config.MainWindowState; if (config.InterfaceStyle == 0) //System toolStrip1.RenderMode = ToolStripRenderMode.System; else if (config.InterfaceStyle == 1) //Office 2003 toolStrip1.RenderMode = ToolStripRenderMode.ManagerRenderMode; if (instance.Config.CurrentConfig.UseProxy) { // Apply proxy settings if any METAproxy proxy = new METAproxy(); proxy.SetProxy(config.UseProxy, config.ProxyURL, config.ProxyPort, config.ProxyUser, config.ProxyPWD); } // Check for auto logoff and start time if set if (config.LogOffTime > 0) { if (instance.Config.CurrentConfig.LogOffTimerChanged) { logOffTimer.Stop(); logOffTimer.Enabled = true; logOffTimer.Start(); offtime = DateTime.Now.AddMinutes(Convert.ToDouble(instance.Config.CurrentConfig.LogOffTime)); instance.Config.CurrentConfig.LogOffTimerChanged = false; } tsTimeOut.Visible = true; TimeSpan ts = offtime - DateTime.Now; tsTimeOut.Text = ts.Hours.ToString("00", CultureInfo.CurrentCulture) + ":" + ts.Minutes.ToString("00", CultureInfo.CurrentCulture); } else { tsTimeOut.Visible = false; if (logOffTimer != null) { logoff = false; logOffTimer.Stop(); if (logOffTimer.Enabled) { logOffTimer.Enabled = false; } } } // Menu positions Control control; bool topofscreen = false; switch (instance.Config.CurrentConfig.AppMenuPos) { case "Top": control = toolStripContainer1.TopToolStripPanel; topofscreen = true; break; case "Bottom": control = toolStripContainer1.BottomToolStripPanel; break; case "Left": control = toolStripContainer1.LeftToolStripPanel; break; case "Right": control = toolStripContainer1.RightToolStripPanel; break; default: control = toolStripContainer1.TopToolStripPanel; break; } toolStrip1.Parent = control; if (topofscreen) toolStrip1.Location = new Point(0, 0); topofscreen = false; switch (instance.Config.CurrentConfig.LandMenuPos) { case "Top": control = toolStripContainer1.TopToolStripPanel; topofscreen = true; break; case "Bottom": control = toolStripContainer1.BottomToolStripPanel; break; case "Left": control = toolStripContainer1.LeftToolStripPanel; break; case "Right": control = toolStripContainer1.RightToolStripPanel; break; default: control = toolStripContainer1.TopToolStripPanel; break; } statusStrip1.Parent = control; if (topofscreen) statusStrip1.Location = new Point(0, 25); topofscreen = false; }
public static Config LoadFrom(string filename) { Config config = new Config(); try { IConfigSource conf = new IniConfigSource(filename); config.Version = conf.Configs["General"].GetInt("Version", 0); config.MainWindowState = conf.Configs["Interface"].GetInt("MainWindowState", 0); config.InterfaceStyle = conf.Configs["Interface"].GetInt("Style", 1); // Login config.FirstName = conf.Configs["Login"].GetString("FirstName", string.Empty); config.LastName = conf.Configs["Login"].GetString("LastName", string.Empty); string epwd = conf.Configs["Login"].GetString("Password", string.Empty); config.LoginGrid = conf.Configs["Login"].GetInt("Grid", 0); config.LoginUri = conf.Configs["Login"].GetString("Uri", string.Empty); config.LoginLocationType = conf.Configs["Login"].GetInt("LocationType", 0); config.LoginLocation = conf.Configs["Login"].GetString("Location", string.Empty); config.iRemPWD = conf.Configs["Login"].GetBoolean("iRemPWD", false); config.UserNameList = conf.Configs["Login"].GetString("UserNameList", string.Empty); // General config.Connect4 = conf.Configs["General"].GetBoolean("Connect4", false); config.DisableNotifications = conf.Configs["General"].GetBoolean("DisableNotifications", false); config.DisableInboundGroupInvites = conf.Configs["General"].GetBoolean("DisableInboundGroupInvites", false); config.AutoSit = conf.Configs["General"].GetBoolean("AutoSit", false); config.RadarRange = conf.Configs["General"].GetInt("RadarRange", 64); config.ObjectRange = conf.Configs["General"].GetInt("ObjectRange", 20); config.GroupManPro = conf.Configs["General"].GetString("GroupManPro"); config.HeaderFont = conf.Configs["General"].GetString("HeaderFont", "Tahoma"); config.HeaderFontStyle = conf.Configs["General"].GetString("HeaderFontStyle", "Regular"); config.HeaderFontSize = conf.Configs["General"].GetFloat("HeaderFontSize", 8.5f); config.StartMinimised = conf.Configs["General"].GetBoolean("StartMinimised", false); config.HideDisconnectPrompt = conf.Configs["General"].GetBoolean("HideDisconnectPrompt", false); try { int clr = conf.Configs["General"].GetInt("HeaderBackColour", Color.Lavender.ToArgb()); config.HeaderBackColour = Color.FromArgb(clr); } catch { config.HeaderBackColour = Color.Lavender; } config.TextFont = conf.Configs["General"].GetString("TextFont", "Tahoma"); config.TextFontStyle = conf.Configs["General"].GetString("TextFontStyle", "Regular"); config.TextFontSize = conf.Configs["General"].GetFloat("TextFontSize", 8.5f); config.GivePresent = conf.Configs["General"].GetBoolean("GivePresent", false); config.HideMeta = conf.Configs["General"].GetBoolean("HideMeta", true); config.DeclineInv = conf.Configs["General"].GetBoolean("DeclineInv", false); config.DisableLookAt = conf.Configs["General"].GetBoolean("DisableLookAt", true); config.ClassicChatLayout = conf.Configs["General"].GetBoolean("ClassicChatLayout", false); config.AutoRestart = conf.Configs["General"].GetBoolean("AutoRestart", false); config.LogOffTime = conf.Configs["General"].GetInt("LogOffTime", 0); config.ReStartTime = conf.Configs["General"].GetInt("ReStartTime", 10); config.BandwidthThrottle = conf.Configs["General"].GetFloat("BandwidthThrottle", 500f); config.PlayFriendOnline = conf.Configs["General"].GetBoolean("PlayFriendOnline", false); config.PlayFriendOffline = conf.Configs["General"].GetBoolean("PlayFriendOffline", false); config.PlayIMreceived = conf.Configs["General"].GetBoolean("PlayIMreceived", false); config.PlayGroupIMreceived = conf.Configs["General"].GetBoolean("PlayGroupIMreceived", false); config.PlayGroupNoticeReceived = conf.Configs["General"].GetBoolean("PlayGroupNoticeReceived", false); config.PlayInventoryItemReceived = conf.Configs["General"].GetBoolean("PlayInventoryItemReceived", false); config.PlayPaymentReceived = conf.Configs["General"].GetBoolean("PlayPaymentReceived", false); config.AutoAcceptItems = conf.Configs["General"].GetBoolean("AutoAcceptItems", false); config.AdRemove = conf.Configs["General"].GetString("AdRemove", string.Empty); config.MasterAvatar = conf.Configs["General"].GetString("MasterAvatar", UUID.Zero.ToString()); config.EnforceLSLsecurity = conf.Configs["General"].GetBoolean("EnforceLSLsecurity", true); config.DisplayLSLcommands = conf.Configs["General"].GetBoolean("DisplayLSLcommands", true); // backward compatibility pre V 0.9.47.0 if (string.IsNullOrEmpty(config.MasterAvatar)) { config.MasterAvatar = UUID.Zero.ToString(); } config.MasterObject = conf.Configs["General"].GetString("MasterObject", UUID.Zero.ToString()); config.AutoTransfer = conf.Configs["General"].GetBoolean("AutoTransfer", false); config.DisableTrayIcon = conf.Configs["General"].GetBoolean("DisableTrayIcon", false); config.DisableFriendsNotifications = conf.Configs["General"].GetBoolean("DisableFriendsNotifications", false); config.DisableTyping = conf.Configs["General"].GetBoolean("DisableTyping", false); config.AutoAcceptFriends = conf.Configs["General"].GetBoolean("AutoAcceptFriends", false); //config.BroadcastID = conf.Configs["General"].GetBoolean("BroadcastID", true); config.DisableRadar = conf.Configs["General"].GetBoolean("DisableRadar", false); config.RestrictRadar = conf.Configs["General"].GetBoolean("RestrictRadar", false); config.DisableVoice = conf.Configs["General"].GetBoolean("DisableVoice", false); config.DisableFavs = conf.Configs["General"].GetBoolean("DisableFavs", false); config.DisableHTTPinv = conf.Configs["General"].GetBoolean("DisableHTTPinv", true); config.DisableRadarImageMiniMap = conf.Configs["General"].GetBoolean("DisableRadarImageMiniMap", false); config.AppMenuPos = conf.Configs["General"].GetString("AppMenuPos", "Top"); config.LandMenuPos = conf.Configs["General"].GetString("LandMenuPos", "Top"); config.FnMenuPos = conf.Configs["General"].GetString("FnMenuPos", "Top"); config.UseLLSD = conf.Configs["General"].GetBoolean("UseLLSD", false); config.ChatBufferLimit = conf.Configs["General"].GetInt("ChatBufferLimit", 20); config.ScriptUrlBufferLimit = conf.Configs["General"].GetInt("ScriptUrlBufferLimit", 5); // AI config.AIon = conf.Configs["AI"].GetBoolean("AIon", false); config.replyAI = conf.Configs["AI"].GetBoolean("ReplyAI", false); config.replyText = conf.Configs["AI"].GetString("ReplyText", "I am sorry but I didn't understand what you said or I haven't been taught a response for it. Can you try again, making sure your sentences are short and clear."); config.MultiLingualAI = conf.Configs["AI"].GetBoolean("MultiLingualAI", false); config.ChatTimestamps = conf.Configs["Text"].GetBoolean("ChatTimestamps", true); config.IMTimestamps = conf.Configs["Text"].GetBoolean("IMTimestamps", true); config.ChatSmileys = conf.Configs["Text"].GetBoolean("ChatSmileys", false); config.lineMax = conf.Configs["Text"].GetInt("lineMax", 5000); config.ParcelMusic = conf.Configs["Text"].GetBoolean("ParcelMusic", true); config.ParcelMedia = conf.Configs["Text"].GetBoolean("ParcelMedia", true); config.UseSLT = conf.Configs["Text"].GetBoolean("UseSLT", false); config.PlaySound = conf.Configs["Text"].GetBoolean("PlaySound", false); config.SaveIMs = conf.Configs["Text"].GetBoolean("SaveIMs", true); config.SaveChat = conf.Configs["Text"].GetBoolean("SaveChat", false); config.LogDir = conf.Configs["Text"].GetString("LogDir", METAbolt.DataFolder.GetDataFolder() + "\\Logs\\"); config.DisableGroupNotices = conf.Configs["Text"].GetBoolean("DisableGroupNotices", true); config.DisableGroupIMs = conf.Configs["Text"].GetBoolean("DisableGroupIMs", false); config.BusyReply = conf.Configs["Text"].GetString("BusyReply", "The Resident you messaged is in 'busy mode' which means they have requested not to be disturbed. Your message will still be shown in their IM panel for later viewing."); config.InitialIMReply = conf.Configs["Text"].GetString("InitialIMReply", ""); // Proxy config.UseProxy = conf.Configs["Proxy"].GetBoolean("UseProxy", false); config.ProxyURL = conf.Configs["Proxy"].GetString("ProxyURL", string.Empty); config.ProxyPort = conf.Configs["Proxy"].GetString("ProxyPort", string.Empty); config.ProxyUser = conf.Configs["Proxy"].GetString("ProxyUser", string.Empty); config.ProxyPWD = conf.Configs["Proxy"].GetString("ProxyPWD", string.Empty); // META3D try { config.DisableMipmaps = conf.Configs["META3D"].GetBoolean("DisableMipmaps", false); } catch { ; } //config.TweeterName = conf.Configs["Twitter"].GetString("TweeterName", string.Empty); //config.TweeterPwd = conf.Configs["Twitter"].GetString("TweeterPwd", string.Empty); //config.EnableTweeter = conf.Configs["Twitter"].GetBoolean("EnableTweeter", false); //config.EnableChatTweets = conf.Configs["Twitter"].GetBoolean("EnableChatTweets", false); //config.Tweet = conf.Configs["Twitter"].GetBoolean("Tweet", false); //config.TweeterUser = conf.Configs["Twitter"].GetString("TweeterUser", string.Empty); config.PluginsToLoad = conf.Configs["LoadedPlugIns"].GetString("PluginsToLoad", string.Empty); try { if (!string.IsNullOrEmpty(epwd)) { Crypto cryp = new Crypto(Crypto.SymmProvEnum.Rijndael); //string cpwd = cryp.Decrypting(epwd); string cpwd = cryp.Decrypt(epwd); config.PasswordMD5 = cpwd; } else { config.PasswordMD5 = epwd; } } catch { epwd = config.PasswordMD5 = string.Empty; MessageBox.Show("An error occured while decrypting your stored password.\nThis could mean you have the old format INI file. \nYou will have to re-enter your password so it can be ecrypted with the new method.", "METAbolt", MessageBoxButtons.OK, MessageBoxIcon.Error); //Process.Start("explorer.exe", Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\METAbolt\\"); } //added by GM on 2-JUL-2009 config.groupManagerUid = conf.Configs["PlugIn"].GetString("GroupManager", "ned49b54-325d-486a-af3m"); config.chairAnnouncerUuid = UUID.Parse(conf.Configs["PlugIn"].GetString("ChairAnnouncer", UUID.Zero.ToString())); config.chairAnnouncerInterval = conf.Configs["PlugIn"].GetInt("ChairAnnouncerInterval", 5); config.chairAnnouncerGroup1 = UUID.Parse(conf.Configs["PlugIn"].GetString("ChairAnnouncerGroup1", UUID.Zero.ToString())); config.chairAnnouncerGroup2 = UUID.Parse(conf.Configs["PlugIn"].GetString("ChairAnnouncerGroup2", UUID.Zero.ToString())); config.chairAnnouncerGroup3 = UUID.Parse(conf.Configs["PlugIn"].GetString("ChairAnnouncerGroup3", UUID.Zero.ToString())); config.chairAnnouncerGroup4 = UUID.Parse(conf.Configs["PlugIn"].GetString("ChairAnnouncerGroup4", UUID.Zero.ToString())); config.chairAnnouncerGroup5 = UUID.Parse(conf.Configs["PlugIn"].GetString("ChairAnnouncerGroup5", UUID.Zero.ToString())); config.chairAnnouncerGroup6 = UUID.Parse(conf.Configs["PlugIn"].GetString("ChairAnnouncerGroup6", UUID.Zero.ToString())); config.chairAnnouncerEnabled = conf.Configs["PlugIn"].GetBoolean("ChairAnnouncerEnabled", false); config.chairAnnouncerChat = conf.Configs["PlugIn"].GetBoolean("ChairAnnouncerChat", true); //added by GM on 1-APR-2010 config.chairAnnouncerAdvert = conf.Configs["PlugIn"].GetString("ChairAnnouncerAdvert", "Brought to you by METAbolt"); // removed reference to Machin's Machines, no longer exist //throw new Exception("Test"); try { // Spelling config.EnableSpelling = conf.Configs["Spelling"].GetBoolean("EnableSpelling", false); config.SpellLanguage = conf.Configs["Spelling"].GetString("SpellLanguage", "en_GB"); } catch { ; } } catch (Exception exp) { try { exp.HelpLink = "http://www.metabolt.net/METAwiki/index.php?title=Main_Page"; // updated link addy //Logger.Log("ERROR while loading config file'" + filename + "'. Your settings may not have fully loaded. Message: " + exp.Message, Helpers.LogLevel.Error); MessageBox.Show("The was an error when loading your Config (METAbolt.ini) file.\nNot all of your settings may have been loaded.", "METAbolt", MessageBoxButtons.OK, MessageBoxIcon.Warning); } catch { ; } } return config; }
public void ApplyDefault() { Config config; if (File.Exists(configPath)) { config = Config.LoadFrom(configPath); } else { config = new Config(); config.Save(configPath); } Apply(config); }
private void ApplyConfig(Config config) { if (config.InterfaceStyle == 0) //System tstMain.RenderMode = ToolStripRenderMode.System; else if (config.InterfaceStyle == 1) //Office 2003 tstMain.RenderMode = ToolStripRenderMode.ManagerRenderMode; }
public void Apply(Config config) { currentConfig = config; OnConfigApplied(new ConfigAppliedEventArgs(currentConfig)); }
public void SaveCurrentConfig() { //Check if the file has somehow became read-only FileInfo newFileInfo = new FileInfo(configPath); if (newFileInfo.Exists) { if ((newFileInfo.Attributes & FileAttributes.ReadOnly) > 0) { newFileInfo.Attributes ^= FileAttributes.ReadOnly; } } else { //Reset(); Config config = new Config(); config.Save(configPath); } currentConfig.Save(configPath); }
public void Reset() { Config config = new Config(); config.Save(configPath); Apply(config); }
public ConfigAppliedEventArgs(Config appliedConfig) { this.appliedConfig = appliedConfig; }
private void ApplyConfig(Config config) { if (config.InterfaceStyle == 0) //System { toolStrip1.RenderMode = ToolStripRenderMode.System; } else if (config.InterfaceStyle == 1) //Office 2003 { toolStrip1.RenderMode = ToolStripRenderMode.ManagerRenderMode; } if (instance.Config.CurrentConfig.EnableSpelling) { dicfile = instance.Config.CurrentConfig.SpellLanguage; // "en_GB.dic"; this.instance.AffFile = afffile = dicfile + ".aff"; this.instance.DictionaryFile = dicfile + ".dic"; dic = dir + dicfile; dicfile += ".dic"; if (!System.IO.File.Exists(dic + ".csv")) { //System.IO.File.Create(dic + ".csv"); using (StreamWriter sw = File.CreateText(dic + ".csv")) { sw.Dispose(); } } hunspell.Dispose(); hunspell = new Hunspell(); hunspell.Load(dir + afffile, dir + dicfile); ReadWords(); } else { hunspell.Dispose(); } if (instance.Config.CurrentConfig.DisableRadar) { toolStrip1.Visible = false; tabControl1.TabPages.Remove(tabPage1); tabControl1.TabPages.Remove(tabPage2); picCompass.Visible = false; label1.Visible = false; label2.Visible = false; label19.Visible = false; label20.Visible = false; //tBar1.Visible = false; client.Grid.CoarseLocationUpdate -= new EventHandler<CoarseLocationUpdateEventArgs>(Grid_OnCoarseLocationUpdate); } else { //tBar1.Visible = true; //tBar1.Value = instance.Config.CurrentConfig.RadarRange; if (!tabControl1.TabPages.Contains(tabPage1)) { toolStrip1.Visible = true; tabControl1.TabPages.Remove(tabPage3); tabControl1.TabPages.Remove(tabPage4); tabPage1 = tp1; tabControl1.TabPages.Add(tabPage1); tabPage2 = tp2; tabControl1.TabPages.Add(tabPage2); picCompass.Visible = true; label1.Visible = true; label2.Visible = true; label19.Visible = true; label20.Visible = true; client.Grid.CoarseLocationUpdate += new EventHandler<CoarseLocationUpdateEventArgs>(Grid_OnCoarseLocationUpdate); } } if (instance.Config.CurrentConfig.DisableVoice) { tabControl1.TabPages.Remove(tabPage3); } else { if (!tabControl1.TabPages.Contains(tabPage3)) { tabControl1.TabPages.Remove(tabPage4); tabPage3 = tp3; tabControl1.TabPages.Add(tabPage3); } } if (instance.Config.CurrentConfig.DisableFavs) { tabControl1.TabPages.Remove(tabPage4); } else { if (!tabControl1.TabPages.Contains(tabPage4)) { tabPage4 = tp4; tabControl1.TabPages.Add(tabPage4); } } if (instance.Config.CurrentConfig.DisableRadar && instance.Config.CurrentConfig.DisableFavs && instance.Config.CurrentConfig.DisableVoice) { try { splitContainer1.SplitterDistance = splitContainer1.Width; //513 panel5.Visible = false; tabControl1.Visible = false; } catch (Exception ex) { //Logger.Log("MB ERROR: " + ex.Message, Helpers.LogLevel.Error); splitContainer1.SplitterDistance = splitContainer1.Width - splitContainer1.Panel2MinSize; } } else { splitContainer1.SplitterDistance = 513; panel5.Visible = true; tabControl1.Visible = true; //tabControl1.TabPages.Add(tabPage1); //tabControl1.TabPages.Add(tabPage2); //toolStrip1.Visible = true; //client.Grid.CoarseLocationUpdate += new EventHandler<CoarseLocationUpdateEventArgs>(Grid_OnCoarseLocationUpdate); } textBox1.Text = "Range: " + instance.Config.CurrentConfig.RadarRange.ToString(CultureInfo.CurrentCulture) + "m"; }