Exemplo n.º 1
0
        /// <summary>
        /// Show Properties dialog. Return true if list is changed
        /// </summary>
        /// <param name="parent"></param>
        /// <returns></returns>
        public bool ShowPropertiesDialog(ImageDrawBox parent)
        {
            if (SelectionCount < 1)
            {
                return(false);
            }

            GraphicsProperties properties = GetProperties();
            PropertiesDialog   dlg        = new PropertiesDialog();

            dlg.Properties = properties;

            CommandChangeState c = new CommandChangeState(this);

            if (dlg.ShowDialog(parent) != DialogResult.OK)
            {
                return(false);
            }

            if (ApplyProperties(properties))
            {
                c.NewState(this);
                parent.AddCommandToHistory(c);
            }

            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Right mouse button is released
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(ImageDrawBox drawArea, MouseEventArgs e)
        {
            if (selectMode == SelectionMode.NetSelection)
            {
                // Remove old selection rectangle
                ControlPaint.DrawReversibleFrame(
                    drawArea.RectangleToScreen(DrawRectangle.GetNormalizedRectangle(startPoint, lastPoint)),
                    Color.Black,
                    FrameStyle.Dashed);

                //Point pointscroll = GetEventPointInArea(drawArea, e);
                // Make group selection
                //zhoujin - user zoomfactor
                //drawArea.GraphicsList.SelectInRectangle(
                //    DrawRectangle.GetNormalizedRectangle(new Point(startPoint.X + Math.Abs(drawArea.AutoScrollPosition.X), startPoint.Y + Math.Abs(drawArea.AutoScrollPosition.Y)),
                //                                        new Point(lastPoint.X + Math.Abs(drawArea.AutoScrollPosition.X), lastPoint.Y + Math.Abs(drawArea.AutoScrollPosition.Y))));
                double zoomFactor = drawArea.ZoomFactor;
                drawArea.GraphicsList.SelectInRectangle(
                    DrawRectangle.GetNormalizedRectangle(new Point(ConvertToZoomed(startPoint.X, zoomFactor), ConvertToZoomed(startPoint.Y, zoomFactor)),
                                                         new Point(ConvertToZoomed(lastPoint.X, zoomFactor), ConvertToZoomed(lastPoint.Y, zoomFactor))));

                selectMode = SelectionMode.None;
            }

            if (resizedObject != null)
            {
                // after resizing
                resizedObject.Normalize();
                resizedObject = null;
            }

            drawArea.Capture = false;
            drawArea.Refresh();
            drawArea.GraphicsList.Dirty = true;

            if (commandChangeState != null && wasMove)
            {
                // Keep state after moving/resizing and add command to history
                commandChangeState.NewState(drawArea.GraphicsList);
                drawArea.AddCommandToHistory(commandChangeState);
                commandChangeState = null;
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Left mouse is released.
        /// New object is created and resized.
        /// </summary>
        /// <param name="drawArea"></param>
        /// <param name="e"></param>
        public override void OnMouseUp(ImageDrawBox drawArea, MouseEventArgs e)
        {
            drawArea.GraphicsList[0].Normalize();
            drawArea.AddCommandToHistory(new CommandAdd(drawArea.GraphicsList[0]));
            drawArea.ActiveTool = ImageDrawBox.DrawToolType.Pointer;

            //TODO : 这部分代码需要整理
            //zhoujin: 如果是正在定标则删除图形,并弹出定标窗口
            if (drawArea.DrawMode == ImageDrawBox.DrawingMode.SetUnit)
            {
                DrawObject drawObj = drawArea.GraphicsList[0];
                //定标只支持用画直线的方式
                if (drawObj is DrawLine)
                {
                    DrawLine    drawLine    = drawObj as DrawLine;
                    double      pxLen       = CalcLenght(drawLine.StartPoint, drawLine.EndPoint);
                    SetUnitForm setUnitForm = new SetUnitForm(drawArea, pxLen);
                    setUnitForm.ShowDialog();
                    drawArea.GraphicsList.DeleteLastAddedObject();
                    drawArea.DrawMode = ImageDrawBox.DrawingMode.Measure;
                }
            }
            if (drawArea.DrawMode == ImageDrawBox.DrawingMode.SetROI)
            {
                DrawObject drawObj = drawArea.GraphicsList[0];
                //设置ROI只支持用矩形绘制
                if (drawObj is DrawRectangle)
                {
                    DrawRectangle drawRect = drawObj as DrawRectangle;
                    drawArea.SetROI(drawRect.GetBoundingBox());
                    drawArea.GraphicsList.DeleteLastAddedObject();
                    drawArea.DrawMode = ImageDrawBox.DrawingMode.Measure;
                }
            }

            drawArea.Capture = false;
            drawArea.Refresh();
            drawArea.GraphicsList.Dirty = true;
        }