예제 #1
0
 private void CheckLoadedSettings()
 {
     if (_allSettings == null)
     {
         _allSettings = _filesControl.LoadAllSettings();
     }
 }
예제 #2
0
        /// <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();
        }
예제 #3
0
        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");
            }
        }
예제 #4
0
        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;
            }
        }
예제 #5
0
파일: Program.cs 프로젝트: 0xffhh/scout
        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}");
            }
        }
예제 #6
0
        //---------------------------------------------------------------------------------------------

        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        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);
            }
        }
예제 #9
0
        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));
        }
예제 #10
0
 private void Start()
 {
     // get settings
     if (GameObject.Find("SettingsManager") != null)
     {
         settings      = GameObject.Find("SettingsManager").GetComponent <AllSettings>();
         dynamicCamera = settings.dynamicCamera;
     }
 }
예제 #11
0
 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();
 }
예제 #12
0
 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();
 }
예제 #13
0
        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;
        }
예제 #14
0
        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);
        }
예제 #15
0
        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);
        }
예제 #16
0
        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");
        }
예제 #17
0
        public void Remove(string subfolderName)
        {
            Settings stngs = AllSettings
                             .Where(settings => settings.SubfolderName == subfolderName)
                             .FirstOrDefault();

            if (stngs != null)
            {
                AllSettings.Remove(stngs);
            }
            SaveInFile();
        }
예제 #18
0
        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();
        }
예제 #19
0
파일: IOHelper.cs 프로젝트: mkalinov/DMM365
        /// <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);
            }
        }
예제 #20
0
파일: IOHelper.cs 프로젝트: mkalinov/DMM365
 /// <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);
     }
 }
예제 #21
0
        // 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;
            }
        }
예제 #22
0
        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);
        }
예제 #23
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;
        }
예제 #24
0
        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();
        }
예제 #25
0
        /// <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();
        }
예제 #26
0
        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;
        }
예제 #27
0
 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;
         }
     }
 }
예제 #28
0
        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;
        }
예제 #29
0
파일: IOHelper.cs 프로젝트: mkalinov/DMM365
        /// <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);
        }
예제 #30
0
        // 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;
            }
        }
예제 #31
0
		public frmSettings(AllSettings settings, VM vm)
		{
			this.settings = settings;
			this.vm = vm;
			InitializeComponent();
		}