<commit_before>/*
 * Xibo - Digitial Signage - http://www.xibo.org.uk
 * Copyright (C) 2006,2007,2008 <NAME> and <NAME>
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version. 
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace XiboClient
{
    class WebContent : Media
    {
        int scheduleId;
        int layoutId;
        string mediaId;
        string type;

        public WebContent(RegionOptions options)
            : base(options.width, options.height, options.top, options.left)
        {
            duration        = options.duration;
            scheduleId      = options.scheduleId;
            layoutId        = options.layoutId;
            mediaId         = options.mediaid;
            type = options.type;

            webBrowser = new WebBrowser();

            webBrowser.Size = this.Size;
            webBrowser.ScrollBarsEnabled = false;
            webBrowser.ScriptErrorsSuppressed = true;

            // Attach event
            webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);

            if (!Properties.Settings.Default.powerpointEnabled && options.type == "powerpoint")
            {
                webBrowser.DocumentText = "<html><body><h1>Powerpoint not enabled on this display</h1></body></html>";
                System.Diagnostics.Trace.WriteLine(String.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", "Powerpoint is not enabled on this display", scheduleId, layoutId, mediaId));
            }
            else
            {
                try
                {
                    // Try to make a URI out of the file path
                    try
                    {
                        this.filePath = Uri.UnescapeDataString(options.uri);
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message, "WebContent");
                    }

                    // Navigate
                    webBrowser.Navigate(this.filePath);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(String.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", ex.Message, scheduleId, layoutId, mediaId));

                    webBrowser.DocumentText = "<html><body><h1>Unable to show this web location - invalid address.</h1></body></html>";

                    System.Diagnostics.Trace.WriteLine(String.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", "Unable to show the powerpoint, cannot be located", scheduleId, layoutId, mediaId));
                }
            }
            
            //Add the panel
            this.Controls.Add(webBrowser);
        }

        public override void RenderMedia()
        {
            //do nothing
            return;
        }

        void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            base.Duration = duration;

            base.RenderMedia();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("Disposing {0}", filePath));

                try
                {
                    if (webBrowser != null)
                    {
                        if (webBrowser.Document != null) webBrowser.Document.Body.InnerHtml = "";
                        webBrowser.Dispose();
                    }
                }
                catch { }
            }

            base.Dispose(disposing);

            System.Diagnostics.Debug.WriteLine(String.Format("Disposed {0}", filePath));
        }

        string filePath;
        WebBrowser webBrowser;
        int duration;
    }
}<commit_msg>[dotnetclient] Change to webcontent so that it doesnt show until loaded.<commit_after>/*
 * Xibo - Digitial Signage - http://www.xibo.org.uk
 * Copyright (C) 2006,2007,2008 <NAME> and <NAME>
 *
 * This file is part of Xibo.
 *
 * Xibo is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version. 
 *
 * Xibo is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with Xibo.  If not, see <http://www.gnu.org/licenses/>.
 */
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace XiboClient
{
    class WebContent : Media
    {
        int scheduleId;
        int layoutId;
        string mediaId;
        string type;

        public WebContent(RegionOptions options)
            : base(options.width, options.height, options.top, options.left)
        {
            duration        = options.duration;
            scheduleId      = options.scheduleId;
            layoutId        = options.layoutId;
            mediaId         = options.mediaid;
            type = options.type;

            webBrowser = new WebBrowser();

            webBrowser.Size = this.Size;
            webBrowser.ScrollBarsEnabled = false;
            webBrowser.ScriptErrorsSuppressed = true;

            // Attach event
            webBrowser.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(webBrowser_DocumentCompleted);

            if (!Properties.Settings.Default.powerpointEnabled && options.type == "powerpoint")
            {
                webBrowser.DocumentText = "<html><body><h1>Powerpoint not enabled on this display</h1></body></html>";
                System.Diagnostics.Trace.WriteLine(String.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", "Powerpoint is not enabled on this display", scheduleId, layoutId, mediaId));
            }
            else
            {
                try
                {
                    // Try to make a URI out of the file path
                    try
                    {
                        this.filePath = Uri.UnescapeDataString(options.uri);
                    }
                    catch (Exception ex)
                    {
                        System.Diagnostics.Debug.WriteLine(ex.Message, "WebContent");
                    }

                    // Navigate
                    webBrowser.Navigate(this.filePath);
                }
                catch (Exception ex)
                {
                    System.Diagnostics.Trace.WriteLine(String.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", ex.Message, scheduleId, layoutId, mediaId));

                    webBrowser.DocumentText = "<html><body><h1>Unable to show this web location - invalid address.</h1></body></html>";

                    System.Diagnostics.Trace.WriteLine(String.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", "Unable to show the powerpoint, cannot be located", scheduleId, layoutId, mediaId));
                }
            }
        }

        public override void RenderMedia()
        {
            //do nothing
            return;
        }

        void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            base.Duration = duration;

            base.RenderMedia();

            //Add the panel
            this.Controls.Add(webBrowser);

            Show();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                System.Diagnostics.Debug.WriteLine(String.Format("Disposing {0}", filePath));

                try
                {
                    if (webBrowser != null)
                    {
                        if (webBrowser.Document != null) webBrowser.Document.Body.InnerHtml = "";
                        webBrowser.Dispose();
                    }
                }
                catch { }
            }

            base.Dispose(disposing);

            System.Diagnostics.Debug.WriteLine(String.Format("Disposed {0}", filePath));
        }

        string filePath;
        WebBrowser webBrowser;
        int duration;
    }
}
{'fraction_non_alphanumeric': 0.09246942716155332, 'fraction_numerical': 0.006650933276121004, 'mean_word_length': 1.5940456316082359, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4501645', 'n_tokens_mistral': 2364, 'n_tokens_neox': 2161, 'n_words': 587}