From acf4d716ca5ae0fcfedac01efb21a7815a15e0fc Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Fri, 2 Mar 2018 14:43:01 +0100 Subject: [PATCH] inseriti metodi x gestione recupero della dimensione pagine --- MP-Tablet/App_Start/BundleConfig.cs | 3 ++ MP-Tablet/MP-Tablet.csproj | 5 +++ MP-Tablet/Scripts/BrowserWindowSize.js | 27 +++++++++++++ MP-Tablet/Test.aspx.cs | 1 - MP-Tablet/WebMasterPages/Bootstrap.Master | 1 + .../WebMasterPages/BootstrapNoUpdPnl.Master | 3 +- .../BootstrapNoUpdPnl.Master.cs | 15 +++++++ MP-Tablet/WebUserControls/mod_footer.ascx | 2 +- MP-Tablet/WebUserControls/mod_footer.ascx.cs | 15 +++++++ MP-Tablet/windowSize.ashx | 1 + MP-Tablet/windowSize.ashx.cs | 39 +++++++++++++++++++ 11 files changed, 109 insertions(+), 3 deletions(-) create mode 100644 MP-Tablet/Scripts/BrowserWindowSize.js create mode 100644 MP-Tablet/windowSize.ashx create mode 100644 MP-Tablet/windowSize.ashx.cs diff --git a/MP-Tablet/App_Start/BundleConfig.cs b/MP-Tablet/App_Start/BundleConfig.cs index 185205d7..95e4c77d 100644 --- a/MP-Tablet/App_Start/BundleConfig.cs +++ b/MP-Tablet/App_Start/BundleConfig.cs @@ -34,6 +34,9 @@ namespace MoonProTablet bundles.Add(new ScriptBundle("~/bundles/jqueryui").Include( "~/Scripts/jquery-ui-{version}.js")); + bundles.Add(new ScriptBundle("~/bundles/BrowserWindowSize").Include( + "~/Scripts/BrowserWindowSize.js")); + //bundles.Add(new ScriptBundle("~/bundles/jqueryui-i18n").Include( // "~/Scripts/jquery-ui-i18n.min.js")); diff --git a/MP-Tablet/MP-Tablet.csproj b/MP-Tablet/MP-Tablet.csproj index c120225b..cdcb719f 100644 --- a/MP-Tablet/MP-Tablet.csproj +++ b/MP-Tablet/MP-Tablet.csproj @@ -364,6 +364,7 @@ + @@ -482,6 +483,7 @@ + @@ -746,6 +748,9 @@ mod_turni.ascx + + windowSize.ashx + diff --git a/MP-Tablet/Scripts/BrowserWindowSize.js b/MP-Tablet/Scripts/BrowserWindowSize.js new file mode 100644 index 00000000..ada48aeb --- /dev/null +++ b/MP-Tablet/Scripts/BrowserWindowSize.js @@ -0,0 +1,27 @@ +// Browser windows size collector +window.onresize = function (event) { + SetWidthHeight(); +} +function SetWidthHeight() { + var height = $(window).height(); + var width = $(window).width(); + $.ajax({ + url: "../windowSize.ashx", + data: { + 'Height': height, + 'Width': width + }, + contentType: "application/json; charset=utf-8", + dataType: "json" + }).done(function (data) { + if (data.isFirst) { + window.location.reload(); + }; + }).fail(function (xhr) { + alert("Problem to retrieve browser size."); + }); + +} +$(function () { + SetWidthHeight(); +}); \ No newline at end of file diff --git a/MP-Tablet/Test.aspx.cs b/MP-Tablet/Test.aspx.cs index 4ada9b65..5c79aad4 100644 --- a/MP-Tablet/Test.aspx.cs +++ b/MP-Tablet/Test.aspx.cs @@ -11,7 +11,6 @@ namespace MoonProTablet { protected void Page_Load(object sender, EventArgs e) { - } } } \ No newline at end of file diff --git a/MP-Tablet/WebMasterPages/Bootstrap.Master b/MP-Tablet/WebMasterPages/Bootstrap.Master index 03c81dd0..9bae52d0 100644 --- a/MP-Tablet/WebMasterPages/Bootstrap.Master +++ b/MP-Tablet/WebMasterPages/Bootstrap.Master @@ -21,6 +21,7 @@ <%: Scripts.Render("~/bundles/modernizr") %> <%: Scripts.Render("~/bundles/jquery") %> <%: Scripts.Render("~/bundles/jqueryui") %> + <%: Scripts.Render("~/bundles/BrowserWindowSize") %> diff --git a/MP-Tablet/WebMasterPages/BootstrapNoUpdPnl.Master b/MP-Tablet/WebMasterPages/BootstrapNoUpdPnl.Master index 20be9248..989bf702 100644 --- a/MP-Tablet/WebMasterPages/BootstrapNoUpdPnl.Master +++ b/MP-Tablet/WebMasterPages/BootstrapNoUpdPnl.Master @@ -18,6 +18,7 @@ <%: Scripts.Render("~/bundles/modernizr") %> <%: Scripts.Render("~/bundles/jquery") %> <%: Scripts.Render("~/bundles/jqueryui") %> + <%: Scripts.Render("~/bundles/BrowserWindowSize") %> @@ -68,7 +69,7 @@ MPTAB - v.<%: currVersion.ToString() %> | <%: DateTime.Now %>
- <%: System.Web.Configuration.WebConfigurationManager.AppSettings["Environment"] %> + <%: System.Web.Configuration.WebConfigurationManager.AppSettings["Environment"] %> | <%: videoSize %>
Powered by Steamware s.r.l. - © 2007-<%: DateTime.Now.Year %>
diff --git a/MP-Tablet/WebMasterPages/BootstrapNoUpdPnl.Master.cs b/MP-Tablet/WebMasterPages/BootstrapNoUpdPnl.Master.cs index 139eb2cc..b85285e2 100644 --- a/MP-Tablet/WebMasterPages/BootstrapNoUpdPnl.Master.cs +++ b/MP-Tablet/WebMasterPages/BootstrapNoUpdPnl.Master.cs @@ -42,5 +42,20 @@ namespace WebMasterPages private void updateLabels() { } + /// + /// Dimensione schermata video attuale + /// + public string videoSize + { + get + { + string answ = "?x?"; + if (Session["BrowserWidth"] != null) + { + answ = string.Format("{0} x {1}", Session["BrowserWidth"], Session["BrowserHeight"]); + } + return answ; + } + } } } \ No newline at end of file diff --git a/MP-Tablet/WebUserControls/mod_footer.ascx b/MP-Tablet/WebUserControls/mod_footer.ascx index 217f7e83..ea382b1d 100644 --- a/MP-Tablet/WebUserControls/mod_footer.ascx +++ b/MP-Tablet/WebUserControls/mod_footer.ascx @@ -5,7 +5,7 @@ v.<%: currVersion.ToString() %> | <%: DateTime.Now %>
- <%: System.Web.Configuration.WebConfigurationManager.AppSettings["Environment"] %> + <%: System.Web.Configuration.WebConfigurationManager.AppSettings["Environment"] %> | <%: videoSize %>
Powered by  diff --git a/MP-Tablet/WebUserControls/mod_footer.ascx.cs b/MP-Tablet/WebUserControls/mod_footer.ascx.cs index ddb861f5..82d41dc3 100644 --- a/MP-Tablet/WebUserControls/mod_footer.ascx.cs +++ b/MP-Tablet/WebUserControls/mod_footer.ascx.cs @@ -24,5 +24,20 @@ namespace MoonProTablet.WebUserControls private void updateLabels() { } + /// + /// Dimensione schermata video attuale + /// + public string videoSize + { + get + { + string answ = "?x?"; + if (Session["BrowserWidth"] != null) + { + answ = string.Format("{0} x {1}", Session["BrowserWidth"], Session["BrowserHeight"]); + } + return answ; + } + } } } \ No newline at end of file diff --git a/MP-Tablet/windowSize.ashx b/MP-Tablet/windowSize.ashx new file mode 100644 index 00000000..0e9f7c3f --- /dev/null +++ b/MP-Tablet/windowSize.ashx @@ -0,0 +1 @@ +<%@ WebHandler Language="C#" CodeBehind="windowSize.ashx.cs" Class="MoonProTablet.windowSize" %> diff --git a/MP-Tablet/windowSize.ashx.cs b/MP-Tablet/windowSize.ashx.cs new file mode 100644 index 00000000..5d9b275f --- /dev/null +++ b/MP-Tablet/windowSize.ashx.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace MoonProTablet +{ + /// + /// Descrizione di riepilogo per windowSize + /// vedere https://techbrij.com/browser-height-width-server-responsive-design-asp-net + /// + public class windowSize : IHttpHandler, System.Web.SessionState.IRequiresSessionState + { + /// + /// Processa la richeista andando a recuperare width-height del browser + /// + /// + public void ProcessRequest(HttpContext context) + { + context.Response.ContentType = "application/json"; + + var json = new System.Web.Script.Serialization.JavaScriptSerializer(); + var output = json.Serialize(new { isFirst = context.Session["BrowserWidth"] == null }); + context.Response.Write(output); + + context.Session["BrowserWidth"] = context.Request.QueryString["Width"]; + context.Session["BrowserHeight"] = context.Request.QueryString["Height"]; + // modificare: salvare in REDIS come conteggio... poi emttere in ABOUT PAGE il resoconto dei conteggi... + } + + public bool IsReusable + { + get + { + return false; + } + } + } +} \ No newline at end of file