/// <summary> /// /// </summary> /// <param name="index"></param> public void Remove(int index) { #region if (index > Count - 1 || index < 0) { ExtConsole.WriteWithColor("添加页排序时,索引出错!"); } else { List.RemoveAt(index); } #endregion }
/// <summary> /// /// </summary> /// <param name="sqlExpression"></param> public void Add(PageSort pagesort) { #region for (int i = 0; i < this.Count; i++) { if (pagesort.Fieldname == ((PageSort)List[i]).Fieldname) { ExtConsole.WriteWithColor("不能重复添加排序字段!"); return; } } List.Add(pagesort); #endregion }
/// <summary> /// 处理资源名 /// </summary> /// <param name="assemblyName"></param> /// <returns></returns> private string filterResourceName(string assemblyName) { #region int findindex = this._icoResourceName.IndexOf(assemblyName + "."); string resource = this._icoResourceName; if (findindex == -1) { resource = string.Format("{0}.{1}", assemblyName, resource); } ExtConsole.Write(resource); return(resource); #endregion }
/// <summary> /// 获取图标 /// </summary> /// <returns></returns> private Icon getIcon() { #region Assembly asm = Assembly.GetAssembly(this._mainFrm.GetType()); string resource = filterResourceName(asm.GetName().Name); Stream manifestResourceStream = asm .GetManifestResourceStream(resource); if (manifestResourceStream == null) { ExtConsole.Write("设置状态栏ico图标出错,请确认!"); return(new Icon(SystemIcons.Exclamation, 16, 16)); } return(new Icon(manifestResourceStream)); #endregion }
/// <summary> /// 把所有自动登录并启动程序的信息写入注册表 /// </summary> /// <param name="writeregisterinformation"></param> public static bool WriteAll(AutoStartInformation infor) { #region bool issuccess = false; try { RegistryKey myKeyMachine, myKeyUser; myKeyMachine = Registry.LocalMachine .CreateSubKey(AutoStartInformation.RegistAutoLogonPath); myKeyMachine.SetValue(AutoStartInformation.KeyAutoLogon , getAutoLogonMarkup(infor.AutologonState)); myKeyMachine.SetValue(AutoStartInformation.KeyDefaultUserName , infor.Username); myKeyMachine.SetValue(AutoStartInformation.KeyDefaultPassword , infor.Password); myKeyUser = Registry.CurrentUser.CreateSubKey( AutoStartInformation.RegistAutoLoadExePath); myKeyUser.SetValue(AutoStartInformation.KeyAutoloadPath , infor.exefilepath); myKeyUser.Close(); myKeyMachine.Close(); issuccess = true; } catch (System.Security.SecurityException) { ErrorInformation = "不允许修改注册表,请检查杀毒软件是否关闭,并要用管理员身份运行程序!"; } catch (Exception ex) { ExtConsole.Write(ex.GetType().ToString()); ErrorInformation = "写入注册表失败,请以管理员身份运行程序!"; } return(issuccess); #endregion }
/// <summary> /// 更新App.config文件对应键值 /// </summary> /// <param name="keyName">键名</param> /// <param name="value">更新值</param> public static void Update(object keyName, ref object newValue) { #region if (_configCacheGroup.Contains(keyName)) { if (_configCacheGroup[keyName] != newValue) { //此处给对应的键进行赋值,下面的save操作会应用此更新。 _configuration.AppSettings.Settings[keyName.ToString()].Value = newValue.ToString(); lock (_lockConfig) { _configuration.Save(); _configCacheGroup[keyName] = newValue; } } } else { ExtConsole.Write(string.Format("系统应针对{0}键先进行读取后才可保存", keyName)); } #endregion }