Exemple #1
0
        private void AppendOverlay()
        {
            List <OverlayBase> horizontalGuides = new List <OverlayBase>(this.overlays.Where(o => o is Guide && (o as Guide).Orienation == Orienation.Horizontal));

            if (this.overlay is Guide && (this.overlay as Guide).Orienation == Orienation.Horizontal)
            {
                horizontalGuides.Add(this.overlay);
            }

            List <OverlayBase> verticalGuides = new List <OverlayBase>(this.overlays.Where(o => o is Guide && (o as Guide).Orienation == Orienation.Vertical));

            if (this.overlay is Guide && (this.overlay as Guide).Orienation == Orienation.Vertical)
            {
                verticalGuides.Add(this.overlay);
            }

            List <OverlayBase> images = new List <OverlayBase>(this.overlays.Where(o => o is Image));

            if (this.overlay is Image)
            {
                images.Add(this.overlay);
            }

            List <OverlayBase> result = new List <OverlayBase>();

            result.AddRange(horizontalGuides);
            result.AddRange(verticalGuides);
            result.AddRange(images);
            this.overlays = result;
            this.overlay  = null;
        }
Exemple #2
0
        private bool IsHovered(OverlayBase overlay)
        {
            if (overlay is Guide)
            {
                if ((overlay as Guide).Orienation == Orienation.Horizontal && (overlay as Guide).Position >= this.mouseY - PxperWnd.precision && (overlay as Guide).Position <= this.mouseY + PxperWnd.precision)
                {
                    return(true);
                }

                if ((overlay as Guide).Orienation == Orienation.Vertical && (overlay as Guide).Position >= this.mouseX - PxperWnd.precision && (overlay as Guide).Position <= this.mouseX + PxperWnd.precision)
                {
                    return(true);
                }
            }

            else if (overlay is Image)
            {
                if (new Rectangle((overlay as Image).Position, (overlay as Image).Normal.Size).Contains(this.mouseX, this.mouseY))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #3
0
        private void hookManager_MouseMove(object sender, MouseEventArgs e)
        {
            this.mouseX = (int)(e.X / DisplayScale.Value);
            this.mouseY = (int)(e.Y / DisplayScale.Value);

            if (this.activeControl == Control.Grip && this.mouseButtonPressed)
            {
                int xDelta = this.mouseX - this.startX;
                int yDelta = this.mouseY - this.startY;

                this.toolbarWnd.Location = new Point(this.toolbarWndX + xDelta, this.toolbarWndY + yDelta);
                return;
            }

            if (this.overlay != null && this.mouseButtonPressed)
            {
                this.MoveOverlay(this.overlay);
                this.RequestInvalidate();
                return;
            }

            if (this.mode1Tool == Tool.Measure)
            {
                this.RequestInvalidate();
                return;
            }

            if (this.mode1Tool == Tool.Move || this.mode1Tool == Tool.Remove)
            {
                this.overlay = null;

                foreach (OverlayBase overlay in this.overlays)
                {
                    overlay.IsHovered = false;

                    if (this.mode2Tool == Tool.Lock)
                    {
                        overlay.IsHovered = true;

                        if (this.mode1Tool == Tool.Move && this.mouseButtonPressed)
                        {
                            this.MoveOverlay(overlay);
                        }
                    }

                    else if (this.overlay == null && this.IsHovered(overlay))
                    {
                        overlay.IsHovered = true;
                        this.overlay      = overlay;
                    }
                }

                this.RequestInvalidate();
                return;
            }
        }
Exemple #4
0
        private void CreateVerticalGuide()
        {
            Guide guide = new Guide();

            guide.GuideColor = this.activeColor;
            guide.Orienation = Orienation.Vertical;
            guide.Position   = guide.TempPosition = this.startX;
            this.overlay     = guide;
            this.RequestInvalidate();
        }
Exemple #5
0
        private void DrawOverlay(Graphics g, OverlayBase overlay)
        {
            if (overlay is Image)
            {
                this.DrawImage(g, overlay as Image);
            }

            else if (overlay is Guide)
            {
                this.DrawGuide(g, overlay as Guide);
            }
        }
Exemple #6
0
        private void MoveOverlay(OverlayBase overlay)
        {
            int xDelta;
            int yDelta;

            if (this.isControlPressed)
            {
                xDelta = this.controlKeyStartX - this.startX;
                yDelta = this.controlKeyStartY - this.startY;

                int xControlKeyDelta = this.mouseX - this.controlKeyStartX;
                int yControlKeyDelta = this.mouseY - this.controlKeyStartY;

                xControlKeyDelta = (int)Math.Round((double)xControlKeyDelta / 5.0);
                yControlKeyDelta = (int)Math.Round((double)yControlKeyDelta / 5.0);
                xDelta          += xControlKeyDelta;
                yDelta          += yControlKeyDelta;
            }

            else
            {
                xDelta = this.mouseX - this.startX;
                yDelta = this.mouseY - this.startY;
            }

            if (overlay is Guide)
            {
                if ((overlay as Guide).Orienation == Orienation.Horizontal)
                {
                    (overlay as Guide).Position = (overlay as Guide).TempPosition + yDelta;
                    Magnifier.X = this.mouseX;
                    Magnifier.Y = (overlay as Guide).TempPosition + yDelta;
                }

                else if ((overlay as Guide).Orienation == Orienation.Vertical)
                {
                    (overlay as Guide).Position = (overlay as Guide).TempPosition + xDelta;
                    Magnifier.X = (overlay as Guide).TempPosition + xDelta;
                    Magnifier.Y = this.mouseY;
                }
            }

            else if (overlay is Image)
            {
                (overlay as Image).Position = new Point(
                    (overlay as Image).TempPosition.X + xDelta,
                    (overlay as Image).TempPosition.Y + yDelta
                    );

                Magnifier.X = (overlay as Image).TempPosition.X + xDelta;
                Magnifier.Y = (overlay as Image).TempPosition.Y + yDelta;
            }
        }
Exemple #7
0
        protected void toolbarWnd_Mode1ToolChanged(object sender, ToolEventArgs e)
        {
            this.overlay = null;
            this.ResetHover();
            this.mode1Tool = e.Tool;
            this.RequestInvalidate();

            if (this.mode1Tool == Tool.Default)
            {
                this.HideShaderWnd();
            }

            else
            {
                this.ShowShaderWnd();
            }
        }
Exemple #8
0
        private void CreateImage()
        {
            Image image = new Image();

            using (Bitmap source = Resources.ImagePlaceholder)
            {
                image.Normal  = source.SetOpacity(this.GetImageOpacity());
                image.Hovered = source.SetOpacity(this.GetImageOpacity()).SetRed();
            }

            image.Position = image.TempPosition = new Point(
                this.startX - Resources.ImagePlaceholder.Width / 2,
                this.startY - Resources.ImagePlaceholder.Height / 2
                );

            this.overlay = image;
            this.RequestInvalidate();
        }
Exemple #9
0
        private void hookHelper_MouseDown(object sender, MouseEventArgs e)
        {
            if (this.mode1Tool != Tool.Default && this.PointInsideToolbarWnd(e.Location))
            {
                return;
            }

            this.mouseButtonPressed = true;
            this.startX             = e.X;
            this.startY             = e.Y;
            this.toolbarWndX        = this.toolbarWnd.Location.X;
            this.toolbarWndY        = this.toolbarWnd.Location.Y;
            this.activeTool         = this.tool;

            foreach (OverlayBase item in this.overlays)
            {
                if (item is Guide)
                {
                    (item as Guide).TempPosition = (item as Guide).Position;
                }

                else if (item is Image)
                {
                    (item as Image).TempPosition = (item as Image).Position;
                }
            }

            if (this.activeTool == Tool.HorizontalGuide)
            {
                this.CreateHorizontalGuide();
                this.ShowMagnifierWnd();
                return;
            }

            if (this.activeTool == Tool.VerticalGuide)
            {
                this.CreateVerticalGuide();
                this.ShowMagnifierWnd();
                return;
            }

            if (this.activeTool == Tool.Image)
            {
                this.CreateImage();
                return;
            }

            if (this.mode1Tool == Tool.Move)
            {
                this.ShowMagnifierWnd();
                return;
            }

            if (this.mode1Tool == Tool.Remove)
            {
                if (this.mode2Tool == Tool.Lock)
                {
                    this.overlays.Clear();
                }

                else if (this.overlay != null)
                {
                    this.overlays.Remove(this.overlay);
                    this.overlay = null;
                }

                this.RequestInvalidate();
                return;
            }
        }