public static int smethod_9(out string[] string_0) { IntPtr intPtr = Marshal.AllocCoTaskMem(32767); int privateProfileSectionNames = IniFileUtils.GetPrivateProfileSectionNames(intPtr, 32767, IniFileUtils.iniPath); if (privateProfileSectionNames == 0) { string_0 = null; return(-1); } string text = Marshal.PtrToStringAnsi(intPtr, privateProfileSectionNames).ToString(); Marshal.FreeCoTaskMem(intPtr); string text2 = text.Substring(0, text.Length - 1); char[] separator = new char[1]; string_0 = text2.Split(separator); return(0); }
public static int smethod_10(string string_0, out string[] string_1, out string[] string_2) { byte[] array = new byte[65535]; IniFileUtils.GetPrivateProfileSection(string_0, array, array.Length, IniFileUtils.iniPath); string @string = Encoding.Default.GetString(array); string text = @string; char[] separator = new char[1]; string[] array2 = text.Split(separator); ArrayList arrayList = new ArrayList(); string[] array3 = array2; foreach (string text2 in array3) { if (text2 != string.Empty) { arrayList.Add(text2); } } string_1 = new string[arrayList.Count]; string_2 = new string[arrayList.Count]; for (int j = 0; j < arrayList.Count; j++) { string[] array4 = arrayList[j].ToString().Split('='); if (array4.Length == 2) { string_1[j] = array4[0].Trim(); string_2[j] = array4[1].Trim(); } else if (array4.Length == 1) { string_1[j] = array4[0].Trim(); string_2[j] = ""; } else if (array4.Length == 0) { string_1[j] = ""; string_2[j] = ""; } } return(0); }
/* * public static int smethod_2(string string_0, string string_1, int int_0) * { * return IniFileUtils.GetPrivateProfileInt(string_0, string_1, int_0, IniFileUtils.iniPath); * } * * public static void smethod_3(string string_0, string string_1, int int_0) * { * IniFileUtils.WritePrivateProfileString(string_0, string_1, int_0.ToString(), IniFileUtils.iniPath); * } */ public static string getProfileStringWithDefault(string string_0, string string_1, string string_2) { if (IniFileUtils.iniPath != null) { StringBuilder stringBuilder = new StringBuilder(1024); IniFileUtils.GetPrivateProfileString(string_0, string_1, string_2, stringBuilder, 1024, IniFileUtils.iniPath); return(stringBuilder.ToString()); } else { var obj = Registry.GetValue(keyName, string_1, string_2); if (obj != null) { return((string)obj); } else { return(string_2); } } }
private void btnOk_Click(object sender, EventArgs e) { base.DialogResult = DialogResult.OK; if (this.txtPwd.Text == "DMR961510") { string string_ = Base64Utils.smethod_0(this.txtPwd.Text.Trim()); IniFileUtils.WriteProfileString("setup", "Power", string_); Settings.smethod_5(Settings.UserMode.Expert); Settings.CUR_MODE = 1; } else if (this.txtPwd.Text == "TYT760") { string string_2 = Base64Utils.smethod_0(this.txtPwd.Text.Trim()); Settings.smethod_5(Settings.UserMode.Expert); Settings.CUR_MODE = 2; IniFileUtils.WriteProfileString("setup", "Power", string_2); } else { base.DialogResult = DialogResult.Cancel; } }
private void btnUploadFirmware_Click(object sender, EventArgs e) { if (IsLoading) { return; } OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "firmware files|*.sgl"; openFileDialog.InitialDirectory = IniFileUtils.getProfileStringWithDefault("Setup", "LastFirmwareLocation", null); if (openFileDialog.ShowDialog() == DialogResult.OK && openFileDialog.FileName != null) { IniFileUtils.WriteProfileString("Setup", "LastFirmwareLocation", Path.GetDirectoryName(openFileDialog.FileName)); this.lblMessage.Text = ""; Action <object> action = (object obj) => { IsLoading = true; SetLoadingState(true); FirmwareLoader.UploadFirmare(openFileDialog.FileName, this); SetLoadingState(false); IsLoading = false; }; try { Task t1 = new Task(action, "LoaderUSB"); t1.Start(); } catch (Exception) { IsLoading = false; SetLoadingState(false); } } }
public string Read(string section, string key) { return(IniFileUtils.ReadContentValue(section, key, filepath)); }
private void AboutForm_Load(object sender, EventArgs e) { Settings.smethod_68(this); this.lblVersion.Text = IniFileUtils.smethod_4("Info", "Version", "v1.0.0"); }
private void btnClose_Click(object sender, EventArgs e) { IniFileUtils.WriteProfileString("Setup", "DownloadContactsURL", txtDownloadURL.Text); this.Close(); }
private IniFileUtils(string string_0) { IniFileUtils.setIniFilePath(string_0); }
public static void smethod_8(string string_0) { IniFileUtils.WritePrivateProfileString(string_0, null, null, IniFileUtils.iniPath); }
public static void WriteProfileString(string string_0, string string_1, string string_2) { IniFileUtils.WritePrivateProfileString(string_0, string_1, string_2, IniFileUtils.iniPath); }
public static void smethod_3(string string_0, string string_1, int int_0) { IniFileUtils.WritePrivateProfileString(string_0, string_1, int_0.ToString(), IniFileUtils.iniPath); }
public static int smethod_2(string string_0, string string_1, int int_0) { return(IniFileUtils.GetPrivateProfileInt(string_0, string_1, int_0, IniFileUtils.iniPath)); }
private IniFileUtils(string string_0) { IniFileUtils.smethod_1(string_0); }
public void Write(string section, string key, string content) { IniFileUtils.WriteContentValue(section, key, content, filepath); return; }
private void downloadStringCompletedCallback(object sender, DownloadStringCompletedEventArgs ev) { if (ev.Cancelled) { MessageBox.Show(StringsDict["DownloadCancelled"], StringsDict["Timeout"], MessageBoxButtons.OK, MessageBoxIcon.Error); SetLoadingState(false); this.progressBarDwnl.Visible = false; return; } else if (ev.Error != null) { MessageBox.Show(ev.Error.Message, StringsDict["Error"], MessageBoxButtons.OK, MessageBoxIcon.Error); SetLoadingState(false); this.progressBarDwnl.Visible = false; return; } String result = ev.Result; this.progressBarDwnl.Visible = false; FirmwareLoaderReleasesList flrl = new FirmwareLoaderReleasesList(result); if (DialogResult.Cancel != flrl.ShowDialog()) { if (_saveDownloadedFile) { SaveFileDialog saveFileDialog = new SaveFileDialog(); saveFileDialog.Filter = "firmware files|*.sgl"; saveFileDialog.InitialDirectory = IniFileUtils.getProfileStringWithDefault("Setup", "LastFirmwareLocation", null); saveFileDialog.FileName = FirmwareLoader.getModelSaveFileString(FirmwareLoader.outputType) + "_" + flrl.SelectedVersion + ".sgl"; if (saveFileDialog.ShowDialog() == DialogResult.OK && saveFileDialog.FileName != null) { tempFile = saveFileDialog.FileName; } else { MessageBox.Show(StringsDict["No_file_location_specified"]); SetLoadingState(false); IsLoading = false; return; } } else { tempFile = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + ".sgl"; } // Download the firmware binary to a temporary file try { Application.DoEvents(); this.progressBarDwnl.Value = 0; this.progressBarDwnl.Visible = true; wc.DownloadFileAsync(new Uri(flrl.SelectedURL), tempFile); } catch (Exception ex) { MessageBox.Show(StringsDict["Error"] + ": " + ex.Message, StringsDict["Error"], MessageBoxButtons.OK, MessageBoxIcon.Error); if (File.Exists(tempFile)) { File.Delete(tempFile); } SetLoadingState(false); this.progressBarDwnl.Visible = false; return; } } else { SetLoadingState(false); } return; }
public void WriteSection(IniFiles iniFile, string sectionName, string[] values) { var file = Path.Combine(this.basePath, FileNames[iniFile]); var result = IniFileUtils.WriteSection(file, sectionName, values); }
public string[] ReadSection(IniFiles iniFile, string sectionName) { var file = Path.Combine(this.basePath, FileNames[iniFile]); return(IniFileUtils.ReadSection(file, sectionName)); }
/// <summary> /// Build a Bing TreeEnsemble .ini representation of the given predictor /// </summary> public static string LinearModelAsIni(ref VBuffer <Float> weights, Float bias, IPredictor predictor = null, RoleMappedSchema schema = null, PlattCalibrator calibrator = null) { // TODO: Might need to consider a max line length for the Weights list, requiring us to split it up into // multiple evaluators StringBuilder inputBuilder = new StringBuilder(); StringBuilder aggregatedNodesBuilder = new StringBuilder("Nodes="); StringBuilder weightsBuilder = new StringBuilder("Weights="); var featureNames = default(VBuffer <ReadOnlyMemory <char> >); MetadataUtils.GetSlotNames(schema, RoleMappedSchema.ColumnRole.Feature, weights.Length, ref featureNames); int numNonZeroWeights = 0; const string weightsSep = "\t"; VBufferUtils.ForEachDefined(ref weights, (idx, value) => { if (Math.Abs(value - 0) >= Epsilon) { numNonZeroWeights++; var name = featureNames.GetItemOrDefault(idx); inputBuilder.AppendLine("[Input:" + numNonZeroWeights + "]"); inputBuilder.AppendLine("Name=" + (featureNames.Count == 0 ? "Feature_" + idx : name.IsEmpty ? $"f{idx}" : name.ToString())); inputBuilder.AppendLine("Transform=linear"); inputBuilder.AppendLine("Slope=1"); inputBuilder.AppendLine("Intercept=0"); inputBuilder.AppendLine(); aggregatedNodesBuilder.Append("I:" + numNonZeroWeights + weightsSep); weightsBuilder.Append(value + weightsSep); } }); StringBuilder builder = new StringBuilder(); builder.AppendLine("[TreeEnsemble]"); builder.AppendLine("Inputs=" + numNonZeroWeights); builder.AppendLine("Evaluators=1"); builder.AppendLine(); builder.AppendLine(inputBuilder.ToString()); builder.AppendLine("[Evaluator:1]"); builder.AppendLine("EvaluatorType=Aggregator"); builder.AppendLine("Type=Linear"); builder.AppendLine("Bias=" + bias); builder.AppendLine("NumNodes=" + numNonZeroWeights); builder.AppendLine(aggregatedNodesBuilder.ToString().Trim()); builder.AppendLine(weightsBuilder.ToString().Trim()); #if false // REVIEW: This should be done by the caller using the actual training args! builder.AppendLine(); builder.AppendLine("[Comments]"); builder.Append("Trained by TLC"); if (predictor != null) { builder.Append(" as /cl " + predictor.GetType().Name); if (predictor is IInitializable) { string settings = string.Join(";", (predictor as IInitializable).GetSettings()); if (!string.IsNullOrEmpty(settings)) { builder.Append(" /cls " + settings); } } } #endif string ini = builder.ToString(); // Add the calibration if the model was trained with calibration if (calibrator != null) { string calibratorEvaluatorIni = IniFileUtils.GetCalibratorEvaluatorIni(ini, calibrator); ini = IniFileUtils.AddEvaluator(ini, calibratorEvaluatorIni); } return(ini); }