Ejemplo n.º 1
0
        public WebkitBrowserWindow Launch()
        {
            if (ExplanationModeMediator.Inst.WebkitOpen)
            {
                return(null);
            }

            try
            {
                var src = DataContext as Source;
                if (src != null)
                {
                    //var browser = new BrowserWindow(src.Text);
                    //browser.ShowDialog();

                    //System.Diagnostics.Process.Start(src.Text);

                    Utils.ReportMediaOpened(StEvent.SourceOpened, src.RichText.ArgPoint);

                    RaiseEvent(new RoutedEventArgs(SourceViewEvent));

                    var browser = WebkitBrowserWindow.Instance(src.Text, src.RichText.ArgPoint.Topic.Id);
                    browser.Show();
                    browser.Activate();
                    return(browser);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(null);
        }
Ejemplo n.º 2
0
        private void btnGoogle_Click_1(object sender, RoutedEventArgs e)
        {
            var ap      = DataContext as ArgPoint;
            var browser = WebkitBrowserWindow.Instance("http://google.com", ap.Topic.Id);

            browser.Show();
            browser.Activate();
        }
Ejemplo n.º 3
0
        public static WebkitBrowserWindow Instance(string url, int? topicId)
        {
            if (_inst == null)
                _inst = new WebkitBrowserWindow();

            _inst.Init(url, topicId);

            return _inst;
        }
        public static WebkitBrowserWindow Instance(string url, int?topicId)
        {
            if (_inst == null)
            {
                _inst = new WebkitBrowserWindow();
            }

            _inst.Init(url, topicId);

            return(_inst);
        }
Ejemplo n.º 5
0
        private void onWebViewerRequest(string Uri)
        {
            var ap = DataContext as ArgPoint;

            if (ap == null)
            {
                return;
            }

            var browser = WebkitBrowserWindow.Instance(Uri, ap.Topic.Id);

            browser.Show();
            browser.Activate();
        }
Ejemplo n.º 6
0
        private void btnInternalBrowser_Click_1(object sender, RoutedEventArgs e)
        {
            var d = DataContext as Discussion;

            if (d != null)
            {
                if (d.HtmlBackground != null)
                {
                    var browser = WebkitBrowserWindow.Instance(getDiscussionBackgroundUrl(d), 0);//0 TopicId for background
                    browser.Show();
                    browser.Activate();
                }
            }
        }
Ejemplo n.º 7
0
        void hyperLink_Click(object sender, RoutedEventArgs e)
        {
            if (ExplanationModeMediator.Inst.WebkitOpen)
            {
                return;
            }

            var link    = (Hyperlink)sender;
            var c       = DataContext as Comment;
            var browser = WebkitBrowserWindow.Instance(link.NavigateUri.ToString(), c != null ? c.ArgPoint.Topic.Id : (int?)null);

            browser.Show();
            browser.Activate();
            e.Handled = true;
        }
        public static void EnsureInstanceDeinited()
        {
            if (_inst == null)
            {
                return; //already closed
            }
            try
            {
                _inst.Deinit();
            }
            catch
            {
            }

            _inst = null;
        }
Ejemplo n.º 9
0
        //message from remote client
        private void __sourceView(ExplanationModeSyncMsg sm)
        {
            if (!ExplanationModeMediator.Inst.ExplanationModeEnabled)
            {
                return;
            }

            if (sm.doExpand)
            {
                switch (sm.syncMsgType)
                {
                case SyncMsgType.SourceView:
                    var src     = PublicBoardCtx.Get().Source.FirstOrDefault(s0 => s0.Id == sm.viewObjectId);
                    var browser = WebkitBrowserWindow.Instance(src.Text, CurrentTopic != null ? CurrentTopic.Id : (int?)null);
                    browser.Show();
                    browser.Activate();
                    break;

                case SyncMsgType.YoutubeView:
                    var attach   = PublicBoardCtx.Get().Attachment.FirstOrDefault(a0 => a0.Id == sm.viewObjectId);
                    var embedUrl = AttachmentToVideoConvertor.AttachToYtInfo(attach).EmbedUrl;
                    browser = WebkitBrowserWindow.Instance(embedUrl, CurrentTopic != null ? CurrentTopic.Id : (int?)null);
                    browser.Show();
                    browser.Activate();
                    break;

                case SyncMsgType.ImageView:
                    attach = PublicBoardCtx.Get().Attachment.FirstOrDefault(a0 => a0.Id == sm.viewObjectId);
                    if (attach != null && !ExplanationModeMediator.Inst.IsViewerOpened(attach.Id))
                    {
                        AttachmentManager.RunViewer(attach, false);
                    }
                    break;

                case SyncMsgType.PdfView:
                    attach = PublicBoardCtx.Get().Attachment.FirstOrDefault(a0 => a0.Id == sm.viewObjectId);
                    if (attach != null && !ExplanationModeMediator.Inst.IsViewerOpened(attach.Id))
                    {
                        AttachmentManager.RunViewer(attach, false);
                    }
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
            else
            {
                switch (sm.syncMsgType)
                {
                case SyncMsgType.SourceView:
                    WebkitBrowserWindow.EnsureInstanceDeinited();
                    break;

                case SyncMsgType.ImageView:
                    ExplanationModeMediator.Inst.EnsureInstanceClosed(sm.viewObjectId);
                    break;

                case SyncMsgType.YoutubeView:
                    WebkitBrowserWindow.EnsureInstanceDeinited();
                    break;

                case SyncMsgType.PdfView:
                    ReaderWindow2.EnsureInstanceClosed();
                    break;

                default:
                    throw new NotImplementedException();
                }
            }
        }
Ejemplo n.º 10
0
        void Init(string url, int? topicId)
        {
            _url = url;

            ExplanationModeMediator.Inst.WebkitOpen = true;

            //if (ExplanationModeMediator.Inst.ExplanationModeEnabled)
            //{
            //    WindowState = WindowState.Maximized;
            //}
            //else
            {
                WindowState = WindowState.Normal;
                Width = 1280;
                Height = 768;
            }

            // 
            // _webKitBrowser1
            // 
            if (_webKitBrowser1 == null)
            {
                _webKitBrowser1 = new WebKit.WebKitBrowser
                {
                    BackColor = System.Drawing.Color.White,
                    Location = new System.Drawing.Point(0, 0),
                    Margin = new System.Windows.Forms.Padding(0),
                    Name = "_webKitBrowser1",
                    TabIndex = 0
                };
                _webKitBrowser1.Navigated += _webKitBrowser1_Navigated;
                webkitHost.Child = _webKitBrowser1;
                _webKitBrowser1.ResumeLayout();
            }

            browserBar.Browser = _webKitBrowser1;
            browserBar.Window = this;

            browserBar.addressBar.Text = _url;
            _webKitBrowser1.Navigate(_url);
            // _webKitBrowser1.Navigate(@"file:///C:\Users\User\Documents\Visual Studio 2013\Projects\tds3\discussions\bin\x86\Debug\qwe.html");
            //string str = Reencoder.GetUrlContent("http://www.shinmai.co.jp/olympic/jouhou/shochi.htm");
            //var reencoded = Reencoder.ShiftJisToUtf8(str);
            //_webKitBrowser1.Document.CreateTextNode(reencoded);// aTextContent = reencoded;

            if (ExplanationModeMediator.Inst.ExplanationModeEnabled)
                DiscWindows.Get().HidePublic();

            ResizeMode = ResizeMode.NoResize;

            //if (_inst != null)
            //    EnsureInstanceDeinited(); //close previous instance
            _inst = this;

            _mediator = ExplanationModeMediator.Inst;

            if (topicId != null)
                _mediator.CurrentTopicId = topicId;

            if (_mediator.ExplanationModeEnabled)
                RequestScrollPosition();

            if (_scrollStateChecker==null)
            {
                _scrollStateChecker = new DispatcherTimer(DispatcherPriority.Background)
                {
                    Interval = new TimeSpan(200)
                };
            }
            _scrollStateChecker.Tick += _scrollStateChecker_Tick;
            _scrollStateChecker.Start();

            if (_overlayWnd==null)
                _overlayWnd = new BrowserOverlayWindow { Window = this };
            _overlayWnd.Show();

            SetListeners(true);
        }
Ejemplo n.º 11
0
        public static void EnsureInstanceDeinited()
        {
            if (_inst == null)
                return; //already closed 

            try
            {
                _inst.Deinit();
            }
            catch
            {
            }

            _inst = null;
        }
        void Init(string url, int?topicId)
        {
            _url = url;

            ExplanationModeMediator.Inst.WebkitOpen = true;

            //if (ExplanationModeMediator.Inst.ExplanationModeEnabled)
            //{
            //    WindowState = WindowState.Maximized;
            //}
            //else
            {
                WindowState = WindowState.Normal;
                Width       = 1280;
                Height      = 768;
            }

            //
            // _webKitBrowser1
            //
            if (_webKitBrowser1 == null)
            {
                _webKitBrowser1 = new WebKit.WebKitBrowser
                {
                    BackColor = System.Drawing.Color.White,
                    Location  = new System.Drawing.Point(0, 0),
                    Margin    = new System.Windows.Forms.Padding(0),
                    Name      = "_webKitBrowser1",
                    TabIndex  = 0
                };
                _webKitBrowser1.Navigated += _webKitBrowser1_Navigated;
                webkitHost.Child           = _webKitBrowser1;
                _webKitBrowser1.ResumeLayout();
            }

            browserBar.Browser = _webKitBrowser1;
            browserBar.Window  = this;

            browserBar.addressBar.Text = _url;
            _webKitBrowser1.Navigate(_url);
            // _webKitBrowser1.Navigate(@"file:///C:\Users\User\Documents\Visual Studio 2013\Projects\tds3\discussions\bin\x86\Debug\qwe.html");
            //string str = Reencoder.GetUrlContent("http://www.shinmai.co.jp/olympic/jouhou/shochi.htm");
            //var reencoded = Reencoder.ShiftJisToUtf8(str);
            //_webKitBrowser1.Document.CreateTextNode(reencoded);// aTextContent = reencoded;

            if (ExplanationModeMediator.Inst.ExplanationModeEnabled)
            {
                DiscWindows.Get().HidePublic();
            }

            ResizeMode = ResizeMode.NoResize;

            //if (_inst != null)
            //    EnsureInstanceDeinited(); //close previous instance
            _inst = this;

            _mediator = ExplanationModeMediator.Inst;

            if (topicId != null)
            {
                _mediator.CurrentTopicId = topicId;
            }

            if (_mediator.ExplanationModeEnabled)
            {
                RequestScrollPosition();
            }

            if (_scrollStateChecker == null)
            {
                _scrollStateChecker = new DispatcherTimer(DispatcherPriority.Background)
                {
                    Interval = new TimeSpan(200)
                };
            }
            _scrollStateChecker.Tick += _scrollStateChecker_Tick;
            _scrollStateChecker.Start();

            if (_overlayWnd == null)
            {
                _overlayWnd = new BrowserOverlayWindow {
                    Window = this
                }
            }
            ;
            _overlayWnd.Show();

            SetListeners(true);
        }

        void _webKitBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            _webKitBrowser1.Visible = true;
        }