Пример #1
0
 public Picture(RegionOptions options) : base(options.Width, options.Height, options.Top, options.Left)
 {
     this._filePath = options.Uri;
     if (!File.Exists(this._filePath))
     {
         Trace.WriteLine(new LogMessage("Image - Dispose", "Cannot Create image object. Invalid Filepath."), LogType.Error.ToString());
     }
     else
     {
         try
         {
             this._pictureBox         = new MediaElement();
             this._pictureBox.Stretch = Stretch.Fill;
             Uri uriSource = new Uri(this._filePath.Replace(@"\", "/"), UriKind.Relative);
             this._pictureBox.Source     = uriSource;
             base.MediaCanvas.Background = new ImageBrush(new BitmapImage(uriSource));
             base.SnapShot           = uriSource;
             this._pictureBox.Width  = base.Width;
             this._pictureBox.Height = base.Height;
             this._pictureBox.HorizontalAlignment = HorizontalAlignment.Center;
             this._pictureBox.VerticalAlignment   = VerticalAlignment.Center;
             this._pictureBox.Margin  = new Thickness(0.0, 0.0, 0.0, 0.0);
             this._pictureBox.Loaded += new RoutedEventHandler(this.PictureBoxLoaded);
             base.MediaCanvas.Children.Add(this._pictureBox);
             base.HasOnLoaded = true;
         }
         catch (Exception exception)
         {
             Trace.WriteLine(new LogMessage("Picture", string.Format("Cannot create Image Object with exception: {0}", exception.Message)), LogType.Error.ToString());
         }
     }
 }
Пример #2
0
 public WebEdge(RegionOptions options) : base(options)
 {
     this.backgroundColor = options.Dictionary.Get("backgroundColor", options.backgroundColor);
     this.backgroundImage = options.backgroundImage;
     this.backgroundLeft  = options.backgroundLeft;
     this.backgroundTop   = options.backgroundTop;
 }
Пример #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="options"></param>
        public Video(RegionOptions options) : base(options)
        {
            this.ShouldBeVisible = true;

            _filePath = Uri.UnescapeDataString(options.uri).Replace('+', ' ');
            _duration = options.duration;

            // Handle Volume
            this.volume = options.Dictionary.Get("volume", 100);

            // Mute - if not provided as an option, we keep the default.
            string muteOption = options.Dictionary.Get("mute");

            if (!string.IsNullOrEmpty(muteOption))
            {
                this.Muted = muteOption == "1";
            }

            // Should we loop?
            this.isLooping = (options.Dictionary.Get("loop", "0") == "1" && _duration != 0);

            // Full Screen?
            this.isFullScreenRequest = options.Dictionary.Get("showFullScreen", "0") == "1";

            // Scale type
            Stretch = options.Dictionary.Get("scaleType", "aspect").ToLowerInvariant() == "stretch";
        }
Пример #4
0
 void Init(SerializedProperty property)
 {
     try
     {
         mObject = property.GetParentObject();
         if (mPI == null && !string.IsNullOrEmpty(Attribute.RegionOptionsPropertyName))
         {
             mPI = mObject.GetType().GetPropertyIncludingBaseClasses(Attribute.RegionOptionsPropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
         }
         if (mPI != null)
         {
             mOptions = (RegionOptions <float>)mPI.GetValue(mObject, null);
         }
         else
         {
             mOptions = RegionOptions <float> .Default;
         }
     }
     catch (System.Exception e)
     {
         Debug.LogError("FloatRegionPropertyDrawer: Unable to find property '" + Attribute.RegionOptionsPropertyName + "'! (" + e.ToString() + ")");
     }
     ppFrom        = property.FindPropertyRelative("From");
     ppTo          = property.FindPropertyRelative("To");
     ppSimpleValue = property.FindPropertyRelative("SimpleValue");
     if (minmax)
     {
         ppSimpleValue.boolValue = false;
     }
 }
Пример #5
0
            public RegionOptions SayHello()
            {
                Console.WriteLine("Hello");
                var options = new RegionOptions();

                return(IO.Handle(options) ? options : null);
            }
Пример #6
0
        public void loadFromOptions(RegionOptions options)
        {
            // Start of by setting our dimensions
            SetDimensions(options.left, options.top, options.width, options.height);

            // Store the options
            this.options = options;
        }
Пример #7
0
 public Video(RegionOptions options) : base(options.Width, options.Height, options.Top, options.Left)
 {
     this.filePath           = options.Uri;
     this.duration           = options.Duration;
     this.videoPlayer        = new VideoPlayer();
     this.videoPlayer.Width  = options.Width;
     this.videoPlayer.Height = options.Height;
     videoPlayer.SetSize(new Size(options.Width, options.Height));
     this.videoPlayer.Location = new Point(0.0, 0.0);
     base.MediaCanvas.Children.Add(this.videoPlayer);
 }
Пример #8
0
        /// <summary>
        /// Media Object
        /// </summary>
        /// <param name="options"></param>
        public Media(RegionOptions options)
        {
            InitializeComponent();

            // Store the options.
            this.options = options;
            this.Id      = options.mediaid;
            ScheduleId   = options.scheduleId;
            LayoutId     = options.layoutId;
            StatsEnabled = options.isStatEnabled;
        }
Пример #9
0
        public ShellCommand(RegionOptions options) : base(options)
        {
            _command = Uri.UnescapeDataString(options.Dictionary.Get("windowsCommand")).Replace('+', ' ');
            _code    = options.Dictionary.Get("commandCode");

            // Default to launching through CMS for backwards compatiblity
            _launchThroughCmd = (options.Dictionary.Get("launchThroughCmd", "1") == "1");

            // Termination
            _terminateCommand = (options.Dictionary.Get("terminateCommand") == "1");
            _useTaskKill      = (options.Dictionary.Get("useTaskkill") == "1");
        }
Пример #10
0
        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.FileType;

            webBrowser = new WebBrowser();

            webBrowser.Height = options.Height;
            webBrowser.Width  = options.Width;

            //webBrowser.ScrollBarsEnabled = false;
            //webBrowser.ScriptErrorsSuppressed = true;

            // Attach event
            webBrowser.LoadCompleted += (WebBrowserDocumentCompleted);

            if (!Settings.Default.powerpointEnabled && options.FileType == "powerpoint")
            {
                webBrowser.Source = new Uri("<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.Source = new Uri("<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));
                }
            }
        }
Пример #11
0
        public Video(RegionOptions options)
            : base(options.Width, options.Height, options.Top, options.Left)
        {
            this.filePath = options.Uri;
            this.duration = options.Duration;

            videoPlayer          = new VideoPlayer();
            videoPlayer.Width    = options.Width;
            videoPlayer.Height   = options.Height;
            videoPlayer.Location = new Point(0, 0);

            MediaCanvas.Children.Add(videoPlayer);
        }
Пример #12
0
        public PowerPoint(RegionOptions options) : base(options)
        {
            // Check if PowerPoint is enabled
            if (!ApplicationSettings.Default.PowerpointEnabled)
            {
                CacheManager.Instance.AddUnsafeItem(UnsafeItemType.Media, options.layoutId, options.mediaid, "PowerPoint not enabled on this Display", 300);
                throw new Exception("PowerPoint not enabled on this Display");
            }

            // We are a normal WebIe control, opened natively
            options.Dictionary.Replace("modeid", "1");

            _filePath = ApplicationSettings.Default.EmbeddedServerAddress + Path.GetFileName(_filePath);
        }
Пример #13
0
        /// <summary>
        /// Get the configured web media engine
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static WebMedia GetConfiguredWebMedia(RegionOptions options)
        {
            WebMedia media;

            if (ApplicationSettings.Default.FallbackToInternetExplorer)
            {
                media = new WebIe(options);
            }
            else
            {
                media = new WebCef(options);
            }
            return(media);
        }
Пример #14
0
        public Picture(RegionOptions options)
            : base(options.Width, options.Height, options.Top, options.Left)
        {
            _filePath = options.Uri;

            if (!File.Exists(_filePath))
            {
                // Exit
                Trace.WriteLine(new LogMessage("Image - Dispose", "Cannot Create image object. Invalid Filepath."),
                                LogType.Error.ToString());
                return;
            }

            try
            {
                _pictureBox = new MediaElement();

                _pictureBox.Stretch = Stretch.UniformToFill;
                var uri = new Uri(_filePath.Replace("\\", "/"), UriKind.Relative);
                _pictureBox.Source     = (uri);
                MediaCanvas.Background = new ImageBrush(new BitmapImage(uri));
                // new Uri("pack://application:,,,/ApplicationName;component/"+_filePath);

                SnapShot = uri;

                _pictureBox.Width  = Width;
                _pictureBox.Height = Height;
                //MediaGrid.Width = Width;
                //MediaGrid.Height = Height;

                _pictureBox.HorizontalAlignment = HorizontalAlignment.Center;
                _pictureBox.VerticalAlignment   = VerticalAlignment.Center;
                _pictureBox.Margin = new Thickness(0, 0, 0, 0);

                //     _pictureBox.BorderStyle = BorderStyle.None;
                //     _pictureBox.BackColor = Color.Transparent;
                _pictureBox.Loaded += PictureBoxLoaded;
                MediaCanvas.Children.Add(_pictureBox);
                HasOnLoaded = true;
            }
            catch (Exception ex)
            {
                Trace.WriteLine(
                    new LogMessage("Picture",
                                   String.Format("Cannot create Image Object with exception: {0}", ex.Message)),
                    LogType.Error.ToString());
            }
        }
Пример #15
0
        public Flash(RegionOptions options) : base(options.Width, options.Height, options.Top, options.Left)
        {
            this._tempHtml        = new TemporaryHtml();
            this._backgroundImage = options.backgroundImage;
            this._backgroundColor = options.backgroundColor;
            this._backgroundTop   = options.BackgroundTop + "px";
            this._backgroundLeft  = options.BackgroundLeft + "px";
            this.GenerateHeadHtml();
            string format = "\r\n                <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' Width='{2}' Height='{3}' id='analog_clock' align='middle'>\r\n                    <param name='allowScriptAccess' value='sameDomain' />\r\n                    <param name='movie' value='{1}' />\r\n                    <param name='quality' value='high' />\r\n                    <param name='bgcolor' value='#000' />\r\n                    <param name='WMODE' value='transparent' />\r\n                    <embed src='{1}' quality='high' wmode='transparent' bgcolor='#ffffff' Width='{2}' Height='{3}' name='analog_clock' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />\r\n                </object>\r\n            ";

            this._tempHtml.BodyContent      = string.Format(format, new object[] { options.Uri, options.Uri, options.Width.ToString(), options.Height.ToString() });
            this._webBrowser                = new WebBrowser();
            this._webBrowser.RenderSize     = base.RenderSize;
            this._webBrowser.LoadCompleted += new LoadCompletedEventHandler(this._webBrowser_DocumentCompleted);
            this._webBrowser.Navigate(this._tempHtml.Path);
        }
Пример #16
0
        public Flash(RegionOptions options) : base(options)
        {
            // Set NativeOpen to true
            options.Dictionary.Replace("modeid", "1");

            // This openes a cached file
            string cacheFile = ApplicationSettings.Default.EmbeddedServerAddress + "flash_" + options.FileId + ".htm";

            options.Dictionary.Replace("uri", cacheFile);

            if (!File.Exists(cacheFile))
            {
                // Set the body
                string html = @"
                <html> 
                    <head>
                    </head>
                    <body>
                        <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' width='{2}' height='{3}' id='analog_clock' align='middle'>
                            <param name='allowScriptAccess' value='sameDomain' />
                            <param name='movie' value='{1}' />
                            <param name='quality' value='high' />
                            <param name='bgcolor' value='#000' />
                            <param name='WMODE' value='transparent' />
                            <embed src='{1}' quality='high' wmode='transparent' bgcolor='#ffffff' width='{2}' height='{3}' name='analog_clock' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />
                        </object>
                    </body>
                </html>
                ";
                html = string.Format(html, options.uri, options.uri, options.width.ToString(), options.height.ToString());

                html = this.MakeHtmlSubstitutions(html);

                // Save this file to disk
                using (FileStream stream = new FileStream(cacheFile, FileMode.Create))
                {
                    using (StreamWriter writer = new StreamWriter(stream, Encoding.UTF8))
                    {
                        writer.WriteLine(html);
                    }
                }
            }
        }
Пример #17
0
        /// <summary>
        /// Get the configured web media engine
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static WebMedia GetConfiguredWebMedia(RegionOptions options)
        {
            if (ApplicationSettings.Default.FallbackToInternetExplorer)
            {
                return(new WebIe(options));
            }
            else if (!string.IsNullOrEmpty(ApplicationSettings.Default.EdgeBrowserWhitelist))
            {
                // Decode the URL
                string url = Uri.UnescapeDataString(options.uri);

                if (url.Contains(ApplicationSettings.Default.EdgeBrowserWhitelist))
                {
                    return(new WebEdge(options));
                }
            }

            return(new WebCef(options));
        }
Пример #18
0
        /// <summary>
        /// Creates a Text display control
        /// </summary>
        /// <param name="options">Region Options for this control</param>
        public Text(RegionOptions options)
            : base(options.Width, options.Height, options.Top, options.Left)
        {
            // Collect some options from the Region Options passed in
            // and store them in member variables.
            _filePath        = options.Uri;
            _direction       = options.direction;
            _backgroundImage = options.backgroundImage;
            _backgroundColor = options.backgroundColor;
            _scaleFactor     = options.ScaleFactor;
            _backgroundTop   = options.BackgroundTop + "px";
            _backgroundLeft  = options.BackgroundLeft + "px";
            _documentText    = options.text;
            _scrollSpeed     = options.scrollSpeed;
            _headJavaScript  = options.javaScript;

            // Generate a temporary file to store the rendered object in.
            _tempHtml = new TemporaryHtml();

            // Generate the Head Html and store to file.
            GenerateHeadHtml();

            // Generate the Body Html and store to file.
            GenerateBodyHtml();

            // Fire up a webBrowser control to display the completed file.
            _webBrowser        = new WebBrowser();
            _webBrowser.Height = options.Height;
            _webBrowser.Width  = options.Width;
            _webBrowser.Margin = new Thickness(0, 0, 0, 0);
            //_webBrowser.ScrollBarsEnabled = false;
            //_webBrowser.ScriptErrorsSuppressed = true;
            _webBrowser.LoadCompleted += (WebBrowserDocumentCompleted);

            _webBrowser.Navigated += delegate
            {
                HideScriptErrors(_webBrowser, true);
            };
            // Navigate to temp file
            _webBrowser.Navigate(_tempHtml.Path);

            MediaCanvas.Children.Add(_webBrowser);
        }
Пример #19
0
 public Rss(RegionOptions options) : base(options.Width, options.Height, options.Top, options.Left)
 {
     if (string.IsNullOrEmpty(options.Uri))
     {
         throw new ArgumentNullException("Uri", "The Uri for the RSS feed can not be empty");
     }
     try
     {
         this._filePath = Uri.UnescapeDataString(options.Uri);
     }
     catch (Exception)
     {
         throw new ArgumentNullException("Uri", "The URI is invalid.");
     }
     this._direction         = options.direction;
     this._backgroundImage   = options.backgroundImage;
     this._backgroundColor   = options.backgroundColor;
     this._copyrightNotice   = options.copyrightNotice;
     this._mediaid           = options.mediaid;
     this._scheduleId        = options.scheduleId;
     this._layoutId          = options.layoutId;
     this._scaleFactor       = options.ScaleFactor;
     this._duration          = options.Duration;
     this._updateInterval    = options.updateInterval;
     this._scrollSpeed       = options.scrollSpeed;
     this._numItems          = Convert.ToInt32(options.Dictionary.Get("numItems", "0"));
     this._durationIsPerItem = Convert.ToInt32(options.Dictionary.Get("durationIsPerItem", "0"));
     this._takeItemsFrom     = options.Dictionary.Get("takeItemsFrom", "start");
     this._tempHtml          = new TemporaryHtml();
     this._backgroundTop     = options.BackgroundTop + "px";
     this._backgroundLeft    = options.BackgroundLeft + "px";
     this._documentText      = options.text;
     this._documentTemplate  = options.documentTemplate;
     this.GenerateHeadHtml();
     this.PrepareRSS();
     this._webBrowser = new WebBrowser();
     if (this._rssReady)
     {
         this.LoadRssIntoTempFile();
         this._webBrowser.Navigate(this._tempHtml.Path);
     }
 }
Пример #20
0
        // Class Methods

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="options"></param>
        public WebMedia(RegionOptions options)
            : base(options)
        {
            // Collect some options from the Region Options passed in
            // and store them in member variables.
            _options = options;

            // Set the file path/local web path
            if (IsNativeOpen())
            {
                // If we are modeid == 1, then just open the webpage without adjusting the file path
                _filePath = Uri.UnescapeDataString(_options.uri).Replace('+', ' ');
            }
            else
            {
                // Set the file path
                _filePath     = ApplicationSettings.Default.LibraryPath + @"\" + _options.mediaid + ".htm";
                _localWebPath = ApplicationSettings.Default.EmbeddedServerAddress + _options.mediaid + ".htm";
            }
        }
Пример #21
0
        public Flash(RegionOptions options)
            : base(options.Width, options.Height, options.Top, options.Left)
        {
            _tempHtml = new TemporaryHtml();

            _backgroundImage = options.backgroundImage;
            _backgroundColor = options.backgroundColor;
            _backgroundTop   = options.BackgroundTop + "px";
            _backgroundLeft  = options.BackgroundLeft + "px";

            // Create the HEAD of the document
            GenerateHeadHtml();

            // Set the body
            string html =
                @"
                <object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0' Width='{2}' Height='{3}' id='analog_clock' align='middle'>
                    <param name='allowScriptAccess' value='sameDomain' />
                    <param name='movie' value='{1}' />
                    <param name='quality' value='high' />
                    <param name='bgcolor' value='#000' />
                    <param name='WMODE' value='transparent' />
                    <embed src='{1}' quality='high' wmode='transparent' bgcolor='#ffffff' Width='{2}' Height='{3}' name='analog_clock' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />
                </object>
            ";

            _tempHtml.BodyContent = string.Format(html, options.Uri, options.Uri, options.Width.ToString(),
                                                  options.Height.ToString());

            // Fire up a webBrowser control to display the completed file.
            _webBrowser            = new WebBrowser();
            _webBrowser.RenderSize = this.RenderSize;

            //      _webBrowser.Size = this.Size;
            //        _webBrowser.ScrollBarsEnabled = false;
            //    _webBrowser.ScriptErrorsSuppressed = true;
            _webBrowser.LoadCompleted += (_webBrowser_DocumentCompleted);

            // Navigate to temp file
            _webBrowser.Navigate(_tempHtml.Path);
        }
Пример #22
0
        /// <summary>
        /// Get the configured web media engine
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public static WebMedia GetConfiguredWebMedia(RegionOptions options, string type)
        {
            WebMedia media;

            if (type == "ie")
            {
                media = new WebIe(options);
            }
            else if (type == "edge")
            {
                media = new WebEdge(options);
            }
            else if (type == "cef")
            {
                media = new WebCef(options);
            }
            else
            {
                media = GetConfiguredWebMedia(options);
            }
            return(media);
        }
Пример #23
0
 public WebContent(RegionOptions options) : base(options.Width, options.Height, options.Top, options.Left)
 {
     this.duration                  = options.Duration;
     this.scheduleId                = options.scheduleId;
     this.layoutId                  = options.layoutId;
     this.mediaId                   = options.mediaid;
     this.type                      = options.FileType;
     this.webBrowser                = new WebBrowser();
     this.webBrowser.Height         = options.Height;
     this.webBrowser.Width          = options.Width;
     this.webBrowser.LoadCompleted += new LoadCompletedEventHandler(this.WebBrowserDocumentCompleted);
     //if (/*!Settings.Default.powerpointEnabled &&*/ (options.FileType == "Powerpoint"))
     //{
     //    this.webBrowser.Source = new Uri("<html><body><h1>Powerpoint not enabled on this display</h1></body></html>");
     //    Trace.WriteLine(string.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", new object[] { "Powerpoint is not enabled on this display", this.scheduleId, this.layoutId, this.mediaId }));
     //}
     //else
     {
         try
         {
             try
             {
                 this.filePath = Uri.UnescapeDataString(options.Uri);
             }
             catch (Exception)
             {
             }
             this.webBrowser.Navigate(Application.StartupPath + "\\" + this.filePath.Replace("\\\\", "\\"));
             MediaCanvas.Children.Add(webBrowser);
         }
         catch (Exception exception)
         {
             Trace.WriteLine(string.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", new object[] { exception.Message, this.scheduleId, this.layoutId, this.mediaId }));
             this.webBrowser.NavigateToString("<html><body><h1>Unable to show this web location - invalid address.</h1></body></html>");
             Trace.WriteLine(string.Format("[*]ScheduleID:{1},LayoutID:{2},MediaID:{3},Message:{0}", new object[] { "Unable to show the powerpoint, cannot be located", this.scheduleId, this.layoutId, this.mediaId }));
         }
     }
 }
Пример #24
0
        public Image(RegionOptions options) : base(options)
        {
            this.filePath  = options.uri;
            this.scaleType = options.Dictionary.Get("scaleType", "stretch");

            // Horizontal Alignment
            switch (options.Dictionary.Get("align", "center"))
            {
            case "left":
                hAlign = System.Windows.HorizontalAlignment.Left;
                break;

            case "right":
                hAlign = System.Windows.HorizontalAlignment.Right;
                break;

            default:
                hAlign = System.Windows.HorizontalAlignment.Center;
                break;
            }

            // Vertical Alignment
            switch (options.Dictionary.Get("valign", "middle"))
            {
            case "top":
                this.vAlign = System.Windows.VerticalAlignment.Top;
                break;

            case "bottom":
                this.vAlign = System.Windows.VerticalAlignment.Bottom;
                break;

            default:
                this.vAlign = System.Windows.VerticalAlignment.Center;
                break;
            }
        }
Пример #25
0
 public DataSetView(RegionOptions options) : base(options.Width, options.Height, options.Top, options.Left)
 {
     this._layoutId                  = options.layoutId;
     this._regionId                  = options.regionId;
     this._mediaId                   = options.mediaid;
     this._duration                  = options.Duration;
     this._scaleFactor               = options.ScaleFactor;
     this._updateInterval            = Convert.ToInt32(options.Dictionary.Get("updateInterval"));
     this._backgroundImage           = options.backgroundImage;
     this._backgroundColor           = options.backgroundColor;
     this._backgroundTop             = options.BackgroundTop + "px";
     this._backgroundLeft            = options.BackgroundLeft + "px";
     this._webBrowser                = new WebBrowser();
     this._webBrowser.LoadCompleted += new LoadCompletedEventHandler(this.webBrowser_DocumentCompleted);
     if (this.HtmlReady())
     {
         string source = Settings.Default.LibraryPath + @"\" + this._mediaId + ".htm";
         this._webBrowser.Navigate(source);
     }
     else
     {
         this.RefreshLocalHtml();
     }
 }
Пример #26
0
        public DataSetView(RegionOptions options)
            : base(options.Width, options.Height, options.Top, options.Left)
        {
            _layoutId    = options.layoutId;
            _regionId    = options.regionId;
            _mediaId     = options.mediaid;
            _duration    = options.Duration;
            _scaleFactor = options.ScaleFactor;

            _updateInterval = Convert.ToInt32(options.Dictionary.Get("updateInterval"));

            _backgroundImage = options.backgroundImage;
            _backgroundColor = options.backgroundColor;

            // Set up the backgrounds
            _backgroundTop  = options.BackgroundTop + "px";
            _backgroundLeft = options.BackgroundLeft + "px";

            // Create a webbrowser to take the temp file loc
            _webBrowser = new WebBrowser();
            //_webBrowser.ScriptErrorsSuppressed = true;
            //_webBrowser.Size = this.Size;
            //_webBrowser.ScrollBarsEnabled = false;
            _webBrowser.LoadCompleted += (webBrowser_DocumentCompleted);

            if (HtmlReady())
            {
                // Navigate to temp file
                string filePath = Settings.Default.LibraryPath + @"\" + _mediaId + ".htm";
                _webBrowser.Navigate(filePath);
            }
            else
            {
                RefreshLocalHtml();
            }
        }
Пример #27
0
 protected override void ConfigureRegions(RegionOptions option)
 {
     option.SetWindowCreator(CreateShell)
     .SupportsRegion(KnownRegions.Content)
     .SupportsModal(CreateModal);
 }
Пример #28
0
        /// <summary>
        /// Get region Details
        /// </summary>
        /// <param name="region"></param>
        public static void RenderRegionDetails(XmlNode region, LayoutOption _layoutOption)
        {
            RegionOptions regionOption = new RegionOptions();
            MediaOption   options      = new MediaOption();

            // Override the default size if necessary
            _clientSize.Height = SystemParameters.PrimaryScreenHeight;
            _clientSize.Width  = SystemParameters.PrimaryScreenWidth;

            // Set the background and size of the form
            double layoutWidth  = int.Parse(_layoutOption.layoutWidth.ToString(), CultureInfo.InvariantCulture);
            double layoutHeight = int.Parse(_layoutOption.layoutHeight.ToString(), CultureInfo.InvariantCulture);

            // Scaling factor, will be applied to all regions
            double scaleFactor = Math.Min(_clientSize.Width / layoutWidth, _clientSize.Height / layoutHeight);

            // Want to be able to center this shiv - therefore work out which one of these is going to have left overs
            int backgroundWidth  = (int)(layoutWidth * scaleFactor);
            int backgroundHeight = (int)(layoutHeight * scaleFactor);

            double leftOverX;
            double leftOverY;

            try
            {
                leftOverX = Math.Abs(_clientSize.Width - backgroundWidth);
                leftOverY = Math.Abs(_clientSize.Height - backgroundHeight);

                if (leftOverX != 0)
                {
                    leftOverX = leftOverX / 2;
                }
                if (leftOverY != 0)
                {
                    leftOverY = leftOverY / 2;
                }
            }
            catch
            {
                leftOverX = 0;
                leftOverY = 0;
            }

            //region attributes

            XmlAttributeCollection regionAttributes = region.Attributes;

            if (regionAttributes.Count > 0)
            {
                //options.scheduleId = _scheduleId;
                options.layoutId         = _layoutOption.layoutId.ToString();
                options.regionId         = regionAttributes["id"].Value.ToString();
                options.width            = (int)(Convert.ToDouble(regionAttributes["width"].Value, CultureInfo.InvariantCulture) * scaleFactor);
                options.height           = (int)(Convert.ToDouble(regionAttributes["height"].Value, CultureInfo.InvariantCulture) * scaleFactor);
                options.left             = (int)(Convert.ToDouble(regionAttributes["left"].Value, CultureInfo.InvariantCulture) * scaleFactor);
                options.top              = (int)(Convert.ToDouble(regionAttributes["top"].Value, CultureInfo.InvariantCulture) * scaleFactor);
                regionOption.scaleFactor = scaleFactor;

                if (regionAttributes["zindex"] != null)
                {
                    regionOption.zIndex = Convert.ToInt16(regionAttributes["zindex"].Value);
                }
                else
                {
                    regionOption.zIndex = 0;
                }
                // Store the original width and original height for scaling
                options.originalWidth  = (int)Convert.ToDouble(regionAttributes["width"].Value, CultureInfo.InvariantCulture);
                options.originalHeight = (int)Convert.ToDouble(regionAttributes["height"].Value, CultureInfo.InvariantCulture);

                // Set the backgrounds (used for Web content offsets)
                options.backgroundLeft = options.left * -1;
                options.backgroundTop  = options.top * -1;

                // Account for scaling
                options.left = options.left + (int)leftOverX;
                options.top  = options.top + (int)leftOverY;
            }

            XmlNode optionNode = region.SelectSingleNode("options");

            foreach (XmlNode optionN in optionNode.ChildNodes)
            {
                if (optionN.Name == "transitionType")
                {
                    regionOption.transitionType = optionN.InnerText;
                }
                else if (optionN.Name == "transitionDuration")
                {
                    regionOption.transitionDuration = double.Parse(optionN.InnerText);
                }
                else if (optionN.Name == "transitionDirection")
                {
                    regionOption.transitionDirection = optionN.InnerText;
                }
            }

            _layoutOption.RegionList.Add(
                new RegionOptions(
                    options.layoutId,
                    options.regionId,
                    options.width,
                    options.height,
                    options.top,
                    options.left,
                    regionOption.transitionType,
                    regionOption.transitionDuration,
                    regionOption.transitionDirection,
                    regionOption.zIndex
                    ));

            if (region.ChildNodes.Count != 0)
            {
                XmlNodeList listMedia = region.SelectNodes("media");
                if (listMedia.Count > 0)
                {
                    RenderMedia.MediaList(listMedia, options, _layoutOption);
                }
                else
                {
                    return;
                }
            }
        }
Пример #29
0
        public void PrepareLayout(string layoutPath)
        {
            Action method = null;
            Action start2 = null;
            Action start3 = null;
            Action <RegionOptions> action = null;
            LayoutModel            layout;

            ClientManager.Instance.Stat            = new ClientApp.Core.Stat();
            ClientManager.Instance.Stat.FileType   = StatType.Layout;
            ClientManager.Instance.Stat.ScheduleID = ClientManager.Instance.ScheduleId;
            ClientManager.Instance.Stat.LayoutID   = this._layoutId;
            ClientManager.Instance.Stat.FromDate   = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
            if ((layoutPath == (Settings.Default.LibraryPath + @"\Default.xml")) || string.IsNullOrEmpty(layoutPath))
            {
                throw new Exception("Default layout");
            }
            try
            {
                using (FileStream stream = File.Open(layoutPath, FileMode.Open, FileAccess.Read, FileShare.Write))
                {
                    XmlSerializer serializer = new XmlSerializer(typeof(LayoutModel));
                    layout = (LayoutModel)serializer.Deserialize(stream);
                }
            }
            catch (Exception exception)
            {
                Trace.WriteLine(string.Format("Could not find the layout file {0}: {1}", layoutPath, exception.Message));
                throw;
            }
            this._layoutWidth  = layout.Width;
            this._layoutHeight = layout.Height;
            int width  = this._clientSize.Width;
            int height = this._clientSize.Height;

            this._regions = new Collection <ClientApp.Core.Region>();
            RegionOptions options = new RegionOptions();

            try
            {
                if (!string.IsNullOrEmpty(layout.Bgcolor))
                {
                    if (method == null)
                    {
                        method = new Action(() =>
                        {
                            this.MediaCanvas.Background = new SolidColorBrush((System.Windows.Media.Color)System.Windows.Media.ColorConverter.ConvertFromString(layout.Bgcolor));
                        });
                    }
                    base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, method);
                    options.backgroundColor = layout.Bgcolor;
                }
            }
            catch
            {
                if (start2 == null)
                {
                    start2 = new Action(() =>
                    {
                        this.MediaCanvas.Background = new SolidColorBrush(Colors.Black);
                    });
                }
                base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, start2);
                options.backgroundColor = "#000000";
            }
            try
            {
                if (layout.Background == null)
                {
                    this.MediaCanvas.Background = null;
                    options.backgroundImage     = "";
                }
                else
                {
                    string bgFilePath = string.Concat(new object[] { Settings.Default.LibraryPath, @"\backgrounds\", width, "x", height, "_", layout.Background });
                    Utilities.CreateFolder(Path.GetDirectoryName(bgFilePath));
                    if (!File.Exists(bgFilePath))
                    {
                        System.Drawing.Image original   = System.Drawing.Image.FromFile(Settings.Default.LibraryPath + @"\" + layout.Background);
                        Bitmap            bitmap        = new Bitmap(original, width, height);
                        EncoderParameters encoderParams = new EncoderParameters(1);
                        EncoderParameter  parameter     = new EncoderParameter(Encoder.Quality, 90L);
                        encoderParams.Param[0] = parameter;
                        ImageCodecInfo encoderInfo = GetEncoderInfo("image/jpeg");
                        bitmap.Save(bgFilePath, encoderInfo, encoderParams);
                        original.Dispose();
                        bitmap.Dispose();
                    }
                    base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(() =>
                    {
                        this.MediaCanvas.Background = new ImageBrush(new BitmapImage(new Uri(bgFilePath.Replace(@"\", "/"), UriKind.Relative)));
                    }));
                    options.backgroundImage = bgFilePath;
                }
            }
            catch (Exception)
            {
                if (start3 == null)
                {
                    start3 = new Action(() =>
                    {
                        this.MediaCanvas.Background = System.Windows.Media.Brushes.Black;
                    });
                }
                base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, start3);
                options.backgroundImage = "";
            }
            App.DoEvents();
            List <LayoutRegion> regions            = layout.Regions;
            List <List <LayoutRegionMedia> > list2 = (from r in layout.Regions select r.Media).ToList <List <LayoutRegionMedia> >();

            if ((regions.Count == 0) || (list2.Count == 0))
            {
                Trace.WriteLine(new LogMessage("PrepareLayout", string.Format("A layout with {0} regions and {1} media has been detected.", regions.Count.ToString(), list2.Count.ToString())), LogType.Info.ToString());
                if (ClientManager.Instance.Schedule.ActiveLayouts == 1)
                {
                    Trace.WriteLine(new LogMessage("PrepareLayout", "Only 1 layout scheduled and it has nothing to show."), LogType.Info.ToString());
                    throw new Exception("Only 1 layout schduled and it has nothing to show");
                }
                Trace.WriteLine(new LogMessage("PrepareLayout", string.Format(string.Format("An empty layout detected, will show for {0} seconds.", Settings.Default.emptyLayoutDuration.ToString()), new object[0])), LogType.Info.ToString());
                List <LayoutRegion> list3  = new List <LayoutRegion>();
                LayoutRegion        region = new LayoutRegion
                {
                    Id     = "blah",
                    Width  = 1,
                    Height = 1,
                    Top    = 1,
                    Left   = 1
                };
                List <LayoutRegionMedia> list4 = new List <LayoutRegionMedia>();
                LayoutRegionMedia        media = new LayoutRegionMedia
                {
                    Id       = "blah",
                    Type     = "Text",
                    Duration = 0
                };
                LayoutRegionMediaRaw raw = new LayoutRegionMediaRaw
                {
                    Text = ""
                };
                media.Raw = raw;
                list4.Add(media);
                region.Media = list4;
                list3.Add(region);
                regions = list3;
            }
            else
            {// Keep Running region, preventing visual blank out;
                regions.Add(
                    new LayoutRegion()
                {
                    Height = 0, Width = 0, Name = "Keep Alive Region", Media = new List <LayoutRegionMedia>()
                    {
                        new LayoutRegionMedia()
                        {
                            Duration = (int)TimeSpan.FromDays(10).TotalMilliseconds,
                            Type     = "KeepAlive"
                        }
                    }
                });
            }

            foreach (LayoutRegion region2 in regions)
            {
                if (region2.Media.Count != 0)
                {
                    options.scheduleId = ClientManager.Instance.ScheduleId;
                    options.layoutId   = this._layoutId;
                    options.regionId   = region2.Id;
                    options.Width      = (int)((((double)(region2.Width + 14)) / this._layoutWidth) * this._clientSize.Width);
                    options.Height     = (int)((((double)(region2.Height + 14)) / this._layoutHeight) * this._clientSize.Height);
                    int left = region2.Left;
                    if (left < 0)
                    {
                        left = 0;
                    }
                    int top = region2.Top;
                    if (top < 0)
                    {
                        top = 0;
                    }
                    options.Left           = (int)((((double)left) / this._layoutWidth) * this._clientSize.Width);
                    options.Top            = (int)((((double)top) / this._layoutHeight) * this._clientSize.Height);
                    options.ScaleFactor    = this._scaleFactor;
                    options.BackgroundLeft = options.Left * -1;
                    options.BackgroundTop  = options.Top * -1;
                    options.mediaNodes     = region2.Media;
                    if (action == null)
                    {
                        action = delegate(RegionOptions opts)
                        {
                            Core.Region region = new ClientApp.Core.Region(ClientManager.Instance.StatLog, ClientManager.Instance.CacheManager);
                            region.DurationElapsedEvent += new ClientApp.Core.Region.DurationElapsedDelegate(this.TempDurationElapsedEvent);
                            if (opts.FileType != "Widget")
                            {
                                region.RegionOptions = opts;
                                this._regions.Add(region);
                                region.Opacity = 0.0;
                                this.MediaCanvas.Children.Add(region);
                                region.AnimateIn();
                            }
                            else if (!WidgetsFactory.Widgets.ContainsKey(opts.Name))
                            {
                                region.RegionOptions = opts;
                                region.Opacity       = 0.0;
                                this.MediaCanvas.Children.Add(region);
                                region.AnimateIn();
                            }
                        };
                    }
                    base.Dispatcher.BeginInvoke(DispatcherPriority.Normal, action, options);
                    App.DoEvents();
                }
            }
            regions = null;
            list2   = null;
        }
Пример #30
0
 public WebCef(RegionOptions options)
     : base(options)
 {
     this.regionId           = options.regionId;
     this.hasBackgroundColor = !string.IsNullOrEmpty(options.Dictionary.Get("backgroundColor", ""));
 }