public static void Draw(DrawObject drawObj) { RectObject rect = drawObj as RectObject; if (rect == null || rect.Picture == null) { return; } rect.Picture.Width = rect.SizeX; rect.Picture.Height = rect.SizeY; rect.Picture.Location = new Point(rect.LocationX, rect.LocationY); Bitmap bm = new Bitmap(rect.SizeX <= 0 ? 1 : rect.SizeX, rect.SizeY <= 0 ? 1 : rect.SizeY); using (Graphics gr = Graphics.FromImage(bm)){ gr.FillRectangle(new SolidBrush(Color.Transparent), new Rectangle(0, 0, bm.Width, bm.Height)); if ((PictureBoxStatus.IsDrawable & rect.Picture.Status) == PictureBoxStatus.IsDrawable) { using (Pen pen = new Pen(new SolidBrush(rect.BrushColor), rect.BrushSize)) { gr.DrawRectangle(pen, new Rectangle(rect.BrushSize / 2, rect.BrushSize / 2, rect.SizeX - rect.BrushSize, rect.SizeY - rect.BrushSize)); } } } rect.Picture.Image = bm; }
public bool UnPack(byte[] pack) { if (pack == null || pack.Length < 48) { return(false); } int ptr = 8; ClientID = BytePacketReader.ReadLong(pack, ref ptr); PictureBoxID = BytePacketReader.ReadLong(pack, ref ptr); Rect = new RectObject(); 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); }
private void NCDrawByRect(IConnector connection, ArgRectObject arg) { if (arg == null || arg.PictureBoxID == 0) { return; } RectObject rect = arg.Rect; rect.Picture = _canvas.GetEditablePictureBox(arg.PictureBoxID); _canvas.AddDrawObject(arg.PictureBoxID, rect); }
public ArgRectObject(long clientID, long pictureID, RectObject rect) { if (rect == null) { throw new ArgumentNullException("rect is null"); } ClientID = clientID; PictureBoxID = pictureID; Rect = rect; }
public DrawObject GetDrawObject(int pX, int pY) { RectObject rect = new RectObject(); rect.Picture = _picture; rect.BrushColor = _color; rect.BrushSize = _brushSize; rect.SizeX = Math.Abs(pX - _startX); rect.SizeY = Math.Abs(pY - _startY); rect.LocationX = pX < _startX ? pX : _startX; rect.LocationY = pY < _startY ? pY : _startY; return(rect); }
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); } }
private void NCDrawByRect(IConnector connection, ArgRectObject arg) { if (arg.PictureBoxID == 0) { return; } long assocID = GetPictureBoxAssociationID(arg.PictureBoxID); if (assocID == 0) { return; } arg.PictureBoxID = assocID; RectObject rect = arg.Rect; rect.Picture = _canvas.GetEditablePictureBox(arg.PictureBoxID); _canvas.AddDrawObject(arg.PictureBoxID, rect); AddCommandToSendClients(arg); }