private void buttonSend_Click(object sender, EventArgs e) { this.buttonSend.Enabled = false; IList <byte[]> imageSlices = new List <byte[]>(); Bitmap bmp = new Bitmap(this._imageSource); double width = (double)bmp.Width / 5; double height = (double)bmp.Height / 5; for (int y = 0; y < 5; y++) { for (int x = 0; x < 5; x++) { Rectangle rect = new Rectangle(Convert.ToInt32(x * width), Convert.ToInt32(y * height), Convert.ToInt32(width), Convert.ToInt32(height)); byte[] data = BitmapToBytes(bmp.Clone(rect, PixelFormat.DontCare)); imageSlices.Add(data); } } IImageTransfer proxy = GetProxy(); proxy.Erase(); for (int i = 0; i < imageSlices.Count; i++) { proxy.Transfer(imageSlices[i]); } this.buttonSend.Enabled = true; }
private IImageTransfer GetProxy() { if (null != _nonReliableSessionProxy) { (_nonReliableSessionProxy as ICommunicationObject).Close(); } if (null != _reliableSessionProxy) { (_reliableSessionProxy as ICommunicationObject).Close(); } if (null != _orderedDeliveryProxy) { (_orderedDeliveryProxy as ICommunicationObject).Close(); } if (!this.checkBoxReliableSession.Checked) { _nonReliableSessionProxy = _nonReliableSessionFactory.CreateChannel(); (_nonReliableSessionProxy as ICommunicationObject).Open(); return(_nonReliableSessionProxy); } else if (!this.checkBoxOrdered.Checked) { _reliableSessionProxy = _reliableSessionFactory.CreateChannel(); (_reliableSessionProxy as ICommunicationObject).Open(); return(_reliableSessionProxy); } else { _orderedDeliveryProxy = _orderedDeliveryFactory.CreateChannel(); (_orderedDeliveryProxy as ICommunicationObject).Open(); return(_orderedDeliveryProxy); } }
private IImageTransfer GetProxy() { if(null != _nonReliableSessionProxy) { (_nonReliableSessionProxy as ICommunicationObject).Close(); } if(null != _reliableSessionProxy) { (_reliableSessionProxy as ICommunicationObject).Close(); } if(null != _orderedDeliveryProxy) { (_orderedDeliveryProxy as ICommunicationObject).Close(); } if (!this.checkBoxReliableSession.Checked) { _nonReliableSessionProxy = _nonReliableSessionFactory.CreateChannel(); (_nonReliableSessionProxy as ICommunicationObject).Open(); return _nonReliableSessionProxy; } else if (!this.checkBoxOrdered.Checked) { _reliableSessionProxy = _reliableSessionFactory.CreateChannel(); (_reliableSessionProxy as ICommunicationObject).Open(); return _reliableSessionProxy; } else { _orderedDeliveryProxy = _orderedDeliveryFactory.CreateChannel(); (_orderedDeliveryProxy as ICommunicationObject).Open(); return _orderedDeliveryProxy; } }