/// <summary> /// Validates a user before saving /// </summary> /// <param name="user" /> /// <returns /> public async Task <IdentityResult> ValidateAsync(KeylolUser user) { if (user == null) { throw new ArgumentNullException(nameof(user)); } // IdCode var idCodeOwner = await _userManager.FindByIdCodeAsync(user.IdCode); if (idCodeOwner == null) { if (!Regex.IsMatch(user.IdCode, Constants.IdCodeConstraint)) { return(IdentityResult.Failed(Errors.InvalidIdCode)); } if (IsIdCodeReserved(user.IdCode)) { return(IdentityResult.Failed(Errors.IdCodeReserved)); } } else if (idCodeOwner.Id != user.Id) { return(IdentityResult.Failed(Errors.IdCodeUsed)); } // UserName var userNameOwner = await _userManager.FindByNameAsync(user.UserName); if (userNameOwner == null) { if (user.UserName.Length < 3 || user.UserName.Length > 16) { return(IdentityResult.Failed(Errors.UserNameInvalidLength)); } if (!Regex.IsMatch(user.UserName, Constants.UserNameConstraint)) { return(IdentityResult.Failed(Errors.UserNameInvalidCharacter)); } } else if (userNameOwner.Id != user.Id) { return(IdentityResult.Failed(Errors.UserNameUsed)); } // Email if (string.IsNullOrWhiteSpace(user.Email)) { user.Email = null; } else { if (!new EmailAddressAttribute().IsValid(user.Email)) { return(IdentityResult.Failed(Errors.InvalidEmail)); } var emailOwner = await _userManager.FindByEmailAsync(user.Email); if (emailOwner != null && emailOwner.Id != user.Id) { return(IdentityResult.Failed(Errors.EmailUsed)); } } // GamerTag if (user.GamerTag.Length > 40) { return(IdentityResult.Failed(Errors.GamerTagInvalidLength)); } // AvatarImage if (string.IsNullOrWhiteSpace(user.AvatarImage)) { user.AvatarImage = string.Empty; } else if (!Helpers.IsTrustedUrl(user.AvatarImage)) { return(IdentityResult.Failed(Errors.AvatarImageUntrusted)); } // HeaderImage if (string.IsNullOrWhiteSpace(user.HeaderImage)) { user.HeaderImage = string.Empty; } else if (!Helpers.IsTrustedUrl(user.HeaderImage)) { return(IdentityResult.Failed(Errors.HeaderImageUntrusted)); } // ThemeColor try { user.ThemeColor = string.IsNullOrWhiteSpace(user.ThemeColor) ? string.Empty : ColorTranslator.ToHtml(ColorTranslator.FromHtml(user.ThemeColor)); } catch (Exception) { return(IdentityResult.Failed(Errors.InvalidThemeColor)); } // LightThemeColor try { user.LightThemeColor = string.IsNullOrWhiteSpace(user.LightThemeColor) ? string.Empty : ColorTranslator.ToHtml(ColorTranslator.FromHtml(user.LightThemeColor)); } catch (Exception) { return(IdentityResult.Failed(Errors.InvalidLightThemeColor)); } return(IdentityResult.Success); }
protected override void ExportContent(TextWriter writer) { foreach (var location in LocationsInExportOrder) { writer.WriteLine(" <object name=\"{0}\">", location.ExportName); writer.WriteLine(" <inherit name=\"editor_room\" />"); writer.WriteLine(" <alias>{0}</alias>", location.Room.Name); if (location.Room.IsDark) { writer.WriteLine(" <dark />"); } writer.WriteLine(" <attr name=\"grid_width\" type=\"int\">{0}</attr>", location.Room.Width / 32); writer.WriteLine(" <attr name=\"grid_length\" type=\"int\">{0}</attr>", location.Room.Height / 32); writer.WriteLine(" <attr name=\"grid_fill\">{0}</attr>", ColorTranslator.ToHtml(location.Room.RoomFillColor)); writer.WriteLine(" <attr name=\"grid_border\">{0}</attr>", ColorTranslator.ToHtml(location.Room.RoomBorderColor)); writer.WriteLine(" <attr name=\"implementation_notes\">{0}</attr>", location.Room.GetToolTipText()); if (!string.IsNullOrEmpty(location.Room.PrimaryDescription)) { writer.WriteLine(" <description>{0}</description>", location.Room.PrimaryDescription); } foreach (var direction in Directions.AllDirections) { var exit = location.GetBestExit(direction); if (exit != null) { writer.WriteLine(" <exit alias=\"{0}\" to=\"{1}\">", toQuestPropertyName(direction), exit.Target.ExportName); writer.WriteLine(" <inherit name=\"{0}direction\" />", toQuestPropertyName(direction)); writer.WriteLine(" </exit>"); } } if (location.Room.IsStartRoom) { writer.WriteLine(" <object name=\"player\">"); writer.WriteLine(" <inherit name=\"editor_object\" />"); writer.WriteLine(" <inherit name=\"editor_player\" />"); writer.WriteLine(" </object>"); } foreach (var thing in location.Things) { writer.WriteLine(" <object name=\"{0}\">", thing.ExportName); writer.WriteLine(" <inherit name=\"editor_object\" />"); if (thing.IsScenery) { writer.WriteLine(" <scenery />"); } if (thing.IsContainer) { writer.WriteLine(" <feature_container />"); writer.WriteLine(" <inherit name=\"container_closed\" />"); } if (thing.Forceplural == Thing.Amounts.Plural) { writer.WriteLine(" <inherit name=\"plural\" />"); } if (thing.IsPerson) { if (thing.Gender == Thing.ThingGender.Female) { if (thing.ProperNamed) { writer.WriteLine(" <inherit name=\"namedfemale\" />"); } else { writer.WriteLine(" <inherit name=\"female\" />"); } } else if (thing.Gender == Thing.ThingGender.Male) { if (thing.ProperNamed) { writer.WriteLine(" <inherit name=\"namedmale\" />"); } else { writer.WriteLine(" <inherit name=\"male\" />"); } } } writer.WriteLine(" <alias>{0}</alias>", thing.DisplayName); writer.WriteLine(" </object>"); } // TODO need to add player if here writer.WriteLine(" </object>"); writer.WriteLine(); } writer.WriteLine(); }
private void renderEvent(HtmlTextWriter output, Event e, Day d) { string displayTextPopup = e.Name + " (" + e.Start.ToShortTimeString() + " - " + e.End.ToShortTimeString() + ")" + ":" + e.Owner; string displayText = e.Name + ": " + e.Owner; // real box dimensions and position DateTime dayVisibleStart = new DateTime(d.Start.Year, d.Start.Month, d.Start.Day, visibleStart.Hour, 0, 0); DateTime realBoxStart = e.BoxStart < dayVisibleStart ? dayVisibleStart : e.BoxStart; DateTime dayVisibleEnd; if (visibleEnd.Day == 1) { dayVisibleEnd = new DateTime(d.Start.Year, d.Start.Month, d.Start.Day, visibleEnd.Hour, 0, 0); } else if (visibleEnd.Day == 2) { dayVisibleEnd = new DateTime(d.Start.Year, d.Start.Month, d.Start.Day, visibleEnd.Hour, 0, 0).AddDays(1); } else { throw new ArgumentOutOfRangeException("Unexpected time for dayVisibleEnd."); } DateTime realBoxEnd = e.BoxEnd > dayVisibleEnd ? dayVisibleEnd : e.BoxEnd; // top double top = (realBoxStart - dayVisibleStart).TotalHours * HourHeight + 1; if (ShowHeader) { top += this.HeaderHeight; } // height double height = ((realBoxEnd - realBoxStart).TotalHours * HourHeight - 2); // It's outside of visible area (for NonBusinessHours set to Hide). // Don't draw it in that case. if (height <= 0) { return; } // MAIN BOX output.AddAttribute("onselectstart", "return false;"); // prevent text selection in IE if (EventClickHandling == UserActionHandling.PostBack) { output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + Page.ClientScript.GetPostBackEventReference(this, "PK:" + e.PK)); } else { output.AddAttribute("onclick", "javascript:event.cancelBubble=true;" + String.Format(EventClickJavaScript, e.PK)); } output.AddStyleAttribute("-moz-user-select", "none"); // prevent text selection in FF output.AddStyleAttribute("-khtml-user-select", "none"); // prevent text selection output.AddStyleAttribute("user-select", "none"); // prevent text selection output.AddStyleAttribute("cursor", "pointer"); //output.AddStyleAttribute("cursor", "hand"); output.AddStyleAttribute("position", "absolute"); output.AddStyleAttribute("font-family", EventFontFamily); output.AddStyleAttribute("font-size", EventFontSize); output.AddStyleAttribute("white-space", "no-wrap"); output.AddStyleAttribute("left", e.Column.StartsAtPct + "%"); output.AddStyleAttribute("top", top + "px"); output.AddStyleAttribute("width", e.Column.WidthPct + "%"); output.AddStyleAttribute("height", (realBoxEnd - realBoxStart).TotalHours * HourHeight + "px"); output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(EventBorderColor)); output.RenderBeginTag("div"); //output.Write(divMain.BeginTag()); // FIX BOX - to fix the outer/inner box differences in Mozilla/IE (to create border) // DivWriter divFix = new DivWriter(); output.AddAttribute("onmouseover", "this.style.backgroundColor='" + ColorTranslator.ToHtml(EventHoverColor) + "';event.cancelBubble=true;"); output.AddAttribute("onmouseout", "this.style.backgroundColor='" + ColorTranslator.ToHtml(EventBackColor) + "';event.cancelBubble=true;"); if (ShowToolTip) { output.AddAttribute("title", displayTextPopup); } output.AddStyleAttribute("margin-top", "1px"); output.AddStyleAttribute("display", "block"); output.AddStyleAttribute("height", height + "px"); output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(EventBackColor)); output.AddStyleAttribute("border-left", "1px solid " + ColorTranslator.ToHtml(EventBorderColor)); output.AddStyleAttribute("border-right", "1px solid " + ColorTranslator.ToHtml(EventBorderColor)); output.AddStyleAttribute("overflow", "hidden"); output.RenderBeginTag("div"); // output.Write(divFix.BeginTag()); // blue column if (e.Start > realBoxStart) { } int startDelta = (int)Math.Floor((e.Start - realBoxStart).TotalHours * HourHeight); int endDelta = (int)Math.Floor((realBoxEnd - e.End).TotalHours * HourHeight); // DivWriter divBlue = new DivWriter(); output.AddStyleAttribute("float", "left"); output.AddStyleAttribute("width", "5px"); output.AddStyleAttribute("height", height - startDelta - endDelta + "px"); output.AddStyleAttribute("margin-top", startDelta + "px"); output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(DurationBarColor)); output.AddStyleAttribute("font-size", "1px"); output.RenderBeginTag("div"); output.RenderEndTag(); // output.Write(divBlue.BeginTag()); // output.Write(divBlue.EndTag()); // right border of blue column // DivWriter divBorder = new DivWriter(); output.AddStyleAttribute("float", "left"); output.AddStyleAttribute("width", "1px"); output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(EventBorderColor)); output.AddStyleAttribute("height", "100%"); output.RenderBeginTag("div"); output.RenderEndTag(); // output.Write(divBorder.BeginTag()); // output.Write(divBorder.EndTag()); // space // DivWriter divSpace = new DivWriter(); output.AddStyleAttribute("float", "left"); output.AddStyleAttribute("width", "2px"); output.AddStyleAttribute("height", "100%"); output.RenderBeginTag("div"); output.RenderEndTag(); // output.Write(divSpace.BeginTag()); // output.Write(divSpace.EndTag()); // PADDING BOX // DivWriter divPadding = new DivWriter(); output.AddStyleAttribute("padding", "1px"); output.RenderBeginTag("div"); // output.Write(divPadding.BeginTag()); output.Write(displayText); // e.BoxStart - dayVisibleStart // closing the PADDING BOX output.RenderEndTag(); // output.Write(divPadding.EndTag()); // closing the FIX BOX output.RenderEndTag(); // output.Write(divFix.EndTag()); // closing the MAIN BOX // output.Write(divMain.EndTag()); output.RenderEndTag(); }
/// <summary> /// Colours to hexadecimal. /// </summary> /// <param name="colour">The colour.</param> /// <returns></returns> public static string ColourToHexadecimal(Color colour) => ColorTranslator.ToHtml(colour);
private static string ColorToHex(Color color) { return(ColorTranslator.ToHtml(Color.FromArgb(color.ToArgb()))); }
private void cDarkSeaGreen_Click(object sender, EventArgs e) { mColor = ColorTranslator.ToHtml(cDarkSeaGreen.BackColor); this.Close(); }
public string ColorToHexa(Color color) { var s = ColorTranslator.ToHtml(Color.FromArgb(color.R, color.G, color.B)); return(s); }
private static void AppendBackgroundSettings(XmlDocument doc, XmlNode parentNode) { parentNode.AppendChild(createNode(doc, "render_background", Runtime.renderBackGround.ToString())); parentNode.AppendChild(createNode(doc, "back_gradient_top", ColorTranslator.ToHtml(Runtime.backgroundGradientTop))); parentNode.AppendChild(createNode(doc, "back_gradient_bottom", ColorTranslator.ToHtml(Runtime.backgroundGradientBottom))); }
string template_style() => $@" /********** MAIN ***********/ .{template_FR}-container {{ {(Width.IsNullOrWhiteSpace() ? "" : $"width: {Width};")} {(Height.IsNullOrWhiteSpace() ? "" : $"height: {Height};")} background-color: white; display: {(Inline ? "inline-" : "")}flex; flex-direction: {Toolbar.Vertical}; position: relative; }} .{template_FR}-container * {{ box-sizing: content-box; -moz-box-sizing: content-box; }} .{template_FR}-body {{ display: flex; overflow: hidden; width: 100%; height: 100%; }} .{template_FR}-report {{ overflow: auto; width: 100%; display: flex; flex-direction: {Toolbar.RowOrColumn}; align-items: flex-start; }} /*********** SPLIT ************/ .{template_FR}-gutter {{ background-color: #f1f1f1; background-repeat: no-repeat; background-position: 50%; }} .{template_FR}-gutter.{template_FR}-gutter-horizontal {{ background-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAeCAYAAADkftS9AAAAIklEQVQoU2M4c+bMfxAGAgYYmwGrIIiDjrELjpo5aiZeMwF+yNnOs5KSvgAAAABJRU5ErkJggg=='); cursor: ew-resize; }} /************* TOOLBAR **************/ .{template_FR}-toolbar {{ flex-shrink: 1; font:{Toolbar.UserFontSettings}; background-color: {ColorTranslator.ToHtml(Toolbar.Color)}; {(Tabs.Count > 1 ? "" : "box-shadow: 0px 3px 4px -2px rgba(0, 0, 0, 0.2);")} display: flex; flex-direction: {Toolbar.RowOrColumn}; /* flex-wrap: wrap; */ width: auto; height: {Toolbar.VerticalToolbarHeight}%; order:{Toolbar.TopOrBottom} ; position: relative; align-items: center; justify-content:{Toolbar.Content}; z-index: 2; border-radius:{Toolbar.ToolbarRoundness}px; min-width:50px; /*min-width: intrinsic; min-width: -moz-max-content; min-width: -webkit-max-content; min-width: max-content;*/ }} .{template_FR}-toolbar-item {{ height: {ToolbarHeight}px; border-radius:{Toolbar.ToolbarRoundness}px; background-color: #00000000; position: relative; }} .{template_FR}-toolbar-item:hover {{ background-color: {ColorTranslator.ToHtml(Toolbar.Color)}; }} .{template_FR}-toolbar-item > img {{ height: calc({ToolbarHeight}px * 0.7); padding-top: calc({ToolbarHeight}px * 0.15); padding-bottom: calc({ToolbarHeight}px * 0.15); padding-left: calc({ToolbarHeight}px * 0.25); padding-right: calc({ToolbarHeight}px * 0.25); opacity: {Toolbar.TransparencyIcon}; display: block; filter:invert({Toolbar.ColorIcon}) }} .{template_FR}-toolbar-item:hover > img {{ opacity: 1; }} .{template_FR}-toolbar-notbutton:hover {{ background-color: transparent; }} .{template_FR}-toolbar-notbutton:hover > img {{ opacity: 0.5; }} /********************** TOOLBAR DROPDOWN ***********************/ .{template_FR}-toolbar-dropdown-content {{ display: none; box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2); background-color: {ColorTranslator.ToHtml(Toolbar.DropDownMenuColor)}; min-width: 120px; z-index: 2; position: absolute; {Toolbar.DropDownMenuPosition} white-space: nowrap; }} .{template_FR}-toolbar-item:hover > .{template_FR}-toolbar-dropdown-content {{ display: block; }} .{template_FR}-toolbar-dropdown-content > a {{ float: none; color: {ColorTranslator.ToHtml(Toolbar.DropDownMenuTextColor)}; padding: 6px 12px 6px 8px; text-decoration: none; display: block; text-align: left; height: auto; font-size: 14px; user-select: none; }} .{template_FR}-toolbar-dropdown-content > a:hover {{ background-color: {ColorTranslator.ToHtml(Toolbar.DropDownMenuColor)}; opacity:0.5; cursor: pointer; }} .{template_FR}-zoom-selected {{ width: 14px; opacity: 0.6; display: inline-block; font-size: 14px; }} /************************ TOOLBAR NAVIGATION *************************/ .{template_FR}-toolbar-narrow > img {{ padding-left: 0px; padding-right: 0px; }} .{template_FR}-toolbar-slash > img {{ height: calc({ToolbarHeight}px * 0.44); padding-top: calc({ToolbarHeight}px * 0.3); padding-bottom: calc({ToolbarHeight}px * 0.26); padding-left: 0; padding-right: 0; }} .{template_FR}-toolbar-item > input {{ font-family: Arial,sans-serif; font-size: calc({ToolbarHeight}px * 0.35); text-align: center; border: 0; background: #fbfbfb; border-radius:{Toolbar.ToolbarRoundness}px; height: calc({ToolbarHeight}px * 0.68); width: 2.5em; margin-top: calc({ToolbarHeight}px * 0.17); margin-bottom: calc({ToolbarHeight}px * 0.15); margin-left: calc({ToolbarHeight}px * 0.1); margin-right: calc({ToolbarHeight}px * 0.1); padding: 0; display: block; }} .{template_FR}-toolbar-item > input:hover:not([readonly]) {{ background: #fff; }} .{template_FR}-toolbar-item > input[readonly] {{ cursor: default; }} /************** SPINNER **************/ .{template_FR}-spinner {{ height: 100%; width: 100%; position: absolute; background-color: rgba(255, 255, 255, 0.7); z-index: 10; }} .{template_FR}-spinner img {{ width: 90px; height: 90px; left: calc(50% - 50px); top: calc(50% - 50px); position: absolute; animation: {template_FR}-spin 1s infinite steps(8); opacity: 0.5; }} @keyframes {template_FR}-spin {{ from {{ -webkit-transform: rotate(0deg); }} to {{ -webkit-transform: rotate(360deg); }} }} /************ ERROR ************/ .{template_FR}-error-container {{ width: 100%; height: 100%; display: flex; flex-direction: column; overflow: auto; }} .{template_FR}-error-text {{ color: red; font-family: Consolas,monospace; font-size: 16px; margin: 20px; text-align: center; }} .{template_FR}-error-response {{ height: 100%; position: relative; }} /*********** TABS ***********/ .{template_FR}-tabs {{ flex-shrink: 0; font-family: Verdana,Arial,sans-serif; background-color: #f1f1f1; display: table; width: {Toolbar.TabsPositionSettings}; max-width: 800px; box-shadow: 0px 3px 4px -2px rgba(0, 0, 0, 0.2); position: relative; z-index: 1; {Toolbar.TabsPositionSettings} }} .{template_FR}-tabs .{template_FR}-tab {{ float: left; display: block; color: #3b3b3b; text-align: center; text-decoration: none; font-size: 12px; background-color: #f1f1f1; margin-top: 2px; margin-right: 2px; height: 24px; }} .{template_FR}-tabs .{template_FR}-tab-title {{ display: block; float: left; padding: 4.5px 10px; }} .{template_FR}-tabs .{template_FR}-tab-close {{ width: 13px; height: 13px; display: block; float: left; margin-top: 6px; margin-right: 6px; }} .{template_FR}-tabs .{template_FR}-tab:hover {{ background-color: lightgray; color: black; cursor: pointer; }} .{template_FR}-tabs .{template_FR}-tab.active {{ background-color: lightgray; color: black; cursor: default; }} .{template_FR}-tabs .{template_FR}-tab a img {{ height: 13px; opacity: 0; }} .{template_FR}-tabs .{template_FR}-tab.active a img {{ opacity: 0.5; }} .{template_FR}-tabs .{template_FR}-tab:hover a img {{ opacity: 0.5; }} .{template_FR}-tabs .{template_FR}-tab a img:hover {{ opacity: 1; background-color: #f1f1f1; cursor: pointer; }} /*********** MISC ***********/ .{template_FR}-pointer:hover {{ cursor: pointer; }} .{template_FR}-disabled {{ opacity: 0.5; }} /************** OUTLINE **************/ .{template_FR}-outline {{ overflow: auto; height: auto; font-family: Verdana,Arial,sans-serif; font-size: 11px; }} .{template_FR}-outline img {{ opacity: 0.5; }} .{template_FR}-outline-inner {{ padding: 5px; }} .{template_FR}-outline-node {{ display: flex; flex-wrap: wrap; }} .{template_FR}-outline-caret {{ height: 14px; width: 14px; margin-top: 1.5px; margin-right: 4px; }} .{template_FR}-outline-caret:hover {{ cursor: pointer; }} .{template_FR}-outline-caret-blank {{ width: 18px; }} .{template_FR}-outline-file {{ height: 14px; margin-top: 1.5px; }} .{template_FR}-outline-text {{ white-space: nowrap; display: flex; align-items: center; }} .{template_FR}-outline-text > a {{ margin: 2px; padding: 2px; }} .{template_FR}-outline-text > a:hover {{ text-decoration: underline; cursor: pointer; }} .{template_FR}-outline-children {{ padding-left: 20px; }} ";
// 获取实体信息 public void GetEntitiesInfo(ArrayList entities, Transaction trans, BlockTableRecord btr, int numSample, Document doc, Editor ed) { ArrayList uuid = new ArrayList(); ArrayList geom = new ArrayList(); // 坐标点集合 ArrayList colorList = new ArrayList(); // 颜色集合 ArrayList type = new ArrayList(); // 类型集合 ArrayList layerName = new ArrayList(); ArrayList tableName = new ArrayList(); // 表名 System.Data.DataTable attributeList = new System.Data.DataTable(); // 属性集合 ArrayList attributeIndexList = new ArrayList(); //属性索引集合 ArrayList tuliList = new ArrayList(); //图例集合 string projectId = ""; //项目ID string chartName = ""; //表名称 ArrayList kgGuide = new ArrayList(); //控规引导 string srid = ""; //地理坐标系统编号 ArrayList parentId = new ArrayList(); //配套设施所在地块集合 ArrayList textContent = new ArrayList(); // 文字内容(GIS端展示) ArrayList blockContent = new ArrayList(); // 块内容(GIS端展示) Dictionary <string, string> result = new Dictionary <string, string>(); // 汇总 // 遍历所有实体 foreach (object entity in entities) { ArrayList singlePositionList = new ArrayList(); // 单个实体坐标点集合 //取得边界数 int loopNum = 1; if (entity is Hatch) { loopNum = (entity as Hatch).NumberOfLoops; type.Add("polygon"); } Point3dCollection col_point3d = new Point3dCollection(); BulgeVertexCollection col_ver = new BulgeVertexCollection(); Curve2dCollection col_cur2d = new Curve2dCollection(); for (int i = 0; i < loopNum; i++) { col_point3d.Clear(); HatchLoop hatLoop = null; if (entity is Hatch) { try { hatLoop = (entity as Hatch).GetLoopAt(i); } catch (System.Exception) { continue; } //如果HatchLoop为PolyLine if (hatLoop.IsPolyline) { col_ver = hatLoop.Polyline; foreach (BulgeVertex vertex in col_ver) { col_point3d.Add(new Point3d(vertex.Vertex.X, vertex.Vertex.Y, 0)); } } } // 如果实体为Polyline if (entity is Polyline) { // 类型 type.Add("polyline"); Polyline polyline = (Polyline)entity; int vn = polyline.NumberOfVertices; for (int w = 0; w < vn; w++) { Point2d pt = polyline.GetPoint2dAt(w); col_point3d.Add(new Point3d(pt.X, pt.Y, 0)); } } //// 如果实体为Curve //if (entity is Curve) //{ // col_cur2d = hatLoop.Curves; // foreach (Curve2d item in col_cur2d) // { // Point2d[] M_point2d = item.GetSamplePoints(numSample); // foreach (Point2d pt in M_point2d) // { // if (!col_point3d.Contains(new Point3d(pt.X, pt.Y, 0))) // col_point3d.Add(new Point3d(pt.X, pt.Y, 0)); // } // } //} // 如果实体为Point2d if (entity is DBPoint) { type.Add("point"); DBPoint entity3 = (DBPoint)entity; col_point3d.Add(new Point3d(entity3.Position.X, entity3.Position.Y, 0)); } // 如果实体为Point if (entity is Point3d) { type.Add("point"); Point3d entity3 = (Point3d)entity; col_point3d.Add(entity3); } // 如果实体为文字 if (entity is MText) { type.Add("text"); col_point3d.Add(new Point3d((entity as MText).Location.X, (entity as MText).Location.Y, 0)); } // 如果实体为文字 if (entity is DBText) { type.Add("text"); col_point3d.Add(new Point3d((entity as DBText).Position.X, (entity as DBText).Position.Y, 0)); } // 块参照 if (entity is BlockReference) { type.Add("block"); col_point3d.Add(new Point3d((entity as BlockReference).Position.X, (entity as BlockReference).Position.Y, 0)); } double[] pointPositionList = new double[2]; //单个点的坐标点集合 // 经纬度转换 foreach (Point3d point in col_point3d) { pointPositionList = new double[2] { Transform(point)[0], Transform(point)[1] }; singlePositionList.Add(pointPositionList); } // 经纬度转换结束 } // 单个实体几何坐标数量循环结束 // UUID Entity entityLayer = (Entity)entity; Guid guid = new Guid(); guid = Guid.NewGuid(); string str = guid.ToString(); uuid.Add(str); // 坐标 geom.Add(singlePositionList); // 颜色 if (entity is Point3d) { colorList.Add(""); // 图层名 layerName.Add("无"); } else { LayerTableRecord ltr = (LayerTableRecord)trans.GetObject(entityLayer.LayerId, OpenMode.ForRead); string color; color = entityLayer.ColorIndex == 256 ? MethodCommand.GetLayerColorByID(entityLayer.LayerId) : ColorTranslator.ToHtml(entityLayer.Color.ColorValue); colorList.Add(color); // 图层名 layerName.Add(ltr.Name); } // 表名 tableName.Add("a"); // 属性索引 // 获取每个闭合多段线对应的个体编号和用地代号 ArrayList tagList = new ArrayList(); PromptSelectionResult psrss = ed.SelectCrossingPolygon(col_point3d); // 获取闭合区域内实体方法 if (psrss.Status == PromptStatus.OK) { tagList.Clear(); SelectionSet SS = psrss.Value; ObjectId[] idArray = SS.GetObjectIds(); // 如果读取的块参照数量大于1,取中心点在闭合多段线的块参照 if (idArray.Length > 1) { for (int i = 0; i < idArray.Length; i++) { Entity ent1 = (Entity)idArray[i].GetObject(OpenMode.ForRead); if (ent1 is BlockReference) { BlockReference ent2 = (BlockReference)ent1; if (IsInPolygon(ent2.Position, col_point3d)) { foreach (ObjectId rt in ((BlockReference)ent1).AttributeCollection) { DBObject dbObj = trans.GetObject(rt, OpenMode.ForRead) as DBObject; AttributeReference acAttRef = dbObj as AttributeReference; tagList.Add(acAttRef.TextString); //MessageBox.Show("Tag: " + acAttRef.Tag + "\n" + // "Value: " + acAttRef.TextString + "\n"); } } } } } // 如果读取的块参照数量等于1,取中心点在闭合多段线的块参照 else { for (int i = 0; i < idArray.Length; i++) { Entity ent1 = (Entity)idArray[i].GetObject(OpenMode.ForRead); if (ent1 is BlockReference) { foreach (ObjectId rt in ((BlockReference)ent1).AttributeCollection) { DBObject dbObj = trans.GetObject(rt, OpenMode.ForRead) as DBObject; AttributeReference acAttRef = dbObj as AttributeReference; tagList.Add(acAttRef.TextString); } } } } } // 如果地块编码属性只有两个属性值,attributeIndexList,如果少于2个或者多于2个都视为异常,添加空。 if (tagList.Count == 2) { attributeIndexList.Add(tagList[0] + "_" + tagList[1]); } else { attributeIndexList.Add(""); } // 属性 readAttributeList attributeListObj = new readAttributeList(); attributeList = attributeListObj.AttributeList(); // 配套设施所属的地块UUID // 获取块参照的属性值 ArrayList blockAttribute = new ArrayList(); // 是否是地块编码本身 string isBlockNum = ""; // 如果这个块标注是幼儿园、公厕等,找对对应的地块编号或UUID if (entity is BlockReference) { // 清除原有内容 blockAttribute.Clear(); // 如果entity有两个属性值,可以判断这是一个地块编码 if (((BlockReference)entity).AttributeCollection.Count == 2) { isBlockNum = "Block"; } // 获取地块界限图层上的所有实体 ArrayList polylineEntities = new ArrayList(); // 找出地块界限里的所有闭合多段线,并判断当前块标注实体是否在某一个闭合多段线内,如果在,找出该闭合多段线内的块参照个体编号 TypedValue[] tvs = new TypedValue[1] { new TypedValue( (int)DxfCode.LayerName, "地块界限" ) }; SelectionFilter sf = new SelectionFilter(tvs); PromptSelectionResult psr = ed.SelectAll(sf); if (psr.Status == PromptStatus.OK) { SelectionSet SS = psr.Value; ObjectId[] idArray = SS.GetObjectIds(); //MessageBox.Show(idArray.Length.ToString()); Point3dCollection polylinePoint3d = new Point3dCollection(); for (int j = 0; j < idArray.Length; j++) { // 清除原有内容 polylinePoint3d.Clear(); Entity ent1 = trans.GetObject(idArray[j], OpenMode.ForWrite) as Entity; if (ent1 is Polyline && (ent1 as Polyline).Closed) { Polyline polyline = (Polyline)ent1; int vn = polyline.NumberOfVertices; for (int w = 0; w < vn; w++) { Point2d pt = polyline.GetPoint2dAt(w); polylinePoint3d.Add(new Point3d(pt.X, pt.Y, 0)); } // 获取闭合多段线(地块)内的所有实体 PromptSelectionResult psrss2 = ed.SelectCrossingPolygon(polylinePoint3d); if (psrss2.Status == PromptStatus.OK) { SelectionSet SS2 = psrss2.Value; ObjectId[] idArray2 = SS2.GetObjectIds(); // 如果读取的块参照数量大于1,且包含当前实体,找出当前块参照所在的闭合多段线 if (idArray2.Length > 1) { for (int i = 0; i < idArray2.Length; i++) { Entity ent2 = (Entity)idArray2[i].GetObject(OpenMode.ForRead); // 判断是否是配套设施开始 if (ent2 is BlockReference && (ent2 as BlockReference).Position.X == (entity as BlockReference).Position.X) { for (int k = 0; k < idArray2.Length; k++) { Entity ent3 = (Entity)idArray2[k].GetObject(OpenMode.ForRead); if (ent3 is BlockReference) { // 判断块参照中心点是否在闭合多段线内,只读取中心点在闭合多段线内的块参照 if (IsInPolygon((ent3 as BlockReference).Position, polylinePoint3d)) { foreach (ObjectId rt in ((BlockReference)ent3).AttributeCollection) { DBObject dbObj = trans.GetObject(rt, OpenMode.ForRead) as DBObject; AttributeReference acAttRef = dbObj as AttributeReference; blockAttribute.Add(acAttRef.TextString); } } } } } // 判断是否是配套设施结束 } } } // 获取闭合多段线(地块)内的所有实体结束 } } } } // 如果这个块标注是幼儿园、公厕等,找对对应的地块编号或UUID 结束 // 如果地块编码属性只有两个属性值,而且不是地块编码块参照,添加到parentId,如果少于2个或者多于2个都视为异常,添加空。 if (blockAttribute.Count == 2 && isBlockNum != "Block") { parentId.Add(blockAttribute[0] + "_" + blockAttribute[1]); } else { parentId.Add(""); } // 文字内容(GIS端展示) if (entity is DBText) { textContent.Add((entity as DBText).TextString); } else if (entity is MText) { textContent.Add((entity as MText).Text); } else if (entity is BlockReference) { List <string> singleBlockContent = new List <string>(); string text = ""; if ((entity as BlockReference).AttributeCollection.Count > 0) { foreach (ObjectId rt in ((BlockReference)entity).AttributeCollection) { DBObject dbObj = trans.GetObject(rt, OpenMode.ForRead) as DBObject; AttributeReference acAttRef = dbObj as AttributeReference; text = text + acAttRef.TextString + "//"; } text = text.Substring(0, text.Length - 2); } textContent.Add(text); } else { textContent.Add(""); } // 块内容(GIS端展示) if (entity is BlockReference) { List <string> singleBlockContent = new List <string>(); string text = "//"; foreach (ObjectId rt in ((BlockReference)entity).AttributeCollection) { DBObject dbObj = trans.GetObject(rt, OpenMode.ForRead) as DBObject; AttributeReference acAttRef = dbObj as AttributeReference; text = acAttRef.TextString + text; //singleBlockContent.Add(acAttRef.TextString); } blockContent.Add(text); //blockContent.Add(singleBlockContent); } else { blockContent.Add(""); } } // 所有的实体循环结束 // 图例 readAttributeList attributeListObj3 = new readAttributeList(); //tuliList.Add(attributeListObj3.TuliList()); tuliList.Add(""); // 项目名 //string projectIdBaseAddress = "http://172.18.84.70:8081/PDD/pdd/individual-manage!findAllProject.action"; //var projectIdHttp = (HttpWebRequest)WebRequest.Create(new Uri(projectIdBaseAddress)); //var response = projectIdHttp.GetResponse(); //var stream = response.GetResponseStream(); //var sr = new StreamReader(stream, Encoding.UTF8); //var content = sr.ReadToEnd(); //MessageBox.Show(content); projectId = "D3DEC178-2C05-C5F1-F6D3-45729EB9436A"; // 图表名或者叫文件名 chartName = Path.GetFileName(ed.Document.Name); // 控规引导 readAttributeList attributeListObj2 = new readAttributeList(); kgGuide = attributeListObj2.KgGuide(); //地理坐标系统编号 srid = "4326"; // 发文字信息 RegulatoryPost.FenTuZe.FenTuZe.SendData(result, uuid, geom, colorList, type, layerName, tableName, attributeIndexList, attributeList, tuliList, projectId, chartName, kgGuide, srid, parentId, textContent, blockContent); }
protected override void UpdateItemsList() { _items.Clear(); if (_setting != null) { SingleSelectionColoredList ssl = (SingleSelectionColoredList)_setting; int current = 0; _selectedIndex = ssl.Selected; IsSelectionValid = _selectedIndex >= 0; foreach (ColoredSelectionItem item in ssl.Items) { ListItem listItem = new ListItem(KEY_NAME, item.ResourceString) { Selected = (current == _selectedIndex) }; if (item.BackgroundColor != Color.Empty) { listItem.SetLabel(KEY_COLOR, Common.Localization.LocalizationHelper.CreateStaticString(ColorTranslator.ToHtml(item.BackgroundColor))); } else { listItem.SetLabel(KEY_COLOR, Common.Localization.LocalizationHelper.CreateStaticString("")); } listItem.SelectedProperty.Attach(OnSelectionChanged); _items.Add(listItem); current++; } } _items.FireChange(); }
/// <summary> /// Konstruktor /// </summary> /// <param name="id">Die Nummer des Code-Elements</param> /// <param name="code">Der Inhalt des Code-Elements</param> /// <param name="c">Der Channel</param> /// <param name="function">Ob der Text als funktion geparsed werden soll (blaue links)</param> public KCodeItem(int id, string code, Channel c, bool function) { this.id = id; this.code = code; if (code.Length > 0 && code[0] == '>' || code.StartsWith("BB >") || code.StartsWith("BB>") && code[1] != '{') { string fontColor = ColorTranslator.ToHtml(c.ForeColor); string fontWeight = "'normal'"; string textDecoration = ""; if (code.StartsWith("BB")) { fontColor = ColorTranslator.ToHtml(c.Color1); textDecoration = "underline"; } if (code.Contains('_')) { fontWeight = "bold"; } string specialFormat = " style=\"color: rgb(" + fontColor + "); font-weight:" + fontWeight + "; text-decoration: " + textDecoration + "\""; string[] param = null; string leadingImage = string.Empty; //Klickbarer Link if (code.Contains("|")) { //Debug.WriteLine(code); if (code.Contains("<>")) { string[] temp = code.Split(new string[] { "<>" }, StringSplitOptions.RemoveEmptyEntries); param = temp[1].Split('|'); leadingImage = temp[0]; leadingImage = ImageHTMLBuilder(leadingImage); } else { param = code.Split('|'); } //Debug.WriteLine(string.Join(",", param)); string content = param[0]; string classes = string.Empty; if (content.Contains("_h")) { classes += "hoverUnderline "; } string stylesheet = string.Empty; if (content.Contains("BB") || function) { stylesheet += "color:" + ColorTranslator.ToHtml(c.Color2) + ";"; } else { stylesheet += "color:" + ColorTranslator.ToHtml(c.ForeColor) + ";"; } content = content.Replace("_h", ""); content = content.Replace("BB>", ""); content = content.Replace("BB >", ""); content = content.Replace(">", ""); string command1 = param.Length >= 2 ? param[1] : null; if (command1 != null) { command1.Replace("\"", content); } string command2 = param.Length >= 3 ? param[2] : command1; string linkHtmlCommand = " name=\"" + command1 + "|" + command2 + "\" "; this.html = "<a style=\"" + stylesheet + "\" class=\"" + classes + "\" href=\"#\" " + linkHtmlCommand + ">" + content + "</a>"; } else { this.html = ImageHTMLBuilder(code); } if (this.html == null || this.html == "" || this.html == string.Empty) { this.html = code; } } #region RGB Color else if (code.Length != 0 && code[0] == '[') { try { code = code.Substring(1); code = code.Remove(code.Length - 1); string[] rgb = code.Split(new char[] { ',' }); Color color = Color.FromArgb( int.Parse(rgb[0]), int.Parse(rgb[1]), int.Parse(rgb[2])); this.html = "<span style=\"color: " + ColorTranslator.ToHtml(color) + ";\">"; } catch { } } #endregion #region ColorLetter, Size, Fehler else if (!code.StartsWith("%")) { //ColorLetter / Size string[] ChatColors = { "W", "E", "R", "O", "P", "A", "D", "G", "K", "Y", "C", "B", "N", "M", "BB", "RR" }; string[] ChatSizes = new string[31]; for (int i = 1; i <= 30; i++) { ChatSizes[i] = i.ToString(); } string[] HTMLColors = { "#FFFFFF", "#00AC00", "#FF0000", "#FFC800", "#FFAFAF", "#808080", "#404040", "#00FF00", "#000000", "#FFFF00", "#00FFFF", "#0000FF", "#964A00", "#FF00FF", ColorTranslator.ToHtml(c.Color1).Replace("#", ""), ColorTranslator.ToHtml(c.Color2).Replace("#", "") }; #region Check Colors for (int i = 1; i <= 16; i++) { if (code == ChatColors[i - 1]) { this.html = "<span style=\"color: " + HTMLColors[i - 1] + ";\">"; return; } } #endregion #region CheckFormatReset if (code == "r") { this.html = "</span></b></i><span style=\"font-size:" + c.FontSize + "px; color: " + ColorTranslator.ToHtml(c.ForeColor) + ";\">"; return; } #endregion #region Check Points if (code == "!") { this.html = "<span style=\"letter-spacing: 2px; color: " + ColorTranslator.ToHtml(c.ForeColor) + "; font-size:7px;\">.........</span>"; return; } #endregion #region Check Sizes try { int.Parse(code); this.html = "<span style=\"font-size:" + code + "px\">"; return; } catch { } #endregion #region Size&Color try { string re1 = "(\\d+)"; // Integer Number 1 string re2 = "([a-z])"; // Any Single Character 1 string size = new Regex(re1, RegexOptions.IgnoreCase | RegexOptions.Singleline).Match(code).Groups[1].ToString(); string color = new Regex(re2, RegexOptions.IgnoreCase | RegexOptions.Singleline).Match(code).Groups[1].ToString(); for (int i = 1; i <= 16; i++) { if (color == ChatColors[i - 1]) { color = HTMLColors[i - 1]; } } this.html = "<span style=\"font-size:" + size + "px; color: " + color + ";\">"; return; } catch { /*Fehler hihi*/ } #endregion this.html = code; //Konnte nichts mit anfangen, also erstmal zurück, //damit man sieht, wenn Fehler auftauchen. } #endregion }
/// <summary> /// Hier werden K-Codes (Textkügelchen) in HTML übersetzt. /// </summary> /// <param name="c">Der betreffende Channel, aus welchem die Nachricht kam</param> /// <param name="function">Ob die Nachricht eine Funktion ist</param> /// <param name="row">Die Nachricht an sich</param> /// <returns>HTML-Code des K-Codes</returns> public static string ToHTML(string row, Channel c, bool function, bool useBB) { Color BB = Color.Blue; Color RR = Color.Red; Color FC = Color.Black; int? Size = 12; BB = c.Color1; RR = c.Color2; int counter = 0; List <KCodeItem> items = new List <KCodeItem>(); for (int i = 0; i < row.Length; i++) { if (row[i] == '°') { if (i > 0) { if (row[i - 1] == '\\') { continue; } } if (row.Length - 1 <= i) { break; } string sub = row.Substring(row.IndexOf('°') + 1); if (!sub.Contains('°')) { break; } else { int index = i + sub.IndexOf('°') + 2; string code = row.Substring(i, index - i); row = row.Replace(code, "\n" + counter + "\n"); code = code.Substring(1, code.Length - 2); KCodeItem tmpItem = new KCodeItem(counter, code, c, function); items.Add(tmpItem); counter++; i += 2; } } } KCode2HTML.ReplaceTags(ref row, "_", "<b>", "</b>"); KCode2HTML.ReplaceTags(ref row, "\"", "<i>", "</i>"); KCode2HTML.ReplaceTags(ref row, "#", "<br>"); KCode2HTML.ReplaceTags(ref row, "§", "</span><span style=\"font-size:" + Size + "px; color: #" + ColorTranslator.ToHtml(FC) + ";\"></b></i>"); KCode2HTML.ReplaceTags(ref row, "\\", ""); KCode2HTML.ReplaceTags(ref row, "\\<", "<"); KCode2HTML.ReplaceTags(ref row, "\\>", ">"); #region Get HTML for ° foreach (KCodeItem item in items) { row = row.Replace("\n" + item.Id + "\n", item.HTML); } #endregion return(row); }
protected virtual void FillStyleAttributes(CssStyleCollection attributes, IUrlResolutionService urlResolver) { Color color; BorderStyle bs; Unit u; if (CheckBit((int)Styles.BackColor)) { color = (Color)viewstate["BackColor"]; if (!color.IsEmpty) { attributes.Add(HtmlTextWriterStyle.BackgroundColor, ColorTranslator.ToHtml(color)); } } if (CheckBit((int)Styles.BorderColor)) { color = (Color)viewstate["BorderColor"]; if (!color.IsEmpty) { attributes.Add(HtmlTextWriterStyle.BorderColor, ColorTranslator.ToHtml(color)); } } bool have_width = false; if (CheckBit((int)Styles.BorderWidth)) { u = (Unit)viewstate ["BorderWidth"]; if (!u.IsEmpty) { if (u.Value > 0) { have_width = true; } attributes.Add(HtmlTextWriterStyle.BorderWidth, u.ToString()); } } if (CheckBit((int)Styles.BorderStyle)) { bs = (BorderStyle)viewstate ["BorderStyle"]; if (bs != BorderStyle.NotSet) { attributes.Add(HtmlTextWriterStyle.BorderStyle, bs.ToString()); } else if (have_width) { attributes.Add(HtmlTextWriterStyle.BorderStyle, "solid"); } } else if (have_width) { attributes.Add(HtmlTextWriterStyle.BorderStyle, "solid"); } if (CheckBit((int)Styles.ForeColor)) { color = (Color)viewstate["ForeColor"]; if (!color.IsEmpty) { attributes.Add(HtmlTextWriterStyle.Color, ColorTranslator.ToHtml(color)); } } if (CheckBit((int)Styles.Height)) { u = (Unit)viewstate["Height"]; if (!u.IsEmpty) { attributes.Add(HtmlTextWriterStyle.Height, u.ToString()); } } if (CheckBit((int)Styles.Width)) { u = (Unit)viewstate["Width"]; if (!u.IsEmpty) { attributes.Add(HtmlTextWriterStyle.Width, u.ToString()); } } Font.FillStyleAttributes(attributes, AlwaysRenderTextDecoration); }
private void cWhite_Click(object sender, EventArgs e) { mColor = ColorTranslator.ToHtml(cWhite.BackColor); this.Close(); }
/// <summary> /// 根据用户ID,获取对应的客户树列表分类JSON /// </summary> /// <param name="userid">当前用户ID</param> /// <returns></returns> public List <TreeNodeInfo> GetSupplierTree(string userId, string companyId, string dataFilter, string shareUserCondition) { this.DataFilter = dataFilter; this.ShareUserCondition = shareUserCondition; //用户配置的列表 userTreeList = BLLFactory <UserTreeSetting> .Instance.GetTreeSetting(treeCategory, userId, companyId); List <TreeNodeInfo> list = new List <TreeNodeInfo>(); TreeNodeInfo pNode = new TreeNodeInfo("全部供应商", 0); list.Add(pNode); string category = "供应商属性分类"; List <SystemTreeNodeInfo> propList = BLLFactory <SystemTree> .Instance.GetTree(category); foreach (SystemTreeNodeInfo nodeInfo in propList) { if (ContainTree(nodeInfo.ID)) { TreeNodeInfo subNode = new TreeNodeInfo(nodeInfo.TreeName, 1); AddSystemTree2(nodeInfo.Children, subNode, 2); list.Add(subNode); } } //字典子列表 for (int i = 0; i < list.Count; i++) { TreeNodeInfo node = list[i]; AddDictData2(node, 3); } //标记颜色的树形列表展示 var colorNode = new TreeNodeInfo("标记颜色", 0); list.Add(colorNode); var dict = ColorHelper.ColorDict; foreach (string key in dict.Keys) { TreeNodeInfo subNode = new TreeNodeInfo(key, 9); var color = ColorTranslator.ToHtml(dict[key]); string filter = ""; if (string.IsNullOrEmpty(color)) { filter += "(MarkColor ='' or MarkColor is null) "; } else { filter = string.Format("{0}='{1}' ", "MarkColor", color); } subNode.Tag = filter; //增加数值 //如果过滤条件不为空,那么需要进行过滤 if (!string.IsNullOrEmpty(shareUserCondition)) { filter = string.Format(" {0} AND {1}", shareUserCondition, filter); } int count = BLLFactory <Supplier> .Instance.GetRecordCount(filter); subNode.Text += string.Format("({0})", count); //避免透明不显示字体 subNode.ForeColor = color; colorNode.Nodes.Add(subNode); } category = "供应商状态分类"; List <SystemTreeNodeInfo> statusList = BLLFactory <SystemTree> .Instance.GetTree(category); foreach (SystemTreeNodeInfo nodeInfo in statusList) { if (ContainTree(nodeInfo.ID)) { TreeNodeInfo subNode = new TreeNodeInfo(nodeInfo.TreeName, 1); AddStatusTree2(nodeInfo.Children, subNode, 2); //subNode.Expand(); list.Add(subNode); } } //~个人分组~ TreeNodeInfo myGroupNode = new TreeNodeInfo("个人分组", 4); List <SupplierGroupNodeInfo> groupList = BLLFactory <SupplierGroup> .Instance.GetTree(userId, dataFilter); AddCustomerGroupTree2(groupList, myGroupNode, 3); //添加一个未分类和全部客户的组别 myGroupNode.Nodes.Add(new TreeNodeInfo("未分组供应商", 3)); myGroupNode.Nodes.Add(new TreeNodeInfo("全部供应商", 3)); list.Add(myGroupNode); return(list); }
private void cPaleGoldenrod_Click(object sender, EventArgs e) { mColor = ColorTranslator.ToHtml(cPaleGoldenrod.BackColor); this.Close(); }
protected override void OnRowCreated(GridViewRowEventArgs e) { base.OnRowCreated(e); if (e.Row.RowType == DataControlRowType.DataRow) { if (IsOpenMouseOverColor) { string mOverColor = (Color.Empty == this.MouseOverColor) ? "#ffffff" : ColorTranslator.ToHtml(this.MouseOverColor); string mOutColor = (Color.Empty == this.MouseOutColor) ? "#ffffff" : ColorTranslator.ToHtml(this.MouseOutColor); e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor = '" + mOverColor + "';"); e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor = '" + mOutColor + "';"); } } else if (e.Row.RowType == DataControlRowType.Header) { foreach (TableCell headerCell in e.Row.Cells) { if (IsShowSortDirectionImg && headerCell.HasControls()) { AddSortImageToHeaderCell(headerCell); } } } }
public static int ToRgb(this Color color) { return(int.Parse(ColorTranslator.ToHtml(Color.FromArgb(color.ToArgb())).Replace("#", ""), NumberStyles.HexNumber)); }
private void cMediumAquamarine_Click(object sender, EventArgs e) { mColor = ColorTranslator.ToHtml(cMediumAquamarine.BackColor); this.Close(); }
/// <summary> /// HTML form of color. /// </summary> /// <returns></returns> public override string ToString() { return(ColorTranslator.ToHtml(Color.FromArgb(R, G, B))); }
private void cPaleTurquoise_Click(object sender, EventArgs e) { mColor = ColorTranslator.ToHtml(cPaleTurquoise.BackColor); this.Close(); }
public static void DescribeComponent(object instance, ScriptComponentDescriptor descriptor, IUrlResolutionService urlResolver, IControlResolver controlResolver) { // validate preconditions if (instance == null) { throw new ArgumentNullException("instance"); } if (descriptor == null) { throw new ArgumentNullException("descriptor"); } if (urlResolver == null) { urlResolver = instance as IUrlResolutionService; } if (controlResolver == null) { controlResolver = instance as IControlResolver; } // describe properties // PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(instance); PropertyInfo[] properties = instance.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (PropertyInfo prop in properties) { ScriptControlPropertyAttribute propAttr = null; ScriptControlEventAttribute eventAttr = null; string propertyName = prop.Name; System.ComponentModel.AttributeCollection attribs = new System.ComponentModel.AttributeCollection(Attribute.GetCustomAttributes(prop, false)); // Try getting a property attribute propAttr = (ScriptControlPropertyAttribute)attribs[typeof(ScriptControlPropertyAttribute)]; if (propAttr == null || !propAttr.IsScriptProperty) { // Try getting an event attribute eventAttr = (ScriptControlEventAttribute)attribs[typeof(ScriptControlEventAttribute)]; if (eventAttr == null || !eventAttr.IsScriptEvent) { continue; } } // attempt to rename the property/event ClientPropertyNameAttribute nameAttr = (ClientPropertyNameAttribute)attribs[typeof(ClientPropertyNameAttribute)]; if (nameAttr != null && !string.IsNullOrEmpty(nameAttr.PropertyName)) { propertyName = nameAttr.PropertyName; } // determine whether to serialize the value of a property. readOnly properties should always be serialized //bool serialize = true;// prop.ShouldSerializeValue(instance) || prop.IsReadOnly; //if (serialize) //{ // get the value of the property, skip if it is null Control c = null; object value = prop.GetValue(instance, new object[0] { }); if (value == null) { continue; } // convert and resolve the value if (eventAttr != null && prop.PropertyType != typeof(String)) { throw new InvalidOperationException("ScriptControlEventAttribute can only be applied to a property with a PropertyType of System.String."); } else { if (!prop.PropertyType.IsPrimitive && !prop.PropertyType.IsEnum) { if (prop.PropertyType == typeof(Color)) { value = ColorTranslator.ToHtml((Color)value); } else { // TODO: Determine if we should let ASP.NET AJAX handle this type of conversion, as it supports JSON serialization //TypeConverter conv = prop.Converter; //value = conv.ConvertToString(null, CultureInfo.InvariantCulture, value); //if (prop.PropertyType == typeof(CssStyleCollection)) // value = (new CssStyleCollectionJSCoverter()).Serialize(value, new JavaScriptSerializer()); //if (prop.PropertyType == typeof(Style)) // value = (new CssStyleCollectionJSCoverter()).Serialize(((Style)value).GetStyleAttributes(null), new JavaScriptSerializer()); Type valueType = value.GetType(); JavaScriptConverterAttribute attr = (JavaScriptConverterAttribute)attribs[typeof(JavaScriptConverterAttribute)]; JavaScriptConverter converter = attr != null ? (JavaScriptConverter)TypeCreator.CreateInstance(attr.ConverterType) : JSONSerializerFactory.GetJavaScriptConverter(valueType); if (converter != null) { value = converter.Serialize(value, JSONSerializerFactory.GetJavaScriptSerializer()); } else { value = JSONSerializerExecute.PreSerializeObject(value); } //Dictionary<string, object> dict = value as Dictionary<string, object>; //if (dict != null && !dict.ContainsKey("__type")) // dict["__type"] = valueType.AssemblyQualifiedName; } } if (attribs[typeof(IDReferencePropertyAttribute)] != null && controlResolver != null) { c = controlResolver.ResolveControl((string)value); } if (attribs[typeof(UrlPropertyAttribute)] != null && urlResolver != null) { value = urlResolver.ResolveClientUrl((string)value); } } // add the value as an appropriate description if (eventAttr != null) { if (!string.IsNullOrEmpty((string)value)) { descriptor.AddEvent(propertyName, (string)value); } } else if (attribs[typeof(ElementReferenceAttribute)] != null) { if (c == null && controlResolver != null) { c = controlResolver.ResolveControl((string)value); } if (c != null) { value = c.ClientID; } descriptor.AddElementProperty(propertyName, (string)value); } else if (attribs[typeof(ComponentReferenceAttribute)] != null) { if (c == null && controlResolver != null) { c = controlResolver.ResolveControl((string)value); } if (c != null) { //ExtenderControlBase ex = c as ExtenderControlBase; //if (ex != null && ex.BehaviorID.Length > 0) // value = ex.BehaviorID; //else value = c.ClientID; } descriptor.AddComponentProperty(propertyName, (string)value); } else { if (c != null) { value = c.ClientID; } descriptor.AddProperty(propertyName, value); } } //} // determine if we should describe methods foreach (MethodInfo method in instance.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)) { ScriptControlMethodAttribute methAttr = (ScriptControlMethodAttribute)Attribute.GetCustomAttribute(method, typeof(ScriptControlMethodAttribute)); if (methAttr == null || !methAttr.IsScriptMethod) { continue; } // We only need to support emitting the callback target and registering the WebForms.js script if there is at least one valid method Control control = instance as Control; if (control != null) { // Force WebForms.js control.Page.ClientScript.GetCallbackEventReference(control, null, null, null); // Add the callback target descriptor.AddProperty("_callbackTarget", control.UniqueID); } break; } }
private void cLightSalmon_Click(object sender, EventArgs e) { mColor = ColorTranslator.ToHtml(cLightSalmon.BackColor); this.Close(); }
/// <summary> /// returns the RGB Value of a color. /// </summary> /// <param name="color">The color.</param> /// <returns>String</returns> /// <remarks></remarks> public static String ToHtmlColor(this Color color) { return(ColorTranslator.ToHtml(color)); }
private void cSandyBrown_Click(object sender, EventArgs e) { mColor = ColorTranslator.ToHtml(cSandyBrown.BackColor); this.Close(); }
private void renderHourTr(HtmlTextWriter output, DateTime i) { // <tr> output.AddStyleAttribute("height", HourHeight + "px"); output.RenderBeginTag("tr"); // <td> output.AddAttribute("valign", "bottom"); output.AddStyleAttribute("background-color", ColorTranslator.ToHtml(HourNameBackColor)); output.AddStyleAttribute("cursor", "default"); output.RenderBeginTag("td"); // <div> block // DivWriter divBlock = new DivWriter(); output.AddStyleAttribute("display", "block"); output.AddStyleAttribute("border-bottom", "1px solid " + ColorTranslator.ToHtml(HourNameBorderColor)); output.AddStyleAttribute("height", (HourHeight - 1) + "px"); output.AddStyleAttribute("text-align", "right"); output.RenderBeginTag("div"); // output.Write(divBlock.BeginTag()); // <div> text // DivWriter divText = new DivWriter(); output.AddStyleAttribute("padding", "2px"); output.AddStyleAttribute("font-family", HourFontFamily); output.AddStyleAttribute("font-size", HourFontSize); output.RenderBeginTag("div"); // output.Write(divText.BeginTag()); int hour = i.Hour; bool am = (i.Hour / 12) == 0; if (TimeFormat == TimeFormat.Clock12Hours) { hour = i.Hour % 12; if (hour == 0) { hour = 12; } } output.Write(hour); output.Write("<span style='font-size:10px; vertical-align: super; '> "); if (TimeFormat == TimeFormat.Clock24Hours) { output.Write("00"); } else { if (am) { output.Write("AM"); } else { output.Write("PM"); } } output.Write("</span>"); output.RenderEndTag(); output.RenderEndTag(); // output.Write(divText.EndTag()); // output.Write(divBlock.EndTag()); output.RenderEndTag(); // </td> output.RenderEndTag(); // </tr> }
private void cBurlyWood_Click(object sender, EventArgs e) { mColor = ColorTranslator.ToHtml(cBurlyWood.BackColor); this.Close(); }
private void addHalfHourCell(HtmlTextWriter output, DateTime hour, bool hourStartsHere, bool isLast) { string cellBgColor; if (hour.Hour < BusinessBeginsHour || hour.Hour >= BusinessEndsHour || hour.DayOfWeek == DayOfWeek.Saturday || hour.DayOfWeek == DayOfWeek.Sunday) { cellBgColor = ColorTranslator.ToHtml(NonBusinessBackColor); } else { cellBgColor = ColorTranslator.ToHtml(BackColor); } string borderBottomColor; if (hourStartsHere) { borderBottomColor = ColorTranslator.ToHtml(HourHalfBorderColor); } else { borderBottomColor = ColorTranslator.ToHtml(HourBorderColor); } DateTime startingTime = hour; if (!hourStartsHere) { startingTime = hour.AddMinutes(30); } if (FreetimeClickHandling == UserActionHandling.PostBack) { output.AddAttribute("onclick", "javascript:" + Page.ClientScript.GetPostBackEventReference(this, "TIME:" + startingTime.ToString("s"))); } else { output.AddAttribute("onclick", "javascript:" + String.Format(FreeTimeClickJavaScript, startingTime.ToString("s"))); } output.AddAttribute("onmouseover", "this.style.backgroundColor='" + ColorTranslator.ToHtml(HoverColor) + "';"); output.AddAttribute("onmouseout", "this.style.backgroundColor='" + cellBgColor + "';"); output.AddAttribute("valign", "bottom"); output.AddStyleAttribute("background-color", cellBgColor); output.AddStyleAttribute("cursor", "pointer"); output.AddStyleAttribute("cursor", "hand"); output.AddStyleAttribute("border-right", "1px solid " + ColorTranslator.ToHtml(BorderColor)); output.AddStyleAttribute("height", (HourHeight / 2) + "px"); output.RenderBeginTag("td"); // FIX BOX - to fix the outer/inner box differences in Mozilla/IE (to create border) // DivWriter divFix = new DivWriter(); output.AddStyleAttribute("display", "block"); output.AddStyleAttribute("height", "14px"); if (!isLast) { output.AddStyleAttribute("border-bottom", "1px solid " + borderBottomColor); } output.RenderBeginTag("div"); // output.Write(divFix.BeginTag()); // required output.Write("<span style='font-size:1px'> </span>"); // closing the FIX BOX output.RenderEndTag(); // output.Write(divFix.EndTag()); // </td> output.RenderEndTag(); }
public void save() { var path = util.getJarPath()[0] + "\\"; var mode = isUserMode ? "user" : "com"; var f = path + "favorite" + mode + ".ini_"; try { using (var sw = new StreamWriter(f, false, Encoding.UTF8)) { sw.WriteLine("130"); foreach (AlartInfo ai in dataSource) { for (var i = 0; i < 36; i++) //namaroku 29 save 32 { if (i == 1) { sw.WriteLine(ai.communityId); } else if (i == 2) { sw.WriteLine(ai.hostId); } else if (i == 4) { sw.WriteLine(ai.communityName); } else if (i == 5) { sw.WriteLine(ai.hostName); } else if (i == 7) { sw.WriteLine(ai.lastHostDate); } else if (i == 10) { sw.WriteLine(ColorTranslator.ToHtml(ai.textColor)); } else if (i == 11) { sw.WriteLine(ColorTranslator.ToHtml(ai.backColor)); } else if (i == 12) { sw.WriteLine(ai.soundType + "," + ai.isSoundId.ToString().ToLower()); } else if (i == 15) { sw.WriteLine(ai.addDate); } //else if (i == 16) sw.WriteLine(ai.isAnd.ToString().ToLower()); else if (i == 17) { sw.WriteLine(ai.popup.ToString().ToLower()); } else if (i == 18) { sw.WriteLine(ai.baloon.ToString().ToLower()); } else if (i == 19) { sw.WriteLine(ai.browser.ToString().ToLower()); } else if (i == 20) { sw.WriteLine(ai.mail.ToString().ToLower()); } else if (i == 21) { sw.WriteLine(ai.sound.ToString().ToLower()); } else if (i == 24) { sw.WriteLine(ai.appliA.ToString().ToLower()); } else if (i == 25) { sw.WriteLine(ai.appliB.ToString().ToLower()); } else if (i == 26) { sw.WriteLine(ai.appliC.ToString().ToLower()); } else if (i == 27) { sw.WriteLine(ai.appliD.ToString().ToLower()); } else if (i == 28) { sw.WriteLine(ai.appliE.ToString().ToLower()); } else if (i == 29) { sw.WriteLine(ai.appliF.ToString().ToLower()); } else if (i == 30) { sw.WriteLine(ai.appliG.ToString().ToLower()); } else if (i == 31) { sw.WriteLine(ai.appliH.ToString().ToLower()); } else if (i == 32) { sw.WriteLine(ai.appliI.ToString().ToLower()); } else if (i == 33) { sw.WriteLine(ai.appliJ.ToString().ToLower()); } else if (i == 34) { sw.WriteLine(ai.memo); } else if (i == 8) { sw.WriteLine(ai.communityFollow); } else if (i == 9) { sw.WriteLine(ai.hostFollow); } else if (i == 13) { sw.WriteLine(ai.lastLvid); } else if (i == 3) { sw.WriteLine(ai.keyword); } else if (i == 14) { sw.WriteLine(ai.isMustCom.ToString().ToLower() + "," + ai.isMustUser.ToString().ToLower() + "," + ai.isMustKeyword.ToString().ToLower()); } else if (i == 6) { var ckiStr = ""; try { if (ai.cki != null) { ckiStr = Newtonsoft.Json.Linq.JToken.FromObject(ai.cki).ToString(Newtonsoft.Json.Formatting.None); ckiStr = (ai.isCustomKeyword ? "1" : "0") + ckiStr; } } catch (Exception e) { util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite); } sw.WriteLine(ckiStr); } else if (i == 35) { sw.WriteLine(ai.memberOnlyMode.ToString()); } else if (i == 0) { var etc = new AiEtcInfo(); etc.isAutoReserve = ai.isAutoReserve; etc.recentColorMode = ai.recentColorMode; etc.lastLvTitle = ai.lastLvTitle; var json = JToken.FromObject(etc).ToString(Formatting.None); sw.WriteLine(json); } else { sw.WriteLine(""); } } } sw.WriteLine("EndLine"); //sw.Close(); } File.Copy(f, f.Substring(0, f.Length - 1), true); File.Delete(f); util.saveBackupList(path, "favorite" + mode); } catch (Exception e) { util.debugWriteLine(e.Message + e.Source + e.StackTrace + e.TargetSite); } }