コード例 #1
0
ファイル: ShapeManager.cs プロジェクト: itneste/ShareX
        private void AutoCropImage()
        {
            Rectangle source = new Rectangle(0, 0, Form.Canvas.Width, Form.Canvas.Height);
            Rectangle rect   = ImageHelpers.FindAutoCropRectangle((Bitmap)Form.Canvas);

            if (source != rect && rect.X >= 0 && rect.Y >= 0 && rect.Width > 0 && rect.Height > 0)
            {
                CurrentTool = ShapeType.ToolCrop;
                CropTool tool = (CropTool)CreateShape(ShapeType.ToolCrop);
                tool.Rectangle = rect.LocationOffset(Form.CanvasRectangle.Location);
                tool.OnCreated();
                AddShape(tool);
                SelectCurrentShape();
            }
        }
コード例 #2
0
ファイル: ShapeManager.cs プロジェクト: itneste/ShareX
        private BaseShape CreateShape(ShapeType shapeType)
        {
            BaseShape shape;

            switch (shapeType)
            {
            default:
            case ShapeType.RegionRectangle:
                shape = new RectangleRegionShape();
                break;

            case ShapeType.RegionEllipse:
                shape = new EllipseRegionShape();
                break;

            case ShapeType.RegionFreehand:
                shape = new FreehandRegionShape();
                break;

            case ShapeType.DrawingRectangle:
                shape = new RectangleDrawingShape();
                break;

            case ShapeType.DrawingEllipse:
                shape = new EllipseDrawingShape();
                break;

            case ShapeType.DrawingFreehand:
                shape = new FreehandDrawingShape();
                break;

            case ShapeType.DrawingLine:
                shape = new LineDrawingShape();
                break;

            case ShapeType.DrawingArrow:
                shape = new ArrowDrawingShape();
                break;

            case ShapeType.DrawingTextOutline:
                shape = new TextOutlineDrawingShape();
                break;

            case ShapeType.DrawingTextBackground:
                shape = new TextDrawingShape();
                break;

            case ShapeType.DrawingSpeechBalloon:
                shape = new SpeechBalloonDrawingShape();
                break;

            case ShapeType.DrawingStep:
                shape = new StepDrawingShape();
                break;

            case ShapeType.DrawingImage:
                shape = new ImageDrawingShape();
                break;

            case ShapeType.DrawingImageScreen:
                shape = new ImageScreenDrawingShape();
                break;

            case ShapeType.DrawingCursor:
                shape = new CursorDrawingShape();
                break;

            case ShapeType.EffectBlur:
                shape = new BlurEffectShape();
                break;

            case ShapeType.EffectPixelate:
                shape = new PixelateEffectShape();
                break;

            case ShapeType.EffectHighlight:
                shape = new HighlightEffectShape();
                break;

            case ShapeType.ToolCrop:
                shape = new CropTool();
                break;
            }

            shape.Manager = this;

            shape.OnConfigLoad();

            return(shape);
        }