private int[] CalculateResolution() { // Width and Height int[] resolution = { 0, 0 }; float ratio = SRWE_Utility.SAFE_ParseRatio(EDT_WINRC_ASPRAT.Text); float mpx = SRWE_Utility.SAFE_String_2_Float(EDT_WINRC_MPX.Text) * 1e6f; resolution[1] = (int)Math.Sqrt(mpx / ratio); resolution[0] = (int)(resolution[1] * ratio); return(resolution); }
public SRWE_HotKey(XmlElement xmlHotKey) { this.Name = SRWE_Utility.SAFE_XmlNodeValue(xmlHotKey.Attributes["Name"]); Keys key; if (Enum.TryParse(xmlHotKey.InnerText, out key)) { this.HotKey = key; } this.CTRL = SRWE_Utility.SAFE_XmlNodeValue(xmlHotKey.Attributes["CTRL"]) == "1"; this.ALT = SRWE_Utility.SAFE_XmlNodeValue(xmlHotKey.Attributes["ALT"]) == "1"; this.SHIFT = SRWE_Utility.SAFE_XmlNodeValue(xmlHotKey.Attributes["SHIFT"]) == "1"; }
private void UpdateWindowRect() { m_states = (m_states | States.UpdateWindowRect) ^ States.UpdateWindowRect; if (TV_WINDOW_TREE.SelectedNode == null) { return; } Window win = (Window)TV_WINDOW_TREE.SelectedNode.Tag; win.PosX = SRWE_Utility.SAFE_String_2_Int(EDT_WINRC_X.Text, win.PosX); win.PosY = SRWE_Utility.SAFE_String_2_Int(EDT_WINRC_Y.Text, win.PosY); win.Width = SRWE_Utility.SAFE_String_2_Int(EDT_WINRC_WIDTH.Text, win.Width); win.Height = SRWE_Utility.SAFE_String_2_Int(EDT_WINRC_HEIGHT.Text, win.Height); win.ApplyChanges(); }
private void UpdateWindowFromProfile(XPathNavigator navWindow) { string hierID = navWindow.SelectSingleNode("@HierID").Value; string[] numbers = hierID.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); int[] ordinals = new int[numbers.Length]; for (int i = 0, iMax = ordinals.Length; i < iMax; i++) { ordinals[i] = int.Parse(numbers[i]) - 1; } TreeNodeCollection treeNodes = TV_WINDOW_TREE.Nodes; TreeNode tNode = null; int nTopOrdinal = ordinals.Length - 1; for (int i = 0, iMax = ordinals.Length; i < iMax; i++) { if (ordinals[i] >= treeNodes.Count) { throw new Exception("A window with hierarchical ID '" + hierID + "' not found"); } tNode = treeNodes[ordinals[i]]; if (i < nTopOrdinal) { treeNodes = tNode.Nodes; } } if (tNode != null) { tNode.Checked = true; Window win = (Window)tNode.Tag; win.Refresh(); win.PosX = SRWE_Utility.SAFE_String_2_Int(navWindow.SelectSingleNode("@PosX").Value, win.PosX); win.PosY = SRWE_Utility.SAFE_String_2_Int(navWindow.SelectSingleNode("@PosY").Value, win.PosY); win.Width = SRWE_Utility.SAFE_String_2_Int(navWindow.SelectSingleNode("@Width").Value, win.Width); win.Height = SRWE_Utility.SAFE_String_2_Int(navWindow.SelectSingleNode("@Height").Value, win.Height); win.Style = (uint)SRWE_Utility.SAFE_HexString_2_Int(navWindow.SelectSingleNode("@Style").Value, (int)win.Style); win.ExStyle = (uint)SRWE_Utility.SAFE_HexString_2_Int(navWindow.SelectSingleNode("@ExStyle").Value, (int)win.ExStyle); win.ApplyChanges(); } }
private void UpdateWindowRect() { m_states = (m_states | States.UpdateWindowRect) ^ States.UpdateWindowRect; if (TV_WINDOW_TREE.SelectedNode == null) { return; } Window win = (Window)TV_WINDOW_TREE.SelectedNode.Tag; win.PosX = SRWE_Utility.SAFE_String_2_Int(EDT_WINRC_X.Text, win.PosX); win.PosY = SRWE_Utility.SAFE_String_2_Int(EDT_WINRC_Y.Text, win.PosY); win.Scale = SRWE_Utility.SAFE_String_2_Float(EDT_WINRC_SCALE.Text); win.Width = (int)(SRWE_Utility.SAFE_String_2_Int(EDT_WINRC_WIDTH.Text, win.Width) * win.Scale); win.Height = (int)(SRWE_Utility.SAFE_String_2_Int(EDT_WINRC_HEIGHT.Text, win.Height) * win.Scale); win.ApplyChanges(); EDT_WINRC_SCALE.Text = "1"; _windowSizeSpecificationManuallyChanged = false; }
private void UpdateWindowStyles(bool exStyles) { if (exStyles) { m_states = (m_states | States.UpdateWindowExStyle) ^ States.UpdateWindowExStyle; } else { m_states = (m_states | States.UpdateWindowStyle) ^ States.UpdateWindowStyle; } if (TV_WINDOW_TREE.SelectedNode == null) { return; } Window win = (Window)TV_WINDOW_TREE.SelectedNode.Tag; if (exStyles) { win.ExStyle = (uint)SRWE_Utility.SAFE_HexString_2_Int(EDT_WSEX_HEX.Text, (int)win.ExStyle); foreach (DataRow dr in m_dtWS_EX.Rows) { dr[1] = (win.ExStyle & (uint)dr[0]) != 0; } } else { win.Style = (uint)SRWE_Utility.SAFE_HexString_2_Int(EDT_WS_HEX.Text, (int)win.Style); foreach (DataRow dr in m_dtWS.Rows) { dr[1] = (win.Style & (uint)dr[0]) != 0; } } win.ApplyChanges(); }
private static void LoadSettings() { var settingsElement = s_xmlSettings.DocumentElement["Settings"]; s_nUpdateInterval = SRWE_Utility.SAFE_String_2_Int(settingsElement["UpdateInterval"].Attributes["Value"].Value, 1000); var forceExitSizeMoveMessageElement = settingsElement["ForceExitSizeMoveMessage"]; if (forceExitSizeMoveMessageElement == null) { // migrate settings file. forceExitSizeMoveMessageElement = SRWE_Utility.AppendChildElement(s_xmlSettings, settingsElement, "ForceExitSizeMoveMessage"); SRWE_Utility.AppendAttribute(s_xmlSettings, forceExitSizeMoveMessageElement, "Value"); SetForceExitSizeMoveMessageValue(); } else { s_bForceExitSizeMoveMessage = SRWE_Utility.SAFE_String_2_Bool(forceExitSizeMoveMessageElement.Attributes["Value"].Value, SRWE_Defaults.ForceExitSizeMoveMessage); } var autoAttachToLastKnownProcessElement = settingsElement["AutoAttachToLastKnownProcess"]; if (autoAttachToLastKnownProcessElement == null) { // migrate settings file autoAttachToLastKnownProcessElement = SRWE_Utility.AppendChildElement(s_xmlSettings, settingsElement, "AutoAttachToLastKnownProcess"); SRWE_Utility.AppendAttribute(s_xmlSettings, autoAttachToLastKnownProcessElement, "Value"); SetAutoAttachToLastKnownProcessValue(); } else { s_bAutoAttachToLastKnownProcess = SRWE_Utility.SAFE_String_2_Bool(autoAttachToLastKnownProcessElement.Attributes["Value"].Value, SRWE_Defaults.AutoAttachToLastKnownProcess); } if (s_nUpdateInterval < 100) { s_nUpdateInterval = 100; } else if (s_nUpdateInterval > 30000) { s_nUpdateInterval = 30000; } XmlNodeList xmlNodes = s_xmlSettings.DocumentElement.SelectNodes("RecentProcesses/Process"); s_recentProcesses = new List <string>(); foreach (XmlNode xmlItem in xmlNodes) { s_recentProcesses.Add(xmlItem.Attributes["Name"].Value); } xmlNodes = s_xmlSettings.DocumentElement.SelectNodes("RecentProfiles/Profile"); s_recentProfiles = new List <string>(); foreach (XmlNode xmlItem in xmlNodes) { s_recentProfiles.Add(xmlItem.Attributes["FilePath"].Value); } s_hotKeys.Clear(); xmlNodes = s_xmlSettings.DocumentElement.SelectNodes("HotKeys/HotKey"); foreach (XmlNode hotkey in xmlNodes) { s_hotKeys.Add(new SRWE_HotKey((XmlElement)hotkey)); } }