예제 #1
0
        public void Add(CommandType type, float x, float y)
        {
            PaintCommand cmd = new PaintCommand();

            cmd.Type    = type;
            cmd.Coord.X = x;
            cmd.Coord.Y = y;
            _paintingCommands.Add(cmd);
        }
예제 #2
0
        void OnReceiveRtsData(string sessionId, int channelType, string uid, IntPtr data, int size)
        {
            if (_sessionId != sessionId)
            {
                return;
            }
            var content = Marshal.PtrToStringAnsi(data, size);

            System.Diagnostics.Debug.WriteLine(content);
            var lines = content.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
            var s     = _peerPaintingRecord.Count;

            foreach (var item in lines)
            {
                var cmd = PaintCommand.Create(item, panel1.Size);
                if (cmd == null || cmd.Type == CommandType.DrawOpPktId)
                {
                    continue;
                }
                _peerPaintingRecord.Add(cmd);
            }
            var c = _peerPaintingRecord.Count;

            if (c <= 0)
            {
                return;
            }
            CommandType lastCmdType = _peerPaintingRecord[c - 1].Type;

            if (lastCmdType == CommandType.DrawOpUndo)
            {
                _peerPaintingRecord.Revert();
                _peerDrawingGraphics.Clear(panel1.BackColor);
                _myDrawingGraphics.Clear(panel1.BackColor);
                DoDraw(_selfPaintingRecord, 0, _selfPaintingRecord.Count - 1, _myDrawingGraphics, _myPen);
                DoDraw(_peerPaintingRecord, 0, _peerPaintingRecord.Count - 1, _peerDrawingGraphics, _peerPen);
            }
            else if (lastCmdType == CommandType.DrawOpClear)
            {
                SendControlCommand(CommandType.DrawOpClearCb);
                ClearGraph();
            }
            else if (lastCmdType == CommandType.DrawOpClearCb)
            {
                ClearGraph();
            }
            else if (lastCmdType == CommandType.DrawOpStart || lastCmdType == CommandType.DrawOpMove || lastCmdType == CommandType.DrawOpEnd)
            {
                DoDraw(_peerPaintingRecord, s, _peerPaintingRecord.Count - 1, _peerDrawingGraphics, _peerPen);
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("unknow data type:{0}", content);
            }
        }
예제 #3
0
        public static PaintCommand Create(string cmdStr, Size size)
        {
            var c = cmdStr.Split(new char[] { ':', ',' });

            if (c.Length >= 3)
            {
                PaintCommand cmd = new PaintCommand();
                cmd.Type    = (CommandType)int.Parse(c[0]);
                cmd.Coord.X = float.Parse(c[1]) * size.Width;
                cmd.Coord.Y = float.Parse(c[2]) * size.Height;
                return(cmd);
            }
            return(null);
        }
예제 #4
0
 public void Add(PaintCommand cmd)
 {
     _paintingCommands.Add(cmd);
 }