Example #1
0
        public static void Draw(DrawObject drawObj)
        {
            EllipseObject ellipse = drawObj as EllipseObject;

            if (ellipse == null || ellipse.Picture == null)
            {
                return;
            }

            ellipse.Picture.Width    = ellipse.SizeX;
            ellipse.Picture.Height   = ellipse.SizeY;
            ellipse.Picture.Location = new Point(ellipse.LocationX, ellipse.LocationY);

            Bitmap bm = new Bitmap(ellipse.SizeX <= 0 ? 1 : ellipse.SizeX, ellipse.SizeY <= 0 ? 1 : ellipse.SizeY);

            using (Graphics gr = Graphics.FromImage(bm)){
                gr.FillRectangle(new SolidBrush(Color.Transparent), new Rectangle(0, 0, bm.Width, bm.Height));

                if ((PictureBoxStatus.IsDrawable & ellipse.Picture.Status) == PictureBoxStatus.IsDrawable)
                {
                    using (Pen pen = new Pen(new SolidBrush(ellipse.BrushColor), ellipse.BrushSize))
                    {
                        gr.DrawEllipse(pen, new Rectangle(ellipse.BrushSize / 2, ellipse.BrushSize / 2, ellipse.SizeX - ellipse.BrushSize, ellipse.SizeY - ellipse.BrushSize));
                    }
                }
            }
            ellipse.Picture.Image = bm;
        }
Example #2
0
        public bool UnPack(byte[] pack)
        {
            if (pack == null || pack.Length < 48)
            {
                return(false);
            }
            int ptr = 8;

            CliendID     = BytePacketReader.ReadLong(pack, ref ptr);
            PictureBoxID = BytePacketReader.ReadLong(pack, ref ptr);

            Rect = new EllipseObject();
            byte cR = BytePacketReader.ReadByte(pack, ref ptr);
            byte cG = BytePacketReader.ReadByte(pack, ref ptr);
            byte cB = BytePacketReader.ReadByte(pack, ref ptr);
            byte cA = BytePacketReader.ReadByte(pack, ref ptr);

            Rect.BrushColor = Color.FromArgb(cA, cR, cG, cB);

            Rect.BrushSize = BytePacketReader.ReadInt(pack, ref ptr);
            Rect.LocationX = BytePacketReader.ReadInt(pack, ref ptr);
            Rect.LocationY = BytePacketReader.ReadInt(pack, ref ptr);
            Rect.SizeX     = BytePacketReader.ReadInt(pack, ref ptr);
            Rect.SizeY     = BytePacketReader.ReadInt(pack, ref ptr);
            return(true);
        }
Example #3
0
        private void NCDrawByEllipse(IConnector connection, ArgEllipseObject arg)
        {
            if (arg == null || arg.PictureBoxID == 0)
            {
                return;
            }
            EllipseObject ellipse = arg.Rect;

            ellipse.Picture = _canvas.GetEditablePictureBox(arg.PictureBoxID);
            _canvas.AddDrawObject(arg.PictureBoxID, ellipse);
        }
Example #4
0
        public ArgEllipseObject(long clientID, long pictureID, EllipseObject rect)
        {
            if (rect == null)
            {
                throw new ArgumentNullException("ellipse is null");
            }

            CliendID     = clientID;
            PictureBoxID = pictureID;

            Rect = rect;
        }
Example #5
0
        public DrawObject GetDrawObject(int pX, int pY)
        {
            EllipseObject ellipse = new EllipseObject();

            ellipse.Picture    = _picture;
            ellipse.BrushColor = _color;
            ellipse.BrushSize  = _brushSize;

            ellipse.SizeX = Math.Abs(pX - _startX);
            ellipse.SizeY = Math.Abs(pY - _startY);

            ellipse.LocationX = pX < _startX ? pX : _startX;
            ellipse.LocationY = pY < _startY ? pY : _startY;
            return(ellipse);
        }
Example #6
0
        private void SendDrawObject(DrawObject drObj)
        {
            if (drObj == null || drObj.Picture == null)
            {
                return;
            }

            long        picBoxID = drObj.Picture.UniqueID; //canvas
            ICommandArg arg      = null;

            if (drObj is BrushLineObject)
            {
                BrushLineObject line = drObj as BrushLineObject;
                arg = new ArgBrushObject(_netClient.ClientID, picBoxID, line);
            }
            else if (drObj is LineObject)
            {
                LineObject line = drObj as LineObject;
                arg = new ArgLineObject(_netClient.ClientID, picBoxID, line);
            }
            else if (drObj is RectObject)
            {
                RectObject rect = drObj as RectObject;
                arg = new ArgRectObject(_netClient.ClientID, picBoxID, rect);
            }
            else if (drObj is EllipseObject)
            {
                EllipseObject ellipse = drObj as EllipseObject;
                arg = new ArgEllipseObject(_netClient.ClientID, picBoxID, ellipse);
            }
            else if (drObj is MoveObject)
            {
                MoveObject move = drObj as MoveObject;
                arg = new ArgMoveObject(_netClient.ClientID, picBoxID, move);
            }
            else if (drObj is SelectorObject)
            {
                SelectorObject selector = drObj as SelectorObject;
                arg = new ArgSelectorCopyObject(_netClient.ClientID, picBoxID, selector);
            }

            if (arg != null && _netClient.Connector != null)
            {
                _netClient.Connector.SendCommand(arg);
            }
        }
Example #7
0
        private void NCDrawByEllipse(IConnector connection, ArgEllipseObject arg)
        {
            if (arg.PictureBoxID == 0)
            {
                return;
            }
            long assocID = GetPictureBoxAssociationID(arg.PictureBoxID);

            if (assocID == 0)
            {
                return;
            }

            arg.PictureBoxID = assocID;
            EllipseObject ellipse = arg.Rect;

            ellipse.Picture = _canvas.GetEditablePictureBox(arg.PictureBoxID);
            _canvas.AddDrawObject(arg.PictureBoxID, ellipse);
            AddCommandToSendClients(arg);
        }