Beispiel #1
0
 public void CopyFrom(BaseSetting setting)
 {
     Key          = setting.Key;
     Value        = setting.Value;
     DefaultValue = setting.DefaultValue;
     SettingType  = setting.SettingType;
 }
Beispiel #2
0
 public SettingChangeRequest(
     string userId,
     BaseSetting settingToChange)
 {
     UserId          = userId;
     SettingToChange = settingToChange;
 }
Beispiel #3
0
 public override void Update(BaseSetting baseSetting)
 {
     if (baseSetting is SkinSetting skinSetting)
     {
         ChangeValue(skinSetting.Value);
     }
 }
Beispiel #4
0
 /// <summary>
 /// All the Settings that are not Read-Only will raise this Event when the User Requests changing them
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void ValueChanged(object sender, System.EventArgs e)
 {
     try
     {
         BaseSetting setting = sender as BaseSetting;
         if (setting != null)
         {
             if (!setting.ChangeRequiresBackendPermission)
             {
                 UpdateSetting(setting, true);
                 if (setting.LongText == Strings.Setting_ShowSidebarLong && setting is BooleanSetting boolSet)
                 {
                     Properties.Dashboard.Default.ShowSidebar = boolSet.Value;
                     Properties.Dashboard.Default.Save();
                 }
             }
             else
             {
                 WCFService.RequestSettingChange(DashboardViewModel.Username, setting);
             }
         }
     }
     catch (Exception)
     {
     }
 }
 public override void Update(BaseSetting baseSetting)
 {
     if (baseSetting is LocalizationSetting localizationSetting)
     {
         ChangeValue(localizationSetting.Value);
     }
 }
Beispiel #6
0
 private static ISettingControl?CreateSettingControl(ToolTip toolTip, BaseSetting setting)
 {
     try
     {
         if (setting is BooleanSetting booleanSetting)
         {
             return(new CheckboxSetting(toolTip, booleanSetting));
         }
         if (setting is IntegerSetting integerSetting)
         {
             if (integerSetting.Range)
             {
                 return(new NumericIntSetting(toolTip, integerSetting));
             }
             return(new ComboboxIntSetting(toolTip, integerSetting));
         }
         if (setting is FloatSetting floatSetting)
         {
             if (floatSetting.Range)
             {
                 return(new NumericFloatSetting(toolTip, floatSetting));
             }
             return(new ComboboxFloatSetting(toolTip, floatSetting));
         }
     }
     catch (Exception e)
     {
         _logger.Warn(e, $"Ignore invalid setting: {setting.Key}");
         return(null);
     }
     _logger.Info($"Ignore not supported setting: {setting.Key}");
     return(null);
 }
Beispiel #7
0
        private async Task GetAvailableSettings()
        {
            var availableSettings = await WCFService?.GetAvailableSettings(DashboardViewModel.Username);

            lock (settingsLocker)
            {
                foreach (var dto in availableSettings)
                {
                    var setting = GetSettingFromDTO(dto);
                    if (setting != null)
                    {
                        BaseSetting existingSetting =
                            Settings
                            .FirstOrDefault(s => s.Equals(setting));

                        if (existingSetting != null)
                        {
                            existingSetting.Update(setting);
                        }
                        else
                        {
                            Settings.Add(setting);
                            if (!setting.IsReadOnly)
                            {
                                setting.ValueChanged += this.ValueChanged;
                            }
                            ;
                        }
                    }
                }
            }
        }
 public override void Setup(BaseSetting setting)
 {
     Setting         = setting as T;
     _titleText.text = GetDisplayName();
     OnSetup();
     Present();
 }
Beispiel #9
0
    public static SettingFileResult Creat(string fileName)
    {
        isCreating = true;

        //文件路径
        var realPath = PathName(fileName);

        //目录路径
        var path = Path.GetDirectoryName(realPath);

        //对应目录是否存在
        if (!Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
            AssetDatabase.ImportAsset(path);
        }

        //从配置文件列表中取出对应类
        BaseSetting fileObj = Get(fileName);

        if (fileObj == null)
        {
            return(SettingFileResult.ERROR);
        }

        //对应文件是否存在
        if (File.Exists(realPath))
        {
            return(SettingFileResult.ALREADYHAVE);
        }

        //创建
        AssetDatabase.CreateAsset(fileObj, realPath);
        return(SettingFileResult.SUCCESS);
    }
Beispiel #10
0
        public BaseSetting Copy()
        {
            var setting = new BaseSetting();

            setting.CopyFrom(this);

            return(setting);
        }
Beispiel #11
0
        private void PublishSettingChangeNotification(BaseSetting setting, bool wasChanged)
        {
            NotificationModel notificationToSend = null;

            if (wasChanged)
            {
                if (setting.ChangeRequiresBackendRestart)
                {
                    EventAggregator.Publish(
                        new NotificationOccurredEvent(
                            new NotificationModel(
                                "SettingChangeResponse",
                                NotificationType.Warning,
                                string.Format(Strings.Setting_ChangeSuccessful, setting.ShortText),
                                Strings.Setting_ChangeRequiresBackendRestart,
                                true, new BackendRestartRequestedEvent(), Strings.Setting_ChangeRequiresRestartAccept,
                                false, null, null,
                                true, null, Strings.Notification_DefaultCancel)));
                }
                else if (setting.ChangeRequiresDashboardRestart)
                {
                    EventAggregator.Publish(
                        new NotificationOccurredEvent(
                            new NotificationModel(
                                "SettingChangeResponse",
                                NotificationType.Warning,
                                string.Format(Strings.Setting_ChangeSuccessful, setting.ShortText),
                                Strings.Setting_ChangeRequiresDashboardRestart,
                                true, new DashboardRestartRequestedEvent(), Strings.Setting_ChangeRequiresRestartAccept,
                                false, null, null,
                                true, null, Strings.Notification_DefaultCancel)));
                }
                else
                {
                    EventAggregator.Publish(
                        new NotificationOccurredEvent(
                            new NotificationModel(
                                "SettingChangeResponse",
                                NotificationType.Success,
                                string.Format(Strings.Setting_ChangeSuccessful, setting.ShortText),
                                string.Empty,
                                true, null, Strings.Setting_ChangeDoesNotRequireRestartAccept,
                                false, null, null,
                                false, null, null)));
                }
            }
            else
            {
                notificationToSend = new NotificationModel(
                    "SettingChangeResponse",
                    NotificationType.Error,
                    string.Format(Strings.Setting_ChangeSuccessful, setting.ShortText),
                    Strings.Setting_ChangeRequiresBackendRestart,
                    true, new BackendRestartRequestedEvent(), Strings.Setting_ChangeRequiresRestartAccept,
                    true, null, Strings.Setting_ChangeRequiresRestartDecline,
                    true, null, Strings.Notification_DefaultCancel);
            }
        }
 public async Task RequestSettingChange(string userId, BaseSetting setting)
 {
     if (IsLoggedInAndConnected)
     {
         await client.RequestSettingChangeAsync(
             new SettingChangeRequestDTO(userId, setting.ToDto()),
             userId);
     }
 }
Beispiel #13
0
        private static void ConfigAddFix(ConfigScene __instance, ref IEnumerator __result)
        {
            BaseSetting setting = null;

            __result = __result
                       .AppendCo(new WaitForEndOfFrame())
                       .AppendCo(() =>
            {
                try
                {
                    var add = __instance.transform.Find("Canvas/imgWindow/ScrollView/Content/Node Addtional");

                    if (add && add.gameObject.activeInHierarchy)
                    {
                        var add20Prop = Traverse.Create <Game>().Property("isAdd20");
                        if (add20Prop.FieldExists() && add20Prop.GetValue <bool>())
                        {
                            var add20Tr = __instance.transform.Find("Canvas/imgWindow/ScrollView/Content/Node Addtional_20");
                            if (add20Tr)
                            {
                                add20Tr.gameObject.SetActive(true);
                                add20Tr.SetSiblingIndex(add.GetSiblingIndex());
                                setting = add20Tr.GetComponent <BaseSetting>();
                                add.gameObject.SetActive(false);
                            }
                        }
                        else
                        {
                            var addNormalTr = __instance.transform.Find("Canvas/imgWindow/ScrollView/Content/Node Addtional_normal");
                            if (addNormalTr)
                            {
                                addNormalTr.gameObject.SetActive(true);
                                addNormalTr.SetSiblingIndex(add.GetSiblingIndex());
                                setting = addNormalTr.GetComponent <BaseSetting>();
                                add.gameObject.SetActive(false);
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    UnityEngine.Debug.LogException(e);
                }
            })
                       .AppendCo(new WaitForEndOfFrame())
                       .AppendCo(() =>
            {
                if (setting != null)
                {
                    // Need to wait until next frame to init because mobcolor setting will be corrupted if inited before colorpicker Start runs
                    setting.Init();
                    setting.UIPresenter();
                }
            });
        }
Beispiel #14
0
 private static void PrintSetting(BaseSetting setting, string ident)
 {
     Console.WriteLine($"{ident}{setting.Key}: {setting.Name}");
     if (!string.IsNullOrEmpty(setting.Description))
     {
         Console.WriteLine($"{ident}  Description: {setting.Description}");
     }
     if (setting is BooleanSetting booleanSetting && booleanSetting.DefaultValue.HasValue)
     {
         Console.WriteLine($"{ident}  Default: {booleanSetting.DefaultValue.Value}");
     }
Beispiel #15
0
 public SettingChangeResponse(
     string userId,
     bool wasChanged,
     string additionalInfo,
     BaseSetting setting)
 {
     UserId         = userId;
     WasChanged     = wasChanged;
     AdditionalInfo = additionalInfo;
     Setting        = setting;
 }
 public void Insert(BaseSetting entity)
 {
     if (entity == null)
     {
         throw new ArgumentNullException(nameof(entity));
     }
     using (var db = new BaseDatabaseContext())
     {
         db.BaseSettings.Add(entity);
         db.SaveChanges();
     }
 }
Beispiel #17
0
        public object GetSampleSetting()
        {
            var obj = new BaseSetting
            {
                IsInputStrageNeedAlow = Config.GetSampleConfig().IsInputStrageNeedAlow,
                InStrageAlowChange    = Config.GetSampleConfig().InStrageAlowChange,
                EnableLimtView        = Config.GetSampleConfig().EnableLimtView,
                AllSampleCanLend      = Config.GetSampleConfig().AllSampleCanLend,
            };

            return(Ok(obj));
        }
Beispiel #18
0
 public SettingChangeResponse(SettingChangeResponseDTO dto)
 {
     UserId         = dto.UserId;
     WasChanged     = dto.WasChanged;
     AdditionalInfo = dto.Info;
     if (dto.Setting is BooleanSettingDTO boolDTO)
     {
         Setting = new BooleanSetting(boolDTO);
     }
     else if (dto.Setting is IntegerSettingDTO intDTO)
     {
         Setting = new IntegerSetting(intDTO);
     }
 }
Beispiel #19
0
        public async Task <bool> SaveBaseSetting(BaseSetting model)
        {
            using (var connection = new SqlConnection(_connectionString))
            {
                connection.Open();
                model.ID = Guid.NewGuid();
                var result = await connection.ExecuteAsync(@"
                            insert into [dbo].[BaseExamSetting]([ID]
                            ,[TypeTimeSpan1],[TypeTimeSpan2],[TypeTimeSpan3],[PartTimeSpan]
                            ) values(@ID,@TypeTimeSpan1,@TypeTimeSpan2,@TypeTimeSpan3,@PartTimeSpan)", model);

                return(result > 0);
            }
        }
Beispiel #20
0
 public object SaveSampleSetting(BaseSetting obj)
 {
     try
     {
         Config.GetSampleConfig().IsInputStrageNeedAlow = obj.IsInputStrageNeedAlow;
         Config.GetSampleConfig().InStrageAlowChange    = obj.InStrageAlowChange;
         Config.GetSampleConfig().EnableLimtView        = obj.EnableLimtView;
         Config.GetSampleConfig().AllSampleCanLend      = obj.AllSampleCanLend;
         return(Ok());
     }
     catch (Exception e)
     {
         return(BadRequest(e.Message));
     }
 }
Beispiel #21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldBeInvalidIfPrefixDoesNotMatch()
        public virtual void ShouldBeInvalidIfPrefixDoesNotMatch()
        {
            // given
            BaseSetting <string>         setting   = Settings.prefixSetting("bar", Settings.STRING, "");
            IDictionary <string, string> rawConfig = new Dictionary <string, string>();

            rawConfig["foo.us_east_1c"] = "abcdef";

            // when
            IDictionary <string, string> validConfig = setting.Validate(rawConfig, s =>
            {
            });

            // then
            assertEquals(0, validConfig.Count);
        }
Beispiel #22
0
 public void DelAllPredmetInGroupThisTeacher(BaseSetting DelFrom)
 {
     for (int q = 0; q < this.ArrayOfPredmet.Count; q++)
     {
         for (int i = 0; i < DelFrom.GetAllGroups().Length; i++)
         {
             for (int a = 0; a < DelFrom.GetGroup(i).GetAllPredmet().Length; a++)
             {
                 if (DelFrom.GetGroup(i).GetPredmet(a).ToString().Equals(this.ArrayOfPredmet[q].ToString()))
                 {
                     this.DelPredmetInGroup(DelFrom.GetGroup(i), ((Predmet)this.ArrayOfPredmet[q]));
                 }
             }
         }
     }
 }
Beispiel #23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldValidatePrefixBasedKeys()
        public virtual void ShouldValidatePrefixBasedKeys()
        {
            // given
            BaseSetting <string> setting = Settings.prefixSetting("foo", Settings.STRING, "");

            IDictionary <string, string> rawConfig = new Dictionary <string, string>();

            rawConfig["foo.us_east_1c"] = "abcdef";

            // when
            IDictionary <string, string> validConfig = setting.Validate(rawConfig, s =>
            {
            });

            // then
            assertEquals(1, validConfig.Count);
            assertEquals(rawConfig, validConfig);
        }
    private BaseSettingPresenter FindPresenterPrefabFor(BaseSetting setting)
    {
        foreach (var presenterPrefab in _presentersPrefabs)
        {
            if (presenterPrefab.TargetType == setting.GetType())
            {
                return(presenterPrefab);
            }
        }

        foreach (var presenterPrefab in _presentersPrefabs)
        {
            if (setting.GetType().IsSubclassOf(presenterPrefab.TargetType))
            {
                return(presenterPrefab);
            }
        }

        return(null);
    }
Beispiel #25
0
        private BaseSetting GetSettingFromDTO(SettingDTO dto)
        {
            BaseSetting baseSetting = null;

            try
            {
                if (dto is BooleanSettingDTO boolDto)
                {
                    return(new BooleanSetting(boolDto));
                }

                if (dto is IntegerSettingDTO intDto)
                {
                    return(new IntegerSetting(intDto));
                }
            }
            catch (Exception e)
            {
                Log.Error(nameof(GetSettingFromDTO), e);
            }
            return(baseSetting);
        }
Beispiel #26
0
        public async Task <ActionResult> SaveBaseSetting(BaseSetting model)
        {
            var json = new mJsonResult();

            try
            {
                if (await _examService.SaveBaseSetting(model))
                {
                    json.success = true;
                    json.msg     = "保存成功!";
                }
                else
                {
                    json.msg = "保存失败!";
                }
            }
            catch (Exception ex)
            {
                _logger.Error("保存配置出现错误{0}", ex.Message);
                json.msg = "保存异常!";
            }
            return(Json(json));
        }
        public async Task SaveDeviceSettingFromDiskAsync(BaseSetting deviceSetting)
        {
            var savePicker = new Windows.Storage.Pickers.FileSavePicker();

            savePicker.SuggestedStartLocation =
                Windows.Storage.Pickers.PickerLocationId.DocumentsLibrary;

            // Dropdown of file types the user can save the file as
            savePicker.FileTypeChoices.Add(_translationsService.GetString("JsonConfig"),
                                           new List <string>()
            {
                FileTypeFilterJsonExtension
            });

            // Default file name if the user does not type one in or select a file to replace
            savePicker.SuggestedFileName = _translationsService.GetString("DeviceConfigFileName");

            Windows.Storage.StorageFile file = await savePicker.PickSaveFileAsync();

            if (file != null)
            {
                // Prevent updates to the remote version of the file until
                // we finish making changes and call CompleteUpdatesAsync.
                Windows.Storage.CachedFileManager.DeferUpdates(file);

                var deviceSettingJsonString = JsonConvert.SerializeObject(deviceSetting);

                // write to file
                await Windows.Storage.FileIO.WriteTextAsync(file, deviceSettingJsonString);

                // Let Windows know that we're finished changing the file so
                // the other app can update the remote version of the file.
                // Completing updates may require Windows to ask for user input.
                await Windows.Storage.CachedFileManager.CompleteUpdatesAsync(file);
            }
        }
Beispiel #28
0
        private void UpdateSetting(BaseSetting setting, bool wasChanged)
        {
            #region BooleanSettings
            BooleanSetting newValue = setting as BooleanSetting;
            if (newValue != null)
            {
                var oldValue = Settings.FirstOrDefault(set => set.Equals(newValue));
                if (oldValue != null)
                {
                    BooleanSetting oldBoolValue = oldValue as BooleanSetting;
                    if (oldBoolValue != null)
                    {
                        if (wasChanged)
                        {
                            oldBoolValue.ChangeValue(newValue.Value);
                        }
                        else
                        {
                            oldBoolValue.ChangeValue(oldBoolValue.Value);
                        }
                        PublishSettingChangeNotification(setting, wasChanged);
                        return;
                    }
                }
            }
            #endregion

            #region IntegerSettings
            IntegerSetting newIntValue = setting as IntegerSetting;
            if (newIntValue != null)
            {
                var oldValue = Settings.FirstOrDefault(set => set.Equals(newIntValue));
                if (oldValue != null)
                {
                    IntegerSetting oldIntValue = oldValue as IntegerSetting;
                    if (oldIntValue != null)
                    {
                        if (wasChanged)
                        {
                            oldIntValue.ChangeValue(newIntValue.Value);
                        }
                        else
                        {
                            oldIntValue.ChangeValue(oldIntValue.Value);
                        }
                        PublishSettingChangeNotification(setting, wasChanged);
                        return;
                    }
                }
            }
            #endregion

            #region SkinSettings
            SkinSetting newSkinValue = setting as SkinSetting;
            if (newSkinValue != null)
            {
                var oldValue = Settings.FirstOrDefault(set => set.Equals(newSkinValue));
                if (oldValue != null)
                {
                    SkinSetting oldSkinValue = oldValue as SkinSetting;
                    if (oldSkinValue != null)
                    {
                        if (wasChanged)
                        {
                            oldSkinValue.ChangeValue(newSkinValue.Value);
                            Configuration.Skinning.CurrentSkin = newSkinValue.Value;
                        }
                        else
                        {
                            oldSkinValue.ChangeValue(oldSkinValue.Value);
                        }
                        PublishSettingChangeNotification(setting, wasChanged);
                        return;
                    }
                }
            }
            #endregion

            #region LocalizationSettings
            if (setting is LocalizationSetting newLocalizationValue)
            {
                var oldValue = Settings.FirstOrDefault(set => set.Equals(newLocalizationValue));
                if (oldValue != null)
                {
                    if (oldValue is LocalizationSetting oldLocalizationValue)
                    {
                        if (wasChanged)
                        {
                            oldLocalizationValue.ChangeValue(newLocalizationValue.Value);
                            Configuration.Localization.CurrentLanguage = newLocalizationValue.Value;
                        }
                        else
                        {
                            oldLocalizationValue.ChangeValue(oldLocalizationValue.Value);
                        }
                        PublishSettingChangeNotification(setting, wasChanged);
                        return;
                    }
                }
            }
            #endregion
        }
Beispiel #29
0
	public AttachedSetting()
	{
		baseSet = new BaseSetting();
		param = new ActionParam();
		callbackFunc = new CallbackEvent();
	}
 public static BaseSettingModel ToModel(this BaseSetting entity)
 {
     return(entity.MapTo <BaseSetting, BaseSettingModel>());
 }
 public static BaseSetting ToEntity(this BaseSettingModel model, BaseSetting destination)
 {
     return(model.MapTo(destination));
 }