/// <summary> /// Code to show browser based content, applicable for URL's /// If the Header value is not provided, the content is projected in full screen mode /// </summary> /// <param name="Content"></param> /// <param name="header"></param> private void ShowBrowser(String Content, String header) { try { //Check if header is null //Null - Show full screen content if (String.IsNullOrEmpty(header)) { //Show the full screen video control //Display HTML content host = new System.Windows.Forms.Integration.WindowsFormsHost(); browserElement = new System.Windows.Forms.WebBrowser(); browserElement.ScriptErrorsSuppressed = true; helper = new Utilities.ScriptingHelper(this); browserElement.ObjectForScripting = helper; host.Child = browserElement; helper.PropertyChanged += helper_PropertyChanged; FullScreenContentGrid.Children.Clear(); FullScreenContentGrid.Children.Add(host); FullScreenContentGrid.Visibility = Visibility.Visible; FullScreenVideoGrid.Visibility = Visibility.Collapsed; } else { TitleLabel.Text = header; host = new System.Windows.Forms.Integration.WindowsFormsHost(); browserElement = new System.Windows.Forms.WebBrowser(); browserElement.ScriptErrorsSuppressed = true; helper = new Utilities.ScriptingHelper(this); host.Child = browserElement; browserElement.ObjectForScripting = helper; helper.PropertyChanged += helper_PropertyChanged; ContentGrid.Children.Clear(); ContentGrid.Children.Add(host); ContentGrid.Visibility = Visibility.Visible; FullScreenContentGrid.Visibility = Visibility.Collapsed; FullScreenVideoGrid.Visibility = Visibility.Collapsed; VideoGrid.Visibility = Visibility.Collapsed; } String fileLocation = Helper.GetAssetURI(Content); String pageUri = String.Empty; //Local file if (File.Exists(fileLocation)) { String[] PathParts = fileLocation.Split(new char[] { ':' }); pageUri = "file://127.0.0.1/" + PathParts[0] + "$" + PathParts[1]; } //Web hosted file else { pageUri = Content; } browserElement.Navigate(pageUri); this.UpdateLayout(); } catch (Exception ex) { RippleCommonUtilities.LoggingHelper.LogTrace(1, "Went wrong in Show Browser {0}", ex.Message); } }
private void ProjectIntroContent(RippleDictionary.ScreenContent screenContent) { try { //Dispose the previous content //Stop any existing projections DocumentPresentation.HelperMethods.StopPresentation(); FullScreenContentGrid.Children.Clear(); ContentGrid.Children.Clear(); //Set focus for screen window also Utilities.Helper.ClickOnScreenToGetFocus(); //Stop any existing videos loopVideo = false; VideoControl.Source = null; FullScreenVideoControl.Source = null; //Clean the images fullScreenImgElement.Source = null; imgElement.Source = null; //Clear the header text TitleLabel.Text = ""; if (browserElement != null) browserElement.Dispose(); browserElement = null; if (host != null) host.Dispose(); host = null; if (helper != null) helper.PropertyChanged -= helper_PropertyChanged; helper = null; //Play the Intro video this.TitleLabel.Text = ""; ContentGrid.Visibility = Visibility.Collapsed; FullScreenContentGrid.Visibility = Visibility.Collapsed; FullScreenVideoGrid.Visibility = Visibility.Collapsed; IntroVideoControl.Visibility = Visibility.Visible; VideoControl.Visibility = Visibility.Collapsed; VideoGrid.Visibility = Visibility.Visible; IntroVideoControl.Play(); this.UpdateLayout(); myBackgroundWorker = new BackgroundWorker(); myBackgroundWorker.DoWork += myBackgroundWorker_DoWork; myBackgroundWorker.RunWorkerCompleted += myBackgroundWorker_RunWorkerCompleted; myBackgroundWorker.RunWorkerAsync(rippleData.Floor.Start.IntroVideoWaitPeriod); } catch (Exception ex) { RippleCommonUtilities.LoggingHelper.LogTrace(1, "Went wrong in ProjectIntroContent Method for screen {0}", ex.Message); } }
/// <summary> /// Identifies the content type and project accordingly /// </summary> /// <param name="screenContent"></param> private void ProjectContent(RippleDictionary.ScreenContent screenContent) { try { if (screenContent.Type == ContentType.HTMLMessage) { if (helper != null && currentScreenContent == ContentType.HTML) { helper.MessageReceived(screenContent.Content); return; } } //Stop any existing projections DocumentPresentation.HelperMethods.StopPresentation(); FullScreenContentGrid.Children.Clear(); ContentGrid.Children.Clear(); //Set focus for screen window also Utilities.Helper.ClickOnScreenToGetFocus(); //Stop any existing videos loopVideo = false; VideoControl.Source = null; FullScreenVideoControl.Source = null; //Clean the images fullScreenImgElement.Source = null; imgElement.Source = null; //Clear the header text TitleLabel.Text = ""; //Dispose the objects if (browserElement != null) browserElement.Dispose(); browserElement = null; if (host != null) host.Dispose(); host = null; if (helper != null) helper.PropertyChanged -= helper_PropertyChanged; helper = null; currentScreenContent = screenContent.Type; if (screenContent.Id == "Tile0" && StartVideoPlayed) { currentScreenContent = ContentType.Image; ShowImage("\\Assets\\Images\\default_start.png", screenContent.Header); return; } switch (screenContent.Type) { case RippleDictionary.ContentType.HTML: ShowBrowser(screenContent.Content, screenContent.Header); break; case RippleDictionary.ContentType.Image: ShowImage(screenContent.Content, screenContent.Header); break; case RippleDictionary.ContentType.PPT: ShowPPT(screenContent.Content, screenContent.Header); break; case RippleDictionary.ContentType.Text: ShowText(screenContent.Content, screenContent.Header); break; case RippleDictionary.ContentType.Video: loopVideo = (screenContent.LoopVideo == null) ? false : Convert.ToBoolean(screenContent.LoopVideo); if (screenContent.Id == "Tile0") StartVideoPlayed = true; ShowVideo(screenContent.Content, screenContent.Header); break; } } catch (Exception ex) { RippleCommonUtilities.LoggingHelper.LogTrace(1, "Went wrong in ProjectContent Method for screen {0}", ex.Message); } }
/// <summary> /// Code will receive messages from the floor /// Invoke appropriate content projection based on the tile ID passed /// </summary> /// <param name="val"></param> public void OnMessageReceived(string val) { try { //Check for reset if (val.Equals("Reset")) { //Update the previous entry Utilities.TelemetryWriter.UpdatePreviousEntry(); //Reset the system ResetUI(); } //Check for System start //Check for System start else if (val.StartsWith("System Start")) { //Load the telemetry Data Utilities.TelemetryWriter.RetrieveTelemetryData(); //The floor has asked the screen to start the system //Get the User Name Globals.UserName = val.Split(':')[1]; //Get the person identity for the session personName = String.IsNullOrEmpty(Globals.UserName) ? Convert.ToString(Guid.NewGuid()) : Globals.UserName; Utilities.TelemetryWriter.AddTelemetryRow(rippleData.Floor.SetupID, personName, "Unlock", val, "Unlock"); //Set the system state Globals.currentAppState = RippleSystemStates.UserDetected; //Play the Intro Content ProjectIntroContent(rippleData.Screen.ScreenContents["IntroVideo"]); } //Check for gestures else if (val.StartsWith("Gesture")) { OnGestureInput(val.Split(':')[1]); } //Check for HTMl messages else if (val.StartsWith("HTML")) { OnHTMLMessagesReceived(val.Split(':')[1]); } //Check for options- TODO need to figure out else if (val.StartsWith("Option")) { //Do nothing } //Check if a content - tile mapping or in general content tag exists else { if (rippleData.Screen.ScreenContents.ContainsKey(val) && rippleData.Screen.ScreenContents[val].Type != ContentType.Nothing) { //Set the system state Globals.currentAppState = RippleSystemStates.OptionSelected; ProjectContent(rippleData.Screen.ScreenContents[val]); RippleCommonUtilities.LoggingHelper.LogTrace(1, "In Message Received {0} {1}:{2}", Utilities.TelemetryWriter.telemetryData.Tables[0].Rows.Count, Utilities.TelemetryWriter.telemetryData.Tables[0].Rows[Utilities.TelemetryWriter.telemetryData.Tables[0].Rows.Count - 1].ItemArray[6], DateTime.Now); //Update the end time for the previous Utilities.TelemetryWriter.UpdatePreviousEntry(); //Insert the new entry Utilities.TelemetryWriter.AddTelemetryRow(rippleData.Floor.SetupID, personName, ((currentTile = GetFloorTileForID(val))==null)?"Unknown":currentTile.Name, val, (val == "Tile0") ? "Start" : "Option"); } else { //Stop any existing projections DocumentPresentation.HelperMethods.StopPresentation(); FullScreenContentGrid.Children.Clear(); ContentGrid.Children.Clear(); //Set focus for screen window also Utilities.Helper.ClickOnScreenToGetFocus(); //Stop any existing videos loopVideo = false; VideoControl.Source = null; FullScreenVideoControl.Source = null; //Clean the images fullScreenImgElement.Source = null; imgElement.Source = null; //Clear the header text TitleLabel.Text = ""; //Dispose the objects if(browserElement != null) browserElement.Dispose(); browserElement = null; if (host != null) host.Dispose(); host = null; if (helper != null) helper.PropertyChanged -= helper_PropertyChanged; helper = null; currentScreenContent = ContentType.Nothing; ShowText("No content available for this option, Please try some other tile option", "No Content"); } } } catch (Exception ex) { //Do nothing RippleCommonUtilities.LoggingHelper.LogTrace(1, "Went wrong in On message received for Screen {0}", ex.Message); } }
private void ProjectIntroContent(RippleDictionary.ScreenContent screenContent) { try { //Dispose the previous content //Stop any existing projections DocumentPresentation.HelperMethods.StopPresentation(); FullScreenContentGrid.Children.Clear(); ContentGrid.Children.Clear(); //Set focus for screen window also Utilities.Helper.ClickOnScreenToGetFocus(); //Stop any existing videos loopVideo = false; VideoControl.Source = null; FullScreenVideoControl.Source = null; //Clean the images fullScreenImgElement.Source = null; imgElement.Source = null; //Clear the header text TitleLabel.Text = ""; if (browserElement != null) { browserElement.Dispose(); } browserElement = null; if (host != null) { host.Dispose(); } host = null; if (helper != null) { helper.PropertyChanged -= helper_PropertyChanged; } helper = null; //Play the Intro video this.TitleLabel.Text = ""; ContentGrid.Visibility = Visibility.Collapsed; FullScreenContentGrid.Visibility = Visibility.Collapsed; FullScreenVideoGrid.Visibility = Visibility.Collapsed; IntroVideoControl.Visibility = Visibility.Visible; VideoControl.Visibility = Visibility.Collapsed; VideoGrid.Visibility = Visibility.Visible; IntroVideoControl.Play(); this.UpdateLayout(); myBackgroundWorker = new BackgroundWorker(); myBackgroundWorker.DoWork += myBackgroundWorker_DoWork; myBackgroundWorker.RunWorkerCompleted += myBackgroundWorker_RunWorkerCompleted; myBackgroundWorker.RunWorkerAsync(rippleData.Floor.Start.IntroVideoWaitPeriod); } catch (Exception ex) { RippleCommonUtilities.LoggingHelper.LogTrace(1, "Went wrong in ProjectIntroContent Method for screen {0}", ex.Message); } }
/// <summary> /// Identifies the content type and project accordingly /// </summary> /// <param name="screenContent"></param> private void ProjectContent(RippleDictionary.ScreenContent screenContent) { try { if (screenContent.Type == ContentType.HTMLMessage) { if (helper != null && currentScreenContent == ContentType.HTML) { helper.MessageReceived(screenContent.Content); return; } } //Stop any existing projections DocumentPresentation.HelperMethods.StopPresentation(); FullScreenContentGrid.Children.Clear(); ContentGrid.Children.Clear(); //Set focus for screen window also Utilities.Helper.ClickOnScreenToGetFocus(); //Stop any existing videos loopVideo = false; VideoControl.Source = null; FullScreenVideoControl.Source = null; //Clean the images fullScreenImgElement.Source = null; imgElement.Source = null; //Clear the header text TitleLabel.Text = ""; //Dispose the objects if (browserElement != null) { browserElement.Dispose(); } browserElement = null; if (host != null) { host.Dispose(); } host = null; if (helper != null) { helper.PropertyChanged -= helper_PropertyChanged; } helper = null; currentScreenContent = screenContent.Type; if (screenContent.Id == "Tile0" && StartVideoPlayed) { currentScreenContent = ContentType.Image; ShowImage("\\Assets\\Images\\default_start.png", screenContent.Header); return; } switch (screenContent.Type) { case RippleDictionary.ContentType.HTML: ShowBrowser(screenContent.Content, screenContent.Header); break; case RippleDictionary.ContentType.Image: ShowImage(screenContent.Content, screenContent.Header); break; case RippleDictionary.ContentType.PPT: ShowPPT(screenContent.Content, screenContent.Header); break; case RippleDictionary.ContentType.Text: ShowText(screenContent.Content, screenContent.Header); break; case RippleDictionary.ContentType.Video: loopVideo = (screenContent.LoopVideo == null) ? false : Convert.ToBoolean(screenContent.LoopVideo); if (screenContent.Id == "Tile0") { StartVideoPlayed = true; } ShowVideo(screenContent.Content, screenContent.Header); break; } } catch (Exception ex) { RippleCommonUtilities.LoggingHelper.LogTrace(1, "Went wrong in ProjectContent Method for screen {0}", ex.Message); } }
/// <summary> /// Code will receive messages from the floor /// Invoke appropriate content projection based on the tile ID passed /// </summary> /// <param name="val"></param> public void OnMessageReceived(string val) { try { //Check for reset if (val.Equals("Reset")) { //Update the previous entry Utilities.TelemetryWriter.UpdatePreviousEntry(); //Reset the system ResetUI(); } //Check for System start //Check for System start else if (val.StartsWith("System Start")) { //Load the telemetry Data Utilities.TelemetryWriter.RetrieveTelemetryData(); //The floor has asked the screen to start the system //Get the User Name Globals.UserName = val.Split(':')[1]; //Get the person identity for the session personName = String.IsNullOrEmpty(Globals.UserName) ? Convert.ToString(Guid.NewGuid()) : Globals.UserName; Utilities.TelemetryWriter.AddTelemetryRow(rippleData.Floor.SetupID, personName, "Unlock", val, "Unlock"); //Set the system state Globals.currentAppState = RippleSystemStates.UserDetected; //Play the Intro Content ProjectIntroContent(rippleData.Screen.ScreenContents["IntroVideo"]); } //Check for gestures else if (val.StartsWith("Gesture")) { OnGestureInput(val.Split(':')[1]); } //Check for HTMl messages else if (val.StartsWith("HTML")) { OnHTMLMessagesReceived(val.Split(':')[1]); } //Check for options- TODO need to figure out else if (val.StartsWith("Option")) { //Do nothing } //Check if a content - tile mapping or in general content tag exists else { if (rippleData.Screen.ScreenContents.ContainsKey(val) && rippleData.Screen.ScreenContents[val].Type != ContentType.Nothing) { //Set the system state Globals.currentAppState = RippleSystemStates.OptionSelected; ProjectContent(rippleData.Screen.ScreenContents[val]); RippleCommonUtilities.LoggingHelper.LogTrace(1, "In Message Received {0} {1}:{2}", Utilities.TelemetryWriter.telemetryData.Tables[0].Rows.Count, Utilities.TelemetryWriter.telemetryData.Tables[0].Rows[Utilities.TelemetryWriter.telemetryData.Tables[0].Rows.Count - 1].ItemArray[6], DateTime.Now); //Update the end time for the previous Utilities.TelemetryWriter.UpdatePreviousEntry(); //Insert the new entry Utilities.TelemetryWriter.AddTelemetryRow(rippleData.Floor.SetupID, personName, ((currentTile = GetFloorTileForID(val)) == null)?"Unknown":currentTile.Name, val, (val == "Tile0") ? "Start" : "Option"); } else { //Stop any existing projections DocumentPresentation.HelperMethods.StopPresentation(); FullScreenContentGrid.Children.Clear(); ContentGrid.Children.Clear(); //Set focus for screen window also Utilities.Helper.ClickOnScreenToGetFocus(); //Stop any existing videos loopVideo = false; VideoControl.Source = null; FullScreenVideoControl.Source = null; //Clean the images fullScreenImgElement.Source = null; imgElement.Source = null; //Clear the header text TitleLabel.Text = ""; //Dispose the objects if (browserElement != null) { browserElement.Dispose(); } browserElement = null; if (host != null) { host.Dispose(); } host = null; if (helper != null) { helper.PropertyChanged -= helper_PropertyChanged; } helper = null; currentScreenContent = ContentType.Nothing; ShowText("No content available for this option, Please try some other tile option", "No Content"); } } } catch (Exception ex) { //Do nothing RippleCommonUtilities.LoggingHelper.LogTrace(1, "Went wrong in On message received for Screen {0}", ex.Message); } }