public async Task <int> RunAsync(SetSettingCommandSettings commandSettings, CancellationToken cancellationToken)
        {
            var settingsLoader = new SettingsLoader();
            var settings       = await settingsLoader.Load(cancellationToken);

            if (string.Equals(commandSettings.SettingName, nameof(Settings.NumberValue), StringComparison.OrdinalIgnoreCase))
            {
                if (int.TryParse(commandSettings.SettingValue, out var numberValue))
                {
                    settings.NumberValue = numberValue;
                }
                else
                {
                    Console.WriteLine($"Could not convert '{commandSettings.SettingValue}' to an int.");
                    return(1);
                }
            }
            else if (string.Equals(commandSettings.SettingName, nameof(Settings.StringValue), StringComparison.OrdinalIgnoreCase))
            {
                settings.StringValue = commandSettings.SettingValue;
            }
            else
            {
                Console.WriteLine($"Unknown setting name: '{commandSettings.SettingName}'.");
                return(1);
            }

            await settingsLoader.Write(settings, cancellationToken);

            return(0);
        }
Esempio n. 2
0
        private void LoadSettings()
        {
            Logger.Log(LogLevel.Debug, "Loading settings...");
            var loader = new SettingsLoader <MeasurementSettings>();

            measurementSettings = loader.Load(settingsFileName);
        }
        public async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var settingsLoader = new SettingsLoader();
            var settings       = await settingsLoader.Load(cancellationToken);

            Console.WriteLine($"StringValue => {settings.StringValue ?? "<null>"}");
            Console.WriteLine($"NumberValue => {settings.NumberValue}");
            return(0);
        }
Esempio n. 4
0
        private static async Task Main(string[] args)
        {
            _settings = SettingsLoader.Load();
            Logger.Initialize(_settings.LogLevel, Path.Combine(Directory.GetCurrentDirectory(), "log.txt"), Version);

            await using var services = SetupServices();
            services.GetRequiredService <DatabaseHandler>().Initialize();
            await services.GetRequiredService <DiscordHandler>().InitializeAsync(services);

            await Task.Delay(-1);
        }
        public SettingsViewModel()
        {
            _settingsLoader           = SettingsLoader.Load();
            ProgramSettings           = _settingsLoader.GetSettings();
            _organizationManager      = Directory.GetOrganizationManager();
            _communicationTypeManager = Directory.GetCommunicationTypeManager();

            OrganizationViewModel      = new OrganizationViewModel();
            CommunicationTypeViewModel = new CommunicationTypeViewModel();

            AddedOrganization      = new Organization();
            AddedCommunicationType = new CommunicationType();
        }
Esempio n. 6
0
        public async Task <int> RunAsync(GetSettingCommandSettings commandSettings, CancellationToken cancellationToken)
        {
            var settingsLoader = new SettingsLoader();
            var settings       = await settingsLoader.Load(cancellationToken);

            if (string.Equals(commandSettings.SettingName, nameof(Settings.NumberValue), StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine(settings.NumberValue);
            }
            else if (string.Equals(commandSettings.SettingName, nameof(Settings.StringValue), StringComparison.OrdinalIgnoreCase))
            {
                Console.WriteLine(settings.StringValue ?? "<null>");
            }
            else
            {
                Console.WriteLine($"Unknown setting name: '{commandSettings.SettingName}'.");
                return(1);
            }

            return(0);
        }
Esempio n. 7
0
        static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(AppContext.BaseDirectory);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Task.Run(() => {
                InternalSettings.EnableWebPIfPossible();
                SettingsLoader.Load();
            });

            bool singleInstance = true;

            // -n means run as new instance
            if (args.Contains("-n"))
            {
                singleInstance = false;
            }
            else if (args.Length < 1)
            {
                singleInstance = false;
            }

            using (InstanceManager instanceManager = new InstanceManager(singleInstance, args, SingleInstanceCallback))
            {
                mainForm = new MainForm(args);
                Application.Run(mainForm);
            }

            Directory.SetCurrentDirectory(AppContext.BaseDirectory);

            if (InternalSettings.Delete_Temp_Directory && Directory.Exists(InternalSettings.Temp_Image_Folder))
            {
                Directory.Delete(InternalSettings.Temp_Image_Folder, true);
            }

            SettingsLoader.Save();
        }
Esempio n. 8
0
        private static async Task Main(string[] args)
        {
            _settings = SettingsLoader.Load();
            Logger.Initialize(LogType.Debug, Path.Combine(Directory.GetCurrentDirectory(), "log.txt"), "0.0.1");

            using (var services = SetupServices())
            {
                CheckArguments(args, services);
                services.GetRequiredService <DatabaseManager>().CheckConfig();
                await services.GetRequiredService <DiscordHandler>().InitializeAsync(services).ConfigureAwait(false);

                var trusted = services.GetRequiredService <DatabaseManager>().Get <BotConfig>("Config").UserAgents
                              .ToArray();
                services.GetService <HTTPServerManager>().Initialize(null, trusted);
                services.GetService <RSSManager>().Initialize();


                /* TODO
                 * Here you would put a command line program to manage the bot.
                 * Mainly so it can be shutdown safely (close/Dispose all the services).
                 * (IDisposable objects may not necessarilly be Disposed on program exit). */
                await Task.Delay(-1);
            }
        }
Esempio n. 9
0
 void When_the_project_is_loaded()
 {
     SettingsLoader.Load();
 }
Esempio n. 10
0
    // Update is called once per frame
    void Update()
    {
        Camera cam = gameObject.GetComponent<Camera> ();
        GameObject plane = GameObject.Find ("Root");

        if(!loaded)
        {
            loaded = true;

            SettingsLoader loader = new SettingsLoader();
            Settings settings = loader.Load();
            if(settings != null)
            {
                cam.fieldOfView = settings.cameraFOV;
                gameObject.transform.position = settings.getPosition();
                Quaternion rot = new Quaternion();

                rot.eulerAngles = settings.getRotation();

                plane.transform.rotation = rot;
            }
            else{

                Debug.Log ("Loading failed");
            }

        }

        if (Input.GetButton ("PS4_PS")) {
            Application.Quit();
        }

        if (Input.GetButton ("PS4_Square")) {
            if (!squarePressed) {
                squarePressed = true;

                SettingsLoader loader = new SettingsLoader();
                Settings settings = new Settings();
                settings.cameraFOV = cam.fieldOfView;
                settings.setPosition(gameObject.transform.position);
                settings.setRotation(plane.transform.rotation.eulerAngles);

                loader.Save(settings);
            }
        } else {
            squarePressed = false;
        }

        // Depth of field.
        float dpadX = Input.GetAxis ("PS4_DPadX");
        cam.fieldOfView += dpadX;

        // Translate camera.
        float leftX = Input.GetAxis ("PS4_LeftStickX");
        float leftY = Input.GetAxis ("PS4_LeftStickY");

        // Zoom camera.
        float l2 = Input.GetAxis ("PS4_L2");
        float r2 = Input.GetAxis ("PS4_R2");

        // Rot camera.
        float rightX = Input.GetAxis ("PS4_RightStickX");
        float rightY = Input.GetAxis ("PS4_RightStickY");
        //		Debug.LogFormat ("{0} {1}", rightX, rightY);

        float dz = 0;
        // L2 pressed
        if (l2 > 0) {
            dz+=l2;
        }

        if (r2 > 0) {
            dz -= r2;
        }

        Vector3 newPos = gameObject.transform.position;
        newPos.x += leftX;
        newPos.y +=dz;
        newPos.z -= leftY;
        gameObject.transform.position = newPos;

        Quaternion newPlaneRot = plane.transform.rotation;
        Vector3 angles = plane.transform.rotation.eulerAngles;
        angles.x += (rightY*2.0f);
        angles.z += (rightX*2.0f);
        // HACK
        if(angles.x == 90)
        {
            angles.x+=1;
        }
        newPlaneRot.eulerAngles = angles;
        plane.transform.rotation = newPlaneRot;

        //		at.x += rightX;
        //		at.z += rightY;
        //		gameObject.transform.LookAt (at);
        //
        //		if (rightX!=0f || rightY!=0f) {
        //			Vector3 newRot = gameObject.transform.rotation.eulerAngles;
        //			newRot.z += rightX;
        //			newRot.y += rightY;
        //
        //			Quaternion r = gameObject.transform.rotation;
        //			r.eulerAngles = newRot;
        //
        //			gameObject.transform.rotation = r;
        //		}
    }