public void updateToggle() { if (Toggled) { togglePanel.Left = Width - togglePanel.Width - 4; } else { togglePanel.Left = 4; } togglePanel.Refresh(); UpdateSetting?.Invoke(this, null); }
public static bool HasNewVer(string webver) { if (!string.IsNullOrEmpty(webver)) { webver = webver.Replace(",", "."); if (string.Compare(UpdateSetting.GetInstance().AppVersion, webver) < 0) { MessageBox.Show("服务器有新版本" + webver + "新下载" + Environment.NewLine + "本地版本" + UpdateSetting.GetInstance().AppVersion, "更新提示", MessageBoxButtons.OK); return(true); } } return(false); }
public async Task <IActionResult> SaveSettingAsync([FromBody] UpdateSetting command) { await rules .RequireSettingNameOrFacilityId() .Apply(command, ModelState); if (ModelState.IsValid) { await service.Execute(command); return(Ok()); } return(BadRequest(ModelState)); }
public async Task Execute(UpdateSetting command) { var outbreak = await writeContext.Outbreak .Include(o => o.OutbreakSettings) .FirstOrDefaultAsync(o => o.IdOutbreak == command.OutbreakId); var setting = outbreak.OutbreakSettings .FirstOrDefault(s => s.IdSetting == command.Id); if (setting == null) { throw new EntityNotFoundException(typeof(OutbreakSettings), command.Id); } await SaveSetting(command, outbreak, setting); await writeContext.SaveChangesAsync(); }
public void Load() { int version = _settings.Load("Version", () => 0); this.UseLanguage = _settings.Load(nameof(this.UseLanguage), () => { if (CultureInfo.CurrentUICulture.Name == "ja-JP") { return("Japanese"); } else if (CultureInfo.CurrentUICulture.Name == "zh-CN") { return("Chinese"); } else { return("English"); } }); this.AccountSetting = _settings.Load(nameof(this.AccountSetting), () => { var info = new AccountSetting(); info.DigitalSignature = new DigitalSignature("Anonymous", DigitalSignatureAlgorithm.EcDsaP521_Sha256_v3); info.Agreement = new Agreement(AgreementAlgorithm.EcDhP521_Sha256); return(info); }); this.SubscribeSignatures.UnionWith(_settings.Load(nameof(this.SubscribeSignatures), () => new Signature[] { Signature.Parse("Lyrise@i-2IpSdusn_TKfn6NSECLYRVO4r51cpHZ5wFgBo_0eU") })); this.UpdateSetting = _settings.Load(nameof(this.UpdateSetting), () => { var info = new UpdateSetting(); info.IsEnabled = true; info.Signature = Signature.Parse("Lyrise@i-2IpSdusn_TKfn6NSECLYRVO4r51cpHZ5wFgBo_0eU"); return(info); }); this.ViewSetting = _settings.Load(nameof(this.ViewSetting), () => new ViewSetting()); this.DownloadItemInfos.UnionWith(_settings.Load(nameof(this.DownloadItemInfos), () => new LockedHashSet <DownloadItemInfo>())); this.DownloadedSeeds.UnionWith(_settings.Load(nameof(this.DownloadedSeeds), () => new LockedHashSet <Seed>())); // ViewSetting { if (this.ViewSetting.Colors.Tree_Hit == null) { this.ViewSetting.Colors.Tree_Hit = System.Windows.Media.Colors.LightPink.ToString(); } if (this.ViewSetting.Colors.Link_New == null) { this.ViewSetting.Colors.Link_New = System.Windows.Media.Colors.LightPink.ToString(); } if (this.ViewSetting.Colors.Link_Visited == null) { this.ViewSetting.Colors.Link_Visited = System.Windows.Media.Colors.SkyBlue.ToString(); } if (this.ViewSetting.Colors.Message_Trust == null) { this.ViewSetting.Colors.Message_Trust = System.Windows.Media.Colors.SkyBlue.ToString(); } if (this.ViewSetting.Colors.Message_Untrust == null) { this.ViewSetting.Colors.Message_Untrust = System.Windows.Media.Colors.LightPink.ToString(); } if (this.ViewSetting.Fonts.Chat_Message == null) { this.ViewSetting.Fonts.Chat_Message = new ViewSetting.FontsSetting.FontSetting() { FontFamily = "MS PGothic", FontSize = 12 } } ; } }
void CellGUI(Rect cellRect, TreeViewItem <JObject> item, int column, ref RowGUIArgs args) { if (column <= 2) { switch (column) { case 0: CenterRectUsingSingleLineHeight(ref cellRect); var toggle = GUI.Toggle(cellRect, item.enabled, ""); if (toggle != item.enabled) { SetActiveOnSettingChanged?.Invoke(item.data["entityId"].Value <string>(), toggle); } break; case 1: EditorGUI.BeginDisabledGroup(true); GUI.TextField(cellRect, item.data["key"].Value <string>()); EditorGUI.EndDisabledGroup(); break; case 2: CenterRectUsingSingleLineHeight(ref cellRect); EditorGUI.BeginDisabledGroup(true); GUIContent ddBtnContent = new GUIContent(string.IsNullOrEmpty(item.data["type"].Value <string>()) ? "Select a type" : item.data["type"].Value <string>()); if (GUI.Button(cellRect, ddBtnContent, EditorStyles.popup)) { } EditorGUI.EndDisabledGroup(); break; } } else if (column != ((JArray)rule["value"]).Count + 3) { var whichVariant = column - 3; EditorGUI.BeginDisabledGroup(item.enabled == false); var valuesArr = (JArray)item.data["values"]; var useDefaultValue = false; if (valuesArr.Count <= whichVariant) { useDefaultValue = true; } bool itemUpdated = false; JToken newValue = null; switch (item.data["type"].Value <string>()) { case "string": var oldStringVal = useDefaultValue ? item.data["defaultValue"].Value <string>() : valuesArr[whichVariant].Value <string>(); var newStringVal = GUI.TextField(cellRect, oldStringVal); if (item.enabled) { EditorGUIUtility.AddCursorRect(cellRect, MouseCursor.Text); } if (newStringVal != oldStringVal) { itemUpdated = true; newValue = newStringVal; } break; case "bool": var boolVal = useDefaultValue ? item.data["defaultValue"].Value <bool>() : valuesArr[whichVariant].Value <bool>(); var menu = new GenericMenu(); menu.AddItem(new GUIContent("True"), boolVal == true, () => UpdateSetting?.Invoke(whichVariant, item.data["entityId"].Value <string>(), true)); menu.AddItem(new GUIContent("False"), boolVal == false, () => UpdateSetting?.Invoke(whichVariant, item.data["entityId"].Value <string>(), false)); GUIContent boolDdBtnContent = new GUIContent(boolVal.ToString()); if (GUI.Button(cellRect, boolDdBtnContent, EditorStyles.popup)) { menu.DropDown(cellRect); } break; case "float": var oldFloatval = useDefaultValue ? item.data["defaultValue"].Value <float>() : valuesArr[whichVariant].Value <float>(); var newFloatVal = EditorGUI.FloatField(cellRect, oldFloatval); if (Math.Abs(oldFloatval - newFloatVal) > float.Epsilon) { itemUpdated = true; newValue = newFloatVal; } break; case "int": var oldIntVal = useDefaultValue ? item.data["defaultValue"].Value <int>() : valuesArr[whichVariant].Value <int>(); var newIntVal = EditorGUI.IntField(cellRect, oldIntVal); if (oldIntVal != newIntVal) { itemUpdated = true; newValue = newIntVal; } break; case "long": var oldLongVal = useDefaultValue ? item.data["defaultValue"].Value <long>() : valuesArr[whichVariant].Value <long>(); var newLongVal = EditorGUI.LongField(cellRect, oldLongVal); if (oldLongVal != newLongVal) { itemUpdated = true; newValue = newLongVal; } break; } EditorGUI.EndDisabledGroup(); if (itemUpdated && newValue != null) { UpdateSetting?.Invoke(whichVariant, item.data["entityId"].Value <string>(), newValue); } } }
private void RSTypeChangedCallback(object obj) { var rSTypeChangedStruct = (RSTypeChangedStruct)obj; if (rSTypeChangedStruct.newType != rSTypeChangedStruct.rs["rs"]["type"].Value <string>()) { var newObj = new JObject(rSTypeChangedStruct.rs); newObj["rs"]["type"] = rSTypeChangedStruct.newType; switch (rSTypeChangedStruct.newType) { case "string": newObj["rs"]["value"] = rSTypeChangedStruct.rs["rs"]["value"].Value <string>(); break; case "int": int intVal = 0; try { intVal = rSTypeChangedStruct.rs["rs"]["value"].Value <int>(); } catch (FormatException) { } newObj["rs"]["value"] = intVal; break; case "float": float floatVal = 0.0f; try { floatVal = rSTypeChangedStruct.rs["rs"]["value"].Value <float>(); } catch (FormatException) { } newObj["rs"]["value"] = floatVal; break; case "bool": bool boolVal = false; try { boolVal = rSTypeChangedStruct.rs["rs"]["value"].Value <bool>(); } catch (FormatException) { } newObj["rs"]["value"] = boolVal; break; case "long": long longVal = 0L; try { longVal = rSTypeChangedStruct.rs["rs"]["value"].Value <long>(); } catch (FormatException) { } newObj["rs"]["value"] = longVal; break; } UpdateSetting?.Invoke(rSTypeChangedStruct.rs, newObj); } }
void CellGUI(Rect cellRect, TreeViewItem <JObject> item, int column, ref RowGUIArgs args) { switch (column) { case 0: CenterRectUsingSingleLineHeight(ref cellRect); if (enableEditingSettingsKeys) { var isDisabled = enableEditingSettingsKeys && IsKeyInRules(item.data["metadata"]["entityId"].Value <string>(), rulesList); EditorGUI.BeginDisabledGroup(isDisabled || isLoading); if (GUI.Button(cellRect, new GUIContent(EditorGUIUtility.FindTexture("d_TreeEditor.Trash"), isDisabled ? "Can't remove a setting used in a rule" : ""))) { UpdateSetting?.Invoke(item.data, null); } EditorGUI.EndDisabledGroup(); break; } else { var toggle = GUI.Toggle(cellRect, item.enabled, ""); if (toggle != item.enabled) { if (toggle) { UpdateSetting?.Invoke(null, item.data); } else { UpdateSetting?.Invoke(item.data, null); } } break; } case 1: EditorGUI.BeginDisabledGroup(!enableEditingSettingsKeys || isLoading); var newKey = GUI.TextField(cellRect, item.data["rs"]["key"].Value <string>()); if (enableEditingSettingsKeys && !isLoading) { EditorGUIUtility.AddCursorRect(cellRect, MouseCursor.Text); } EditorGUI.EndDisabledGroup(); if (newKey != item.data["rs"]["key"].Value <string>()) { var newObj = new JObject(item.data); newObj["rs"]["key"] = newKey; UpdateSetting?.Invoke(item.data, newObj); } break; case 2: CenterRectUsingSingleLineHeight(ref cellRect); EditorGUI.BeginDisabledGroup(!enableEditingSettingsKeys || isLoading); GUIContent ddBtnContent = new GUIContent(string.IsNullOrEmpty(item.data["rs"]["type"].Value <string>()) ? "Select a type" : item.data["rs"]["type"].Value <string>()); if (GUI.Button(cellRect, ddBtnContent, EditorStyles.popup)) { BuildPopupListForSettingTypes(item).DropDown(cellRect); } EditorGUI.EndDisabledGroup(); break; case 3: EditorGUI.BeginDisabledGroup(isLoading || item.enabled == false); var newSetting = new JObject(item.data); switch (item.data["rs"]["type"].Value <string>()) { case "string": string newStringValue = item.data["rs"]["value"].Value <string>(); newStringValue = GUI.TextField(cellRect, item.data["rs"]["value"].Value <string>()); if (!isLoading && item.enabled) { EditorGUIUtility.AddCursorRect(cellRect, MouseCursor.Text); } if (newStringValue != item.data["rs"]["value"].Value <string>()) { newSetting["rs"]["value"] = newStringValue; UpdateSetting?.Invoke(item.data, newSetting); } break; case "bool": bool boolVal = false; try { boolVal = item.data["rs"]["value"].Value <bool>(); } catch (FormatException) { newSetting["rs"]["value"] = boolVal; UpdateSetting?.Invoke(item.data, newSetting); } var menu = new GenericMenu(); menu.AddItem(new GUIContent("True"), boolVal == true, () => { newSetting["rs"]["value"] = true; UpdateSetting?.Invoke(item.data, newSetting); }); menu.AddItem(new GUIContent("False"), boolVal == false, () => { newSetting["rs"]["value"] = false; UpdateSetting?.Invoke(item.data, newSetting); }); GUIContent boolDdBtnContent = new GUIContent(boolVal.ToString()); if (GUI.Button(cellRect, boolDdBtnContent, EditorStyles.popup)) { menu.DropDown(cellRect); } break; case "float": float floatVal = 0.0f; try { floatVal = item.data["rs"]["value"].Value <float>(); } catch (FormatException) { newSetting["rs"]["value"] = floatVal; UpdateSetting?.Invoke(item.data, newSetting); } var floatFieldVal = EditorGUI.FloatField(cellRect, floatVal); // TODO: abs check if (floatFieldVal != floatVal) { newSetting["rs"]["value"] = floatFieldVal; UpdateSetting?.Invoke(item.data, newSetting); } break; case "int": int intVal = 0; try { intVal = item.data["rs"]["value"].Value <int>(); } catch (FormatException) { newSetting["rs"]["value"] = intVal; UpdateSetting?.Invoke(item.data, newSetting); } var intFieldValue = EditorGUI.IntField(cellRect, intVal); if (intFieldValue != intVal) { newSetting["rs"]["value"] = intFieldValue; UpdateSetting?.Invoke(item.data, newSetting); } break; case "long": long longVal = 0L; try { longVal = item.data["rs"]["value"].Value <long>(); } catch (FormatException) { newSetting["rs"]["value"] = longVal; UpdateSetting?.Invoke(item.data, newSetting); } var longFieldValue = EditorGUI.LongField(cellRect, longVal); if (longFieldValue != longVal) { newSetting["rs"]["value"] = longFieldValue; UpdateSetting?.Invoke(item.data, newSetting); } break; } EditorGUI.EndDisabledGroup(); break; } }