public void Render(Entity entity, SpriteBatch batch, AssetManager assetManager) { var tex = assetManager[AssetManager.SolidGrayColor]; var rectBg = new Rectangle(RenderPosition.ToPoint(), LayoutSize.ToPoint()); if (MouseState == ElementMouseState.Pressed) { rectBg.Offset(1, 1); } var rectShadow = rectBg; rectShadow.Offset(2, 2); var textOffset = new Vector2(2); Color buttonColor = Color.White; if (MouseState == ElementMouseState.Pressed) { textOffset += new Vector2(1); buttonColor = Color.LightGray; } else if (MouseState == ElementMouseState.Hover) { buttonColor = Color.LightGray; } batch.Draw(tex, rectShadow, Color.Gray); batch.Draw(tex, rectBg, buttonColor); batch.DrawString(Font, Text, RenderPosition + textOffset, Color.Black); }
public static HtmlString RenderIncludes(Profiler profiler, RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool xhtml = false, bool? showControls = null) { const string format = @"<link rel=""stylesheet"" type=""text/css"" href=""{path}ss-includes.css?v={version}""{closeXHTML}> <script type=""text/javascript""> if (!window.jQuery) document.write(unescape(""%3Cscript src='{path}ss-jquip.all.js?v={version}' type='text/javascript'%3E%3C/script%3E"")); </script> <script type=""text/javascript"" src=""{path}ss-includes.js?v={version}""></script> <script type=""text/javascript""> jQuery(function() {{ MiniProfiler.init({{ ids: {ids}, path: '{path}', version: '{version}', renderPosition: '{position}', showTrivial: {showTrivial}, showChildrenTime: {showChildren}, maxTracesToShow: {maxTracesToShow}, showControls: {showControls} }}); }}); </script>"; var result = ""; if (profiler != null) { // HACK: unviewed ids are added to this list during Storage.Save, but we know we haven't see the current one yet, // so go ahead and add it to the end - it's usually the only id, but if there was a redirect somewhere, it'll be there, too Profiler.Settings.EnsureStorageStrategy(); var ids = Profiler.Settings.Storage.GetUnviewedIds(profiler.User); ids.Add(profiler.Id); var path = EndpointHost.Config.ServiceStackHandlerFactoryPath; result = format.Format(new { //path = VirtualPathUtility.ToAbsolute(MiniProfiler.Settings.RouteBasePath).EnsureTrailingSlash(), path = !string.IsNullOrEmpty(path) ? path + "/" : "", version = Profiler.Settings.Version, ids = ids.ToJson(), position = (position ?? Profiler.Settings.PopupRenderPosition).ToString().ToLower(), showTrivial = showTrivial ?? Profiler.Settings.PopupShowTrivial ? "true" : "false", showChildren = showTimeWithChildren ?? Profiler.Settings.PopupShowTimeWithChildren ? "true" : "false", maxTracesToShow = maxTracesToShow ?? Profiler.Settings.PopupMaxTracesToShow, closeXHTML = xhtml ? "/" : "", showControls = showControls ?? Profiler.Settings.ShowControls ? "true" : "false" }); } return new HtmlString(result); }
/// <summary> /// 注入MiniProfiler性能测试,需同时开启中间件,请在Swagger中间件中设置开启IsOpenMiniProfiler为True /// </summary> /// <param name="services"></param> /// <param name="options">开启后在Swagger上显示的地方</param> public static void AddMiniProfilerStartUp(this IServiceCollection services, Action <RenderPosition> options) { services.NotNull(nameof(IServiceCollection)); services.NotNull(nameof(Action <RenderPosition>)); var model = new RenderPosition(); options(model); services.AddMiniProfiler(op => { op.RouteBasePath = "/profiler"; op.PopupRenderPosition = RenderPosition.Left; op.PopupShowTimeWithChildren = true; }); }
private ActionResult HomeWithPosition(RenderPosition pos) { DefaultActions(); ViewBag.Orientation = pos; return(View("Index")); }
/// <summary> /// Returns the <c>css</c> and <c>javascript</c> includes needed to display the MiniProfiler results UI. /// </summary> /// <param name="position">Which side of the page the profiler popup button should be displayed on (defaults to left)</param> /// <param name="showTrivial">Whether to show trivial timings by default (defaults to false)</param> /// <param name="showTimeWithChildren">Whether to show time the time with children column by default (defaults to false)</param> /// <param name="maxTracesToShow">The maximum number of trace popups to show before removing the oldest (defaults to 15)</param> /// <param name="showControls">when true, shows buttons to minimize and clear MiniProfiler results</param> /// <param name="useExistingjQuery"> /// Should MiniProfiler attempt to load its own version of jQuery, or rely on a version previously loaded on the page? /// </param> /// <param name="samplingOnly">The sampling Only.</param> /// <param name="startHidden">Should the profiler start as hidden. Default to null.</param> /// <returns>Script and link elements normally; an empty string when there is no active profiling session.</returns> public static IHtmlString RenderIncludes( RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool? showControls = null, bool? useExistingjQuery = null, // TODO: we need to deprecate this bool samplingOnly = false, // TODO: can we remove this? bool? startHidden = null) { return MiniProfilerHandler.RenderIncludes( Current, position, showTrivial, showTimeWithChildren, maxTracesToShow, showControls, startHidden); }
/// <summary> /// Renders script tag found in "include.partial.html" - this is shared with all other language implementations, so if you change it, you MUST /// provide changes for those other implementations, e.g. ruby. /// </summary> internal static HtmlString RenderIncludes( MiniProfiler profiler, RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool? showControls = null, bool? startHidden = null) { if (profiler == null) return new HtmlString(""); MiniProfiler.Settings.EnsureStorageStrategy(); var authorized = MiniProfiler.Settings.Results_Authorize == null || MiniProfiler.Settings.Results_Authorize(HttpContext.Current.Request); // unviewed ids are added to this list during Storage.Save, but we know we haven't see the current one yet, so go ahead and add it to the end var ids = authorized ? MiniProfiler.Settings.Storage.GetUnviewedIds(profiler.User) : new List<Guid>(); ids.Add(profiler.Id); var format = GetResource("include.partial.html"); var result = format.Format(new { path = VirtualPathUtility.ToAbsolute(MiniProfiler.Settings.RouteBasePath).EnsureTrailingSlash(), version = MiniProfiler.Settings.Version, ids = string.Join(",", ids.Select(guid => guid.ToString())), position = (position ?? MiniProfiler.Settings.PopupRenderPosition).ToString().ToLower(), showTrivial = (showTrivial ?? MiniProfiler.Settings.PopupShowTrivial).ToJs(), showChildren = (showTimeWithChildren ?? MiniProfiler.Settings.PopupShowTimeWithChildren).ToJs(), maxTracesToShow = maxTracesToShow ?? MiniProfiler.Settings.PopupMaxTracesToShow, showControls = (showControls ?? MiniProfiler.Settings.ShowControls).ToJs(), currentId = profiler.Id, authorized = authorized.ToJs(), toggleShortcut = MiniProfiler.Settings.PopupToggleKeyboardShortcut, startHidden = (startHidden ?? MiniProfiler.Settings.PopupStartHidden).ToJs() }); return new HtmlString(result); }
public static System.Web.IHtmlString RenderIncludes(RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool xhtml = false, bool? showControls = null) { var path = VirtualPathUtility.ToAbsolute("~"); return MiniProfilerHandler.RenderIncludes(Profiler.Current, position, showTrivial, showTimeWithChildren, maxTracesToShow, xhtml, showControls, path) .ToMvcHtmlString(); }
/// <summary> /// Returns the <c>css</c> and <c>javascript</c> includes needed to display the MiniProfiler results UI. /// </summary> /// <param name="position">Which side of the page the profiler popup button should be displayed on (defaults to left)</param> /// <param name="showTrivial">Whether to show trivial timings by default (defaults to false)</param> /// <param name="showTimeWithChildren">Whether to show time the time with children column by default (defaults to false)</param> /// <param name="maxTracesToShow">The maximum number of trace popups to show before removing the oldest (defaults to 15)</param> /// <param name="showControls">when true, shows buttons to minimize and clear MiniProfiler results</param> /// <param name="useExistingjQuery">Whether MiniProfiler should attempt to load its own version of jQuery, or rely on a version previously loaded on the page</param> /// <param name="samplingOnly">The sampling Only.</param> /// <returns>Script and link elements normally; an empty string when there is no active profiling session.</returns> public static IHtmlString RenderIncludes(RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool? showControls = null, bool? useExistingjQuery = null, bool samplingOnly = false) { return UI.MiniProfilerHandler.RenderIncludes(Current, position, showTrivial, showTimeWithChildren, maxTracesToShow, showControls, useExistingjQuery); }
internal static HtmlString RenderIncludes(MiniProfiler profiler, RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool? showControls = null, bool? useExistingjQuery = null) { string format = GetResource("include.partial.html"); var result = ""; if (profiler != null) { // HACK: unviewed ids are added to this list during Storage.Save, but we know we haven't see the current one yet, // so go ahead and add it to the end - it's usually the only id, but if there was a redirect somewhere, it'll be there, too MiniProfiler.Settings.EnsureStorageStrategy(); var authorized = MiniProfiler.Settings.Results_Authorize == null || MiniProfiler.Settings.Results_Authorize(HttpContext.Current.Request); List<Guid> ids; if (authorized) { ids = MiniProfiler.Settings.Storage.GetUnviewedIds(profiler.User); ids.Add(profiler.Id); } else { ids = new List<Guid> { profiler.Id }; } result = format.Format(new { path = VirtualPathUtility.ToAbsolute(MiniProfiler.Settings.RouteBasePath).EnsureTrailingSlash(), version = MiniProfiler.Settings.Version, ids = ids.ToJson(), position = (position ?? MiniProfiler.Settings.PopupRenderPosition).ToString().ToLower(), showTrivial = showTrivial ?? MiniProfiler.Settings.PopupShowTrivial ? "true" : "false", showChildren = showTimeWithChildren ?? MiniProfiler.Settings.PopupShowTimeWithChildren ? "true" : "false", maxTracesToShow = maxTracesToShow ?? MiniProfiler.Settings.PopupMaxTracesToShow, showControls = showControls ?? MiniProfiler.Settings.ShowControls ? "true" : "false", currentId = profiler.Id, authorized = authorized ? "true" : "false", useExistingjQuery = useExistingjQuery ?? MiniProfiler.Settings.UseExistingjQuery ? "true" : "false" }); } return new HtmlString(result); }
internal static HtmlString RenderIncludes(MiniProfiler profiler, RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool? showControls = null, bool? useExistingjQuery = null) { const string format = @"<script type=""text/javascript""> (function(){{ var init = function() {{ var load = function(s,f){{ var sc = document.createElement(""script""); sc.async = ""async""; sc.type = ""text/javascript""; sc.src = s; var l = false; sc.onload = sc.onreadystatechange = function(_, abort) {{ if (!l && (!sc.readyState || /loaded|complete/.test(sc.readyState))) {{ if (!abort){{l=true; f();}} }} }}; document.getElementsByTagName('head')[0].appendChild(sc); }}; var initMp = function(){{ load(""{path}includes.js?v={version}"",function(){{ MiniProfiler.init({{ ids: {ids}, path: '{path}', version: '{version}', renderPosition: '{position}', showTrivial: {showTrivial}, showChildrenTime: {showChildren}, maxTracesToShow: {maxTracesToShow}, showControls: {showControls}, currentId: '{currentId}', authorized: {authorized} }}); }}); }}; if ({useExistingjQuery}) {{ jQueryMP = jQuery; initMp(); }} else {{ load('{path}jquery.1.7.1.js?v={version}', initMp); }} }}; var w = 0; var f = false; var deferInit = function(){{ if (f) return; if (window.performance && window.performance.timing && window.performance.timing.loadEventEnd == 0 && w < 10000){{ setTimeout(deferInit, 100); w += 100; }} else {{ f = true; init(); }} }}; if (document.addEventListener) {{ document.addEventListener('DOMContentLoaded',deferInit); }} var o = window.onload; window.onload = function(){{if(o)o; deferInit()}}; }})(); </script>"; var result = ""; if (profiler != null) { // HACK: unviewed ids are added to this list during Storage.Save, but we know we haven't see the current one yet, // so go ahead and add it to the end - it's usually the only id, but if there was a redirect somewhere, it'll be there, too MiniProfiler.Settings.EnsureStorageStrategy(); var authorized = MiniProfiler.Settings.Results_Authorize == null || MiniProfiler.Settings.Results_Authorize(HttpContext.Current.Request); List<Guid> ids; if (authorized) { ids = MiniProfiler.Settings.Storage.GetUnviewedIds(profiler.User); ids.Add(profiler.Id); } else { ids = new List<Guid> { profiler.Id }; } result = format.Format(new { path = VirtualPathUtility.ToAbsolute(MiniProfiler.Settings.RouteBasePath).EnsureTrailingSlash(), version = MiniProfiler.Settings.Version, ids = ids.ToJson(), position = (position ?? MiniProfiler.Settings.PopupRenderPosition).ToString().ToLower(), showTrivial = showTrivial ?? MiniProfiler.Settings.PopupShowTrivial ? "true" : "false", showChildren = showTimeWithChildren ?? MiniProfiler.Settings.PopupShowTimeWithChildren ? "true" : "false", maxTracesToShow = maxTracesToShow ?? MiniProfiler.Settings.PopupMaxTracesToShow, showControls = showControls ?? MiniProfiler.Settings.ShowControls ? "true" : "false", currentId = profiler.Id, authorized = authorized ? "true" : "false", useExistingjQuery = useExistingjQuery ?? MiniProfiler.Settings.UseExistingjQuery ? "true" : "false" }); } return new HtmlString(result); }
internal static HtmlString RenderIncludes(MiniProfiler profiler, RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null) { const string format = @"<link rel=""stylesheet"" type=""text/css"" href=""{path}mini-profiler-includes.css?v={version}""> <script type=""text/javascript""> if (!window.jQuery) document.write(unescape(""%3Cscript src='{path}mini-profiler-jquery.1.6.1.js' type='text/javascript'%3E%3C/script%3E"")); if (window.jQuery && !window.jQuery.tmpl) document.write(unescape(""%3Cscript src='{path}mini-profiler-jquery.tmpl.beta1.js' type='text/javascript'%3E%3C/script%3E"")); </script> <script type=""text/javascript"" src=""{path}mini-profiler-includes.js?v={version}""></script> <script type=""text/javascript""> jQuery(function() {{ MiniProfiler.init({{ ids: {ids}, path: '{path}', version: '{version}', renderPosition: '{position}', showTrivial: {showTrivial}, showChildrenTime: {showChildren}, maxTracesToShow: {maxTracesToShow} }}); }}); </script>"; var result = ""; if (profiler != null) { // HACK: unviewed ids are added to this list during Storage.Save, but we know we haven't see the current one yet, // so go ahead and add it to the end - it's usually the only id, but if there was a redirect somewhere, it'll be there, too MiniProfiler.Settings.EnsureStorageStrategy(); var ids = MiniProfiler.Settings.Storage.GetUnviewedIds(profiler.User); ids.Add(profiler.Id); result = format.Format(new { path = VirtualPathUtility.ToAbsolute(MiniProfiler.Settings.RouteBasePath).EnsureTrailingSlash(), version = MiniProfiler.Settings.Version, ids = ids.ToJson(), position = (position ?? MiniProfiler.Settings.PopupRenderPosition).ToString().ToLower(), showTrivial = showTrivial ?? MiniProfiler.Settings.PopupShowTrivial ? "true" : "false", showChildren = showTimeWithChildren ?? MiniProfiler.Settings.PopupShowTimeWithChildren ? "true" : "false", maxTracesToShow = maxTracesToShow ?? MiniProfiler.Settings.PopupMaxTracesToShow }); } return new HtmlString(result); }
internal static HtmlString RenderIncludes(MiniProfiler profiler, RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool xhtml = false, bool? showControls = null) { const string format = @"<script type=""text/javascript""> (function(){{ var init = function() {{ var load = function(s,f){{ var sc = document.createElement(""script""); sc.async = ""async""; sc.type = ""text/javascript""; sc.src = s; sc.onload = sc.onreadystatechange = function(_, abort) {{ if (!sc.readyState || /loaded|complete/.test(sc.readyState)) {{ if (!abort) f(); }} }}; document.getElementsByTagName('head')[0].appendChild(sc); }}; var initMp = function(){{ load(""{path}mini-profiler-includes.js?v={version}"",function(){{ MiniProfiler.init({{ ids: {ids}, path: '{path}', version: '{version}', renderPosition: '{position}', showTrivial: {showTrivial}, showChildrenTime: {showChildren}, maxTracesToShow: {maxTracesToShow}, showControls: {showControls}, currentId: '{currentId}' }}); }}); }}; if (!window.jQuery) {{ load('{path}mini-profiler-jquery.1.6.2.js', initMp); }} else {{ initMp(); }} }}; var w = 0; var deferInit = function(){{ if (window.performance && window.performance.timing && window.performance.timing.loadEventEnd == 0 && w < 10000){{ setTimeout(deferInit, 100); w += 100; }} else {{ init(); }} }}; deferInit(); }})(); </script>"; var result = ""; if (profiler != null) { // HACK: unviewed ids are added to this list during Storage.Save, but we know we haven't see the current one yet, // so go ahead and add it to the end - it's usually the only id, but if there was a redirect somewhere, it'll be there, too MiniProfiler.Settings.EnsureStorageStrategy(); var ids = MiniProfiler.Settings.Storage.GetUnviewedIds(profiler.User); ids.Add(profiler.Id); result = format.Format(new { path = VirtualPathUtility.ToAbsolute(MiniProfiler.Settings.RouteBasePath).EnsureTrailingSlash(), version = MiniProfiler.Settings.Version, ids = ids.ToJson(), position = (position ?? MiniProfiler.Settings.PopupRenderPosition).ToString().ToLower(), showTrivial = showTrivial ?? MiniProfiler.Settings.PopupShowTrivial ? "true" : "false", showChildren = showTimeWithChildren ?? MiniProfiler.Settings.PopupShowTimeWithChildren ? "true" : "false", maxTracesToShow = maxTracesToShow ?? MiniProfiler.Settings.PopupMaxTracesToShow, closeXHTML = xhtml ? "/" : "", showControls = showControls ?? MiniProfiler.Settings.ShowControls ? "true" : "false", currentId = profiler.Id }); } return new HtmlString(result); }
public static System.Web.IHtmlString RenderIncludes(RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool xhtml = false, bool? showControls = null) { return MiniProfilerHandler.RenderIncludes(Profiler.Current, position, showTrivial, showTimeWithChildren, maxTracesToShow, xhtml, showControls) .ToMvcHtmlString(); }
public static string RenderIncludesAsString(RenderPosition? position = null, bool? showTrivial = null, bool? showTimeWithChildren = null, int? maxTracesToShow = null, bool? showControls = null, bool? startHidden = null) { var mvcString = UI.MiniProfilerHandler.RenderIncludes(Current, position, showTrivial, showTimeWithChildren, maxTracesToShow, showControls, startHidden); return mvcString.ToString(); }