private void ResizeThumb_DragCompleted(object sender, System.Windows.Controls.Primitives.DragCompletedEventArgs e)
 {
     Resized?.Invoke(this);
 }
示例#2
0
 internal void OnResize(int newWidth, int newHeight)
 {
     Width  = newWidth;
     Height = newHeight;
     Resized?.Invoke(this);
 }
示例#3
0
 public virtual void DoResize(ResizeEventArgs e)
 {
     Resized?.Invoke(this, e);
 }
示例#4
0
        private void OnResize(object sender, EventArgs e)
        {
            var windowSize = new Point(this.GameWindow.ClientBounds.Width, this.GameWindow.ClientBounds.Height);

            Resized?.Invoke(windowSize);
        }
示例#5
0
 private void OnResized(Size size)
 {
     Resized?.Invoke(size / ScalingFactor);
 }
示例#6
0
 int IVsWindowFrameNotify.OnSize()
 {
     Resized?.Invoke(_window, EventArgs.Empty);
     return(VSConstants.S_OK);
 }
示例#7
0
 private void Plug_SizeAllocated(object o, SizeAllocatedArgs args)
 {
     Resized?.Invoke(new Size(args.Allocation.Width, args.Allocation.Height));
 }
示例#8
0
 public virtual void OnResized(ResizedEventArgs e)
 {
     Resized?.Invoke(this, e);
 }
示例#9
0
 protected virtual void OnResized(Size size)
 {
     Resized?.Invoke(size);
 }
示例#10
0
 public void Resize(WindowSize windowSize)
 {
     Resized?.Invoke(windowSize);
 }
示例#11
0
        /// <summary>
        /// Handler invoked on mouse moved event.
        /// </summary>
        /// <param name="x">X coordinate.</param>
        /// <param name="y">Y coordinate.</param>
        /// <param name="dx">X change.</param>
        /// <param name="dy">Y change.</param>
        protected override void OnMouseMoved(int x, int y, int dx, int dy)
        {
            if (null == m_Target)
            {
                return;
            }
            if (!m_Held)
            {
                return;
            }

            Rectangle oldBounds = m_Target.Bounds;
            Rectangle bounds    = m_Target.Bounds;

            Vector2i min = m_Target.MinimumSize;

            Vector2i pCursorPos = m_Target.CanvasPosToLocal(new Vector2i(x, y));

            Vector2i delta = m_Target.LocalPosToCanvas(m_HoldPos);

            delta.X -= x;
            delta.Y -= y;

            if (0 != (m_ResizeDir & Pos.Left))
            {
                bounds.X     -= delta.X;
                bounds.Width += delta.X;

                // Conform to minimum size here so we don't
                // go all weird when we snap it in the base conrt

                if (bounds.Width < min.X)
                {
                    int diff = min.X - bounds.Width;
                    bounds.Width += diff;
                    bounds.X     -= diff;
                }
            }

            if (0 != (m_ResizeDir & Pos.Top))
            {
                bounds.Y      -= delta.Y;
                bounds.Height += delta.Y;

                // Conform to minimum size here so we don't
                // go all weird when we snap it in the base conrt

                if (bounds.Height < min.Y)
                {
                    int diff = min.Y - bounds.Height;
                    bounds.Height += diff;
                    bounds.Y      -= diff;
                }
            }

            if (0 != (m_ResizeDir & Pos.Right))
            {
                // This is complicated.
                // Basically we want to use the HoldPos, so it doesn't snap to the edge of the control
                // But we need to move the HoldPos with the window movement. Yikes.
                // I actually think this might be a big hack around the way this control works with regards
                // to the holdpos being on the parent panel.

                int woff = bounds.Width - m_HoldPos.X;
                int diff = bounds.Width;
                bounds.Width = pCursorPos.X + woff;
                if (bounds.Width < min.X)
                {
                    bounds.Width = min.X;
                }
                diff -= bounds.Width;

                m_HoldPos.X -= diff;
            }

            if (0 != (m_ResizeDir & Pos.Bottom))
            {
                int hoff = bounds.Height - m_HoldPos.Y;
                int diff = bounds.Height;
                bounds.Height = pCursorPos.Y + hoff;
                if (bounds.Height < min.Y)
                {
                    bounds.Height = min.Y;
                }
                diff -= bounds.Height;

                m_HoldPos.Y -= diff;
            }

            m_Target.SetBounds(bounds);

            if (Resized != null)
            {
                Resized.Invoke(this);
            }
        }
示例#12
0
 protected void RaiseResized(bool deviceRotated)
 {
     using (Context.Activate().Scoped()) {
         Resized?.Invoke(deviceRotated);
     }
 }
示例#13
0
 public override void LayoutSubviews() => Resized?.Invoke(ClientSize);
示例#14
0
        private void UpdateResizing(Camera cam)
        {
            isHighlighted = true;

            int startX = ResizeHorizontal ? -1 : 0;
            int StartY = ResizeVertical ? -1 : 0;

            for (int x = startX; x < 2; x += 2)
            {
                for (int y = StartY; y < 2; y += 2)
                {
                    Vector2 handlePos = cam.WorldToScreen(Position + new Vector2(x * (rect.Width * 0.5f + 5), y * (rect.Height * 0.5f + 5)));

                    bool highlighted = Vector2.Distance(PlayerInput.MousePosition, handlePos) < 5.0f;

                    if (highlighted && PlayerInput.PrimaryMouseButtonDown())
                    {
                        selectionPos   = Vector2.Zero;
                        resizeDirX     = x;
                        resizeDirY     = y;
                        resizing       = true;
                        startMovingPos = Vector2.Zero;
                    }
                }
            }

            if (resizing)
            {
                if (prevRect == null)
                {
                    prevRect = new Rectangle(Rect.Location, Rect.Size);
                }

                Vector2 placePosition = new Vector2(rect.X, rect.Y);
                Vector2 placeSize     = new Vector2(rect.Width, rect.Height);

                Vector2 mousePos = Submarine.MouseToWorldGrid(cam, Submarine.MainSub);

                if (PlayerInput.IsShiftDown())
                {
                    mousePos = cam.ScreenToWorld(PlayerInput.MousePosition);
                }

                if (resizeDirX > 0)
                {
                    mousePos.X  = Math.Max(mousePos.X, rect.X + Submarine.GridSize.X);
                    placeSize.X = mousePos.X - placePosition.X;
                }
                else if (resizeDirX < 0)
                {
                    mousePos.X = Math.Min(mousePos.X, rect.Right - Submarine.GridSize.X);

                    placeSize.X     = (placePosition.X + placeSize.X) - mousePos.X;
                    placePosition.X = mousePos.X;
                }
                if (resizeDirY < 0)
                {
                    mousePos.Y  = Math.Min(mousePos.Y, rect.Y - Submarine.GridSize.Y);
                    placeSize.Y = placePosition.Y - mousePos.Y;
                }
                else if (resizeDirY > 0)
                {
                    mousePos.Y = Math.Max(mousePos.Y, rect.Y - rect.Height + Submarine.GridSize.X);

                    placeSize.Y     = mousePos.Y - (rect.Y - rect.Height);
                    placePosition.Y = mousePos.Y;
                }

                if ((int)placePosition.X != rect.X || (int)placePosition.Y != rect.Y || (int)placeSize.X != rect.Width || (int)placeSize.Y != rect.Height)
                {
                    Rect = new Rectangle((int)placePosition.X, (int)placePosition.Y, (int)placeSize.X, (int)placeSize.Y);
                }

                if (!PlayerInput.PrimaryMouseButtonHeld())
                {
                    resizing = false;
                    Resized?.Invoke(rect);
                    if (prevRect != null)
                    {
                        var newData = new List <Rectangle> {
                            Rect
                        };
                        var oldData = new List <Rectangle> {
                            prevRect.Value
                        };
                        SubEditorScreen.StoreCommand(new TransformCommand(new List <MapEntity> {
                            this
                        }, newData, oldData, true));
                    }
                    prevRect = null;
                }
            }
        }
示例#15
0
        /// <summary>
        /// Handler invoked on mouse moved event.
        /// </summary>
        /// <param name="x">X coordinate.</param>
        /// <param name="y">Y coordinate.</param>
        /// <param name="dx">X change.</param>
        /// <param name="dy">Y change.</param>
        protected override void OnMouseMoved(int x, int y, int dx, int dy)
        {
            if (null == m_Target)
            {
                return;
            }
            if (!m_Held)
            {
                return;
            }

            Rectangle oldBounds = m_Target.Bounds;
            Rectangle bounds    = m_Target.Bounds;

            Size min = m_Target.MinimumSize;

            Point delta = m_Target.LocalPosToCanvas(m_HoldPos);

            delta.X -= x;
            delta.Y -= y;

            if (0 != (m_ResizeDir & Dock.Left))
            {
                bounds.X     -= delta.X;
                bounds.Width += delta.X;

                if (bounds.X < 0)
                {
                    bounds.Width += bounds.X;
                    bounds.X      = 0;
                }

                // Conform to minimum size here so we don't
                // go all weird when we snap it in the base conrt

                if (bounds.Width < min.Width)
                {
                    int diff = min.Width - bounds.Width;
                    bounds.Width += diff;
                    bounds.X     -= diff;
                }

                m_Target.Left  = bounds.Left;
                m_Target.Width = bounds.Width;
            }

            if (0 != (m_ResizeDir & Dock.Top))
            {
                bounds.Y      -= delta.Y;
                bounds.Height += delta.Y;

                if (bounds.Y < 0)
                {
                    bounds.Height += bounds.Y;
                    bounds.Y       = 0;
                }

                // Conform to minimum size here so we don't
                // go all weird when we snap it in the base conrt

                if (bounds.Height < min.Height)
                {
                    int diff = min.Height - bounds.Height;
                    bounds.Height += diff;
                    bounds.Y      -= diff;
                }

                m_Target.Top    = bounds.Top;
                m_Target.Height = bounds.Height;
            }

            if (0 != (m_ResizeDir & Dock.Right))
            {
                bounds.Width -= delta.X;

                if (bounds.Width < min.Width)
                {
                    bounds.Width = min.Width;
                }

                m_HoldPos.X += bounds.Width - oldBounds.Width;

                m_Target.Left  = bounds.Left;
                m_Target.Width = bounds.Width;
            }

            if (0 != (m_ResizeDir & Dock.Bottom))
            {
                bounds.Height -= delta.Y;

                if (bounds.Height < min.Height)
                {
                    bounds.Height = min.Height;
                }

                m_HoldPos.Y += bounds.Height - oldBounds.Height;

                m_Target.Top    = bounds.Top;
                m_Target.Height = bounds.Height;
            }

            // Lets set quickly new bounds and let the layout measure and arrange child controls later
            m_Target.SetBounds(bounds);
            // Set bounds that are checked by SetBounds() implementations
            if (!Util.IsIgnore(m_Target.Width))
            {
                m_Target.Width = m_Target.Bounds.Width;
            }
            if (!Util.IsIgnore(m_Target.Height))
            {
                m_Target.Height = m_Target.Bounds.Height;
            }

            m_Target.Invalidate();

            if (Resized != null)
            {
                Resized.Invoke(this, EventArgs.Empty);
            }
        }
示例#16
0
        protected OsuTKWindow([NotNull] IGameWindow osuTKGameWindow)
        {
            OsuTKGameWindow          = osuTKGameWindow;
            OsuTKGameWindow.KeyDown += OnKeyDown;

            CurrentDisplayBindable.Value = PrimaryDisplay;

            // Moving or resizing the window needs to check to see if we've moved to a different display.
            // This will update the CurrentDisplay bindable.
            Move   += (sender, e) => checkCurrentDisplay();
            Resize += (sender, e) =>
            {
                checkCurrentDisplay();
                Resized?.Invoke();
            };

            Closing += (sender, e) =>
            {
                // always block a graceful exit as it's treated as a regular window event.
                // the host will force-close the window if the game decides not to block the exit.
                ExitRequested?.Invoke();
                e.Cancel = true;
            };
            Closed += (sender, e) => Exited?.Invoke();

            MouseEnter += (sender, args) => cursorInWindow.Value = true;
            MouseLeave += (sender, args) => cursorInWindow.Value = false;

            supportedWindowModes.AddRange(DefaultSupportedWindowModes);

            UpdateFrame += (o, e) => UpdateFrameScheduler.Update();

            MakeCurrent();

            string version = GL.GetString(StringName.Version);
            string versionNumberSubstring = getVersionNumberSubstring(version);

            GLVersion = new Version(versionNumberSubstring);

            // As defined by https://www.khronos.org/registry/OpenGL-Refpages/es2.0/xhtml/glGetString.xml
            IsEmbedded = version.Contains("OpenGL ES");

            version = GL.GetString(StringName.ShadingLanguageVersion);

            if (!string.IsNullOrEmpty(version))
            {
                try
                {
                    GLSLVersion = new Version(versionNumberSubstring);
                }
                catch (Exception e)
                {
                    Logger.Error(e, $@"couldn't set GLSL version using string '{version}'");
                }
            }

            if (GLSLVersion == null)
            {
                GLSLVersion = new Version();
            }

            Logger.Log($@"GL Initialized
                        GL Version:                 {GL.GetString(StringName.Version)}
                        GL Renderer:                {GL.GetString(StringName.Renderer)}
                        GL Shader Language version: {GL.GetString(StringName.ShadingLanguageVersion)}
                        GL Vendor:                  {GL.GetString(StringName.Vendor)}
                        GL Extensions:              {GL.GetString(StringName.Extensions)}");
        }
示例#17
0
 protected virtual void OnResize(ISizeEventArgs e) =>
 Resized?.Invoke(this, e);