Beispiel #1
0
        public void CleanUp()
        {
            // delete folder created.
            string generalSettings_file_name = string.Empty;

            if (SettingsUtils.SettingsFolderExists(generalSettings_file_name))
            {
                DeleteFolder(generalSettings_file_name);
            }

            if (SettingsUtils.SettingsFolderExists(Module))
            {
                DeleteFolder(Module);
            }
        }
Beispiel #2
0
        public void JPEGQualityLevelShouldSetValueToTenWhenSuccessful()
        {
            // arrange
            var fileSystemMock    = new MockFileSystem();
            var mockSettingsUtils = new SettingsUtils(fileSystemMock);
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG);

            // act
            viewModel.JPEGQualityLevel = 10;

            // Assert
            viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG);
            Assert.AreEqual(10, viewModel.JPEGQualityLevel);
        }
Beispiel #3
0
        public void TiffCompressOptionShouldSetValueToTenWhenSuccessful()
        {
            // arrange
            var mockIOProvider    = IIOProviderMocks.GetMockIOProviderForSaveLoadExists();
            var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object);
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);

            // act
            viewModel.TiffCompressOption = 10;

            // Assert
            viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);
            Assert.AreEqual(10, viewModel.TiffCompressOption);
        }
Beispiel #4
0
        private void LoadSettingsFromJson()
        {
            // TODO this IO call should by Async, update GetFileWatcher helper to support async
            lock (_loadingSettingsLock)
            {
                {
                    var retry      = true;
                    var retryCount = 0;

                    while (retry)
                    {
                        try
                        {
                            retryCount++;

                            if (!SettingsUtils.SettingsExists(ColorPickerModuleName))
                            {
                                Logger.LogInfo("ColorPicker settings.json was missing, creating a new one");
                                var defaultColorPickerSettings = new ColorPickerSettings();
                                defaultColorPickerSettings.Save();
                            }
                            var settings = SettingsUtils.GetSettings <ColorPickerSettings>(ColorPickerModuleName);
                            if (settings != null)
                            {
                                ChangeCursor.Value              = settings.properties.ChangeCursor;
                                ActivationShortcut.Value        = settings.properties.ActivationShortcut.ToString();
                                CopiedColorRepresentation.Value = settings.properties.CopiedColorRepresentation;
                            }

                            retry = false;
                        }
                        catch (IOException ex)
                        {
                            if (retryCount > MaxNumberOfRetry)
                            {
                                retry = false;
                            }
                            Logger.LogError("Failed to read changed settings", ex);
                            Thread.Sleep(500);
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError("Failed to read changed settings", ex);
                        }
                    }
                };
            }
        }
        public void SaveSettingsShouldCreateFileWhenFilePathIsNotFound()
        {
            // Arrange
            var    mockFileSystem = new MockFileSystem();
            var    settingsUtils  = new SettingsUtils(mockFileSystem);
            string file_name      = "test\\Test Folder";
            string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";

            BasePTSettingsTest expected_json = JsonSerializer.Deserialize <BasePTSettingsTest>(file_contents_correct_json_content);

            settingsUtils.SaveSettings(file_contents_correct_json_content, file_name);
            BasePTSettingsTest actual_json = settingsUtils.GetSettings <BasePTSettingsTest>(file_name);

            // Assert
            Assert.AreEqual(expected_json.ToJsonString(), actual_json.ToJsonString());
        }
Beispiel #6
0
        public void EncoderShouldUpdateValueWhenSuccessful()
        {
            // arrange
            var mockIOProvider    = IIOProviderMocks.GetMockIOProviderForSaveLoadExists();
            var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object);
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);

            // act
            viewModel.Encoder = 3;

            // Assert
            viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);
            Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.EncoderGuid);
            Assert.AreEqual(3, viewModel.Encoder);
        }
        public PowerPreviewViewModel()
        {
            try
            {
                Settings = SettingsUtils.GetSettings <PowerPreviewSettings>(ModuleName);
            }
            catch
            {
                Settings = new PowerPreviewSettings();
                SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
            }

            this._svgRenderIsEnabled    = Settings.Properties.EnableSvgPreview;
            this._svgThumbnailIsEnabled = Settings.Properties.EnableSvgThumbnail;
            this._mdRenderIsEnabled     = Settings.Properties.EnableMdPreview;
        }
Beispiel #8
0
        public void FileNameShouldUpdateValueWhenSuccessful()
        {
            // arrange
            var fileSystemMock    = new MockFileSystem();
            var mockSettingsUtils = new SettingsUtils(fileSystemMock);
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
            string expectedValue = "%1 (%3)";

            // act
            viewModel.FileName = expectedValue;

            // Assert
            viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
            Assert.AreEqual(expectedValue, viewModel.FileName);
        }
Beispiel #9
0
        public void CleanUp()
        {
            // delete folder created.
            string generalSettings_file_name = string.Empty;
            if (SettingsUtils.SettingsFolderExists(generalSettings_file_name))
            {
                DeleteFolder(generalSettings_file_name);
            }

            if (SettingsUtils.SettingsFolderExists(ModuleName))
            {
                DeleteFolder(ModuleName);
            }

            ShellPage.DefaultSndMSGCallback = null;
        }
Beispiel #10
0
        public void EncoderShouldUpdateValueWhenSuccessful()
        {
            // arrange
            var fileSystemMock    = new MockFileSystem();
            var mockSettingsUtils = new SettingsUtils(fileSystemMock);
            Func <string, int>    sendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);

            // act
            viewModel.Encoder = 3;

            // Assert
            viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(_mockGeneralSettingsUtils.Object), sendMockIPCConfigMSG, (string name) => name);
            Assert.AreEqual("163bcc30-e2e9-4f0b-961d-a3e9fdb788a3", viewModel.EncoderGuid);
            Assert.AreEqual(3, viewModel.Encoder);
        }
        static SearchDialogIndexClient()
        {
            var indexName = SettingsUtils.GetAppSettings("SearchDialogsIndexName");
            var adminKey  = SettingsUtils.GetAppSettings("SearchDialogsServiceAdminKey");

            if (adminKey != null)
            {
                var adminClient = new SearchServiceClient(SettingsUtils.GetAppSettings("SearchDialogsServiceName"),
                                                          new SearchCredentials(adminKey));
                schema = new SearchSchema().AddFields(adminClient.Indexes.Get(indexName).Fields);
            }
            var client = new SearchServiceClient(SettingsUtils.GetAppSettings("SearchDialogsServiceName"),
                                                 new SearchCredentials(SettingsUtils.GetAppSettings("SearchDialogsServiceKey")));

            searchClient = client.Indexes.GetClient(indexName);
        }
Beispiel #12
0
        public void FileNameShouldUpdateValueWhenSuccessful()
        {
            // arrange
            var mockIOProvider    = IIOProviderMocks.GetMockIOProviderForSaveLoadExists();
            var mockSettingsUtils = new SettingsUtils(mockIOProvider.Object);
            Func <string, int>    SendMockIPCConfigMSG = msg => { return(0); };
            ImageResizerViewModel viewModel            = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);
            string expectedValue = "%1 (%3)";

            // act
            viewModel.FileName = expectedValue;

            // Assert
            viewModel = new ImageResizerViewModel(mockSettingsUtils, SettingsRepository <GeneralSettings> .GetInstance(mockGeneralSettingsUtils.Object), SendMockIPCConfigMSG);
            Assert.AreEqual(expectedValue, viewModel.FileName);
        }
        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            base.OnClosing(e);
            RCONWindow.CloseAllWindows();
            PlayerListWindow.CloseAllWindows();
            ServerMonitorWindow.CloseAllWindows();
            this.versionChecker.DisposeAsync().DoNotWait();

            var installFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            var backupFolder  = IOUtils.NormalizePath(string.IsNullOrWhiteSpace(Config.Default.BackupPath)
                ? Path.Combine(Config.Default.DataDir, Config.Default.BackupDir)
                : Path.Combine(Config.Default.BackupPath));

            SettingsUtils.BackupUserConfigSettings(Config.Default, "userconfig.json", installFolder, backupFolder);
            SettingsUtils.BackupUserConfigSettings(CommonConfig.Default, "commonconfig.json", installFolder, backupFolder);
        }
Beispiel #14
0
        public void CleanUp()
        {
            // delete general settings folder created.
            string generalSettings_file_name = string.Empty;

            if (SettingsUtils.SettingsFolderExists(string.Empty))
            {
                DeleteFolder(string.Empty);
            }

            // delete fancy zones folder created.
            if (SettingsUtils.SettingsFolderExists(FancyZonesTestFolderName))
            {
                DeleteFolder(FancyZonesTestFolderName);
            }
        }
        public KeyboardManagerPage()
        {
            dispatcher = Window.Current.Dispatcher;

            var settingsUtils = new SettingsUtils(new SystemIOProvider());

            ViewModel = new KeyboardManagerViewModel(settingsUtils, SettingsRepository <GeneralSettings> .GetInstance(settingsUtils), ShellPage.SendDefaultIPCMessage, FilterRemapKeysList);

            watcher = Helper.GetFileWatcher(
                PowerToyName,
                ViewModel.Settings.Properties.ActiveConfiguration.Value + ".json",
                OnConfigFileUpdate);

            InitializeComponent();
            DataContext = ViewModel;
        }
Beispiel #16
0
        private void NavigateLink(object sender, TappedRoutedEventArgs e)
        {
            // If selected item is null (no selection) do nothing
            var list = sender as ListView;

            if (e.OriginalSource == null || !(e.OriginalSource is FrameworkElement))
            {
                return;
            }

            var selectedItem = ((FrameworkElement)e.OriginalSource).DataContext as ItemViewModel;

            if (selectedItem == null)
            {
                return;
            }

            try
            {
                SettingsUtils.Set <int>(Constants.PREF_LAST_PAGE, selectedItem.PageNumber);

                // Navigate to the new page
                if (selectedItem.SelectedAyah == null)
                {
                    Frame.Navigate(typeof(DetailsView));
                }
                else
                {
                    Frame.Navigate(typeof(DetailsView),
                                   new NavigationData
                    {
                        Surah = selectedItem.SelectedAyah.Surah,
                        Ayah  = selectedItem.SelectedAyah.Ayah
                    });
                }
            }
            catch (Exception ex)
            {
                telemetry.TrackException(ex, new Dictionary <string, string> {
                    { "Scenario", "NavigateFromMainView" }
                });
                // Navigation exception - ignore
            }

            // Reset selected item to null (no selection)
            list.SelectedItem = null;
        }
        // Token: 0x060001AB RID: 427 RVA: 0x00006A90 File Offset: 0x00004C90
        private void insertOrUpdateUser(bool insertOrUpdate)
        {
            string   text   = this.nameTB.Text;
            string   value  = this.identityCardNumTB.Text.Trim();
            string   text2  = this.phoneNumTB.Text;
            string   text3  = this.addressTB.Text;
            string   value2 = string.Concat(this.getSelectUserTypeId());
            string   value3 = string.Concat(this.getSelectPriceConsistId());
            DateTime now    = DateTime.Now;
            long     num    = (long)(now - CreateUserInNumbersForm.DT1970).TotalSeconds;

            if (this.firstCreateTime == 0L)
            {
                this.firstCreateTime = num;
            }
            DbUtil    dbUtil    = new DbUtil();
            DataTable dataTable = dbUtil.ExecuteQuery("SELECT userId+1 AS newID FROM usersTable WHERE userId+1 NOT IN (SELECT userId FROM usersTable) AND userId+1 BETWEEN 1 AND 4294967295 ORDER BY newID ASC");

            if (dataTable == null || dataTable.Rows.Count <= 0)
            {
                WMMessageBox.Show("无可用设备号!");
                return;
            }
            DataRow dataRow = dataTable.Rows[0];
            long    num2    = Convert.ToInt64(dataRow["newID"]);

            dbUtil.AddParameter("userId", insertOrUpdate ? string.Concat(num2) : this.userIdModified);
            dbUtil.AddParameter("username", text);
            dbUtil.AddParameter("phoneNum", text2);
            dbUtil.AddParameter("identityId", value);
            dbUtil.AddParameter("address", text3);
            dbUtil.AddParameter("isActive", "0");
            dbUtil.AddParameter("opeartor", MainForm.getStaffId());
            dbUtil.AddParameter("userArea", this.userAreaNumTB.Text.Trim());
            dbUtil.AddParameter("userPersons", this.usrePersonsTB.Text.Trim());
            dbUtil.AddParameter("userTypeId", value2);
            dbUtil.AddParameter("userPriceConsistId", value3);
            dbUtil.AddParameter("userBalance", "0");
            dbUtil.AddParameter("createTime", string.Concat(num));
            dbUtil.AddParameter("permanentUserId", string.Concat(SettingsUtils.getLatestId("usersTable", "permanentUserId", 1L)));
            if (insertOrUpdate)
            {
                dbUtil.ExecuteNonQuery("INSERT INTO usersTable(userId, username, phoneNum, identityId, address, isActive, operator, permanentUserId, userArea, userPersons, userTypeId,userPriceConsistId, userBalance,createTime) VALUES (@userId, @username, @phoneNum, @identityId, @address, @isActive, @opeartor,@permanentUserId, @userArea, @userPersons, @userTypeId,@userPriceConsistId, @userBalance,@createTime)");
                return;
            }
            dbUtil.ExecuteNonQuery("UPDATE usersTable SET username=@username, phoneNum=@phoneNum, identityId=@identityId, address=@address, userArea=@userArea, userPersons=@userPersons, userTypeId=@userTypeId, userPriceConsistId=@userPriceConsistId, createTime=@createTime WHERE userId=@userId");
        }
Beispiel #18
0
        public void OriginalFilesModificationTest(string version, string fileName)
        {
            var settingPathMock = new Mock <ISettingsPath>();

            var fileMock          = BackCompatTestProperties.GetModuleIOProvider(version, FancyZonesSettings.ModuleName, fileName);
            var mockSettingsUtils = new SettingsUtils(fileMock.Object, settingPathMock.Object);
            FancyZonesSettings originalSettings = mockSettingsUtils.GetSettings <FancyZonesSettings>(FancyZonesSettings.ModuleName);

            var             mockGeneralIOProvider    = BackCompatTestProperties.GetGeneralSettingsIOProvider(version);
            var             mockGeneralSettingsUtils = new SettingsUtils(mockGeneralIOProvider.Object, settingPathMock.Object);
            GeneralSettings originalGeneralSettings  = mockGeneralSettingsUtils.GetSettings <GeneralSettings>();

            var generalSettingsRepository = new BackCompatTestProperties.MockSettingsRepository <GeneralSettings>(mockGeneralSettingsUtils);
            var fancyZonesRepository      = new BackCompatTestProperties.MockSettingsRepository <FancyZonesSettings>(mockSettingsUtils);

            // Initialise View Model with test Config files
            FancyZonesViewModel viewModel = new FancyZonesViewModel(generalSettingsRepository, fancyZonesRepository, ColorPickerIsEnabledByDefault_IPC);

            // Verify that the old settings persisted
            Assert.AreEqual(originalGeneralSettings.Enabled.FancyZones, viewModel.IsEnabled);
            Assert.AreEqual(originalSettings.Properties.FancyzonesAppLastZoneMoveWindows.Value, viewModel.AppLastZoneMoveWindows);
            Assert.AreEqual(originalSettings.Properties.FancyzonesBorderColor.Value, viewModel.ZoneBorderColor);
            Assert.AreEqual(originalSettings.Properties.FancyzonesDisplayChangeMoveWindows.Value, viewModel.DisplayChangeMoveWindows);
            Assert.AreEqual(originalSettings.Properties.FancyzonesEditorHotkey.Value.ToString(), viewModel.EditorHotkey.ToString());
            Assert.AreEqual(originalSettings.Properties.FancyzonesExcludedApps.Value, viewModel.ExcludedApps);
            Assert.AreEqual(originalSettings.Properties.FancyzonesHighlightOpacity.Value, viewModel.HighlightOpacity);
            Assert.AreEqual(originalSettings.Properties.FancyzonesInActiveColor.Value, viewModel.ZoneInActiveColor);
            Assert.AreEqual(originalSettings.Properties.FancyzonesMakeDraggedWindowTransparent.Value, viewModel.MakeDraggedWindowsTransparent);
            Assert.AreEqual(originalSettings.Properties.FancyzonesMouseSwitch.Value, viewModel.MouseSwitch);
            Assert.AreEqual(originalSettings.Properties.FancyzonesMoveWindowsAcrossMonitors.Value, viewModel.MoveWindowsAcrossMonitors);
            Assert.AreEqual(originalSettings.Properties.FancyzonesMoveWindowsBasedOnPosition.Value, viewModel.MoveWindowsBasedOnPosition);
            Assert.AreEqual(originalSettings.Properties.FancyzonesOpenWindowOnActiveMonitor.Value, viewModel.OpenWindowOnActiveMonitor);
            Assert.AreEqual(originalSettings.Properties.FancyzonesOverrideSnapHotkeys.Value, viewModel.OverrideSnapHotkeys);
            Assert.AreEqual(originalSettings.Properties.FancyzonesRestoreSize.Value, viewModel.RestoreSize);
            Assert.AreEqual(originalSettings.Properties.FancyzonesShiftDrag.Value, viewModel.ShiftDrag);
            Assert.AreEqual(originalSettings.Properties.FancyzonesShowOnAllMonitors.Value, viewModel.ShowOnAllMonitors);
            Assert.AreEqual(originalSettings.Properties.FancyzonesSpanZonesAcrossMonitors.Value, viewModel.SpanZonesAcrossMonitors);
            Assert.AreEqual(originalSettings.Properties.FancyzonesZoneHighlightColor.Value, viewModel.ZoneHighlightColor);
            Assert.AreEqual(originalSettings.Properties.FancyzonesZoneSetChangeMoveWindows.Value, viewModel.ZoneSetChangeMoveWindows);
            Assert.AreEqual(originalSettings.Properties.UseCursorposEditorStartupscreen.Value, viewModel.UseCursorPosEditorStartupScreen);

            // Verify that the stub file was used
            var expectedCallCount = 2;  // once via the view model, and once by the test (GetSettings<T>)

            BackCompatTestProperties.VerifyModuleIOProviderWasRead(fileMock, FancyZonesSettings.ModuleName, expectedCallCount);
            BackCompatTestProperties.VerifyGeneralSettingsIOProviderWasRead(mockGeneralIOProvider, expectedCallCount);
        }
 // Token: 0x060001A5 RID: 421 RVA: 0x0000629C File Offset: 0x0000449C
 private void resetDisplay(DataRow dr)
 {
     if (dr != null)
     {
         this.nameTB.Text            = dr["username"].ToString();
         this.phoneNumTB.Text        = dr["phoneNum"].ToString();
         this.identityCardNumTB.Text = dr["identityId"].ToString();
         this.addressTB.Text         = dr["address"].ToString();
         this.userAreaNumTB.Text     = dr["userArea"].ToString();
         this.usrePersonsTB.Text     = dr["userPersons"].ToString();
         string value  = dr["userTypeId"].ToString();
         string value2 = dr["userPriceConsistId"].ToString();
         DbUtil dbUtil = new DbUtil();
         dbUtil.AddParameter("userTypeId", value);
         DataRow dataRow = dbUtil.ExecuteRow("SELECT * FROM userTypeTable WHERE typeId=@userTypeId");
         if (dataRow != null)
         {
             string value3 = dataRow["userType"].ToString();
             SettingsUtils.displaySelectRow(this.userTypeCB, value3);
         }
         dbUtil.AddParameter("priceConsistId", value2);
         dataRow = dbUtil.ExecuteRow("SELECT * FROM priceConsistTable WHERE priceConsistId=@priceConsistId");
         if (dataRow != null)
         {
             string value4 = dataRow["priceConstistName"].ToString();
             SettingsUtils.displaySelectRow(this.priceTypeCB, value4);
             return;
         }
     }
     else
     {
         this.nameTB.Text            = "";
         this.phoneNumTB.Text        = "";
         this.identityCardNumTB.Text = "";
         this.addressTB.Text         = "";
         this.userAreaNumTB.Text     = "";
         this.usrePersonsTB.Text     = "";
         if (this.userTypeCB.SelectedIndex > 0)
         {
             this.userTypeCB.SelectedIndex = 0;
         }
         if (this.priceTypeCB.SelectedIndex > 0)
         {
             this.priceTypeCB.SelectedIndex = 0;
         }
     }
 }
Beispiel #20
0
        public ColorPickerViewModel()
        {
            if (SettingsUtils.SettingsExists(ColorPickerSettings.ModuleName))
            {
                _colorPickerSettings = SettingsUtils.GetSettings <ColorPickerSettings>(ColorPickerSettings.ModuleName);
            }
            else
            {
                _colorPickerSettings = new ColorPickerSettings();
            }

            if (SettingsUtils.SettingsExists())
            {
                var generalSettings = SettingsUtils.GetSettings <GeneralSettings>();
                _isEnabled = generalSettings.Enabled.ColorPicker;
            }
        }
Beispiel #21
0
        public void CleanUp()
        {
            // delete folder created.
            // delete general settings folder.
            string ShortCutGuideTestFolderName = string.Empty;

            if (SettingsUtils.SettingsFolderExists(string.Empty))
            {
                DeleteFolder(string.Empty);
            }

            // delete power rename folder.
            if (SettingsUtils.SettingsFolderExists(ShortCutGuideTestFolderName))
            {
                DeleteFolder(ShortCutGuideTestFolderName);
            }
        }
Beispiel #22
0
		protected override bool DrawUniqueDetectorProperties()
		{
			if (!ACTkSettings.Instance.InjectionDetectorEnabled)
			{
				using (GUITools.Vertical(GUITools.PanelWithBackground))
				{
					EditorGUILayout.Separator();
					EditorGUILayout.HelpBox("Injection Detector support is not enabled! Injection Detector will not work properly", 
						MessageType.Error, true);

					using (new GUILayout.HorizontalScope())
					{
						if (GUILayout.Button("Enable Now"))
						{
							ACTkSettings.Instance.InjectionDetectorEnabled = true;
						}
						if (GUILayout.Button("Enable In settings..."))
						{
							ACTkSettings.Show();
						}
					}

					EditorGUILayout.Separator();
				}

				return true;
			}

			if (SettingsUtils.IsIL2CPPEnabled())
			{
				EditorGUILayout.HelpBox("Mono Injections are not possible in IL2CPP, this detector is not needed in IL2CPP builds", 
					MessageType.Info, true);

				return true;
			}

			if (!InjectionRoutines.IsTargetPlatformCompatible())
			{
				EditorGUILayout.HelpBox("Injection Detection is only supported in Standalone and Android builds", 
					MessageType.Warning, true); 

				return true;
			}

			return false;
		}
Beispiel #23
0
        public void SettingsFolderExists_ShouldReturnFalse_WhenFilePathIsNotFound()
        {
            // Arrange
            string file_name_random = "test\\" + RandomString();
            string file_name_exists = "test\\exists";
            string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";

            // Act
            bool pathNotFound = SettingsUtils.SettingsFolderExists(file_name_random);

            SettingsUtils.SaveSettings(file_contents_correct_json_content, file_name_exists);
            bool pathFound = SettingsUtils.SettingsFolderExists(file_name_exists);

            // Assert
            Assert.IsFalse(pathNotFound);
            Assert.IsTrue(pathFound);
        }
Beispiel #24
0
        public async Task PlayFromAyah(QuranAyah ayah)
        {
            int currentQari = AudioUtils.GetReciterIdByName(SettingsUtils.Get <string>(Constants.PREF_ACTIVE_QARI));

            if (currentQari == -1)
            {
                return;
            }

            var request = new QuranAudioTrack(currentQari, ayah,
                                              FileUtils.ScreenInfo);

            // if necessary download aya position file
            await DownloadAyahPositionFile();

            QuranApp.NativeProvider.AudioProvider.SetTrack(request);
        }
Beispiel #25
0
        public bool SetSettings(ZombieSettings settings)
        {
            // (Konrad) Update Service Settings but only if they are local
            // We should never override remote settings from the GUI.
            if (settings.StoreSettings)
            {
                Program.Settings = settings;
            }

            // (Konrad) Update Registry
            var assemblyLocation = Assembly.GetExecutingAssembly().Location;

            RegistryUtils.SetImagePath(settings, assemblyLocation);

            // (Konrad) This flag is true for local settings only.
            return(!settings.StoreSettings || SettingsUtils.StoreSettings(settings));
        }
        public void OverloadSettings()
        {
            Monitor.Enter(_watcherSyncObject);
            var retry = true;

            for (int i = 0; retry && i < MAX_RETRIES; i++)
            {
                retry = false;
                try
                {
                    var overloadSettings = SettingsUtils.GetSettings <PowerLauncherSettings>(PowerLauncherSettings.POWERTOYNAME);

                    var openPowerlauncher = ConvertHotkey(overloadSettings.properties.open_powerlauncher);
                    if (_settings.Hotkey != openPowerlauncher)
                    {
                        _settings.Hotkey = openPowerlauncher;
                    }

                    var shell = PluginManager.AllPlugins.Find(pp => pp.Metadata.Name == "Shell");
                    if (shell != null)
                    {
                        var shellSettings = shell.Plugin as ISettingProvider;
                        shellSettings.UpdateSettings(overloadSettings);
                    }

                    if (_settings.MaxResultsToShow != overloadSettings.properties.maximum_number_of_results)
                    {
                        _settings.MaxResultsToShow = overloadSettings.properties.maximum_number_of_results;
                    }

                    if (_settings.IgnoreHotkeysOnFullscreen != overloadSettings.properties.ignore_hotkeys_in_fullscreen)
                    {
                        _settings.IgnoreHotkeysOnFullscreen = overloadSettings.properties.ignore_hotkeys_in_fullscreen;
                    }
                }
                // the settings application can hold a lock on the settings.json file which will result in a IOException.
                // This should be changed to properly synch with the settings app instead of retrying.
                catch (IOException e)
                {
                    retry = true;
                    Thread.Sleep(1000);
                    Debug.WriteLine(e.Message);
                }
            }
            Monitor.Exit(_watcherSyncObject);
        }
Beispiel #27
0
        public ShortcutGuideViewModel()
        {
            try
            {
                Settings = SettingsUtils.GetSettings <ShortcutGuideSettings>(ModuleName);
            }
            catch
            {
                Settings = new ShortcutGuideSettings();
                SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
            }

            GeneralSettings generalSettings;

            try
            {
                generalSettings = SettingsUtils.GetSettings <GeneralSettings>(string.Empty);
            }
            catch
            {
                generalSettings = new GeneralSettings();
                SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
            }

            _isEnabled = generalSettings.Enabled.ShortcutGuide;
            _pressTime = Settings.Properties.PressTime.Value;
            _opacity   = Settings.Properties.OverlayOpacity.Value;

            string theme = Settings.Properties.Theme.Value;

            if (theme == "dark")
            {
                _themeIndex = 0;
            }

            if (theme == "light")
            {
                _themeIndex = 1;
            }

            if (theme == "system")
            {
                _themeIndex = 2;
            }
        }
Beispiel #28
0
        public ImageResizerViewModel(Func <string, int> ipcMSGCallBackFunc)
        {
            try
            {
                Settings = SettingsUtils.GetSettings <ImageResizerSettings>(ModuleName);
            }
            catch
            {
                Settings = new ImageResizerSettings();
                SettingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
            }

            GeneralSettings generalSettings;

            try
            {
                generalSettings = SettingsUtils.GetSettings <GeneralSettings>(string.Empty);
            }
            catch
            {
                generalSettings = new GeneralSettings();
                SettingsUtils.SaveSettings(generalSettings.ToJsonString(), string.Empty);
            }

            // set the callback functions value to hangle outgoing IPC message.
            SendConfigMSG = ipcMSGCallBackFunc;

            _isEnabled          = generalSettings.Enabled.ImageResizer;
            _advancedSizes      = Settings.Properties.ImageresizerSizes.Value;
            _jpegQualityLevel   = Settings.Properties.ImageresizerJpegQualityLevel.Value;
            _pngInterlaceOption = Settings.Properties.ImageresizerPngInterlaceOption.Value;
            _tiffCompressOption = Settings.Properties.ImageresizerTiffCompressOption.Value;
            _fileName           = Settings.Properties.ImageresizerFileName.Value;
            _keepDateModified   = Settings.Properties.ImageresizerKeepDateModified.Value;
            _encoderGuidId      = GetEncoderIndex(Settings.Properties.ImageresizerFallbackEncoder.Value);

            int i = 0;

            foreach (ImageSize size in _advancedSizes)
            {
                size.Id = i;
                i++;
                size.PropertyChanged += Size_PropertyChanged;
            }
        }
        public void SaveSettingsSaveSettingsToFileWhenFilePathExists()
        {
            // Arrange
            var mockIOProvider = IIOProviderMocks.GetMockIOProviderForSaveLoadExists();
            var settingsUtils  = new SettingsUtils(mockIOProvider.Object);

            string file_name = "\\test";
            string file_contents_correct_json_content = "{\"name\":\"powertoy module name\",\"version\":\"powertoy version\"}";

            BasePTSettingsTest expected_json = JsonSerializer.Deserialize <BasePTSettingsTest>(file_contents_correct_json_content);

            // Act
            settingsUtils.SaveSettings(file_contents_correct_json_content, file_name);
            BasePTSettingsTest actual_json = settingsUtils.GetSettings <BasePTSettingsTest>(file_name);

            // Assert
            Assert.AreEqual(expected_json.ToJsonString(), actual_json.ToJsonString());
        }
Beispiel #30
0
        void InstallAsset()
        {
            UpdateShaders();

            SettingsUtils.SaveSettingsData(userFolder + "Version.asset", assetVersion);
            SettingsUtils.SaveSettingsData(userFolder + "Pipeline.asset", "Standard");
            SettingsUtils.SaveSettingsData(userFolder + "Engine.asset", engineOptions[coreEngineIndex]);

            FileUtil.DeleteFileOrDirectory(assetFolder + "/Core/Editor/TVEHubAutorun.cs");
            AssetDatabase.Refresh();

            SetDefineSymbols("Standard");
            SetScriptExecutionOrder();

            Debug.Log("[The Vegetation Engine] " + "The Vegetation Engine " + bannerVersion + " is installed!");

            GUIUtility.ExitGUI();
        }