~dangarner/xibo/client-170alpha

« back to all changes in this revision

Viewing changes to client/dotNET/Media/CefWebMedia.cs

  • Committer: Dan Garner
  • Date: 2014-09-01 13:33:50 UTC
  • Revision ID: dan@xibo.org.uk-20140901133350-a6fy2jnrsohnoazo
[dotnetclient] Dedicated media class for powerpoint. Background setting on CefWebMedia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
7
7
using System.Text;
8
8
using System.Text.RegularExpressions;
9
9
using System.Windows.Forms;
 
10
using XiboClient.Control;
10
11
using Xilium.CefGlue;
11
12
using Xilium.CefGlue.WindowsForms;
12
13
 
15
16
    class CefWebMedia : Media
16
17
    {
17
18
        private bool _disposed = false;
 
19
        private bool _startWhenReady = false;
18
20
        private string _filePath;
19
21
        private RegionOptions _options;
20
22
        private TemporaryFile _temporaryFile;
33
35
            // We will need a temporary file to store this HTML
34
36
            _temporaryFile = new TemporaryFile();
35
37
 
 
38
            Color backgroundColor = ColorTranslator.FromHtml(_options.backgroundColor);
 
39
 
 
40
            CefBrowserSettings settings = new CefBrowserSettings();
 
41
            settings.BackgroundColor = new CefColor(backgroundColor.A, backgroundColor.R, backgroundColor.G, backgroundColor.B);
 
42
 
36
43
            // Create the web view we will use
37
44
            _webView = new CefWebBrowser();
 
45
            _webView.BrowserSettings = settings;
38
46
            _webView.Dock = DockStyle.Fill;
39
47
            _webView.BrowserCreated += _webView_BrowserCreated;
40
48
            _webView.LoadEnd += _webView_LoadEnd;
41
49
            _webView.Size = Size;
42
50
 
 
51
            // Check to see if the HTML is ready for us.
 
52
            if (HtmlReady())
 
53
            {
 
54
                // Write to temporary file
 
55
                SaveToTemporaryFile();
 
56
 
 
57
                _startWhenReady = true;
 
58
            }
 
59
            else
 
60
            {
 
61
                RefreshFromXmds();
 
62
            }
 
63
 
43
64
            // We need to come up with a way of setting this control to Visible = false here and still kicking
44
65
            // off the webbrowser.
45
66
            // I think we can do this by hacking some bits into the Cef.WinForms dll.
52
73
            
53
74
            //_webView.Visible = false;
54
75
 
55
 
            
56
76
            Controls.Add(_webView);
57
77
 
58
78
            // Show the control
64
84
            if (_disposed)
65
85
                return;
66
86
 
67
 
            // Check to see if the HTML is ready for us.
68
 
            if (HtmlReady())
69
 
            {                
70
 
                // Write to temporary file
71
 
                SaveToTemporaryFile();
72
 
 
 
87
            if (_startWhenReady)
73
88
                // Navigate to temp file
74
89
                _webView.Browser.GetMainFrame().LoadUrl(_temporaryFile.Path);
75
 
            }
76
 
            else
77
 
            {
78
 
                RefreshFromXmds();
79
 
            }
80
90
        }
81
91
 
82
92
        void _webView_LoadEnd(object sender, LoadEndEventArgs e)
84
94
            if (_disposed)
85
95
                return;
86
96
 
87
 
            _webView.Visible = true;
88
 
 
89
97
            // Start the timer
90
98
            base.StartTimer();
91
99
        }