示例#1
0
        private void pnlImage_DragDrop(object sender, DragEventArgs e)
        {
            string[] drops = (string[])e.Data.GetData(DataFormats.FileDrop, false);
            if (drops != null && drops.Length > 0)
            {
                string fileName = Path.GetFileName(drops[0]);
                Image  img      = Bitmap.FromFile(drops[0]);
                if (img == null)
                {
                    return;
                }

                if (_canvas.IsCleared)
                {
                    SendComNewCanvas(img.Width, img.Height, img);
                }
                else
                {
                    Point cp = _canvas.PointToClient(new Point(e.X, e.Y));
                    if (_movedControl != null)
                    {
                        SendApplyPictureBox(_movedControl.UniqueID);
                        _movedControl.Dispose();
                        _movedControl = null;
                    }
                    _movedControl = CreateNewPictureBox(img, cp);
                }
            }
        }
示例#2
0
        public void Clear()
        {
            if (_isCleared)
            {
                return;
            }
            _isCleared = true;
            _needUpdateFrontPicture = true;

            _toRemovePB.Clear();
            _toApplyPB.Clear();

            PictureBoxObj[] pbs = _drawObjects.GetValues();
            for (int i = 0; i < pbs.Length; i++)
            {
                RemovePictureObj(pbs[i].UniqueID);
            }
            _drawObjects.Clear();
            this.Controls.Remove(_backPicture);
            this.Controls.Remove(_frontPicture);

            CanvasClearEvent?.Invoke(this, null);

            _backPicture.Dispose();
            _frontPicture.Dispose();
        }