public void UpdateTime(string group, string second) { int currenttime = Convert.ToInt32(second); List <SSImage> images = CourseApi.GetScreenshotData(currenttime); List <ScreenImage> list = new List <ScreenImage>(); // convert image from byte[] to base64 string. foreach (SSImage item in images) { if (item.Image == null) { continue; } list.Add(new ScreenImage { Row = item.Row, Col = item.Col, ImageStream = Convert.ToBase64String(item.Image) }); } JavaScriptSerializer jss = new JavaScriptSerializer(); Clients.Group(group).broadcastDrawScreenshot(jss.Serialize(list)); WBData wbData = CourseApi.GetWhiteboardData(currenttime); JavaScriptSerializer jss2 = new JavaScriptSerializer(); Clients.Group(group).broadcastDrawWhiteboard(jss2.Serialize(wbData)); }
void TimerWB_Elapsed(object sender, ElapsedEventArgs e) { InvokeOnMainThread(delegate { int second = Convert.ToInt32(sliderTimeline.Value); WBData wbData = CourseApi.GetWhiteboardData(second); canvasWB.WBData = wbData; canvasWB.CurrentSecond = second; canvasWB.SetNeedsDisplay(); }); }
public static WBData GetWhiteboardData(int second) { // get lines List <WBLine> lines = GetWBImageData(second); // get events List <WBEvent> events = GetWBSequenceData(second); // combine them to whiteboard data WBData wb = new WBData(second, lines, events); return(wb); }
private void DrawWhiteBoard(string group, int currenttime, bool forcerefresh, COLDataSource ds) { bool drawLines = true; int currentMin = Helper.GetMinute(currenttime * 1000); if (previousMin == currentMin && forcerefresh == false) { // Whiteboard data is based on minute, not second. // Only draw when in different minute, or user changed the slider manually. drawLines = false; } else { forcerefresh = false; previousMin = currentMin; currentEventTs = -1; } WBData wbdata = ds.GetWhiteBoardData(DataType.WB_1, currenttime); if (wbdata == null) { return; } if (drawLines && wbdata.WBLines != null && wbdata.WBLines.Count > 0) { //JavaScriptSerializer jss = new JavaScriptSerializer(); //List<BoardLine> list = new List<BoardLine>(); foreach (WBLine line in wbdata.WBLines) { WBLineStyle linestyle = Helper.GetLineStyle(line.UColor); Clients.Group(group).broadcastDrawWBLine(linestyle.Color, linestyle.Width, line.X0, line.Y0, line.X1, line.Y1); //list.Add(new BoardLine { Color = linestyle.Color, Width = linestyle.Width, X0 = line.X0, Y0 = line.Y0, X1 = line.X1, Y1 = line.Y1 }); } Clients.Group(group).broadcastDrawWBLineFinished(); //Clients.All.broadcastDrawWBLine(jss.Serialize(list)); } if (wbdata.WBEvents != null && wbdata.WBEvents.Count > 0) { Hashtable htgroup = GroupWBEventsBySecond(wbdata.WBEvents); int endMilliseconds = currenttime * 1000 % 60000; int ix; //JavaScriptSerializer jss = new JavaScriptSerializer(); //List<BoardLine> list = new List<BoardLine>(); for (ix = currentEventTs; ix <= endMilliseconds; ix++) { List <WBEvent> wbevents = htgroup[(uint)ix] as List <WBEvent>; if (wbevents == null) { continue; } foreach (WBEvent wbevent in wbevents) { if (wbevent.X >= 0) { if (lastPoint == null) { lastPoint = wbevent; } else { //currentLineStyle.Color.SetStroke(); //gctx.SetLineWidth(currentLineStyle.Width); //gctx.MoveTo(lastPoint.X * xRate, lastPoint.Y * yRate); //gctx.AddLineToPoint(wbevent.X * xRate, wbevent.Y * yRate); //gctx.StrokePath(); Clients.Group(group).broadcastDrawWBEvent(currentLineStyle.Color, currentLineStyle.Width, lastPoint.X, lastPoint.Y, wbevent.X, wbevent.Y); //list.Add(new BoardLine { Color = currentLineStyle.Color, Width = currentLineStyle.Width, X0 = lastPoint.X, Y0 = lastPoint.Y, X1 = wbevent.X, Y1 = wbevent.Y }); lastPoint = wbevent; } } else { switch (wbevent.X) { case -100: //Pen Up currentLineStyle.Color = -8; lastPoint = null; break; case -200: //Clear event //gctx.ClearRect(rect); Clients.Group(group).broadcastClearReat(); lastPoint = null; break; default: currentLineStyle = Helper.GetLineStyle(wbevent.X); break; } lastPoint = null; } } } Clients.Group(group).broadcastDrawWBEventFinished(); // Clients.All.broadcastDrawWBEvent(jss.Serialize(list)); currentEventTs = ix; } }