private static void Load() { string file = Path.Combine(Config.GetUserDirectory(), "counters.xml"); if (!File.Exists(file)) { return; } try { XmlDocument doc = new XmlDocument(); doc.Load(file); XmlElement root = doc["counters"]; if (root != null) { foreach (XmlElement node in root.GetElementsByTagName("counter")) { m_List.Add(new Counter(node)); } } } catch { MessageBox.Show(Engine.ActiveWindow, Language.GetString(LocString.CounterFux), "Counters.xml Load Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); } m_NeedXMLSave = false; }
public static void SetupProfilesList(ComboBox list, string selectName) { if (list == null || list.Items == null) { return; } string[] files = Directory.GetFiles(Config.GetUserDirectory("Profiles"), "*.xml"); string compare = String.Empty; if (selectName != null) { compare = selectName.ToLower(); } for (int i = 0; i < files.Length; i++) { string name = Path.GetFileNameWithoutExtension(files[i]); if (name == null || name.Length <= 0) { name = files[i]; } if (name == null) { continue; } list.Items.Add(name); if (name.ToLower() == compare) { list.SelectedIndex = i; } } }
public static void SaveCharList() { if (m_Chars == null) { m_Chars = new Dictionary <Serial, string>(); } try { using (StreamWriter writer = new StreamWriter(Path.Combine(Config.GetUserDirectory("Profiles"), "chars.lst"))) { foreach (KeyValuePair <Serial, string> de in m_Chars) { writer.WriteLine("{0}={1}", de.Key, de.Value); } } } catch { } }
public static void LoadCharList() { if (m_Chars == null) { m_Chars = new Dictionary <Serial, string>(); } else { m_Chars.Clear(); } string file = Path.Combine(Config.GetUserDirectory("Profiles"), "chars.lst"); if (!File.Exists(file)) { return; } using (StreamReader reader = new StreamReader(file)) { string line; while ((line = reader.ReadLine()) != null) { if (line.Length <= 0 || line[0] == ';' || line[0] == '#') { continue; } string[] split = line.Split('='); try { m_Chars.Add(Serial.Parse(split[0]), split[1]); } catch { } } } }
public static void Save() { if (!m_NeedXMLSave) { return; } try { string file = Path.Combine(Config.GetUserDirectory(), "counters.xml"); using (StreamWriter op = new StreamWriter(file)) { XmlTextWriter xml = new XmlTextWriter(op); xml.Formatting = Formatting.Indented; xml.IndentChar = '\t'; xml.Indentation = 1; xml.WriteStartDocument(true); xml.WriteStartElement("counters"); foreach (Counter c in m_List) { c.Save(xml); } xml.WriteEndElement(); xml.Close(); } m_NeedXMLSave = false; } catch { } }
public void Save() { string profileDir = Config.GetUserDirectory("Profiles"); string file = Path.Combine(profileDir, String.Format("{0}.xml", m_Name)); if (m_Name != "default" && !m_Warned) { try { m_Mutex = new System.Threading.Mutex(true, String.Format("Razor_Profile_{0}", m_Name)); if (!m_Mutex.WaitOne(10, false)) { throw new Exception("Can't grab profile mutex, must be in use!"); } } catch { //MessageBox.Show( Engine.ActiveWindow, Language.Format( LocString.ProfileInUse, m_Name ), "Profile In Use", MessageBoxButtons.OK, MessageBoxIcon.Warning ); //m_Warned = true; return; // refuse to overwrite profiles that we don't own. } } XmlTextWriter xml; try { xml = new XmlTextWriter(file, Encoding.Default); } catch { return; } xml.Formatting = Formatting.Indented; xml.IndentChar = '\t'; xml.Indentation = 1; xml.WriteStartDocument(true); xml.WriteStartElement("profile"); foreach (KeyValuePair <string, object> de in m_Props) { xml.WriteStartElement("property"); xml.WriteAttributeString("name", de.Key); if (de.Value == null) { xml.WriteAttributeString("type", "-null-"); } else { xml.WriteAttributeString("type", de.Value.GetType().FullName); xml.WriteString(de.Value.ToString()); } xml.WriteEndElement(); } xml.WriteStartElement("filters"); Filter.Save(xml); xml.WriteEndElement(); xml.WriteStartElement("counters"); Counter.SaveProfile(xml); xml.WriteEndElement(); xml.WriteStartElement("agents"); Agent.SaveProfile(xml); xml.WriteEndElement(); xml.WriteStartElement("dresslists"); DressList.Save(xml); xml.WriteEndElement(); xml.WriteStartElement("hotkeys"); HotKey.Save(xml); xml.WriteEndElement(); xml.WriteStartElement("passwords"); PasswordMemory.Save(xml); xml.WriteEndElement(); xml.WriteEndElement(); // end profile section xml.Close(); }
public bool Load() { if (m_Name == null || m_Name.Trim() == "") { return(false); } string path = Config.GetUserDirectory("Profiles"); string file = Path.Combine(path, String.Format("{0}.xml", m_Name)); if (!File.Exists(file)) { return(false); } XmlDocument doc = new XmlDocument(); try { doc.Load(file); } catch { MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileCorrupt, file), "Profile Load Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } XmlElement root = doc["profile"]; if (root == null) { return(false); } Assembly exe = Assembly.GetCallingAssembly(); if (exe == null) { return(false); } foreach (XmlElement el in root.GetElementsByTagName("property")) { try { string name = el.GetAttribute("name"); string typeStr = el.GetAttribute("type"); string val = el.InnerText; if (typeStr == "-null-" || name == "LimitSize" || name == "VisRange") { //m_Props[name] = null; if (m_Props.ContainsKey(name)) { m_Props.Remove(name); } } else { Type type = Type.GetType(typeStr); if (type == null) { type = exe.GetType(typeStr); } if (m_Props.ContainsKey(name) || name == "ForceSize") { if (type == null) { m_Props.Remove(name); } else { m_Props[name] = GetObjectFromString(val, type); } } } } catch (Exception e) { MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileLoadEx, e.ToString()), "Profile Load Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Filter.Load(root["filters"]); Counter.LoadProfile(root["counters"]); Agent.LoadProfile(root["agents"]); DressList.Load(root["dresslists"]); HotKey.Load(root["hotkeys"]); PasswordMemory.Load(root["passwords"]); if (m_Props.ContainsKey("ForceSize")) { try { int x, y; switch ((int)m_Props["ForceSize"]) { case 1: x = 960; y = 600; break; case 2: x = 1024; y = 768; break; case 3: x = 1152; y = 864; break; case 4: x = 1280; y = 720; break; case 5: x = 1280; y = 768; break; case 6: x = 1280; y = 800; break; case 7: x = 1280; y = 960; break; case 8: x = 1280; y = 1024; break; case 0: default: x = 800; y = 600; break; } SetProperty("ForceSizeX", x); SetProperty("ForceSizeY", y); if (x != 800 || y != 600) { SetProperty("ForceSizeEnabled", true); } m_Props.Remove("ForceSize"); } catch { } } //if ( !Language.Load( GetString( "Language" ) ) ) // MessageBox.Show( Engine.ActiveWindow, "Warning: Could not load language from profile, using current language instead.", "Language Error", MessageBoxButtons.OK, MessageBoxIcon.Warning ); return(true); }
public static void CaptureNow() { string filename; string playerName = "Unknown"; string path = Config.GetString("CapPath"); string type = Config.GetString("ImageFormat").ToLower(); if (World.Player != null) playerName = World.Player.Name; if (playerName == null || playerName.Trim() == "" || playerName.IndexOfAny(Path.GetInvalidPathChars()) != -1) playerName = "Unknown"; string imageTimestampTag = Config.GetBool("CapTimeStamp") ? $"{playerName} ({World.ShardName}) - {Engine.MistedDateTime:M/dd/yy - HH:mm:ss}" : ""; playerName = !string.IsNullOrEmpty(LastMobileDeathName) ? $"{playerName}_{LastMobileDeathName}_{Engine.MistedDateTime:M-d_HH.mm}" : $"{playerName}_{Engine.MistedDateTime:M-d_HH.mm}"; try { Engine.EnsureDirectory(path); } catch { try { path = Config.GetUserDirectory("ScreenShots"); Config.SetProperty("CapPath", path); } catch { path = ""; } } int count = 0; do { filename = Path.Combine(path, $"{playerName}{(count != 0 ? count.ToString() : "")}.{type}"); count--; // cause a - to be put in front of the number } while (File.Exists(filename)); try { IntPtr hBmp = Platform.CaptureScreen(Client.Instance.GetWindowHandle(), Config.GetBool("CapFullScreen"), imageTimestampTag); using (Image img = Image.FromHbitmap(hBmp)) img.Save(filename, GetFormat(type)); DeleteObject(hBmp); } catch { // ignored } LastMobileDeathName = string.Empty; Engine.MainWindow.SafeAction(s => s.ReloadScreenShotsList()); }
public bool Load() { if (m_Name == null || m_Name.Trim() == "") { return(false); } string path = Config.GetUserDirectory("Profiles"); string file = Path.Combine(path, $"{m_Name}.xml"); if (!File.Exists(file)) { return(false); } XmlDocument doc = new XmlDocument(); try { doc.Load(file); } catch { MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileCorrupt, file), "Profile Load Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } XmlElement root = doc["profile"]; if (root == null) { return(false); } Assembly exe = Assembly.GetCallingAssembly(); if (exe == null) { return(false); } foreach (XmlElement el in root.GetElementsByTagName("property")) { try { string name = el.GetAttribute("name"); string typeStr = el.GetAttribute("type"); string val = el.InnerText; if (typeStr == "-null-" || name == "LimitSize" || name == "VisRange") { //m_Props[name] = null; if (m_Props.ContainsKey(name)) { m_Props.Remove(name); } } else { Type type = Type.GetType(typeStr); if (type == null) { type = exe.GetType(typeStr); } if (m_Props.ContainsKey(name) || name == "ForceSize") { if (type == null) { m_Props.Remove(name); } else { m_Props[name] = GetObjectFromString(val, type); } } } } catch (Exception e) { MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileLoadEx, e.ToString()), "Profile Load Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Filter.Load(root["filters"]); Counter.LoadProfile(root["counters"]); Agent.LoadProfile(root["agents"]); DressList.Load(root["dresslists"]); TargetFilterManager.Load(root["targetfilters"]); SoundMusicManager.Load(root["soundfilters"]); WaypointManager.Load(root["waypoints"]); TextFilterManager.Load(root["textfilters"]); FriendsManager.Load(root["friends"]); HotKey.Load(root["hotkeys"]); PasswordMemory.Load(root["passwords"]); OverheadManager.Load(root["overheadmessages"]); ContainerLabels.Load(root["containerlabels"]); MacroVariables.Load(root["macrovariables"]); //imports previous absolutetargets and doubleclickvariables if present in profile if ((root.SelectSingleNode("absolutetargets") != null) || (root.SelectSingleNode("doubleclickvariables") != null)) { MacroVariables.Import(root); } ScriptVariables.Load(root["scriptvariables"]); GoldPerHourTimer.Stop(); DamageTracker.Stop(); if (m_Props.ContainsKey("ForceSize")) { try { int x, y; switch ((int)m_Props["ForceSize"]) { case 1: x = 960; y = 600; break; case 2: x = 1024; y = 768; break; case 3: x = 1152; y = 864; break; case 4: x = 1280; y = 720; break; case 5: x = 1280; y = 768; break; case 6: x = 1280; y = 800; break; case 7: x = 1280; y = 960; break; case 8: x = 1280; y = 1024; break; case 0: default: x = 800; y = 600; break; } SetProperty("ForceSizeX", x); SetProperty("ForceSizeY", y); if (x != 800 || y != 600) { SetProperty("ForceSizeEnabled", true); } m_Props.Remove("ForceSize"); } catch { } } //if ( !Language.Load( GetString( "Language" ) ) ) // MessageBox.Show( Engine.ActiveWindow, "Warning: Could not load language from profile, using current language instead.", "Language Error", MessageBoxButtons.OK, MessageBoxIcon.Warning ); return(true); }
public static void CaptureNow() { string filename; string timestamp; string name = "Unknown"; string path = Config.GetString("CapPath"); string type = Config.GetString("ImageFormat").ToLower(); if (World.Player != null) { name = World.Player.Name; } if (name == null || name.Trim() == "" || name.IndexOfAny(Path.GetInvalidPathChars()) != -1) { name = "Unknown"; } if (Config.GetBool("CapTimeStamp")) { timestamp = String.Format("{0} ({1}) - {2}", name, World.ShardName, Engine.MistedDateTime.ToString(@"M/dd/yy - HH:mm:ss")); } else { timestamp = ""; } name = String.Format("{0}_{1}", name, Engine.MistedDateTime.ToString("M-d_HH.mm")); try { Engine.EnsureDirectory(path); } catch { try { path = Config.GetUserDirectory("ScreenShots"); Config.SetProperty("CapPath", path); } catch { path = ""; } } int count = 0; do { filename = Path.Combine(path, String.Format("{0}{1}.{2}", name, count != 0 ? count.ToString() : "", type)); count--; // cause a - to be put in front of the number }while (File.Exists(filename)); try { IntPtr hBmp = ClientCommunication.CaptureScreen(Config.GetBool("CapFullScreen"), timestamp); using (Image img = Image.FromHbitmap(hBmp)) img.Save(filename, GetFormat(type)); DeleteObject(hBmp); } catch { } Engine.MainWindow.ReloadScreenShotsList(); }
public bool Load() { if (m_Name == null || m_Name.Trim() == "") { return(false); } string path = Config.GetUserDirectory("Profiles"); string file = Path.Combine(path, String.Format("{0}.xml", m_Name)); if (!File.Exists(file)) { return(false); } XmlDocument doc = new XmlDocument(); try { doc.Load(file); } catch { MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileCorrupt, file), "Profile Load Error", MessageBoxButtons.OK, MessageBoxIcon.Stop); return(false); } XmlElement root = doc["profile"]; if (root == null) { return(false); } Assembly exe = Assembly.GetCallingAssembly(); if (exe == null) { return(false); } foreach (XmlElement el in root.GetElementsByTagName("property")) { try { string name = el.GetAttribute("name"); string typeStr = el.GetAttribute("type"); string val = el.InnerText; if (typeStr == "-null-" || name == "LimitSize" || name == "VisRange") { //m_Props[name] = null; if (m_Props.ContainsKey(name)) { m_Props.Remove(name); } } else { Type type = Type.GetType(typeStr); if (type == null) { type = exe.GetType(typeStr); } if (m_Props.ContainsKey(name)) { if (type == null) { m_Props.Remove(name); } else { m_Props[name] = GetObjectFromString(val, type); } } } } catch (Exception e) { MessageBox.Show(Engine.ActiveWindow, Language.Format(LocString.ProfileLoadEx, e.ToString()), "Profile Load Exception", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } Filter.Load(root["filters"]); Counter.LoadProfile(root["counters"]); Agent.LoadProfile(root["agents"]); DressList.Load(root["dresslists"]); HotKey.Load(root["hotkeys"]); return(true); }