private void Sh_MouseDown(object sender, MouseButtonEventArgs e)
        {
            t_resizing = Resizing.IsResizing;

            t_handleMousePoint = new Point(e.GetPosition(t_container).X, e.GetPosition(t_container).Y);

            // the handle being pressed determines a virtual selection rectangle transformation so that all
            // handles can use same resizing code
            SelectionHandle sh = (SelectionHandle)sender;

            double left = SelectionLocationLeft;
            double top  = SelectionLocationTop;

            System.Windows.Point point0 = new Point(left, top);
            System.Windows.Point point1 = new Point(left + t_selection.Width, top);
            System.Windows.Point point2 = new Point(left + t_selection.Width, top + t_selection.Height);
            System.Windows.Point point3 = new Point(left, top + t_selection.Height);

            switch (sh.Order)
            {
            case 0:
                t_currentMatrix = 0;     // rotation 180 °

                t_transformedRectanglePoints[0] = Engine.Calc.Matrix.Dot(point2, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[1] = Engine.Calc.Matrix.Dot(point3, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[2] = Engine.Calc.Matrix.Dot(point0, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[3] = Engine.Calc.Matrix.Dot(point1, t_matrices[t_currentMatrix]);
                break;

            case 1:
                t_currentMatrix = 1;     // rotation 90 °

                t_transformedRectanglePoints[0] = Engine.Calc.Matrix.Dot(point3, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[1] = Engine.Calc.Matrix.Dot(point0, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[2] = Engine.Calc.Matrix.Dot(point1, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[3] = Engine.Calc.Matrix.Dot(point2, t_matrices[t_currentMatrix]);
                break;

            case 2:
                t_currentMatrix = 2;     // rotation 0 °

                t_transformedRectanglePoints[0] = Engine.Calc.Matrix.Dot(point0, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[1] = Engine.Calc.Matrix.Dot(point1, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[2] = Engine.Calc.Matrix.Dot(point2, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[3] = Engine.Calc.Matrix.Dot(point3, t_matrices[t_currentMatrix]);

                break;

            case 3:
                t_currentMatrix = 3;     // rotation 270 °

                t_transformedRectanglePoints[0] = Engine.Calc.Matrix.Dot(point1, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[1] = Engine.Calc.Matrix.Dot(point2, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[2] = Engine.Calc.Matrix.Dot(point3, t_matrices[t_currentMatrix]);
                t_transformedRectanglePoints[3] = Engine.Calc.Matrix.Dot(point0, t_matrices[t_currentMatrix]);
                break;
            }

            t_container.MouseMove += Sh_MouseMove;
        }
Esempio n. 2
0
        //  Resizing possibleResize;


        public ContainerBorder(ContainerCamera parentContainerCamera, int borderThickness, Resizing allowedResize, int textureColour)
        {
            this.parentContainerCamera = parentContainerCamera;
            spriteBack           = GraphicsManager.GetSpriteColour(textureColour);
            this.borderThickness = borderThickness;
            this.allowedResize   = allowedResize;

            name = "ContainerBorder";
            SetSize();
            parentContainerCamera.ToggleBorder(borderThickness);
        }
        void WhenTouchDownAndMouseLeftButtonDown(Point getPositionToThis)
        {
            DebugWriteLine("WhenTouchDownAndMouseLeftButtonDown(" + getPositionToThis + ")");
            if (cameraViewWindowModel == null)
            {
                return;
            }
            mouseLeftButtonDownPointToThis   = getPositionToThis;
            cameraViewWindowModel.IsDragging = false;
            CurrentDpi = Egs.DotNetUtility.Dpi.DpiFromHdcForTheEntireScreen;
            var scaledCursorPosition = CurrentDpi.GetScaledPosition(System.Windows.Forms.Cursor.Position);

            Resizing.OnMouseDownOrTouchOnWindow(scaledCursorPosition.X, scaledCursorPosition.Y);
            isBeingResizedByMouse = true;
        }
Esempio n. 4
0
        protected virtual void OnUpdating(IntPtr handle)
        {
            switch (_state)
            {
            case State.Moving:
                System.Diagnostics.Debug.WriteLine($"Moving");
                Moving?.Invoke(this, handle);
                break;

            case State.Resizing:
                System.Diagnostics.Debug.WriteLine($"Resizing");
                Resizing?.Invoke(this, handle);
                break;

            default: break;
            }
        }
Esempio n. 5
0
        public void OnResize(int width, int height)
        {
            if (_cairoSurface is not null)
            {
                var oldHeight = _cairoSurface.Height;
                var oldWidth  = _cairoSurface.Width;

                if (oldWidth == width &&
                    oldHeight == height)
                {
                    Services.Logger.LogWindowingSystemEvent("Having resize request, but size didn't change. Ignoring.");
                    return;
                }

                _cairoSurface.SetSize(width, height);
            }

            Resizing?.Invoke(width, height);
        }
Esempio n. 6
0
        public void ResizeViewport(Input input, Resizing possibleResize)
        {
            moveDifference += input.GetMousePosDifference();

            if (possibleResize == Resizing.WIDTH)
            {
                moveDifference.Y = 0;
            }
            else if (possibleResize == Resizing.HEIGHT)
            {
                moveDifference.X = 0;
            }

            worldViewport = new Viewport(tempWorldViewport.X, tempWorldViewport.Y, tempWorldViewport.Width + (int)moveDifference.X, tempWorldViewport.Height + (int)moveDifference.Y);

            ClampWorldViewport();

            UpdateWorldCameraViewport();
            refreshNextFrame = true;

            attemptingWidth  = worldViewport.Width;
            attemptingHeight = worldViewport.Height;
        }
Esempio n. 7
0
 protected void AddBorder(int borderThickness, Resizing resizableType, int textureColour)
 {
     containerBorder = new ContainerBorder(containerCamera, borderThickness, resizableType, textureColour);
     hasBorder       = true;
 }
 void Start()
 {
     // Get the reference to the script controlling the speed
     rotation = gameObject.GetComponent <Rotation>();
     resizing = gameObject.GetComponent <Resizing>();
 }
Esempio n. 9
0
        public override void RenderTo(Resizing.ImageState s)
        {
            if (string.IsNullOrEmpty(Text)) return;

            string finalText = Text;

            if (finalText.IndexOf('#') > -1) {
                Regex r = new Regex("\\#\\{([^}]+)\\}");
                finalText = r.Replace(finalText, delegate(Match m){
                    string val =  s.settings[m.Groups[1].Value];
                    if (val == null) return "";
                    else return val;
                });
            }

            SizeF naturalSize = SizeF.Empty;
            SizeF unrotatedSize = SizeF.Empty;
             RectangleF bounds = this.CalculateLayerCoordinates(s, delegate(double maxwidth, double maxheight) {
                 using (Font f= GetFont())
                 using (StringFormat sf = GetFormat()){
                    naturalSize = s.destGraphics.MeasureString(finalText, f, new PointF(), sf);
                     SizeF size = naturalSize;

                     unrotatedSize = Fill ? PolygonMath.ScaleInside(size, new SizeF((float)maxwidth, (float)maxheight)) : size;

                     if (Angle != 0) size = PolygonMath.GetBoundingBox(PolygonMath.RotatePoly(PolygonMath.ToPoly(new RectangleF(new PointF(0, 0), size)), Angle)).Size;
                     if (Fill) {
                         size = PolygonMath.ScaleInside(size, new SizeF((float)maxwidth, (float)maxheight));
                     }
                     f.FontFamily.Dispose();
                     return PolygonMath.RoundPoints(size);

                 }
             }, true);
             using (Font f = GetFont()) {

                 s.destGraphics.SmoothingMode = SmoothingMode.HighQuality;
                 s.destGraphics.TextRenderingHint = Rendering; // Utils.parseEnum<TextRenderingHint>(s.settings["watermark.rendering"], this.Rendering); ;
                 s.destGraphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
                 s.destGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
                 s.destGraphics.CompositingMode = CompositingMode.SourceOver;
                 s.destGraphics.CompositingQuality = CompositingQuality.HighQuality;

                 s.destGraphics.ResetTransform();
                 if (Angle != 0) s.destGraphics.RotateTransform((float)Angle);
                 s.destGraphics.ScaleTransform(unrotatedSize.Width / naturalSize.Width, unrotatedSize.Height / naturalSize.Height);
                 s.destGraphics.TranslateTransform(bounds.X, bounds.Y, MatrixOrder.Append);
                 using (StringFormat sf = GetFormat()) {
                     DrawString(s.destGraphics, finalText, f, new Point(0, 0), sf);
                 }
                 s.destGraphics.ResetTransform();

                 f.FontFamily.Dispose();
             }
        }
Esempio n. 10
0
        public override void RenderTo(Resizing.ImageState s)
        {
            if (string.IsNullOrEmpty(Path)) return;

            s.destGraphics.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
            s.destGraphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
            s.destGraphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;

            Bitmap img = null;
            if (this.ShouldLoadAsOriginalSize()) {
                img = GetMemCachedBitmap(Path, ImageQuery);
            }

            //Calculate the location for the bitmap
            RectangleF imgBounds = this.CalculateLayerCoordinates(s, delegate(double maxwidth, double maxheight) {
                ResizeSettings opts = new ResizeSettings(ImageQuery);
                if (Fill && string.IsNullOrEmpty(opts["scale"])) opts.Scale = ScaleMode.Both;
                if (!double.IsNaN(maxwidth)) opts.MaxWidth = (int)Math.Floor(maxwidth);
                if (!double.IsNaN(maxheight)) opts.MaxHeight = (int)Math.Floor(maxheight);

                if (img == null) img = GetMemCachedBitmap(Path, opts); //Delayed creation allows the maxwidth/maxheight to be used in gradient plugin
                lock (img) {
                    return ImageBuilder.Current.GetFinalSize(img.Size, opts);
                }
            }, true);

            lock (img) { //Only one reader from the cached bitmap at a time.
                //Skip rendering unless we have room to work with.
                if (imgBounds.Width <2 || imgBounds.Height < 2) return;

                if (ImageQuery.Keys.Count > 0 || Fill) {
                    ResizeSettings settings = new ResizeSettings(ImageQuery);
                    if (Fill && string.IsNullOrEmpty(settings["scale"])) settings.Scale = ScaleMode.Both;

                    settings.MaxWidth = (int)Math.Floor(imgBounds.Width);
                    settings.MaxHeight = (int)Math.Floor(imgBounds.Height);

                    using (Bitmap final = ImageBuilder.Current.Build(img, settings,false)) {
                        s.destGraphics.DrawImage(final, PolygonMath.ToRectangle(PolygonMath.CenterInside(PolygonMath.DownScaleInside(final.Size,imgBounds.Size), imgBounds)));
                    }
                } else {

                    s.destGraphics.DrawImage(img, PolygonMath.ToRectangle(PolygonMath.CenterInside(PolygonMath.DownScaleInside(img.Size,imgBounds.Size), imgBounds)));
                }

            }
        }
Esempio n. 11
0
 private void OnResizing()
 {
     Resizing?.Invoke(this, new EventArgs());
 }
Esempio n. 12
0
 protected virtual void OnResizing(ResizeEventArgs e)
 {
     Resizing?.Invoke(this, e);
 }
Esempio n. 13
0
 private void Sh_MouseUp(object sender, MouseButtonEventArgs e)
 {
     t_resizing             = Resizing.IsNot;
     t_container.MouseMove -= Sh_MouseMove;
 }
Esempio n. 14
0
        // -------------------------------------------------
        public RectangleGeneral (Rectangle rect, RectRange range, int rad, int half, Color color)   
        {
            rc = new Rectangle (rect .X, rect .Y, Math .Max (minsize, rect .Width), Math .Max (minsize, rect .Height));
            if (range == null)
            {
                wMin = wMax = rc .Width;
                hMin = hMax = rc .Height;
            }
            else
            {
                wMin = Math .Max (minsize, Math .Min (rc .Width, range .MinWidth));
                wMax = Math .Max (rc .Width, range .MaxWidth);
                hMin = Math .Max (minsize, Math .Min (rc .Height, range .MinHeight));
                hMax = Math .Max (rc .Height, range .MaxHeight);
            }
            RectRange realrange = new RectRange (wMin, wMax, hMin, hMax);
            resize = realrange .Resizing;

            radius = rad;
            halfstrip = half;
            brush = new SolidBrush (color);
        }
Esempio n. 15
0
 private void OnResizing(string filename)
 {
     Resizing?.Invoke(this, new ResizeEventArgs(filename));
 }