예제 #1
0
        private void ClearDraw()
        {
            drawingList       = new DShapeList();
            drawingListUndo   = new DShapeList();
            tempPoint         = new DShapeList();
            pointViewList     = new DShapeList();
            notchangeList     = new DShapeList();
            notchangeListUndo = new DShapeList();

            pointCollection = new ArrayList();

            regionCollection     = new NewRegion();
            regionCollectionUndo = new NewRegion();
            pointArray           = new PointArrayCollection();
            pointArrayUndo       = new PointArrayCollection();

            regionArrayCollection     = new NewRegionArray();
            regionArrayCollectionUndo = new NewRegionArray();
            drawImageType             = new TypeI();
            drawImageTypeUndo         = new TypeI();
            newType = ImageType.Empty;

            //picked = false;
            changed     = false;
            mouseMove   = false;
            eraser      = false;
            regionIndex = 0;

            this.pictureBox1.Invalidate();
        }
예제 #2
0
        private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
        {
            try
            {
                if (e.Button != MouseButtons.Left)
                {
                    return;
                }

                if (this.xtraTabControl1.SelectedTabPageIndex != 0)
                {
                    return;
                }

                newPoint = new MousePoint(e.X, e.Y);
                switch (newType)
                {
                case ImageType.Pick:
                    if (picked == true)
                    {
                        for (int k = 0; k < regionArrayCollection[regionIndex].Length; k++)
                        {
                            if (regionArrayCollection[regionIndex][k].IsVisible(newPoint.StartP))
                            {
                                pointIndex = k;
                                changed    = true;
                                break;
                            }
                            else
                            {
                                changed = false;
                            }
                        }
                        if (changed == true)
                        {
                            break;
                        }
                    }
                    int m = regionIndex;
                    if (picked == true)
                    {
                        m = (regionIndex + 1) % regionCollection.Count;                 //循环下一项开始
                    }
                    int n = 0;
                    for (; n < regionCollection.Count; n++)
                    {
                        if (m >= regionCollection.Count)
                        {
                            m = 0;
                        }
                        if (regionCollection[m++].IsVisible(newPoint.StartP))
                        {
                            pointViewList = new DShapeList();
                            regionIndex   = m - 1;
                            tempMovePoint = new Point[pointArray[regionIndex].Length];
                            for (int j = 0; j < pointArray[regionIndex].Length; j++)
                            {
                                tempMovePoint[j] = pointArray[regionIndex][j];
                            }
                            PointView(regionIndex);
                            this.pictureBox1.Invalidate();
                            picked = true;
                            if (drawImageType[regionIndex] == (int)ImageType.Path)
                            {
                                mousePath = drawingList[regionIndex].pathChange(mousePath, true);
                            }
                            changed = false;
                            break;
                        }
                        else
                        {
                            //pointViewList = new DShapeList();
                            //this.pictureBox1.Invalidate();
                            picked = false;
                        }
                    }
                    break;
                }
            }
            catch
            { }
        }
예제 #3
0
        private void pictureBox1_Paint(object sender, PaintEventArgs e)
        {
            try
            {
                if (this.xtraTabControl1.SelectedTabPageIndex != 0 && drawingList.Count == 0)
                {
                    return;
                }
                if (this.xtraTabControl1.SelectedTabPageIndex != 0 && drawingList.Count != 0)
                {
                    ClearDraw();
                    return;
                }
                Graphics displayGraphics = e.Graphics;
                if (drawingList.Count <= 0)
                {
                    int       width  = 100;
                    int       height = 60;
                    Rectangle rec;
                    if (rdbOverallSignRatio.Checked)
                    {
                        width  = ControlService.SignCombo.Current.Width * 2;
                        height = ControlService.SignCombo.Current.Height * 2;
                        if (width > pictureBox1.Width)
                        {
                            width  = pictureBox1.Width / 2;
                            height = width * ControlService.SignCombo.Current.Height / ControlService.SignCombo.Current.Width;
                        }
                    }
                    if (rdbOriginalPictureRatio.Checked)
                    {
                        width  = CurrentImage.Width / 2;
                        height = CurrentImage.Height / 2;
                        if (width > pictureBox1.Width)
                        {
                            width  = pictureBox1.Width / 2;
                            height = width * CurrentImage.Height / CurrentImage.Width;
                        }
                    }

                    rec = new Rectangle(0, 0, width, height);
                    DrawRectangle(displayGraphics, rec);

                    //int m = regionIndex;

                    //m = (regionIndex + 1) % regionCollection.Count;		//循环下一项开始
                    int n = 0;
                    for (; n < regionCollection.Count; n++)
                    {
                        //if (m >= regionCollection.Count)
                        //    m = 0;
                        //if (regionCollection[m++].IsVisible(newPoint.StartP))
                        //{
                        pointViewList = new DShapeList();
                        regionIndex   = 0;
                        tempMovePoint = new Point[pointArray[regionIndex].Length];
                        for (int j = 0; j < pointArray[regionIndex].Length; j++)
                        {
                            tempMovePoint[j] = pointArray[regionIndex][j];
                        }
                        PointView(regionIndex);
                        this.pictureBox1.Invalidate();
                        picked = true;
                        if (drawImageType[regionIndex] == (int)ImageType.Path)
                        {
                            mousePath = drawingList[regionIndex].pathChange(mousePath, true);
                        }
                        changed = false;
                        break;
                        //}
                        //else
                        //{
                        //    pointViewList = new DShapeList();
                        //    this.pictureBox1.Invalidate();
                        //    picked = false;
                        //}
                    }
                }
                switch (newType)
                {
                case ImageType.Rectangle:

                    break;

                case ImageType.Pick:
                    if (picked == true)
                    {
                        pointViewList.DrawList(displayGraphics);
                        if (changed == true && drawImageType[regionIndex] != (int)ImageType.Path)
                        {
                            if (drawImageType[regionIndex] == (int)ImageType.Rectangle)
                            {
                                displayGraphics.DrawRectangle(new Pen(newColor, lineWidth), tempChangePoint.Rect);
                            }
                        }
                    }
                    break;
                }
                drawingList.DrawList(displayGraphics);
                SetStatus();
            }
            catch { }
            //this.pictureBox1.Invalidate();
            //Graphics g = e.Graphics;
            //g.DrawImage(imageHandler.CurrentBitmap, new Rectangle(this.AutoScrollPosition.X, this.AutoScrollPosition.Y, Convert.ToInt32(imageHandler.CurrentBitmap.Width * zoomFactor), Convert.ToInt32(imageHandler.CurrentBitmap.Height * zoomFactor)));
        }