本文整理汇总了C#中Role.ContrastColor方法的典型用法代码示例。如果您正苦于以下问题:C# Role.ContrastColor方法的具体用法?C# Role.ContrastColor怎么用?C# Role.ContrastColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Role
的用法示例。
在下文中一共展示了Role.ContrastColor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveRole
public JsonResult SaveRole(RoleInfo Info)
{
RequestResultModel _model = new RequestResultModel();
if (Info.Name == null || Info.Name.Trim().Length == 0)
{
_model = new RequestResultModel();
_model.Title = "Warning";
_model.Message = "Name is empty. Please, enter role name.";
_model.InfoType = RequestResultInfoType.ErrorOrDanger;
AuditEvent.AppEventWarning(Profile.Member.Email, _model.Message);
return Json(new
{
NotifyType = NotifyType.DialogInline,
Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model)
}, JsonRequestBehavior.AllowGet);
}
if (!AppSession.IsColor(Info.Color))
{
_model = new RequestResultModel();
_model.Title = "Warning";
_model.Message = "Wrong color value or format, please check.";
_model.InfoType = RequestResultInfoType.ErrorOrDanger;
AuditEvent.AppEventWarning(Profile.Member.Email, _model.Message);
return Json(new
{
NotifyType = NotifyType.DialogInline,
Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model)
}, JsonRequestBehavior.AllowGet);
}
if (Info.RoleID > 0)
{
Role role = Web.Admin.Logic.Collections.Roles.GetBy(Info.RoleID);
Role roleExists = Web.Admin.Logic.Collections.Roles.GetBy(Info.Name);
// The role has been deleted.
if (role.RoleID <= 0)
{
_model.Title = "Warning";
_model.Message = String.Format("Role '{0}' doesn't exist. Please, refresh role list and try again.", roleExists.Name);
AuditEvent.AppEventWarning(Profile.Member.Email, _model.Message);
return Json(new
{
NotifyType = NotifyType.DialogInline,
Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model)
}, JsonRequestBehavior.AllowGet);
}
// The role already esists.
if (roleExists.RoleID > 0 && Info.RoleID != roleExists.RoleID)
{
_model.Title = "Warning";
_model.Message = String.Format("Role '{0}' already exists. Please, change role name and try again.", roleExists.Name);
AuditEvent.AppEventWarning(Profile.Member.Email, _model.Message);
return Json(new
{
NotifyType = NotifyType.DialogInline,
Html = this.RenderPartialView(@"_RequestResultDialogInLine", _model)
}, JsonRequestBehavior.AllowGet);
}
if (!role.IsBuiltIn)
{
role.Name = Info.Name;
role.IsBuiltIn = false;
}
else
{
role.IsBuiltIn = true;
}
role.Settings = Info.Settings;
role.BackColor = Info.Color != null ? Info.Color.Replace("#", "") : "FFFFFF";
role.ForeColor = Role.ContrastColor(role.BackColor.Replace("#", ""));
role.Save();
_model = new RequestResultModel();
_model.Message = String.Format("Role \"{0}\"has been updated.",role.Name);
_model.HideInSeconds = 4000;
AuditEvent.AppEventSuccess(Profile.Member.Email, _model.Message);
return Json(new
{
NotifyType = NotifyType.PageInline,
Html = this.RenderPartialView(@"_RequestResultPageInLine", _model)
}, JsonRequestBehavior.AllowGet);
}
else
//.........这里部分代码省略.........