Exemplo n.º 1
0
        public static WBLineStyle GetLineStyle(int color)
        {
            WBLineStyle linestyle = new WBLineStyle();
            switch (color)
            {
                case -1:
                    linestyle.Color = -1;
                    break;
                case -2:
                    linestyle.Color = -2;
                    break;
                case -3:
                    linestyle.Color = -3;
                    break;
                case -8:
                    linestyle.Color = -8;
                    break;
                case -9:
                    linestyle.Color = -9;
                    linestyle.Width = 8 * 10 / 12;
                    break;
                case -10:
                    linestyle.Color = -10;
                    linestyle.Width = 39 * 10 / 12;
                    break;
                default:
                    linestyle.Color = -10;
                    break;
            }

            return linestyle;
        }
Exemplo n.º 2
0
        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;
            }
        }