// 读取ini中配置, 赋值给全局变量 private void ReadDefault() { markNames = new List <string>(); markNames.AddRange(OperIni.ReadIni("Default", "DWNames", iniFilePath).Split(',')); string tmp = OperIni.ReadIni("Default", "MarkKind", iniFilePath).ToString(); switch (tmp) { case "Solid": markKind = MarkKind.Solid; break; case "Names": markKind = MarkKind.Names; break; case "Numbers": markKind = MarkKind.Numbers; break; default: markKind = MarkKind.Solid; break; } markText = OperIni.ReadIni("Default", "Text", iniFilePath); markOrderStart = Convert.ToInt32(OperIni.ReadIni("Default", "OrderStart", iniFilePath)); markOrderEnd = Convert.ToInt32(OperIni.ReadIni("Default", "OrderEnd", iniFilePath)); markFont = OperIni.ReadIni("Default", "Font", iniFilePath); markWidth = Convert.ToInt32(OperIni.ReadIni("Default", "Width", iniFilePath)); markHeight = Convert.ToInt32(OperIni.ReadIni("Default", "Height", iniFilePath)); markFontColor = ColorTranslator.FromHtml(OperIni.ReadIni("Default", "FontColor", iniFilePath)); markRotation = Convert.ToInt32(OperIni.ReadIni("Default", "Rotation", iniFilePath)); }
private bool CheckAllValues() { if (rdoNames.Checked) { if (string.IsNullOrEmpty(OperIni.ReadIni("Default", "DWNames", iniFilePath))) { MessageBox.Show("配置文件中找不到单位名称名单"); return(false); } } if (rdoSolid.Checked) { if (string.IsNullOrEmpty(txtSolidText.Text.Trim())) { txtSolidText.Focus(); return(false); } } if (string.IsNullOrEmpty(txtFont.Text.Trim())) { txtFont.Focus(); return(false); } return(true); }
private void SaveToIniFile() { OperIni.WriteIni("Default", "MarkKind", markKind.ToString(), iniFilePath); OperIni.WriteIni("Default", "Text", txtSolidText.Text.Trim(), iniFilePath); OperIni.WriteIni("Default", "OrderStart", numOrderStart.Value.ToString().Trim(), iniFilePath); OperIni.WriteIni("Default", "OrderEnd", numOrderEnd.Value.ToString().Trim(), iniFilePath); OperIni.WriteIni("Default", "Font", txtFont.Text.Trim(), iniFilePath); OperIni.WriteIni("Default", "Width", numMarkWidth.Value.ToString().Trim(), iniFilePath); OperIni.WriteIni("Default", "Height", numMarkHeight.Value.ToString().Trim(), iniFilePath); OperIni.WriteIni("Default", "FontColor", ColorTranslator.ToHtml(picFontColor.BackColor), iniFilePath); OperIni.WriteIni("Default", "Rotation", numRotation.Value.ToString().Trim(), iniFilePath); }
// 创建初始配置文件 private void CreateIniFile() { OperIni.WriteIni("Default", "MarkKind", "true", iniFilePath); OperIni.WriteIni("Default", "Text", "", iniFilePath); OperIni.WriteIni("Default", "OrderStart", "0", iniFilePath); OperIni.WriteIni("Default", "OrderEnd", "0", iniFilePath); OperIni.WriteIni("Default", "Font", "宋体", iniFilePath); OperIni.WriteIni("Default", "Width", "500", iniFilePath); OperIni.WriteIni("Default", "Height", "100", iniFilePath); OperIni.WriteIni("Default", "FontColor", "#000000", iniFilePath); OperIni.WriteIni("Default", "Rotation", "-40", iniFilePath); OperIni.WriteIni("Default", "DWNames", "商务局," + "税务局," + "工委," + "区委办", iniFilePath); }