/// <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); }
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); } } }
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; } }
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); } }
//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; } }