Esempio n. 1
0
 public void SaveConfig()
 {
     Configuration config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
     config.AppSettings.Settings.Remove("Strength");
     config.AppSettings.Settings.Add("Strength", smoothingStrength.ToString());
     config.AppSettings.Settings.Remove("Interpolation");
     config.AppSettings.Settings.Add("Interpolation", smoothingInterpolation.ToString());
     config.AppSettings.Settings.Remove("Manual Interpolation");
     config.AppSettings.Settings.Add("Manual Interpolation", manualInterpolation.ToString());
     config.AppSettings.Settings.Remove("Smooth On Draw");
     config.AppSettings.Settings.Add("Smooth On Draw", smoothOnDraw.ToString());
     config.AppSettings.Settings.Remove("Stay On Top");
     config.AppSettings.Settings.Add("Stay On Top", stayOnTop.ToString());
     config.AppSettings.Settings.Remove("Tablet Mode");
     config.AppSettings.Settings.Add("Tablet Mode", mainForm.tabletMode.ToString());
     config.AppSettings.Settings.Remove("Overlay Screen");
     config.AppSettings.Settings.Add("Overlay Screen", overlayScreen.ToString());
     config.AppSettings.Settings.Remove("Disable Overlay");
     config.AppSettings.Settings.Add("Disable Overlay", disableOverlay.ToString());
     config.AppSettings.Settings.Remove("All Screens");
     config.AppSettings.Settings.Add("All Screens", allScreens.ToString());
     config.AppSettings.Settings.Remove("Manual Overlay Override");
     config.AppSettings.Settings.Add("Manual Overlay Override", manualOverlayOverride.ToString());
     config.AppSettings.Settings.Remove("Override Bounds");
     RectangleConverter r = new RectangleConverter();
     config.AppSettings.Settings.Add("Override Bounds", r.ConvertToString(overrideBounds));
     config.AppSettings.Settings.Remove("Disable Catch Up");
     config.AppSettings.Settings.Add("Disable Catch Up", disableCatchUp.ToString());
     config.AppSettings.Settings.Remove("Snap to Cursor");
     config.AppSettings.Settings.Add("Snap to Cursor", snapToCursor.ToString());
     config.AppSettings.Settings.Remove("Cursor Graphic");
     config.AppSettings.Settings.Add("Cursor Graphic", overlayForm.cursorType.ToString());
     config.AppSettings.Settings.Remove("Main Color");
     config.AppSettings.Settings.Add("Main Color", ColorTranslator.ToHtml(overlayForm.cursorColor));
     config.AppSettings.Settings.Remove("Fill Color");
     config.AppSettings.Settings.Add("Fill Color", ColorTranslator.ToHtml(overlayForm.cursorFillColor));
     config.AppSettings.Settings.Remove("Disable Auto Detection");
     config.AppSettings.Settings.Add("Disable Auto Detection", disableAutoDetection.ToString());
     config.AppSettings.Settings.Remove("Tolerance");
     config.AppSettings.Settings.Add("Tolerance", tolerance.ToString());
     config.AppSettings.Settings.Remove("Tablet Offset Override");
     config.AppSettings.Settings.Add("Tablet Offset Override", tabletOffsetOverride.ToString());
     config.AppSettings.Settings.Remove("Tablet Offset");
     PointConverter p = new PointConverter();
     config.AppSettings.Settings.Add("Tablet Offset", p.ConvertToString(tabletOffset));
     config.AppSettings.Settings.Remove("Hotkey 1");
     config.AppSettings.Settings.Add("Hotkey 1", hotkeys[0].ToString());
     config.AppSettings.Settings.Remove("Hotkey 2");
     config.AppSettings.Settings.Add("Hotkey 2", hotkeys[1].ToString());
     config.AppSettings.Settings.Remove("Hotkey 3");
     config.AppSettings.Settings.Add("Hotkey 3", hotkeys[2].ToString());
     config.AppSettings.Settings.Remove("Hotkey 4");
     config.AppSettings.Settings.Add("Hotkey 4", hotkeys[3].ToString());
     config.AppSettings.Settings.Remove("Hotkey 5");
     config.AppSettings.Settings.Add("Hotkey 5", hotkeys[4].ToString());
     config.AppSettings.Settings.Remove("Hotkey 6");
     config.AppSettings.Settings.Add("Hotkey 6", hotkeys[5].ToString());
     config.Save(ConfigurationSaveMode.Modified);
 }
Esempio n. 2
0
        void InstallPad_FormClosing(object sender, FormClosingEventArgs e)
        {
            // Serialize form position to file, so we can restore it later.
            RectangleConverter convert = new RectangleConverter();
            string formPosition = convert.ConvertToString(this.Bounds);

            TextWriter writer = null;
            try
            {
                string configFolder = Path.GetDirectoryName(InstallPadApp.ConfigFilePath);
                if (!Directory.Exists(configFolder))
                    Directory.CreateDirectory(configFolder);
                writer = new StreamWriter(InstallPadApp.ConfigFilePath);
                writer.Write(formPosition);
            }
            // We can get here if InstallPad.form_load had a problem,
            // so just eat exceptions rather than throwing more of them.
            catch (Exception ex) { }
            finally
            {
                if (writer != null)
                    writer.Close();
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates XML string from instance of module
        /// </summary>
        /// <param name="module">Module</param>
        /// <returns>XML Node of module</returns>
        public HtmlNode GetNodeFromModule(AModule module)
        {
            Type moduleType = module.GetType();
            Type setupType = module.setup.GetType();

            // Create root node
            String moduleName = (String)moduleType.GetField("name", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy).GetValue(null);

            HtmlDocument htmlDoc = new HtmlDocument();
            HtmlNode node = htmlDoc.CreateElement("module");

            // Save all setup_* members to attributes
            MemberInfo[] setupMembers = setupType.GetMember("setup_*", BindingFlags.Public | BindingFlags.Instance);
            foreach (MemberInfo setupMember in setupMembers)
            {
                HtmlAttribute attribute = htmlDoc.CreateAttribute(setupMember.Name);
                attribute.Value = (String)setupType.InvokeMember(setupMember.Name, BindingFlags.Public | BindingFlags.Instance | BindingFlags.GetProperty, null, module.setup, null);
                node.Attributes.Append(attribute);
            }

            // Save name(type) of module
            HtmlAttribute nameAttr = htmlDoc.CreateAttribute("name");
            nameAttr.Value = moduleName;
            node.Attributes.Append(nameAttr);

            // Save position as attr
            Rectangle location = (Rectangle)setupType.GetField("location", BindingFlags.Public | BindingFlags.Instance | BindingFlags.FlattenHierarchy).GetValue(module.setup);
            HtmlAttribute locationAttr = htmlDoc.CreateAttribute("location");
            RectangleConverter converter = new RectangleConverter();
            locationAttr.Value = converter.ConvertToString(location);
            node.Attributes.Append(locationAttr);

            return node;
        }