public async Task <IProjectConfigurationSettingsAccess> OpenProjectSettingsAccessAsync(
            UnconfiguredProject unconfiguredProject, IRProjectProperties propertes)
        {
            Check.ArgumentNull(nameof(unconfiguredProject), unconfiguredProject);
            Check.ArgumentNull(nameof(propertes), propertes);
            SettingsAccess access = null;

            await _semaphore.WaitAsync();

            try {
                string projectFolder = Path.GetDirectoryName(unconfiguredProject.FullPath);
                if (!_settings.TryGetValue(projectFolder, out access))
                {
                    var settings = await OpenCollectionAsync(projectFolder, propertes);

                    var th = unconfiguredProject.Services?.ExportProvider?.GetExportedValue <IThreadHandling>();
                    access = new SettingsAccess(this, th, projectFolder, propertes, settings);
                    _settings[projectFolder] = access;
                }
                access.Counter.Increment();
            } finally {
                _semaphore.Release();
            }
            return(access);
        }
Пример #2
0
        public async void UpdateSettingTest()
        {
            try
            {
                int                 parallelnum   = 1000;
                SettingsAccess      settingAccess = new SettingsAccess();
                RecentHistoryAccess recenthistory = new RecentHistoryAccess();
                List <Task>         tasks         = new List <Task>(parallelnum);
                await LoginUtil.Instance.ValidateUserLogin("*****@*****.**", "1234", "AU");

                for (int i = 0; i < parallelnum; i++)
                {
                    tasks.Add(Task.Run(() =>
                    {
                        //settingAccess.GetSetting(BusinessModel.SettingsEnum.FontSize, "*****@*****.**", "AU")
                        settingAccess.UpdateSetting(i.ToString(), BusinessModel.SettingsEnum.FontSize, "*****@*****.**", "AU");
                        recenthistory.UpdateRecentHistory(new RecentHistory
                        {
                            BookId      = i,
                            TOCTitle    = "",
                            Email       = "*****@*****.**",
                            ServiceCode = "AU"
                        });
                        PublicationUtil.Instance.GetPublicationOnline();
                        PublicationContentUtil.Instance.GetRecentHistory();
                    }));
                }
                await Task.WhenAll(tasks);
            }
            catch (Exception)
            {
                throw;
            }
        }
Пример #3
0
        /// <summary>
        /// Создать планеты из списка
        /// </summary>
        /// <param name="cellItems">Список планет для создания</param>
        private void FillAdvancedVisiblePlanets(SortedCellItem[] cellItems)
        {
            _planets.DestroyAll();

            var precision = _zoom.GetZoomPrecision();

            for (int i = 0; i < cellItems.Length; i++)
            {
                var cellItem = cellItems[i];

                var cell = _cells.GetCell(cellItem.CellPos);

                var worldPos = cell.GetWordPosition(cellItem.Index);

                var posId = SettingsAccess.GetId(worldPos);

                var planet = _planets.Create(posId);

                planet.Show(worldPos, SettingsAccess.ConvertToWorldPosition(worldPos, precision), cellItem.Rating);
            }

            SetPosition();

            _prevRect = null;
        }
Пример #4
0
        public MainViewModel(IEventAggregator eventAggregator)
        {
            _eventAggregator = eventAggregator;
            _eventAggregator.GetEvent <ScriptInfoAddedEvent>().Subscribe(OnScriptInfoAdded);
            _eventAggregator.GetEvent <ScriptInfoChangedEvent>().Subscribe((scriptInfo) => ScriptInfo = scriptInfo);
            _eventAggregator.GetEvent <SettingsChangedEvent>().Subscribe((settings) => LoadSettings(settings));

            // Disable global hotkeys while user is changing hotkey
            _eventAggregator.GetEvent <SettingsWindowOpenEvent>().Subscribe(
                () => _winService.GlobalKeyDown -= OnGlobalHotkeyDown);
            _eventAggregator.GetEvent <SettingsWindowClosedEvent>().Subscribe(
                () => _winService.GlobalKeyDown += OnGlobalHotkeyDown);

            _settingsAccess = new SettingsAccess();
            _scriptAccess   = new ScriptAccess();

            _dialogService = new DialogService();
            _scriptService = new ScriptService();

            _winService = new WinService();
            _winService.GlobalKeyDown += OnGlobalHotkeyDown;
            _winService.GlobalKeyUp   += OnGlobalHotkeyUp;

            _automationService = new AutomationService();
            _automationService.RemoveFileModificationDetectedDialogOnCreated();

            _settings = _settingsAccess.LoadSettings();

            FormViewModel = new ScriptInfoViewModel(eventAggregator, SaveScriptInfoAction);

            LoadCommands();
            LoadSettings(_settings, firstTime: true);
            ScriptNames = _scriptAccess.GetScriptNames();
        }
Пример #5
0
        /// <summary>
        /// Создать или добавить ячейку на поле
        /// </summary>
        /// <param name="centerCellPos">Координаты центральной ячейки, для расчёта координат полностью генерируемых ячеек</param>
        /// <param name="cellPos">Координаты ячейки</param>
        /// <returns>Ячейка для заданной позиции</returns>
        private CellInfo GetOrCreateCell(Vector2Int centerCellPos, Vector2Int cellPos)
        {
            var index = SettingsAccess.GetFieldIndex(cellPos);

            CellInfo cell = _cells[index];

            if (cell == null)
            {
                cell = new CellInfo();

                _cells[index] = cell;
            }

            ushort[] ratings = null;

            // Если эта ячейка должна быть сгенерирована полностью, найдём для неё индекс реиспользуемого массива
            int visibleIndex = GetFullGenerationIndex(centerCellPos, cellPos);

            if (visibleIndex != -1)
            {
                ratings = _fullGenerationRatingsArray[visibleIndex];

                if (ratings == null)
                {
                    ratings = new ushort[SettingsAccess.CellPxLenght];

                    _fullGenerationRatingsArray[visibleIndex] = ratings;
                }
            }

            cell.InitCell(cellPos, ratings);

            return(cell);
        }
Пример #6
0
        /// <summary>
        /// Отобразить планеты, входящие в прямоугольник
        /// </summary>
        /// <param name="rect">Прямоугольник в который входят планеты, которые требуется создать</param>
        private void FillPlanets(RectInt rect)
        {
            var iterator = rect.allPositionsWithin;

            CellInfo cell = null;

            while (iterator.MoveNext())
            {
                var worldPos = iterator.Current;
                var cellPos  = SettingsAccess.GetCellBeginPosition(worldPos);

                if (cell == null ||
                    cell.Pos != cellPos)
                {
                    cell = _cells.GetCell(cellPos);
                }

                var cellItemPos = cell.GetCellItemPosition(worldPos);

                var rating = cell.GetRating(cellItemPos);

                if (rating > 0)
                {
                    var posId = SettingsAccess.GetId(worldPos);

                    var planet = _planets.Create(posId);

                    planet.Show(worldPos, SettingsAccess.ConvertToWorldPosition(worldPos), rating);
                }
            }
        }
Пример #7
0
        public void CellBeginPositionCheck()
        {
            Vector2Int[] positions = new Vector2Int[]
            {
                new Vector2Int(0, 0),
                new Vector2Int(50, 50),
                new Vector2Int(99, 99),
                new Vector2Int(-50, -50),
                new Vector2Int(-99, -99),
                new Vector2Int(-1, -1),
                new Vector2Int(-99, 100),
            };

            Vector2Int[] cellPositions = new Vector2Int[]
            {
                new Vector2Int(0, 0),
                new Vector2Int(0, 0),
                new Vector2Int(0, 0),
                new Vector2Int(-100, -100),
                new Vector2Int(-100, -100),
                new Vector2Int(-100, -100),
                new Vector2Int(-100, 100),
            };

            Assert.AreEqual(positions.Length, cellPositions.Length);

            for (int i = 0; i < positions.Length; i++)
            {
                Assert.AreEqual(cellPositions[i], SettingsAccess.GetCellBeginPosition(positions[i]), string.Format("for {0}", i));
            }
        }
Пример #8
0
        public static void Initialize()
        {
            sessionAccess  = new SessionAccess();
            settingsAccess = new SettingsAccess();

            var sessionResult  = sessionAccess.LoadSession();
            var settingsResult = settingsAccess.LoadSettings();

            if (sessionResult.Status != Status.Success)
            {
                sessionResult.Print();
            }

            if (settingsResult.Status != Status.Success)
            {
                settingsResult.Print();
            }

            Session  = sessionResult.Data;
            Settings = settingsResult.Data;


            Author        = "Near Huscarl";
            License       = "BSD 3-Clauses";
            SourceCodeURL = "https://github.com/NearHuscarl/Breakout";

            ScoreFont = new FontShape(width: 6, height: 18);
            MenuFont  = new FontShape(width: 9, height: 20);

            SpriteData = new SpriteData();

            Theme = new Dictionary <string, Color>()
            {
                { "Red", "#c0392b".ToColor() },
                { "Orange", "#d35400".ToColor() },
                { "Yellow", "#f39c12".ToColor() },
                { "Green", "#27ae60".ToColor() },
                { "Blue", "#2980b9".ToColor() },
                { "Cyan", "#16a085".ToColor() },
                { "Magenta", "#8e44ad".ToColor() },
                { "Gray", "#7f8c8d".ToColor() },
                { "Black", "#2c3e50".ToColor() },

                { "LightRed", "#e74c3c".ToColor() },
                { "LightOrange", "#e67e22".ToColor() },
                { "LightYellow", "#f1c40f".ToColor() },
                { "LightGreen", "#2ecc71".ToColor() },
                { "LightBlue", "#3498db".ToColor() },
                { "LightCyan", "#1abc9c".ToColor() },
                { "LightMagenta", "#9b59b6".ToColor() },
                { "LightGray", "#95a5a6".ToColor() },
                { "Dark", "#34495e".ToColor() },

                { "Silver", "#bdc3c7".ToColor() },
                { "White", "#ecf0f1".ToColor() },
            };

            ExplosiveRadius = 40;
        }
Пример #9
0
 public bool updateSettings(string username, string setString)
 {
     return(SettingsAccess.SaveOrUpdate(new Settings()
     {
         settings = setString,
         username = username
     }));
 }
Пример #10
0
        public void LineEnumeratorCheck()
        {
            var rect = SettingsAccess.GetFieldRectPx(Vector2Int.zero);

            CheckLine(rect, 100, 100);
            CheckLine(rect, 100, 1000);
            CheckLine(rect, 1000, 100);
            CheckLine(rect, 1000, 1000);
        }
Пример #11
0
        /// <summary>
        /// Возвращает индекс для полной генерации мира вокруг игрока <see cref="_fullGenerationRatingsArray"/>
        /// </summary>
        /// <returns>Индекс массива</returns>
        private int GetFullGenerationIndex(Vector2Int centerCellPosition, Vector2Int cellPos)
        {
            if (SettingsAccess.GetRadius(centerCellPosition, cellPos) <= SettingsAccess.FullGeneratedCellsRadius)
            {
                return(Mathf.Abs(cellPos.x % SettingsAccess.FullGeneratedCellsRadiusSize + cellPos.y % SettingsAccess.FullGeneratedCellsRadiusSize * SettingsAccess.FullGeneratedCellsRadiusSize));
            }

            return(-1);
        }
Пример #12
0
        /// <summary>
        /// Инициализация поля
        /// </summary>
        /// <param name="zoom">Зум поля</param>
        /// <param name="progress">Прогресс инициализации</param>
        /// <param name="input">Управление игроком</param>
        /// <param name="debug">Отладка</param>
        public void Init(ZoomControl zoom, ProgressBar progress, IPlayerInput input, IGameDebug debug)
        {
            // Подпишемся на изменения зума
            _zoom = zoom;

            _input = input;

            // Инициализируем случайные значения положения игрока на поле и его рейтинг
            _currentCellPosition     = SettingsAccess.GetRandomFieldPosition();
            _currentCellItemPosition = SettingsAccess.GetRandomCellPosition(_currentCellPosition);
            _playerRating            = NoiseTool.GetRandomPlayerRating();

            // Инициализируем коллекцию ячеек
            _cells = new CellCollection(_playerRating);

            // Инициализируем механизм поиска первых <see cref="SettingsAccess.MaxAdvancedVisiblePlanet"/> планет, ближайших по рейтингу к рейтингу игрока
            _sortedCellsVisitor = gameObject.AddComponent <SortedCellsVisitor>().Init(_cells, _playerRating, debug);
            _sortedCellsVisitor.OnProcessEnd += OnSearchTopRatingsEnd;

            string generationString;

            if (SystemInfo.supportsComputeShaders)
            {
                // Если поддерживаются Computed Shader
                _generator = gameObject.AddComponent <ComputedShaderNoiseGenerator>()
                             .SetDebug(debug);

                generationString = "GENERATE COMPUTED SHADER";
            }
            else
            {
#if (UNITY_ANDROID)
                // По идее, должен поддерживаться большинством платформ, добавлять директивы препроцессора по мере тестирования
                _generator = gameObject.AddComponent <CustomRenderTextureNoiseGenerator>()
                             .SetDebug(debug);

                generationString = "GENERATE RENDER TEXTURE";
#else
                // Для всех остальных платформ.
                _generator = gameObject.AddComponent <CpuNoiseGenerator>()
                             .SetDebug(debug);

                generationString = "GENERATE CPU";
#endif
            }

            _generator.OnProcessEnd += OnGenerationEnd;

            // Добавим первое задание на генерацию всего поля
            _generator.AppendRect(SettingsAccess.GetFieldRectPx(_currentCellPosition));

            // Отобразим прогресс
            progress.Begin(() => _generator.GetProgress(), generationString, OnEndInit);
        }
Пример #13
0
        /// <summary>
        /// Возвращает ячейку по её индексу
        /// </summary>
        /// <param name="cellPos"></param>
        /// <returns></returns>
        public CellInfo GetCell(Vector2Int cellPos)
        {
            var cell = _cells[SettingsAccess.GetFieldIndex(cellPos)];

            if (cell.Pos != cellPos)
            {
                return(null);
            }

            return(cell);
        }
Пример #14
0
        public void CellRadiusCheck()
        {
            for (int radius = 1; radius < 10; radius++)
            {
                var size = SettingsAccess.RadiusToLength(radius);

                for (int index = 0; index < size; index++)
                {
                    var pos = SpiralPositionsIterator.Spiral(index) * radius;

                    Assert.GreaterOrEqual(radius, SettingsAccess.GetRadius(Vector2Int.zero, pos));
                }
            }
        }
Пример #15
0
        /// <summary>
        /// Установить текущую позицию поля и игрока
        /// </summary>
        private void SetPosition()
        {
            var playerPos = SettingsAccess.ConvertToWorldPosition(_currentCellItemPosition, _zoom.GetZoomPrecision());

            if (_zoom.IsCellsView())
            {
                _tr.position = SettingsAccess.ConvertToWorldPosition(_currentCellPosition + Vector2Int.one * SettingsAccess.HalfCellPxSize, _zoom.GetZoomPrecision());
            }
            else
            {
                _tr.position = playerPos;
            }

            _player.SetPosition(playerPos);
        }
Пример #16
0
        public CreateNewScriptViewModel(IEventAggregator eventAggregator, Action closeAction)
        {
            _eventAggregator = eventAggregator;
            _scriptService   = new ScriptService();
            _scriptAccess    = new ScriptAccess();
            _settingsAccess  = new SettingsAccess();

            _settings = _settingsAccess.LoadSettings();

            FormViewModel      = new ScriptInfoViewModel(eventAggregator, AddScriptInfoAction);
            FormViewModel.Mode = ChangeMode.Add;

            Close        = closeAction;
            CloseCommand = new DelegateCommand(() => Close());
        }
Пример #17
0
        /// <summary>
        /// Очистить прямоугольник от планет
        /// </summary>
        /// <param name="rect">Прямоугольник который требуется очистить от планет</param>
        private void ClearPlanets(RectInt rect)
        {
            var iterator = rect.allPositionsWithin;

            while (iterator.MoveNext())
            {
                var posId = SettingsAccess.GetId(iterator.Current);

                var planet = _planets.GetByIdOrNull(posId);

                if (planet != null)
                {
                    planet.Destroy();
                }
            }
        }
Пример #18
0
        /// <summary>
        /// Изменилась текущая позиция игрока на поле
        /// </summary>
        private void OnPlayerPositionChanged()
        {
            var newCellPosition = SettingsAccess.GetCellBeginPosition(_currentCellItemPosition);

            // Если изменилась текущая ячейка игрока на поле, добавим разницу между прямоугольниками старых и новых координат игрока на генерацию
            if (newCellPosition != _currentCellPosition)
            {
                var prevRect        = SettingsAccess.GetFieldRectPx(_currentCellPosition);
                var prevVisibleRect = SettingsAccess.GetFullGenerationRect(_currentCellPosition);

                var newRect        = SettingsAccess.GetFieldRectPx(newCellPosition);
                var newVisibleRect = SettingsAccess.GetFullGenerationRect(newCellPosition);

                // Разница между старым прямоугольником всего поля и текущим
                var rectsToFill = RectIntTool.Subtract(newRect, prevRect);
                // Разница между старым прямоугольником полностью генерируемого мира вокруг игрока и текущим
                var visibleRectsFill = RectIntTool.Subtract(newVisibleRect, prevVisibleRect);

                visibleRectsFill.AddRange(rectsToFill);

                if (visibleRectsFill.Count > 0)
                {
                    // Добавить задание на генерацию - сперва прямоугольники полностью генерируемых ячеек вокруг игрока, потом прямоугольники поля
                    _generator.AppendRects(visibleRectsFill, true);
                }

                _currentCellPosition = newCellPosition;
            }

            if (_zoom.IsAdvancedView() == false)
            {
                RefreshNormalVisibleArea();

                SetPosition();
            }
            else
            {
                if (_zoom.IsCellsView())
                {
                    _sortedCellsVisitor.AppendRect(_zoom.GetVisibleRect(_currentCellPosition));
                }
                else
                {
                    _sortedCellsVisitor.AppendRect(_zoom.GetVisibleRect(_currentCellItemPosition));
                }
            }
        }
Пример #19
0
        public OptionViewModel(IEventAggregator eventAggregator, Action closeAction)
        {
            _eventAggregator = eventAggregator;
            _eventAggregator.GetEvent <SettingsWindowOpenEvent>().Publish();
            _settingsAccess = new SettingsAccess();

            _settings = _settingsAccess.LoadSettings();

            CopyToClipboardHotkey   = _settings.CopyToClipboardHotkey;
            CompileHotkey           = _settings.CompileHotkey;
            CompileAndRunHotkey     = _settings.CompileAndRunHotkey;
            GenerateExtensionScript = _settings.GenerateExtensionScript;

            Close = closeAction;

            SaveSettingsCommand = new DelegateCommand(SaveSettings);
            CloseCommand        = new DelegateCommand(() => Close());
        }
Пример #20
0
        public void CellsIndexCheck()
        {
            Vector2Int[] exists = new Vector2Int[]
            {
                new Vector2Int(6000, -6000)
            };

            Vector2Int[] check = new Vector2Int[]
            {
                new Vector2Int(-6000, -6000)
            };

            for (int i = 0; i < exists.Length; i++)
            {
                Assert.AreNotEqual(SettingsAccess.GetFieldIndex(exists[i]), SettingsAccess.GetFieldIndex(check[i]));
            }

            uint[] idList = new uint[SettingsAccess.FieldLength];

            for (int x = 0; x < SettingsAccess.FieldSize; x++)
            {
                for (int y = 0; y < SettingsAccess.FieldSize; y++)
                {
                    var index = SettingsAccess.GetFieldIndex(new Vector2Int(x, y) * SettingsAccess.CellPxSize);

                    Assert.AreEqual(idList[index], 0);

                    idList[index] = index;
                }
            }

            for (int x = SettingsAccess.FieldSize * -3; x < SettingsAccess.FieldSize * 4; x++)
            {
                for (int y = SettingsAccess.FieldSize * -3; y < SettingsAccess.FieldSize * 4; y++)
                {
                    var index = SettingsAccess.GetFieldIndex(new Vector2Int(x, y) * SettingsAccess.CellPxSize);

                    Assert.AreEqual(idList[index], index);
                }
            }
        }
Пример #21
0
        /// <summary>
        /// Сортирует следущие <see cref="_sliceLenght"/> позиций по координатам из <see cref="_iterator"/>
        /// </summary>
        private void VisitNext()
        {
            if (_isVisitEnded)
            {
                return;
            }

            for (int i = 0; i < _sliceLenght; i++)
            {
                if (_iterator.MoveNext() == false)
                {
                    EndProcess();

                    return;
                }

                if (_size == SettingsAccess.CellPxSize)
                {
                    _cell = _cells.GetCell(_iterator.Current);

                    if (_cell == null)
                    {
                        EndProcess();

                        return;
                    }

                    _sortedCells.Append(_cell.SortedCellItems);
                }
                else
                {
                    var cellPos = SettingsAccess.GetCellBeginPosition(_iterator.Current);

                    if (_cell == null ||
                        _cell.Pos != cellPos)
                    {
                        _cell = _cells.GetCell(cellPos);
                    }

                    if (_cell == null)
                    {
                        EndProcess();

                        return;
                    }

                    var cellItemPos = _cell.GetCellItemPosition(_iterator.Current);

                    ushort index = _cell.GetCellItemIndex(cellItemPos);

                    var rating = _cell.GetRating(index);

                    if (rating > 0)
                    {
                        var ratingDistance = (ushort)Mathf.Abs(rating - _playerRating);

                        if (_sortedCells.IsBelowThanMaxRatingDistance(ratingDistance))
                        {
                            _sortedCells.AppendCellItemFast(new SortedCellItem(cellPos, index, rating, ratingDistance));
                        }
                    }
                }
            }
        }
Пример #22
0
 public SettingsLogic()
 {
     settingsAccess = new SettingsAccess();
 }
Пример #23
0
        /// <summary>
        /// Ячейка с такой позицией существует на поле
        /// </summary>
        /// <param name="cellPos">Позиция</param>
        /// <returns>Результат проверки</returns>
        public bool IsCellExist(Vector2Int cellPos)
        {
            var index = SettingsAccess.GetFieldIndex(cellPos);

            return(_cells[index] != null);
        }
Пример #24
0
 public Settings getUserSetting(string username)
 {
     return(SettingsAccess.Get(username));
 }
Пример #25
0
 /// <summary>
 /// Уникальный индентификатор элемента пулинга
 /// </summary>
 /// <returns>Идентификатор</returns>
 public override int GetId()
 {
     return(SettingsAccess.GetId(_cellItemPosition));
 }
Пример #26
0
 /// <summary>
 /// Reduces the given ratio to their lowest rational representation.
 /// </summary>
 public static Tuple <int, int> GetAspectRatio(int width, int height)
 {
     return(GetAspectRatio(width, height, SettingsAccess.GetInstance()));
 }