// 修改setting.tjs static void ModifySetting(string dataPath, string title, int sw, int sh, int dh, int dw) { // 更新setting string settingFile = Path.Combine(dataPath, WizardConfig.UI_SETTING); // 临时创建一个属性对象用于读取setting ProjectProperty info = new ProjectProperty(); info.LoadSetting(settingFile); TjsDict setting = info.setting; if (setting != null) { setting.SetString("title", title); setting.SetNumber("width", dw); setting.SetNumber("height", dh); // 修正缩略图宽度 int tw = info.thumbnailwidth; if (tw > 0) { tw = tw * dw / sw; setting.SetValue("savedata/thumbnailwidth", new TjsString(tw.ToString())); } setting.Save(settingFile, Encoding.Unicode); } }
public static double ScaleInteger(TjsDict dict, string name, double scale) { TjsValue val = dict.GetValue(name); double num = (val != null) ? val.ToDouble() : double.NaN; if (!double.IsNaN(num)) { num = num * scale; dict.SetNumber(name, Math.Floor(num)); return(num); } string str = dict.GetString(name); if (double.TryParse(str, out num)) { num = num * scale; dict.SetString(name, Math.Floor(num).ToString()); return(num); } return(double.NaN); }