Exemplo n.º 1
0
 private void Panel1_MouseUp(object sender, MouseEventArgs e)
 {
     if (e.Button == MouseButtons.Left)
     {
         _drawing = false;
         _selfPaintingRecord.Add(CommandType.DrawOpEnd, e.X, e.Y);
         SendData();
     }
 }
Exemplo n.º 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);
            }
        }