private void autostartCheckBox_CheckedChanged(object sender, EventArgs e) { if (autostartCheckBox.Checked) { //add application shortcut to startup folder #if (!DEBUG) ClickOnce.AppShortcut.AutoStart(true); #endif AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { profile.SetValue("Settings", "AutoStart", true); } } else { //remove application shortcut from startup folder #if (!DEBUG) ClickOnce.AppShortcut.AutoStart(false); #endif AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { profile.SetValue("Settings", "AutoStart", false); } } }
/// <summary> /// 从加密文件中读取连接字符串 /// </summary> public static void LoadConnectionStrings() { // <connectionStrings configSource="connections.config"></connectionStrings> AMS.Profile.IProfile profile = new AMS.Profile.Xml(IOHelper.GetDataDirectory() + "\\Dbs.dat"); string skey = profile.GetValue("ConnectionStringSetting", "Key", string.Empty); if (!string.IsNullOrEmpty(skey)) { string cryptedConnectionStrings = profile.GetValue("ConnectionStringSetting", "ConnectionString", string.Empty); if (!string.IsNullOrEmpty(cryptedConnectionStrings)) { string connectionStrings = Cryptographer.DecryptSymmetric(cryptedConnectionStrings, skey); if (!string.IsNullOrEmpty(connectionStrings)) { string tempConfigFileName = IOHelper.GetDataDirectory() + "\\temp.config"; System.IO.File.WriteAllText(tempConfigFileName, connectionStrings, Encoding.UTF8); ExeConfigurationFileMap configMap = new ExeConfigurationFileMap { ExeConfigFilename = tempConfigFileName }; Configuration externalConfig = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None); foreach (ConnectionStringSettings i in externalConfig.ConnectionStrings.ConnectionStrings) { SystemHelper.ChangeConnectionString(i.Name, i.ConnectionString, i.ProviderName); } System.IO.File.Delete(tempConfigFileName); } } } }
/// <summary> /// Configuration File Constructor - sets the Path (Full UNC Path and File Name) the Configuration File /// and sets the file as the Profile Configuration File Object. /// </summary> /// <param name="ConfigFilePath"> /// The path to the Configuration File (full UNC Path and File Name). /// </param> public void ConfigFile(string ConfigFilePath) { try { // Make sure the Configuration File exists before attempting to open it as the Profile // Configuration File Object. if (!File.Exists(ConfigFilePath)) { return; } // Instantiate the Profile XML Configuration File Object that will be used to read and // write from and to the Configuration File. xmlConfigurationFile = new AMS.Profile.Xml(ConfigFilePath); // Exit the Method. return; } catch { // Exit the method. return; } } // ConfigFile
/// <summary> /// 加密保存连接字符串 /// </summary> public static void SaveConnectionStrings(string connectionStringFileName, string encryptedFileName) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(encryptedFileName); string sKey = Cryptographer.GeneratePassword(); profile.SetValue("ConnectionStringSetting", "Key", sKey); string originalTxt = System.IO.File.ReadAllText(connectionStringFileName, Encoding.UTF8); string encryptedText = Cryptographer.EncryptSymmetric(originalTxt, sKey); profile.SetValue("ConnectionStringSetting", "ConnectionString", encryptedText); }
/// <summary> /// 加密保存连接字符串 /// </summary> public static void SaveConnectionStrings(string connectionStringFileName, string encryptedFileName) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(encryptedFileName); string sKey = Cryptographer.GenerateKey(); profile.SetValue("ConnectionStringSetting", "Key", sKey); string originalTxt = System.IO.File.ReadAllText(connectionStringFileName, Encoding.UTF8); string encryptedText = Cryptographer.EncryptSymmetric(originalTxt, sKey); profile.SetValue("ConnectionStringSetting", "ConnectionString", encryptedText); }
/// <summary> /// /// </summary> /// <param name="layout"></param> /// <returns></returns> public static bool SaveLayout(this IProfileLayoutControl layout) { if (string.IsNullOrEmpty(layout.LayoutFilePath)) { return(false); } string fileName = SystemDirectory.GetDirectory(DataDirectoryType.User, layout.LayoutFilePath); Feng.Utils.IOHelper.TryCreateDirectory(fileName); AMS.Profile.IProfile profile = new AMS.Profile.Xml(fileName); return(layout.SaveLayout(profile)); }
private void bindGameComboBox() { gameConfigs.Clear(); gameComboBox.DataSource = null; //add None as a default gameConfigs.Add(new GameConfiguration { Path = String.Empty, Title = "None" }); //add games from the Portable Games folder String[] filePaths = Directory.GetFiles(Global.PortableGamesFolderPath, "*.*") .Where(file => file.EndsWith(".exe") || file.EndsWith(".swf")) .ToArray(); foreach (String filePath in filePaths) { gameConfigs.Add(new GameConfiguration { Path = filePath, Title = Path.GetFileNameWithoutExtension(filePath) }); } //add games from the config file AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { String[] entries = profile.GetEntryNames("GamePaths"); foreach (String entry in entries) { String gamePath = (String)profile.GetValue("GamePaths", entry); //if game does not exist delete the entry from the config file if (!File.Exists(gamePath)) { profile.RemoveEntry("GamePaths", entry); continue; } gameConfigs.Add(new GameConfiguration { Path = gamePath, Title = Path.GetFileNameWithoutExtension(gamePath) }); } } //bind game combo box gameComboBox.ValueMember = "Path"; gameComboBox.DisplayMember = "Title"; gameComboBox.DataSource = gameConfigs; }
private void tsmSaveLayout_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.RestoreDirectory = true; saveFileDialog1.InitialDirectory = DefaultDataDirectory; saveFileDialog1.Filter = "配置文件 (*.xmls)|*.xmls"; //saveFileDialog1.Title = "保存"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(saveFileDialog1.FileName); this.SaveLayout(profile); } saveFileDialog1.Dispose(); }
/// <summary> /// /// </summary> /// <param name="layout"></param> /// <returns></returns> public static bool LoadLayout(this IProfileLayoutControl layout) { if (string.IsNullOrEmpty(layout.LayoutFilePath)) return false; AMS.Profile.IProfile profile = new AMS.Profile.Xml(SystemDirectory.GetDirectory(DataDirectoryType.User, layout.LayoutFilePath)); if (layout.LoadLayout(profile)) { return true; } else { profile = new AMS.Profile.Xml(SystemDirectory.GetDirectory(DataDirectoryType.Global, layout.LayoutFilePath)); return layout.LoadLayout(profile); } }
/// <summary> /// /// </summary> /// <param name="layout"></param> /// <returns></returns> public static bool LoadLayout(this IProfileLayoutControl layout) { if (string.IsNullOrEmpty(layout.LayoutFilePath)) { return(false); } AMS.Profile.IProfile profile = new AMS.Profile.Xml(SystemDirectory.GetDirectory(DataDirectoryType.User, layout.LayoutFilePath)); if (layout.LoadLayout(profile)) { return(true); } else { profile = new AMS.Profile.Xml(SystemDirectory.GetDirectory(DataDirectoryType.Global, layout.LayoutFilePath)); return(layout.LoadLayout(profile)); } }
private void browseGameButton_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.InitialDirectory = "c:\\"; openFileDialog.Filter = "Game executables (*.exe)|*.exe|All files (*.*)|*.*"; openFileDialog.RestoreDirectory = true; openFileDialog.Multiselect = false; if (openFileDialog.ShowDialog() == DialogResult.OK) { //add file path to config file AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { profile.SetValue("GamePaths", Path.GetFileNameWithoutExtension(openFileDialog.FileName), openFileDialog.FileName); } bindGameComboBox(); gameComboBox.SelectedItem = gameConfigs.Single(g => g.Path == openFileDialog.FileName); } }
private void playButton_Click(object sender, EventArgs e) //rename button to something else? { GameConfiguration gameConfig = gameConfigs.Single(g => g.Path == (String)gameComboBox.SelectedValue); if (File.Exists(gameConfig.Path)) { //save settings for last game played AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { profile.SetValue("Settings", "PathOfLastGamePlayed", gameConfig.Path); profile.SetValue("Settings", "PathOfLastJoyToKeyConfigUsed", (String)joyToKeyComboBox.SelectedValue); profile.SetValue("Settings", "ArcadeMode", arcadeModeCheckBox.Checked); profile.SetValue("Settings", "FullScreen", fullScreenCheckBox.Checked); profile.SetValue("Settings", "HideMouse", hideMouseCheckBox.Checked); } //run the selected game this.Hide(); //should lock the window instead? GameHandler gameHandler = new GameHandler(ref gameConfig, (String)joyToKeyComboBox.SelectedValue, arcadeModeCheckBox.Checked, fullScreenCheckBox.Checked, hideMouseCheckBox.Checked); this.Show(); return; } }
/// <summary> /// Configuration File Constructor - sets the Path (Full UNC Path and File Name) the Configuration File /// and sets the file as the Profile Configuration File Object. /// </summary> /// <param name="ConfigFilePath"> /// The path to the Configuration File (full UNC Path and File Name). /// </param> public void ConfigFile(string ConfigFilePath) { try { // Make sure the Configuration File exists before attempting to open it as the Profile // Configuration File Object. if (!File.Exists(ConfigFilePath)) { return; } // Instantiate the Profile XML Configuration File Object that will be used to read and // write from and to the Configuration File. xmlConfigurationFile = new AMS.Profile.Xml(ConfigFilePath); // Exit the Method. return; } catch { // Exit the method. return; } }
/// <summary> /// /// </summary> /// <param name="grid"></param> /// <param name="fileName"></param> public static bool SaveLayout(this IGrid grid, string fileName) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(fileName); return SaveLayout(grid, profile); }
/// <summary> /// 从加密文件中读取连接字符串 /// </summary> public static bool LoadConnectionStrings() { try { if (ConfigurationManager.ConnectionStrings[DataConnectionStringName] != null) return false; // <connectionStrings configSource="connections.config"></connectionStrings> AMS.Profile.IProfile profile = new AMS.Profile.Xml(SystemDirectory.DataDirectory + "\\Dbs.dat"); string skey = profile.GetValue("ConnectionStringSetting", "Key", string.Empty); if (!string.IsNullOrEmpty(skey)) { string cryptedConnectionStrings = profile.GetValue("ConnectionStringSetting", "ConnectionString", string.Empty); if (!string.IsNullOrEmpty(cryptedConnectionStrings)) { string connectionStrings = Cryptographer.DecryptSymmetric(cryptedConnectionStrings, skey); if (!string.IsNullOrEmpty(connectionStrings)) { string tempConfigFileName = SystemDirectory.DataDirectory + "\\temp.config"; System.IO.File.WriteAllText(tempConfigFileName, connectionStrings, Encoding.UTF8); ExeConfigurationFileMap configMap = new ExeConfigurationFileMap { ExeConfigFilename = tempConfigFileName }; Configuration externalConfig = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None); Configuration exeConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); foreach (ConnectionStringSettings i in externalConfig.ConnectionStrings.ConnectionStrings) { if (exeConfig.ConnectionStrings.ConnectionStrings[i.Name] == null) { exeConfig.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings(i.Name, i.ConnectionString, i.ProviderName)); } else { //the full name of the connection string can be found in the app.config file // in the "name" attribute of the connection string exeConfig.ConnectionStrings.ConnectionStrings[i.Name].ConnectionString = i.ConnectionString; exeConfig.ConnectionStrings.ConnectionStrings[i.Name].ProviderName = i.ProviderName; } } if (!exeConfig.ConnectionStrings.SectionInformation.IsProtected) { //exeConfig.ConnectionStrings.SectionInformation.UnprotectSection(); // Encrypt the section. exeConfig.ConnectionStrings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); } exeConfig.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection(exeConfig.ConnectionStrings.SectionInformation.Name); // re-init ConfigurationManager var constructorInfo = typeof(System.Configuration.ConfigurationManager).GetConstructor( System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type[0], null); constructorInfo.Invoke(null, null); System.IO.File.Delete(tempConfigFileName); } } } return true; } catch (System.Configuration.ConfigurationErrorsException) { RemoveEncryptedData(); throw; } }
private void bindGameComboBox() { gameConfigs.Clear(); gameComboBox.DataSource = null; //add None as a default gameConfigs.Add(new GameConfiguration { Path = String.Empty, Title = "None" }); //add games from the Portable Games folder String[] filePaths = Directory.GetFiles(Global.PortableGamesFolderPath, "*.*") .Where(file => file.EndsWith(".exe") || file.EndsWith(".swf")) .ToArray(); foreach (String filePath in filePaths) gameConfigs.Add(new GameConfiguration { Path = filePath, Title = Path.GetFileNameWithoutExtension(filePath) }); //add games from the config file AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { String[] entries = profile.GetEntryNames("GamePaths"); foreach (String entry in entries) { String gamePath = (String)profile.GetValue("GamePaths", entry); //if game does not exist delete the entry from the config file if (!File.Exists(gamePath)) { profile.RemoveEntry("GamePaths", entry); continue; } gameConfigs.Add(new GameConfiguration { Path = gamePath, Title = Path.GetFileNameWithoutExtension(gamePath) }); } } //bind game combo box gameComboBox.ValueMember = "Path"; gameComboBox.DisplayMember = "Title"; gameComboBox.DataSource = gameConfigs; }
/// <summary> /// /// </summary> /// <param name="grid"></param> /// <param name="minLevel"></param> /// <returns></returns> public static bool LoadLayout(this IGrid grid, int minLevel) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(GetGridDefaultDataDirectory(grid) + MyGrid.m_layoutDefaultFileName); return LoadLayout(grid, profile, minLevel); }
public bool LoadLayout(string fileName) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(fileName); return LoadLayout(profile); }
private void tsmSaveLayout_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.RestoreDirectory = true; saveFileDialog1.InitialDirectory = DefaultDataDirectory; saveFileDialog1.Filter = "�����ļ� (*.xmls)|*.xmls"; //saveFileDialog1.Title = "����"; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(saveFileDialog1.FileName); this.SaveLayout(profile); } saveFileDialog1.Dispose(); }
public static void Clear() { s_globalProfile = null; s_userProfile = null; }
public bool LoadLayout(string fileName) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(fileName); return(LoadLayout(profile)); }
/// <summary> /// 从加密文件中读取连接字符串 /// </summary> public static bool LoadConnectionStrings() { try { if (ConfigurationManager.ConnectionStrings[DataConnectionStringName] != null) { return(false); } // <connectionStrings configSource="connections.config"></connectionStrings> AMS.Profile.IProfile profile = new AMS.Profile.Xml(SystemDirectory.DataDirectory + "\\Dbs.dat"); string skey = profile.GetValue("ConnectionStringSetting", "Key", string.Empty); if (!string.IsNullOrEmpty(skey)) { string cryptedConnectionStrings = profile.GetValue("ConnectionStringSetting", "ConnectionString", string.Empty); if (!string.IsNullOrEmpty(cryptedConnectionStrings)) { string connectionStrings = Cryptographer.DecryptSymmetric(cryptedConnectionStrings, skey); if (!string.IsNullOrEmpty(connectionStrings)) { string tempConfigFileName = SystemDirectory.DataDirectory + "\\temp.config"; System.IO.File.WriteAllText(tempConfigFileName, connectionStrings, Encoding.UTF8); ExeConfigurationFileMap configMap = new ExeConfigurationFileMap { ExeConfigFilename = tempConfigFileName }; Configuration externalConfig = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None); Configuration exeConfig = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); foreach (ConnectionStringSettings i in externalConfig.ConnectionStrings.ConnectionStrings) { if (exeConfig.ConnectionStrings.ConnectionStrings[i.Name] == null) { exeConfig.ConnectionStrings.ConnectionStrings.Add(new ConnectionStringSettings(i.Name, i.ConnectionString, i.ProviderName)); } else { //the full name of the connection string can be found in the app.config file // in the "name" attribute of the connection string exeConfig.ConnectionStrings.ConnectionStrings[i.Name].ConnectionString = i.ConnectionString; exeConfig.ConnectionStrings.ConnectionStrings[i.Name].ProviderName = i.ProviderName; } } if (!exeConfig.ConnectionStrings.SectionInformation.IsProtected) { //exeConfig.ConnectionStrings.SectionInformation.UnprotectSection(); // Encrypt the section. exeConfig.ConnectionStrings.SectionInformation.ProtectSection("DataProtectionConfigurationProvider"); } exeConfig.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection(exeConfig.ConnectionStrings.SectionInformation.Name); // re-init ConfigurationManager var constructorInfo = typeof(System.Configuration.ConfigurationManager).GetConstructor( System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.NonPublic, null, new Type[0], null); constructorInfo.Invoke(null, null); System.IO.File.Delete(tempConfigFileName); } } } return(true); } catch (System.Configuration.ConfigurationErrorsException) { RemoveEncryptedData(); throw; } }
/// <summary> /// /// </summary> /// <param name="grid"></param> /// <param name="minLevel"></param> /// <returns></returns> public static bool LoadLayout(this IGrid grid, int minLevel) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(GetGridDefaultDataDirectory(grid) + MyGrid.m_layoutDefaultFileName); return(LoadLayout(grid, profile, minLevel)); }
private void tsmPresetSubitem_Click(object sender, EventArgs e) { ToolStripMenuItem item = sender as ToolStripMenuItem; string fileName = item.Tag.ToString(); AMS.Profile.IProfile profile = new AMS.Profile.Xml(fileName); this.LoadLayout(profile); }
private bool readConfig() { try { Assembly asm; asm = Assembly.GetExecutingAssembly(); string path; path = asm.Location.ToString(); path = path.Remove(path.LastIndexOf("\\")); AMS.Profile.Xml xml = new AMS.Profile.Xml(path + "\\Config\\gate.config"); connStr = xml.GetValue("config", "conStr", ""); this.autoStartStopConfig = Convert.ToInt32(xml.GetValue("config", "autoStartStop", "0")); this.dataTimeStart = Convert.ToInt32(xml.GetValue("config", "dataTimeStart", "100000")); this.dataTimeEnd = Convert.ToInt32(xml.GetValue("config", "dataTimeEnd", "180000")); this.mainAccount = xml.GetValue("config", "main_account", ""); this.gDBHost = xml.GetValue("gate", "host", "localhost"); this.gDBPort = xml.GetValue("gate", "port", "4001"); this.gDBPass = xml.GetValue("gate", "pass", ""); this.mailHost = xml.GetValue("email", "host", ""); this.mailPort = xml.GetValue("email", "port", "25"); this.mailFrom = xml.GetValue("email", "from", ""); this.mailTo = xml.GetValue("email", "to", ""); this.mailGateName = xml.GetValue("email", "gate_name", ""); //код брокера в торговой системе, не на бирже this.brokerId = Convert.ToInt32(xml.GetValue("config", "broker_id", "1")); return true; } catch (Exception e) { MessageBox.Show("Ошибка парсинга конфига "+e.Message); return false; } }
/// <summary> /// /// </summary> /// <param name="grid"></param> /// <param name="fileName"></param> public static bool SaveLayout(this IGrid grid, string fileName) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(fileName); return(SaveLayout(grid, profile)); }
//rename button to something else? private void playButton_Click(object sender, EventArgs e) { GameConfiguration gameConfig = gameConfigs.Single(g => g.Path == (String)gameComboBox.SelectedValue); if (File.Exists(gameConfig.Path)) { //save settings for last game played AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { profile.SetValue("Settings", "PathOfLastGamePlayed", gameConfig.Path); profile.SetValue("Settings", "PathOfLastJoyToKeyConfigUsed", (String)joyToKeyComboBox.SelectedValue); profile.SetValue("Settings", "ArcadeMode", arcadeModeCheckBox.Checked); profile.SetValue("Settings", "FullScreen", fullScreenCheckBox.Checked); profile.SetValue("Settings", "HideMouse", hideMouseCheckBox.Checked); } //run the selected game this.Hide(); //should lock the window instead? GameHandler gameHandler = new GameHandler(ref gameConfig, (String)joyToKeyComboBox.SelectedValue, arcadeModeCheckBox.Checked, fullScreenCheckBox.Checked, hideMouseCheckBox.Checked); this.Show(); return; } }
private void UserGUI_Load(object sender, EventArgs e) { //install JoyToKey if it does not exist if (!File.Exists(Global.JoyToKeyFolderPath + "JoyToKey.exe")) { #if (DEBUG) String archivePath = @"..\..\JoyToKey.zip"; #else String archivePath = @"JoyToKey.zip"; #endif using (ZipFile zip = ZipFile.Read(archivePath)) { zip.ExtractAll(Global.CommonApplicationDataFolderPath, ExtractExistingFileAction.DoNotOverwrite); //the archive contains the folder JoyToKey } } //create a config file if it does not exist if (!File.Exists(Global.ConfigurationFilePath)) { XmlDocument configDoc = new XmlDocument(); configDoc.LoadXml("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><configuration><section name=\"GamePaths\"></section></configuration>"); Directory.CreateDirectory(Path.GetDirectoryName(Global.ConfigurationFilePath)); configDoc.Save(Global.ConfigurationFilePath); } //create a portable games folder if it does not exist if (!Directory.Exists(Global.PortableGamesFolderPath)) Directory.CreateDirectory(Global.PortableGamesFolderPath); bindGameComboBox(); bindJoyToKeyComboBox(); //bind settings checkboxes from config file String pathOfLastGamePlayed; Boolean autostartCheckBoxValue; //see http://www.codeproject.com/Articles/5304/Read-Write-XML-files-Config-files-INI-files-or-the AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { pathOfLastGamePlayed = profile.GetValue("Settings", "PathOfLastGamePlayed", String.Empty); joyToKeyComboBox.SelectedItem = profile.GetValue("Settings", "PathOfLastJoyToKeyConfigUsed", String.Empty); arcadeModeCheckBox.Checked = profile.GetValue("Settings", "ArcadeMode", false); fullScreenCheckBox.Checked = profile.GetValue("Settings", "FullScreen", false); hideMouseCheckBox.Checked = profile.GetValue("Settings", "HideMouse", false); autostartCheckBoxValue = profile.GetValue("Settings", "AutoStart", false); } autostartCheckBox.Checked = autostartCheckBoxValue; //TODO: hackish, save all data on closing instead? //autostart last game played if (autostartCheckBox.Checked && arcadeModeCheckBox.Checked == true && pathOfLastGamePlayed != String.Empty) { //select last game gameComboBox.SelectedItem = gameConfigs.Single(g => g.Path == pathOfLastGamePlayed); //play playButton_Click(null, null); } }
/// <summary> /// /// </summary> /// <param name="layout"></param> /// <returns></returns> public static bool SaveLayout(this IProfileLayoutControl layout) { if (string.IsNullOrEmpty(layout.LayoutFilePath)) return false; string fileName = SystemDirectory.GetDirectory(DataDirectoryType.User, layout.LayoutFilePath); Feng.Utils.IOHelper.TryCreateDirectory(fileName); AMS.Profile.IProfile profile = new AMS.Profile.Xml(fileName); return layout.SaveLayout(profile); }
private void UserGUI_Load(object sender, EventArgs e) { //install JoyToKey if it does not exist if (!File.Exists(Global.JoyToKeyFolderPath + "JoyToKey.exe")) { #if (DEBUG) String archivePath = @"..\..\JoyToKey.zip"; #else String archivePath = @"JoyToKey.zip"; #endif using (ZipFile zip = ZipFile.Read(archivePath)) { zip.ExtractAll(Global.CommonApplicationDataFolderPath, ExtractExistingFileAction.DoNotOverwrite); //the archive contains the folder JoyToKey } } //create a config file if it does not exist if (!File.Exists(Global.ConfigurationFilePath)) { XmlDocument configDoc = new XmlDocument(); configDoc.LoadXml("<?xml version=\"1.0\" encoding=\"UTF-8\" ?><configuration><section name=\"GamePaths\"></section></configuration>"); Directory.CreateDirectory(Path.GetDirectoryName(Global.ConfigurationFilePath)); configDoc.Save(Global.ConfigurationFilePath); } //create a portable games folder if it does not exist if (!Directory.Exists(Global.PortableGamesFolderPath)) { Directory.CreateDirectory(Global.PortableGamesFolderPath); } bindGameComboBox(); bindJoyToKeyComboBox(); //bind settings checkboxes from config file String pathOfLastGamePlayed; Boolean autostartCheckBoxValue; //see http://www.codeproject.com/Articles/5304/Read-Write-XML-files-Config-files-INI-files-or-the AMS.Profile.Xml profile = new AMS.Profile.Xml(Global.ConfigurationFilePath); using (profile.Buffer()) { pathOfLastGamePlayed = profile.GetValue("Settings", "PathOfLastGamePlayed", String.Empty); joyToKeyComboBox.SelectedItem = profile.GetValue("Settings", "PathOfLastJoyToKeyConfigUsed", String.Empty); arcadeModeCheckBox.Checked = profile.GetValue("Settings", "ArcadeMode", false); fullScreenCheckBox.Checked = profile.GetValue("Settings", "FullScreen", false); hideMouseCheckBox.Checked = profile.GetValue("Settings", "HideMouse", false); autostartCheckBoxValue = profile.GetValue("Settings", "AutoStart", false); } autostartCheckBox.Checked = autostartCheckBoxValue; //TODO: hackish, save all data on closing instead? //autostart last game played if (autostartCheckBox.Checked && arcadeModeCheckBox.Checked == true && pathOfLastGamePlayed != String.Empty) { //select last game gameComboBox.SelectedItem = gameConfigs.Single(g => g.Path == pathOfLastGamePlayed); //play playButton_Click(null, null); } }
public Xml(AMS.Profile.Xml xml) : base((XmlBased)xml) => this.m_rootName = xml.m_rootName;
private void tsmLoadLayout_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.RestoreDirectory = true; openFileDialog1.InitialDirectory = this.DefaultDataDirectory; openFileDialog1.Filter = "配置文件 (*.xmlc)|*.xmlc"; if (openFileDialog1.ShowDialog() == DialogResult.OK) { AMS.Profile.IProfile profile = new AMS.Profile.Xml(openFileDialog1.FileName); LoadLayout(profile); } openFileDialog1.Dispose(); }