private void CheckLoadedSettings() { if (_allSettings == null) { _allSettings = _filesControl.LoadAllSettings(); } }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); //create a new ball(starting position, starting speed, image, colortint) ball = new Ball(new Vector2(450, 300), new Vector2(3.0f, 3.0f), Content.Load <Texture2D>("ball"), Color.White); redPlayer = new Player(3, Color.IndianRed, Content.Load <Texture2D>("red_player"), new Vector2(0, 300), "West"); bluePlayer = new Player(3, Color.CornflowerBlue, Content.Load <Texture2D>("blue_player"), new Vector2(884, 300), "East"); //create a new settings object st = new Settings(); //create spritefont cms = Content.Load <SpriteFont>("ComicSans"); arial = Content.Load <SpriteFont>("Menu"); //set texturecolor single_pixel = new Texture2D(GraphicsDevice, 1, 1); single_pixel.SetData(new[] { Color.White }); //set gameStates //true = blue | false = red player_turn = true; has_moved = false; currentState = GameStates.Menu; selectedSetting = 0; //initialize the ball's position and speed ResetBall(); }
internal static void projectFileLoad(AllSettings allSettings) { string projectFileName = string.Empty; AllSettings settingsLoaded = new AllSettings(); projectFileName = IOHelper.getPathToProjectFile(allSettings); if (GlobalHelper.isValidString(projectFileName)) { //if DirectoryName.xml exists => existing project, load settings if (File.Exists(projectFileName)) { settingsLoaded = IOHelper.DeserializeXmlFromFile <AllSettings>(projectFileName); //copy deserialized properties GlobalHelper.copyObjectProperies(settingsLoaded, allSettings); //get and load passwords is available allSettings.PasswordSource = CredentialsHelper.getLocalPassword(string.Concat(allSettings.OrgUniqueNameSource, allSettings.ServerUrlSource, allSettings.UsernameSource)); allSettings.IsDirty = false; } //else create/update settings object,create DirectoryName.xml and write settings there else { saveProject(allSettings, true); return; } } //else message "wrong rooth" else { throw new Exception("The root is not appropriate"); } }
protected void Page_Load(object sender, EventArgs e) { AllSettings Setting = (AllSettings)Application["Settings"]; if (Setting.PageRefreshCounter == 0) { Setting.PageRefreshCounter = 1; AllManager.SaveSettings(Setting); } else { Setting.PageRefreshCounter = 0; AllManager.SaveSettings(Setting); } AllSettings Settings = (AllSettings)Application["Settings"]; if (Setting.PageRefreshCounter == 0) { LabelDefaultText1.Text = Settings.DefaultText1; } else { LabelDefaultText1.Text = Settings.DefaultText2; } }
static void Main(string[] args) { if (args == null || args.Length != 1) { Helpers.COMPUTERNAME = Environment.MachineName; } else { Helpers.COMPUTERNAME = args[0]; } Console.WriteLine($"[i] Running Scout against {Helpers.COMPUTERNAME}.."); allSettings = new AllSettings(); try { GetProcesses(); GetServices(); GetPowerShellInformation(); GetDotNetVersions(); ListAuditSettings(); ListWEFSettings(); File.WriteAllText("output.json", GetJson()); } catch (Exception e) { Console.WriteLine($"[!] Error running Scout:\n\n{e}"); } }
//--------------------------------------------------------------------------------------------- private static void SetupContainer(HttpConfiguration config) { var log = new Log(); var consoleLogger = new ConsoleLogger(); log.RegisterLogger(consoleLogger); var settings = new AllSettings(new ApplicationDbContext().Settings, log); var fileLogger = new FileLogger(settings); log.RegisterLogger(fileLogger); var container = new UnityContainer(); config.DependencyResolver = new UnityResolver(container); // Types. container.RegisterType <IUserStore, UserStore>(); container.RegisterType <ITokenDb, ApplicationDbContext>(); container.RegisterType <ITokenStore, TokenStore>(); container.RegisterType <IGoalDb, ApplicationDbContext>(); container.RegisterType <IGoalStore, GoalStore>(); container.RegisterType <IGoalAttemptDb, ApplicationDbContext>(); container.RegisterType <IGoalAttemptStore, GoalAttemptStore>(); container.RegisterType <IDbQuery, ApplicationDbContext>(); // Instances. container.RegisterInstance <IDateTimeSource>(new DateTimeSource()); container.RegisterInstance <IUserSettings>(settings); container.RegisterInstance <ITokenSettings>(settings); container.RegisterInstance <ILogger>(log); }
private Dictionary <string, KeyValuePair <int, string> > GetSettingsDictionary() { //format: <name, <id, value>> var dictionary = new Dictionary <string, KeyValuePair <int, string> >(); foreach (var s in AllSettings.Where(setting => setting.Site != null && setting.Site.Id == _site.Id)) { var resourceName = s.Name.ToLowerInvariant(); if (!dictionary.ContainsKey(resourceName)) { dictionary.Add(resourceName, new KeyValuePair <int, string>(s.Id, s.Value)); } } if (!dictionary.Keys.Any()) { try { if (!_retryingDictionary) { CurrentRequestData.ErrorSignal.Raise( new Exception("settings dictionary empty for " + _site.DisplayName)); } } catch { } if (!_retryingDictionary) { _retryingDictionary = true; ResetSettingCache(); dictionary = GetSettingsDictionary(); } } return(dictionary); }
public static void LoadSettings() { try { if (!Directory.Exists("configs")) { Directory.CreateDirectory("configs"); } var files = Directory.GetFiles("configs", "*.json"); if (files.Length == 0) { throw new Exception(); } AllSettings = files.Select(x => Settings.FromFile(x)).ToArray(); CurrentSettings = AllSettings.FirstOrDefault(x => x.IsActive) ?? AllSettings.First(); } catch (Exception ex) { CurrentSettings = new Settings("dummySettings"); CurrentSettings.Save(); Logger.Error("Failed to read settings!"); Logger.PrintException(ex, true, false); } }
public ActionResult Settings() { AllSettings a = new AllSettings(); a.writaSettings = _blogsettings.LoadSettings(); a.globalSettings = _globalsettings.LoadSettings(); return(View("~/Views/Admin/Settings.cshtml", "~/Views/Admin/_Adminlayout.cshtml", a)); }
private void Start() { // get settings if (GameObject.Find("SettingsManager") != null) { settings = GameObject.Find("SettingsManager").GetComponent <AllSettings>(); dynamicCamera = settings.dynamicCamera; } }
public void Add(string subfolderName, string bindedKey, bool?isMoveFileMode) { if (AllSettings.Where(settings => settings.SubfolderName == subfolderName || settings.Key == bindedKey). FirstOrDefault() == null) { AllSettings.Add(new Settings(subfolderName, bindedKey, isMoveFileMode)); } SaveInFile(); }
public void RefreshSettings(List <string> subfolderNames, List <string> bindedKeys, List <bool?> isMoveFileModes) { AllSettings.Clear(); for (int i = 0; i < subfolderNames.Count; i++) { AllSettings.Add(new Settings( subfolderNames[i], bindedKeys[i], isMoveFileModes[i])); } SaveInFile(); }
internal static void saveProject(AllSettings allSettings, bool isCreate = false) { //clean previous project file to prevent corruption if (!isCreate) { IOHelper.deleteFile(IOHelper.getPathToProjectFile(allSettings)); } IOHelper.SerializeObjectToXmlFile <AllSettings>(allSettings, IOHelper.getPathToProjectFile(allSettings)); allSettings.IsDirty = false; }
void Application_Start(object sender, EventArgs e) { // Code that runs on application startup RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); Application.Add("Key", "1234"); string Key = (string)Application["Key"]; AllSettings Settings = AllManager.LoadSettings(); Application.Add("Settings", Settings); }
internal StoreSetting GetSetting(string name) { // Search local settings storage for setting var s = AllSettings.FirstOrDefault(y => y.SettingName == name); if (s == null) { s = new StoreSetting(); } return(s); }
protected void Button1_Click(object sender, EventArgs e) { AllSettings Setting = (AllSettings)Application["Settings"]; Setting.DefaultText1 = Text1.Text; Setting.DefaultText2 = Text2.Text; Setting.DefaultHeader = HeaderText.Text; Setting.DefaultFooter = FooterText.Text; AllManager.SaveSettings(Setting); Application["Settings"] = Setting; Response.Redirect("Default.aspx"); }
public void Remove(string subfolderName) { Settings stngs = AllSettings .Where(settings => settings.SubfolderName == subfolderName) .FirstOrDefault(); if (stngs != null) { AllSettings.Remove(stngs); } SaveInFile(); }
private void btn_OK_Click(object sender, EventArgs e) { AllSettings.criticalTemperature = (int)num_temp.Value; AllSettings.criticalSpace = (int)num_space.Value; AllSettings.criticalRam = (int)num_RAM.Value; AllSettings.spaceUnit = switch_space.Value; AllSettings.ramUnit = switch_RAM.Value; AllSettings.folder = tb_direction.Text; AllSettings.WriteSettings(); Close(); }
/// <summary> /// Creates projects directories starting from ProjectPath property and based on subFolders enum values /// </summary> /// <param name="settings"></param> internal static void setInnerProjectStructure(AllSettings settings) { IEnumerable <KeyValuePair <int, string> > directoriesNames = enumToList.Of <subFolders>(false); foreach (KeyValuePair <int, string> item in directoriesNames) { string path = Path.Combine(settings.ProjectPath, item.Value); //if (Directory.Exists(path)) continue; //Directory.CreateDirectory(path); createDirectory(path); } }
/// <summary> /// returns absolute path to project xml /// </summary> /// <param name="allSettings"></param> /// <returns></returns> internal static string getPathToProjectFile(AllSettings allSettings) { if (Directory.Exists(allSettings.ProjectPath)) { string dirName = new DirectoryInfo(allSettings.ProjectPath).Name; return(Path.Combine(allSettings.ProjectPath, dirName + ".xml")); } else { return(string.Empty); } }
// change a setting with respect to the bounds public static void ChangeSetting(bool positive = true, AllSettings currentSetting = 0) { //switch on the currentSetting that needs to be changed switch (currentSetting) { // change setting based on bounds case AllSettings.StartingDifficulty: if (positive && StartingDifficulty < 20) { StartingDifficulty++; } else if (!positive && StartingDifficulty > 1) { StartingDifficulty--; } break; case AllSettings.GridWidth: if (positive && GridWidth < 20) { GridWidth++; } else if (!positive && GridWidth > 6) { GridWidth--; } break; case AllSettings.GridHeight: if (positive && GridHeight < 25) { GridHeight++; } else if (!positive && GridHeight > 10) { GridHeight--; } break; // invert the setting | bool setting case AllSettings.SpecialEvents: SpecialEvents = !SpecialEvents; break; case AllSettings.HiddenMode: HiddenMode = !HiddenMode; break; } }
public int RunInfoAndReturnExitCode() { var config = new AllSettings(); if (Utils.TestConfigtation()) { if (Utils.IsAnyPendigFile()) { string rootPath = config.WorkingDirectory; string[] dirs = Directory.GetDirectories(rootPath); foreach (var folder in dirs) { string[] files = Directory.GetFiles(folder, "*.sql", SearchOption.AllDirectories); Console.WriteLine(""); var table = new ConsoleTable("Group", "File Name", "State", "Owner"); foreach (string file in files) { string filename = Path.GetFileNameWithoutExtension(file); FileInfo fileInfo = new FileInfo(file); FileSecurity fileSecurity = fileInfo.GetAccessControl(); IdentityReference identityReference = fileSecurity.GetOwner(typeof(NTAccount)); var directoryInfo = new DirectoryInfo(file).Parent; if (directoryInfo != null) { string result = directoryInfo.Name; table.AddRow(result, filename, "pending", identityReference.Value); } } table.Write(); } } else { Console.WriteLine(string.Concat("Pending file not found in working directory: ", config.WorkingDirectory)); } } else { Console.WriteLine("Configration is missing..."); Utils.DisplayConfigration(); } return(0); }
public BotDataManager() { _filesControl = new FilesControl(); _logger = Logging.GetLogger <BotDataManager>(); _allSettings = _filesControl.LoadAllSettings(); _logger.LogInformation("Bot settings loaded successfully."); this.LoadLoginCredentials(); this.LoadBotSettings(); this.LoadBotIntervals(); this.BotDictionary = _filesControl.LoadBotDictionary(); UseColoredMessages = BotSettings.UseColoredMessages; }
void Session_Start(object sender, EventArgs e) { if (Application["Counter"] == null) { Session.Add("Counter", 0); } int iCounter = Convert.ToInt32(Application["Counter"]); iCounter++; AllSettings sett = (AllSettings)Application["Settings"]; sett.VisitorNumber += iCounter; AllManager.SaveSettings(sett); Application["Counter"] = sett.VisitorNumber.ToString(); }
/// <summary> /// Show All Settings window in a dialog /// </summary> internal static void AllSettingsWindow() { Window window = new AllSettings { Width = double.IsNaN(mainWindow.Width) ? 465 : mainWindow.Width, Height = double.IsNaN(mainWindow.Height) ? 715 : mainWindow.Height, Opacity = 0, Owner = Application.Current.MainWindow, }; var animation = new DoubleAnimation(1, TimeSpan.FromSeconds(.5)); window.BeginAnimation(UIElement.OpacityProperty, animation); window.ShowDialog(); }
protected void Page_Load(object sender, EventArgs e) { if (Session["Username"] != null) { LogButton.Text = "Logout"; } else { LogButton.Text = "Login"; } LabelCounter.Text = "You are visitor No." + Application["Counter"].ToString(); AllSettings Settings = (AllSettings)Application["Settings"]; LabelHeader.Text = Settings.DefaultHeader; LabelInfo.Text = Settings.DefaultFooter; }
protected void Page_Load(object sender, EventArgs e) { if (Session["Username"] == null) { Response.Redirect("Default.aspx"); } else { if (!Page.IsPostBack) { AllSettings Settings = (AllSettings)Application["Settings"]; Text1.Text = Settings.DefaultText1; Text2.Text = Settings.DefaultText2; HeaderText.Text = Settings.DefaultHeader; FooterText.Text = Settings.DefaultFooter; } } }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); var list = FindViewById <ListView>(Resource.Id.settingsList); var separatedAdapter = new SeparatedListAdapter(this); var settingService = new AllSettings(); var settings = settingService.AllTheSettings; separatedAdapter.AddSection("About Me", new SettingsListAdapter(this, settings.Where(s => s.SettingSection == Section.About).ToList())); separatedAdapter.AddSection("App Settings", new SettingsListAdapter(this, settings.Where(s => s.SettingSection == Section.App).ToList())); //list.Adapter = new SettingsListAdapter(this, settings); list.Adapter = separatedAdapter; }
/// <summary> /// Obsolete /// Returns abolute path to project folder selected by folder param. /// Appends directory name or file name with/without extention /// </summary> /// <param name="settings"></param> /// <param name="folder"></param> /// <returns></returns> internal static string getProjectSubfolderPathOld(AllSettings settings, subFolders folder, bool appendFileName = true, string extensionAttach = "") { string dir = Path.Combine(settings.ProjectPath, folder.ToString()); if (Directory.Exists(dir)) { string fileName = folder.ToString(); if (GlobalHelper.isValidString(fileName) && appendFileName) { return(Path.Combine(dir, fileName + extensionAttach)); } else { return(dir); } } return(string.Empty); }
// Keeps local settings synchronized with updates during a single request // Does not update database public void AddOrUpdateLocalSetting(StoreSetting s, bool preserveNotLocalizedValue = false) { // Search local settings storage for setting var found = AllSettings.Where(y => y.SettingName == s.SettingName).FirstOrDefault(); if (found == null) { AllSettings.Add(s); } else { s.Id = found.Id; // Set Id so we'll get a database update instead of insert if (preserveNotLocalizedValue) { s.SettingValue = found.SettingValue; } AllSettings[AllSettings.IndexOf(found)] = s; } }
public frmSettings(AllSettings settings, VM vm) { this.settings = settings; this.vm = vm; InitializeComponent(); }