Exemplo n.º 1
0
 public static ExplanationModeSyncMsg Read(Dictionary<byte, object> par)
 {
     var res = new ExplanationModeSyncMsg();
     res.syncMsgType = (SyncMsgType) (int) par[(byte) DiscussionParamKey.IntParameter1];
     res.viewObjectId = (int) par[(byte) DiscussionParamKey.IntParameter2];
     res.doExpand = (bool) par[(byte) DiscussionParamKey.BoolParameter1];
     return res;
 }
Exemplo n.º 2
0
        public static ExplanationModeSyncMsg Read(Dictionary <byte, object> par)
        {
            var res = new ExplanationModeSyncMsg();

            res.syncMsgType  = (SyncMsgType)(int)par[(byte)DiscussionParamKey.IntParameter1];
            res.viewObjectId = (int)par[(byte)DiscussionParamKey.IntParameter2];
            res.doExpand     = (bool)par[(byte)DiscussionParamKey.BoolParameter1];
            return(res);
        }
Exemplo n.º 3
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();
                }
            }
        }