private void buttonLayerAdjust_Click(object sender, EventArgs e)
        {
            ImageEditInfo selectPic = _imageEditManage.ImageGroup.SelectImage;

            if (selectPic == null)
            {
                return;
            }

            if (sender == buttonLayerTop)
            {
                _imageEditManage.LayerToTop(selectPic);
            }
            else if (sender == buttonLayerBottom)
            {
                _imageEditManage.LayerToBottom(selectPic);
            }
            else if (sender == buttonLayerUp)
            {
                _imageEditManage.LayerToUp(selectPic);
            }
            else if (sender == buttonLayerDown)
            {
                _imageEditManage.LayerToDown(selectPic);
            }
        }
        private void panelPrintArea_MouseDown(object sender, MouseEventArgs e)
        {
            _mouseActionOfPrintArea.MousePress           = true;
            _mouseActionOfPrintArea.LastMouseScreenPoint = panelPrintArea.PointToScreen(e.Location);

            if (_curSpliteDir == EN_LinePart.无)
            {
                _imageEditManage.OnMouseDown(sender, e);

                if (!_imageEditManage.ImageGroup.HasSelectImage)
                {
                    SetSelect(ENAreaType.打印区域);
                    ShowPrintAreaProperty();
                }
                else
                {
                    SetSelect(ENAreaType.图片);
                }
            }
            else
            {
                if (_imageEditManage.ImageGroup.HasSelectImage)
                {
                    if (DrawHelper.IsRotationAdjust(_curSpliteDir))
                    {
                        ImageEditInfo image = _imageEditManage.ImageGroup.SelectImage;
                        Point         pt    = image.GetRotationPoint(_curSpliteDir);

                        Point ptOfCenter = DrawHelper.RotationAt(pt, image.Location, image.RotateAngle, true);
                        _mouseActionOfPrintArea.RotationCenter = panelPrintArea.PointToScreen(ptOfCenter);
                    }
                }
            }
        }
        private void checkBoxShowImageTip_CheckedChanged(object sender, EventArgs e)
        {
            ImageEditInfo selectImage = _imageEditManage.ImageGroup.SelectImage;

            if (selectImage != null)
            {
                selectImage.ShowImageTip = checkBoxShowImageTip.Checked;
                panelPrintArea.Refresh();
            }
        }
        private void ShowImageProperty(ImageEditInfo image)
        {
            textBoxPicX.Text = image.Location.X.ToString();
            textBoxPicY.Text = image.Location.Y.ToString();

            textBoxPicWidth.Text         = image.DrawSize.Width.ToString();
            textBoxPicHieght.Text        = image.DrawSize.Height.ToString();
            checkBoxLockRate.Checked     = image.LockSizeRate;
            checkBoxShowImageTip.Checked = image.ShowImageTip;
        }
        private void panelPrintArea_MouseMove(object sender, MouseEventArgs e)
        {
            _imageEditManage.OnMouseMove(sender, e);

            Point ptToScreen = panelPrintArea.PointToScreen(e.Location);

            //调整所选图片大小
            if (_mouseActionOfPrintArea.MousePress &&
                _imageEditManage.ImageGroup.HasSelectImage &&
                _curSpliteDir != EN_LinePart.无)
            {
                ImageEditInfo selectImage = _imageEditManage.ImageGroup.SelectImage;
                if (_imageEditManage.AdjustImage(_curSpliteDir, selectImage, ptToScreen))
                {
                    if (selectImage.LockSizeRate && DrawHelper.IsSizeAdjust(_curSpliteDir))
                    {
                        if (_curSpliteDir == EN_LinePart.|| _curSpliteDir == EN_LinePart.)
                        {
                            selectImage.AdjustRateByHeight();
                        }
                        else
                        {
                            selectImage.AdjustRateByWidth();
                        }
                    }

                    ShowImageProperty(_imageEditManage.ImageGroup.SelectImage);
                    panelPrintArea.Refresh();
                }
                _mouseActionOfPrintArea.LastMouseScreenPoint = ptToScreen;
                return;
            }

            //移动 打印区域
            if (_mouseActionOfPrintArea.MousePress &&
                !_imageEditManage.ImageGroup.HasSelectImage)
            {
                int xSpan = ptToScreen.X - _mouseActionOfPrintArea.LastMouseScreenPoint.X;
                int ySpan = ptToScreen.Y - _mouseActionOfPrintArea.LastMouseScreenPoint.Y;

                panelPrintArea.Location = new Point(panelPrintArea.Location.X + xSpan, panelPrintArea.Location.Y + ySpan);
                panelPrintArea.Refresh();
                panelEditPaper.Refresh();

                ShowPrintAreaProperty();
            }

            if (!_mouseActionOfPrintArea.MousePress) //探测鼠标所在位置
            {
                SetSpliteOperation(e.Location);
            }

            _mouseActionOfPrintArea.LastMouseScreenPoint = ptToScreen;
        }
        private void menuShowInCenter_Click(object sender, EventArgs e)
        {
            ImageEditInfo image = _imageEditManage.ImageGroup.SelectImage;

            if (image == null)
            {
                Debug.Assert(false);
                return;
            }

            _imageEditManage.ShowInCenter(image);
            panelPrintArea.Refresh();
        }
        private void AddImageToEdit(ImageProperty imageInfo)
        {
            ImageEditInfo info = new ImageEditInfo()
            {
                ImageProperty = imageInfo
            };

            info.Location = new Point(100, 100);
            if (imageInfo.LockSizeRate)
            {
                info.AdjustRateByWidth();
            }

            _imageGroup.AddImage(info);
            _imageEditManage.ShowInCenter(info);
            panelPrintArea.Refresh();
        }
        //设置图片旋转点
        private void ToolStripMenuItemSetRotationBase_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;

            if (_imageEditManage.ImageGroup.HasSelectImage)
            {
                ImageEditInfo image = _imageEditManage.ImageGroup.SelectImage;
                if (menuItem.Tag.ToString() == "add")
                {
                    _imageEditManage.SetRotationBasePoint(image, _mouseActionOfPrintArea.LastMouseScreenPoint);
                }
                else if (menuItem.Tag.ToString() == "del")
                {
                    _imageEditManage.DelRotationBasePoint(image);
                }
                panelPrintArea.Refresh();
            }
        }
        private void toolStripMenuItemShowRate_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem menuItem = sender as ToolStripMenuItem;
            double            rate     = double.Parse(menuItem.Tag.ToString()) / 100;

            ImageEditInfo image = _imageEditManage.ImageGroup.SelectImage;

            if (image == null)
            {
                Debug.Assert(false);
                return;
            }

            _imageEditManage.AdjustSizeByRate(image, rate);
            if (!_imageEditManage.IsCanSee(image))
            {
                _imageEditManage.ShowInCenter(image);
            }
            panelPrintArea.Refresh();
        }
        private void buttonSetProperty_Click(object sender, EventArgs e)
        {
            try
            {
                switch (_selectAreaType)
                {
                case ENAreaType.图片:
                {
                    ImageEditInfo selectImage = _imageEditManage.ImageGroup.SelectImage;
                    if (selectImage != null)
                    {
                        Point point = new Point();
                        point.X = AppHelper.IntParse(textBoxPicX.Text);
                        point.Y = AppHelper.IntParse(textBoxPicY.Text);

                        Size size = new Size();
                        size.Width  = AppHelper.IntParse(textBoxPicWidth.Text);
                        size.Height = AppHelper.IntParse(textBoxPicHieght.Text);
                        selectImage.LockSizeRate = checkBoxLockRate.Checked;

                        selectImage.Location = point;
                        selectImage.DrawSize = size;
                        if (selectImage.LockSizeRate)
                        {
                            selectImage.AdjustRateByWidth();
                        }
                        panelPrintArea.Refresh();
                    }
                    break;
                }

                case ENAreaType.打印区域:
                {
                    Point point = new Point();
                    point.X = AppHelper.IntParse(textBoxPicX.Text);
                    point.Y = AppHelper.IntParse(textBoxPicY.Text);

                    Size size = new Size();
                    size.Width  = AppHelper.IntParse(textBoxPicWidth.Text);
                    size.Height = AppHelper.IntParse(textBoxPicHieght.Text);

                    panelPrintArea.Location = point;
                    panelPrintArea.Size     = size;
                    panelPrintArea.Refresh();
                    break;
                }

                case ENAreaType.纸张:
                {
                    //位置调整没意义 只调整大小
                    //Point point = new Point();
                    //point.X = AppHlper.IntParse(textBoxPicX.Text);
                    //point.Y = AppHlper.IntParse(textBoxPicY.Text);
                    //panelPrintArea.Location = point;

                    Size size = new Size();
                    size.Width  = AppHelper.IntParse(textBoxPicWidth.Text);
                    size.Height = AppHelper.IntParse(textBoxPicHieght.Text);

                    panelEditPaper.Size = size;
                    panelEditPaper.Refresh();
                    break;
                }
                }
            }

            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
 private void SelectImage_SizeChanged(ImageEditManage sender, ImageEditInfo image)
 {
     ShowImageProperty(image);
 }