public void LoadAccounts() { storedAccounts.Clear(); string[] fileNames = Directory.GetFiles( Paths.DataDirectory, "*.account" ); foreach( string fileName in fileNames ) { try { SettingsFile sf = new SettingsFile(); sf.Load( fileName ); SignInAccount newAccount = new SignInAccount { SignInUsername = sf.GetString( "SignInUsername", "" ), PlayerName = sf.GetString( "PlayerName", "" ), Password = sf.GetString( "Password", "" ), LastUrl = sf.GetString( "LastUrl", "" ) }; if( newAccount.Password.Length > 0 ) { newAccount.Password = PasswordSecurity.DecryptPassword( newAccount.Password ); } string tickString = sf.GetString( "SignInDate", "0" ); long ticks; if( Int64.TryParse( tickString, out ticks ) && ticks > DateTime.MinValue.Ticks && ticks <= DateTime.MaxValue.Ticks ) { newAccount.SignInDate = new DateTime( ticks ); } else { newAccount.SignInDate = DateTime.MinValue; } AddAccount( newAccount ); } catch( Exception ex ) { MainForm.Log( "AccountManager.LoadAccounts: " + ex ); } } SaveAllAccounts(); }
public void Load() { lock (SyncRoot) { SettingsFile.Load(SettingsFilePath); } }
public void Begin() { Directory.CreateDirectory(UserDataPath); InitLogging(); settingsFile.Load(); Log.Debug(Tag, "Necessary setup is done"); }
public static void Main(string[] args) { TaskDialogHelper.MainCaption = "Athame"; // Create app instance config DefaultApp = new AthameApplication { IsWindowed = true }; var dataDir = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Athame"); var userDataDirArgIndex = Array.IndexOf(args, "--user-data-dir"); if (userDataDirArgIndex != -1 && args.Length <= userDataDirArgIndex + 2) { var dir = args[userDataDirArgIndex + 1]; if (Directory.Exists(dir)) { dataDir = Path.Combine(dir, "Athame Data"); } } DefaultApp.UserDataPath = dataDir; // Install logging LogDir = DefaultApp.UserDataPathOf("Logs"); Directory.CreateDirectory(LogDir); Log.AddLogger("file", new FileLogger(LogDir)); #if !DEBUG Log.Filter = Level.Warning; AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) => { Log.WriteException(Level.Fatal, "AppDomain", eventArgs.ExceptionObject as Exception); }; #else Log.AddLogger("debug", new DebugLogger()); #endif Log.Debug(Tag, "Logging installed on AppDomain"); // Ensure user data dir Directory.CreateDirectory(DefaultApp.UserDataPath); // Load settings SettingsPath = DefaultApp.UserDataPathOf(SettingsFilename); DefaultSettings = new SettingsFile <AthameSettings>(SettingsPath); DefaultSettings.Load(); // Create plugin manager instance DefaultPluginManager = new PluginManager(Path.Combine(Directory.GetCurrentDirectory(), PluginManager.PluginDir)); Log.Debug(Tag, "Ready to begin main form loop"); // Begin main form Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
/*/// <summary> * /// The Stats Form, not sure how am I gonna use this... * /// </summary> * internal StatsForm statsForm = new StatsForm(); * // */ #endregion /// <summary> /// Called when the plugin has been created successfully. /// </summary> public override void Initialize() { // Bind console commands this.RegisterConsoleCommands(); // Listen for on duty event Functions.OnOnDutyStateChanged += this.Functions_OnOnDutyStateChanged; // Listen when player has joined network game Networking.JoinedNetworkGame += this.Networking_JoinedNetworkGame; // Check if Stats file exists // Actually NooseMod folder contains Stats already, if not exists, it'll throw an error automatically //if (File.Exists(Game.InstallFolder + "\\LCPDFR\\Plugins\\NooseMod\\Stats.mdb")) // Open connection adapters (no conditions set) try { overallstatsadp.Connection.Open(); missionstatsadp.Connection.Open(); overallstatsadp.Disposed += this.overallstatsadp_Disposed; missionstatsadp.Disposed += this.missionstatsadp_Disposed; } catch (OleDbException ex) { Log.Error("Connection cannot be opened: " + ex, this); } catch (InvalidOperationException ex) { Log.Error("Invalid Operation: " + ex, this); } catch (Exception ex) // when other errors caught { Log.Error("Detected other error: " + ex, this); } if (overallstatsadp.Connection.State == ConnectionState.Open && missionstatsadp.Connection.State == ConnectionState.Open) { Log.Info("Started", this); Log.Info("Mission Stats Adapter details: " + missionstatsadp.Connection.ConnectionString, this); // this will return a path to NooseMod folder in LCPDFR.log Log.Info("Server Version: " + missionstatsadp.Connection.ServerVersion, this); Log.Info("Overall Stats Adapter details: " + overallstatsadp.Connection.ConnectionString, this); // this will return a path to NooseMod folder in LCPDFR.log Log.Info("Server Version: " + overallstatsadp.Connection.ServerVersion, this); } else { try { overallstatsadp.Connection.Close(); missionstatsadp.Connection.Close(); } catch (Exception ex) { Log.Error("Cannot close the connection: " + ex, this); } Log.Info("Started without database system", this); } // Just to make sure SettingsIni.Load(); }
public static void Main(string[] args) { // Create app instance config DefaultApp = new AthameApplication { IsWindowed = true, #if DEBUG UserDataPath = Path.Combine(Directory.GetCurrentDirectory(), "UserDataDebug") #else UserDataPath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Athame") #endif }; // Install logging LogDir = DefaultApp.UserDataPathOf("Logs"); Directory.CreateDirectory(LogDir); Log.AddLogger("file", new FileLogger(LogDir)); #if !DEBUG Log.Filter = Level.Warning; AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) => { Log.WriteException(Level.Fatal, "AppDomain", eventArgs.ExceptionObject as Exception); }; #else Log.AddLogger("debug", new DebugLogger()); #endif Log.Debug(Tag, "Logging installed on AppDomain"); // Ensure user data dir Directory.CreateDirectory(DefaultApp.UserDataPath); // Load settings SettingsPath = DefaultApp.UserDataPathOf(SettingsFilename); DefaultSettings = new SettingsFile <AthameSettings>(SettingsPath); DefaultSettings.Load(); // Create plugin manager instance DefaultPluginManager = new PluginManager(Path.Combine(Directory.GetCurrentDirectory(), PluginManager.PluginDir)); if (args.Length >= 2) { if (args[0] == "/loadSinglePlugin") { DefaultPluginManager.SetSinglePlugin(args[1]); } } Log.Debug(Tag, "Ready to begin main form loop"); // Begin main form Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); } }
public void Begin() { Directory.CreateDirectory(UserDataPath); InitLogging(); var settingsPath = UserDataPathOf(SettingsFilename); settingsFile = new SettingsFile <AthameSettings>(settingsPath); PluginManager = new PluginManager(Path.Combine(Directory.GetCurrentDirectory(), PluginManager.PluginDir)); settingsFile.Load(); Log.Debug(Tag, "Necessary setup is done"); }
static Settings() { m_Instance = new Settings(); m_File = new SettingsFile("settings.cfg"); m_Instance.m_Debug = CreateOrOpenSection <DebugSettings>(DebugSettings.SectionName); m_Instance.m_Server = CreateOrOpenSection <ServerSettings>(ServerSettings.SectionName); m_Instance.m_UltimaOnline = CreateOrOpenSection <UltimaOnlineSettings>(UltimaOnlineSettings.SectionName); m_Instance.m_Game = CreateOrOpenSection <GameSettings>(GameSettings.SectionName); m_File.Load(); }
// Constants for paths static SystemSettings() { if (!Directory.Exists(SettingsFile.SystemDirectory)) { Directory.CreateDirectory(SettingsFile.SystemDirectory); } settings = SettingsFile.Load(); if (!Directory.Exists(settings.BasePath)) { Directory.CreateDirectory(settings.BasePath); } }
static Settings() { s_Instance = new Settings(); s_File = new SettingsFile("settings.cfg"); s_Instance.m_Debug = CreateOrOpenSection <DebugSettings>(DebugSettings.SectionName); s_Instance.m_Login = CreateOrOpenSection <LoginSettings>(LoginSettings.SectionName); s_Instance.m_UltimaOnline = CreateOrOpenSection <UltimaOnlineSettings>(UltimaOnlineSettings.SectionName); s_Instance.m_Engine = CreateOrOpenSection <EngineSettings>(EngineSettings.SectionName); s_Instance.m_UI = CreateOrOpenSection <UserInterfaceSettings>(UserInterfaceSettings.SectionName); s_Instance.m_Gumps = CreateOrOpenSection <GumpSettings>(GumpSettings.SectionName); s_Instance.m_Audio = CreateOrOpenSection <AudioSettings>(AudioSettings.SectionName); s_File.Load(); }
public static bool LoadAll() { #region Settings Not Found on Disk if (!System.IO.File.Exists(@"./Settings.Dat")) { return(false); } #endregion #region Load Settings File Contents SettingsFile.Load(); #endregion #region Iterate over Contents, Update Settings try { for (int i = 0; i < SettingsLibrary.SettingsFile.Contents.Count; i++) { if (SettingsLibrary.SettingsFile.Contents[i].Command == "") { continue; } ICommandFileLine thisLine = SettingsLibrary.SettingsFile.Contents[i]; string command = thisLine.Command; List <string> parameters = new List <string>(); for (int j = 0; j < thisLine.NumberOfParameters; j++) { parameters.Add(thisLine.GetParameter(j)); } bool Failed = !FindAndUpdateSetting(command, string.Join(" ", parameters)); if (Failed) { Debug.AddWarningMessage("Setting Not Recognised or Failed Conversion: \"" + command + "\"."); } } return(true); } catch (Exception) { return(false); } #endregion }
static Settings() { s_Instance = new Settings(); s_File = new SettingsFile("settings.cfg"); s_Instance.m_Debug = CreateOrOpenSection <DebugSettings>(DebugSettings.SectionName); s_Instance.m_Server = CreateOrOpenSection <ServerSettings>(ServerSettings.SectionName); s_Instance.m_UltimaOnline = CreateOrOpenSection <UltimaOnlineSettings>(UltimaOnlineSettings.SectionName); s_Instance.m_Game = CreateOrOpenSection <GameSettings>(GameSettings.SectionName); s_Instance.m_World = CreateOrOpenSection <WorldSettings>(WorldSettings.SectionName); s_Instance.m_Gumps = CreateOrOpenSection <GumpSettings>(GumpSettings.SectionName); s_Instance.m_Audio = CreateOrOpenSection <AudioSettings>(AudioSettings.SectionName); s_File.Load(); }
private void MainForm_Load(object sender, EventArgs e) { SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); Direct3D d3d = new Direct3D(); d3ddevice = new Device(d3d, 0, DeviceType.Hardware, panel1.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters { Windowed = true, SwapEffect = SwapEffect.Discard, EnableAutoDepthStencil = true, AutoDepthStencilFormat = Format.D24X8 }); settingsfile = SettingsFile.Load(); EditorOptions.Initialize(d3ddevice); EditorOptions.OverrideLighting = true; EditorOptions.RenderDrawDistance = cam.DrawDistance = settingsfile.SA2EventViewer.DrawDistance_General; cam.ModifierKey = settingsfile.SA2EventViewer.CameraModifier; actionList = ActionMappingList.Load(Path.Combine(Application.StartupPath, "keybinds", "SA2EventViewer.ini"), DefaultActionList.DefaultActionMapping); actionInputCollector = new ActionInputCollector(); actionInputCollector.SetActions(actionList.ActionKeyMappings.ToArray()); actionInputCollector.OnActionStart += ActionInputCollector_OnActionStart; actionInputCollector.OnActionRelease += ActionInputCollector_OnActionRelease; optionsEditor = new EditorOptionsEditor(cam, actionList.ActionKeyMappings.ToArray(), DefaultActionList.DefaultActionMapping, false, false); optionsEditor.FormUpdated += optionsEditor_FormUpdated; optionsEditor.FormUpdatedKeys += optionsEditor_FormUpdatedKeys; cammodel = new ModelFile(Properties.Resources.camera).Model; cammodel.Attach.ProcessVertexData(); cammesh = cammodel.Attach.CreateD3DMesh(); if (Program.Arguments.Length > 0) { LoadFile(Program.Arguments[0]); } }
public KeybindForm(DS4 InputDevice, SettingsFile BindFile) { InitializeComponent(); kb = BindFile; device = InputDevice; labelBindHow.Text = Properties.Resources.STRING_BIND_HOW; labelTouchMode.Text = Properties.Resources.STRING_BIND_TOUCH_MODE; comboTouchMode.Items[0] = Properties.Resources.STRING_BIND_TOUCH_MOUSE; comboTouchMode.Items[1] = Properties.Resources.STRING_BIND_TOUCH_EXTRA; comboTouchMode.Items[2] = Properties.Resources.STRING_BIND_TOUCH_EMULATE; labelMovement.Text = Properties.Resources.STRING_BIND_MOVEMENT; labelCamera.Text = Properties.Resources.STRING_BIND_CAMERA; labelRightDead.Text = Properties.Resources.STRING_BIND_MOUSE_DEADZONE; labelRightSpeed.Text = Properties.Resources.STRING_BIND_MOUSE_SPEED; labelRightCurve.Text = Properties.Resources.STRING_BIND_MOUSE_CURVE; float rSpeed, rCurve, rDead; int touchMode; kb.Settings.Read("RightDead", out rDead); kb.Settings.Read("RightCurve", out rCurve); kb.Settings.Read("RightSpeed", out rSpeed); kb.Settings.Read("TouchMode", out touchMode); numRCurve.Value = (int)rCurve; numRSpeed.Value = (int)rSpeed; numRDeadzone.Value = (int)rDead; comboTouchMode.SelectedIndex = touchMode; // Set right stick panel to double buffered typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, panelRStickAxis, new object[] { true }); kb.Load(); RefreshKeyBindings(); }
public static InstallerConfig Load() { return(new InstallerConfig { InstallerState = SettingsFile.Load <Dictionary <string, IDictionary <string, string> > >(nameof(InstallerState)), }); }
private static UserSettings LoadUserSettings() { var store = new XmlFileStore(); var file = new SettingsFile<UserSettings>("User", store); return file.Load(); }
private static AppSettings LoadAppSettings() { var store = new XmlFileStore(); var file = new SettingsFile<AppSettings>("App", store); return file.Load(); }
void LoadResumeInfo() { if( File.Exists( Paths.GameSettingsFile ) ) { SettingsFile gameSettings = new SettingsFile(); gameSettings.Load( Paths.GameSettingsFile ); string resumeUri = gameSettings.GetString( "mc.lastMcUrl", "" ); if( resumeUri.Length > 0 ) { Match match = PlayLinkDirect.Match( resumeUri ); if( match.Success ) { tResumeUri.Text = resumeUri; tResumeServerIP.Text = match.Groups[1].Value; tResumeUsername.Text = match.Groups[7].Value; string resumeServerName = gameSettings.GetString( "mc.lastClassicServer", "" ); if( resumeServerName.Length > 0 ) { tResumeServerName.Text = resumeServerName; } else { tResumeServerName.Text = "?"; } bResume.Enabled = true; return; } } } ResetResumeInfo(); }
void LoadLauncherSettings() { Log( "LoadLauncherSettings" ); SettingsFile settings = new SettingsFile(); if( File.Exists( Paths.LauncherSettingsFile ) ) { settings.Load( Paths.LauncherSettingsFile ); } bool saveUsername = settings.GetBool( "rememberUsername", true ); bool multiUser = settings.GetBool( "multiUser", false ); bool savePassword = settings.GetBool( "rememberPassword", false ); bool saveUrl = settings.GetBool( "rememberServer", true ); GameUpdateMode gameUpdateMode = settings.GetEnum( "gameUpdateMode", GameUpdateMode.Ask ); StartingTab startingTab = settings.GetEnum( "startingTab", StartingTab.SignIn ); xRememberUsername.Checked = saveUsername; xMultiUser.Checked = multiUser; xRememberPassword.Checked = savePassword; xRememberServer.Checked = saveUrl; cGameUpdates.SelectedIndex = (int)gameUpdateMode; cStartingTab.SelectedIndex = (int)startingTab; settingsLoaded = true; }
void xFailSafe_CheckedChanged( object sender, EventArgs e ) { SettingsFile sf = new SettingsFile(); if( File.Exists( Paths.GameSettingsFile ) ) { sf.Load( Paths.GameSettingsFile ); } bool failSafeEnabled = sf.GetBool( "mc.failsafe", false ); if( failSafeEnabled != xFailSafe.Checked ) { sf.Set( "mc.failsafe", xFailSafe.Checked ); sf.Save( Paths.GameSettingsFile ); } lOptionsStatus.Text = "Fail-safe mode " + (xFailSafe.Checked ? "enabled" : "disabled") + "."; }
void tabs_SelectedIndexChanged( object sender, EventArgs e ) { if( !tabs.Visible ) { return; } if( tabs.SelectedTab == tabSignIn ) { AcceptButton = bSignIn; if( cSignInUsername.Text.Length == 0 ) { cSignInUsername.Focus(); } else if( tSignInPassword.Text.Length == 0 ) { tSignInPassword.Focus(); } else { tSignInUrl.Focus(); } } else if( tabs.SelectedTab == tabResume ) { AcceptButton = bResume; bResume.Focus(); } else if( tabs.SelectedTab == tabDirect ) { AcceptButton = bDirectConnect; tDirectUrl.Focus(); } else if( tabs.SelectedTab == tabOptions ) { AcceptButton = null; SettingsFile sf = new SettingsFile(); if( File.Exists( Paths.GameSettingsFile ) ) { sf.Load( Paths.GameSettingsFile ); } xFailSafe.Checked = sf.GetBool( "mc.failsafe", false ); } else { AcceptButton = null; } }
public KeybindForm(Controller InputDevice, SettingsFile BindFile) { InitializeComponent(); kb = BindFile; device = InputDevice; float rSpeed, rCurve, rDead, touchMode; kb.Settings.Read("RightDead", out rDead); kb.Settings.Read("RightCurve", out rCurve); kb.Settings.Read("RightSpeed", out rSpeed); kb.Settings.Read("TouchMode", out touchMode); numRCurve.Value = (int)rCurve; numRSpeed.Value = (int)rSpeed; numRDeadzone.Value = (int)rDead; // Set right stick panel to double buffered typeof(Panel).InvokeMember("DoubleBuffered", BindingFlags.SetProperty | BindingFlags.Instance | BindingFlags.NonPublic, null, panelRStickAxis, new object[] { true }); kb.Load(); RefreshKeyBindings(); }
public static void Main(string[] args) { //var tempDir = System.IO.Directory.CreateDirectory("Temp"); //Shell shell = new Shell(); //Folder folder = shell.NameSpace(tempDir.FullName); //var item = folder.ParseName("test.txt"); //foreach (FolderItem file in folder.Items()) //{ // if (file.Name == "test.txt") // { // } //} //Folder folder2 = shell.BrowseForFolder(0, "Select a destination for this media:", 0, 0); //if (folder == null) //{ // return; //} //folder2.CopyHere(item); TaskDialogHelper.MainCaption = "Athame"; // Create app instance config DefaultApp = new AthameApplication { IsWindowed = true }; var dataDir = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "Athame"); var userDataDirArgIndex = Array.IndexOf(args, "--user-data-dir"); if (userDataDirArgIndex != -1 && args.Length <= userDataDirArgIndex + 2) { var dir = args[userDataDirArgIndex + 1]; if (Directory.Exists(dir)) { dataDir = Path.Combine(dir, "Athame Data"); } } DefaultApp.UserDataPath = dataDir; // Install logging LogDir = DefaultApp.UserDataPathOf("Logs"); Directory.CreateDirectory(LogDir); Log.AddLogger("file", new FileLogger(LogDir)); #if !DEBUG Log.Filter = Level.Warning; AppDomain.CurrentDomain.UnhandledException += (sender, eventArgs) => { Log.WriteException(Level.Fatal, "AppDomain", eventArgs.ExceptionObject as Exception); }; #else Log.AddLogger("debug", new DebugLogger()); #endif Log.Debug(Tag, "Logging installed on AppDomain"); // Ensure user data dir Directory.CreateDirectory(DefaultApp.UserDataPath); // Load settings SettingsPath = DefaultApp.UserDataPathOf(SettingsFilename); DefaultSettings = new SettingsFile <AthameSettings>(SettingsPath); DefaultSettings.Load(); // Create plugin manager instance DefaultPluginManager = new PluginManager(Path.Combine(Directory.GetCurrentDirectory(), PluginManager.PluginDir), DefaultApp.UserDataPath); Log.Debug(Tag, "Ready to begin main form loop"); // Begin main form Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm()); }
protected void RefreshSettings() { store.Expect(x => x.LoadXml(Arg<string>.Is.Anything)).Return(Xml()); var file = new SettingsFile<AppSettings>(store); settings = file.Load(); }
static Settings() { s_File = new SettingsFile("settings.cfg"); s_Instance = new Settings(); s_File.Load(); }
public FormMain() { if (!WindowManager.IsSingleInstance) { MessageBox.Show(Translations.Get("already_running")); Environment.Exit(0); } PressedKeys = new List <Keys>(); InitializeComponent(); HideMainForm(); this.Text = Translations.Get("about_text"); this.Item_Title.Text = Translations.Get("about_title"); Input = new GlobalHooker(); KInput = new KeyboardHookListener(Input); MInput = new MouseHookListener(Input); KInput.Enabled = true; MInput.Enabled = true; MInput.MouseDown += new MouseEventHandler(OnUserMouseInteraction); MInput.MouseUp += new MouseEventHandler(OnUserMouseInteraction); MInput.MouseMove += new MouseEventHandler(OnUserMouseInteraction); MInput.MouseClick += new MouseEventHandler(OnUserMouseClick); KInput.KeyDown += new KeyEventHandler(OnUserKeyboardPress); KInput.KeyUp += new KeyEventHandler(OnUserKeyboardRelease); KeySender.KeyStroke(KeySender.VkKeyScan('^')); if (File.Exists(SettingsFile.SaveFile)) { SettingsFile.Load(ref ActivateKey); } else { SettingsFile.Save(ActivateKey); if (MessageBox.Show( String.Format( "{0}\n\n{1}\n{2}\n\n{3}", Translations.Get("welcome_text_1"), Translations.Get("welcome_text_2"), Translations.Get("welcome_text_3"), Translations.Get("welcome_text_4") ), Translations.Get("welcome_title"), MessageBoxButtons.YesNo, MessageBoxIcon.Question ) == DialogResult.Yes) { Button_Help_Click(new object(), EventArgs.Empty); } } RefreshFiles(); WqlEventQuery query = new WqlEventQuery("Select * From __InstanceCreationEvent Within 2 Where TargetInstance Isa 'Win32_Process'"); watcher = new ManagementEventWatcher(query); watcher.EventArrived += new EventArrivedEventHandler(OnWindowOpen); watcher.Start(); ProceedOtherMacros(Keys.None, MacroType.Startup); timer = new System.Windows.Forms.Timer(); timer.Interval = 1000; timer.Tick += new EventHandler(OnIDLETick); timer.Start(); }