Esempio n. 1
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);
            mp.command_string($"mouse {e.X} {e.Y}");

            if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
            {
                CursorHelp.Show();
            }
        }
Esempio n. 2
0
        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            // send mouse command to make OSC show
            mpv.CommandString($"mouse {e.X} {e.Y}");

            if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
            {
                CursorHelp.Show();
            }
        }
Esempio n. 3
0
        private void Core_ShowMenu()
        {
            BeginInvoke(new Action(() => {
                if (IsMouseInOSC())
                {
                    return;
                }

                CursorHelp.Show();
                UpdateMenu();
                ContextMenu.IsOpen = true;
            }));
        }
Esempio n. 4
0
 void CursorTimer_Tick(object sender, EventArgs e)
 {
     if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
     {
         LastCursorPosChanged       = Control.MousePosition;
         LastCursorChangedTickCount = Environment.TickCount;
     }
     else if (Environment.TickCount - LastCursorChangedTickCount > 1500 &&
              !IsMouseInOSC() && ClientRectangle.Contains(PointToClient(MousePosition)) &&
              Form.ActiveForm == this && !ContextMenu.Visible)
     {
         CursorHelp.Hide();
     }
 }
Esempio n. 5
0
 protected override void OnLostFocus(EventArgs e)
 {
     base.OnLostFocus(e);
     CursorHelp.Show();
 }
Esempio n. 6
0
        protected override void WndProc(ref Message m)
        {
            //Debug.WriteLine(m);

            switch (m.Msg)
            {
            case 0x0201:     // WM_LBUTTONDOWN
            case 0x0202:     // WM_LBUTTONUP
            case 0x0207:     // WM_MBUTTONDOWN
            case 0x0208:     // WM_MBUTTONUP
            case 0x020b:     // WM_XBUTTONDOWN
            case 0x020c:     // WM_XBUTTONUP
            case 0x020A:     // WM_MOUSEWHEEL
            case 0x0100:     // WM_KEYDOWN
            case 0x0101:     // WM_KEYUP
            case 0x0104:     // WM_SYSKEYDOWN
            case 0x0105:     // WM_SYSKEYUP
            case 0x319:      // WM_APPCOMMAND
                if (mp.WindowHandle != IntPtr.Zero)
                {
                    Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
                }
                break;

            case 0x0200:     // WM_MOUSEMOVE
            {
                Point pos = PointToClient(Cursor.Position);
                mp.command($"mouse {pos.X} {pos.Y}");
                if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
                {
                    CursorHelp.Show();
                }
            }
            break;

            case 0x2a3:                  // WM_MOUSELEAVE
                mp.command("mouse 1 1"); // osc won't always auto hide
                break;

            case 0x203:     // Native.WM.LBUTTONDBLCLK
            {
                Point pos = PointToClient(Cursor.Position);
                mp.command($"mouse {pos.X} {pos.Y} 0 double");
            }
            break;

            case 0x02E0:     // WM_DPICHANGED
                if (!WasShown)
                {
                    break;
                }
                var r2 = Marshal.PtrToStructure <Native.RECT>(m.LParam);
                Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0);
                break;

            case 0x0214:     // WM_SIZING
                var rc = Marshal.PtrToStructure <Native.RECT>(m.LParam);
                var r  = rc;
                NativeHelp.SubtractWindowBorders(Handle, ref r);
                int  c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
                Size s = mp.VideoSize;
                if (s == Size.Empty)
                {
                    s = new Size(16, 9);
                }
                float aspect    = s.Width / (float)s.Height;
                int   d_w       = Convert.ToInt32(c_h * aspect - c_w);
                int   d_h       = Convert.ToInt32(c_w / aspect - c_h);
                int[] d_corners = { d_w, d_h, -d_w, -d_h };
                int[] corners   = { rc.Left, rc.Top, rc.Right, rc.Bottom };
                int   corner    = NativeHelp.GetResizeBorder(m.WParam.ToInt32());
                if (corner >= 0)
                {
                    corners[corner] -= d_corners[corner];
                }
                Marshal.StructureToPtr <Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
                m.Result = new IntPtr(1);
                return;

            case 0x004A:     // WM_COPYDATA
                var      copyData = (Native.COPYDATASTRUCT)m.GetLParam(typeof(Native.COPYDATASTRUCT));
                string[] files    = copyData.lpData.Split('\n');
                string   mode     = files[0];
                files = files.Skip(1).ToArray();

                switch (mode)
                {
                case "single":
                    mp.Load(files, true, Control.ModifierKeys.HasFlag(Keys.Control));
                    break;

                case "queue":
                    foreach (string file in files)
                    {
                        mp.commandv("loadfile", file, "append");
                    }
                    break;
                }

                Activate();
                return;
            }

            if (m.Msg == TaskbarButtonCreatedMessage && mp.TaskbarProgress)
            {
                Taskbar = new Taskbar(Handle);
                ProgressTimer.Start();
            }

            base.WndProc(ref m);
        }
Esempio n. 7
0
 void ContextMenu_Opened(object sender, EventArgs e) => CursorHelp.Show();
Esempio n. 8
0
 void CM_Popup(object sender, EventArgs e) => CursorHelp.Show();
Esempio n. 9
0
        protected override void WndProc(ref Message m)
        {
            //Debug.WriteLine(m);

            switch (m.Msg)
            {
            case 0x201:     // WM_LBUTTONDOWN
            case 0x202:     // WM_LBUTTONUP
            case 0x207:     // WM_MBUTTONDOWN
            case 0x208:     // WM_MBUTTONUP
            case 0x20b:     // WM_XBUTTONDOWN
            case 0x20c:     // WM_XBUTTONUP
            case 0x20A:     // WM_MOUSEWHEEL
            case 0x100:     // WM_KEYDOWN
            case 0x101:     // WM_KEYUP
            case 0x104:     // WM_SYSKEYDOWN
            case 0x105:     // WM_SYSKEYUP
            {
                bool skip = m.Msg == 0x100 && LastAppCommand != 0 &&
                            (Environment.TickCount - LastAppCommand) < 1000;

                if (core.WindowHandle != IntPtr.Zero && !skip)
                {
                    m.Result = WinAPI.SendMessage(core.WindowHandle, m.Msg, m.WParam, m.LParam);
                }
            }
            break;

            case 0x319:     // WM_APPCOMMAND
            {
                string value = mpvHelp.WM_APPCOMMAND_to_mpv_key((int)(m.LParam.ToInt64() >> 16 & ~0xf000));

                if (value != null)
                {
                    core.command("keypress " + value);
                    m.Result       = new IntPtr(1);
                    LastAppCommand = Environment.TickCount;
                    return;
                }
            }
            break;

            case 0x0200:     // WM_MOUSEMOVE
                if (Environment.TickCount - LastCycleFullscreen > 500)
                {
                    Point pos = PointToClient(Cursor.Position);
                    core.command($"mouse {pos.X} {pos.Y}");
                }

                if (CursorHelp.IsPosDifferent(LastCursorPosition))
                {
                    CursorHelp.Show();
                }
                break;

            case 0x2a3:     // WM_MOUSELEAVE
                //osc won't auto hide after mouse left window in borderless mode
                core.command($"mouse {ClientSize.Width / 2} {ClientSize.Height / 3}");
                break;

            case 0x203:     // WM_LBUTTONDBLCLK
            {
                Point pos = PointToClient(Cursor.Position);
                core.command($"mouse {pos.X} {pos.Y} 0 double");
            }
            break;

            case 0x02E0:     // WM_DPICHANGED
            {
                if (!WasShown())
                {
                    break;
                }

                WinAPI.RECT rect = Marshal.PtrToStructure <WinAPI.RECT>(m.LParam);
                WinAPI.SetWindowPos(Handle, IntPtr.Zero, rect.Left, rect.Top, rect.Width, rect.Height, 0);
            }
            break;

            case 0x0214:     // WM_SIZING
            {
                var rc = Marshal.PtrToStructure <WinAPI.RECT>(m.LParam);
                var r  = rc;
                NativeHelp.SubtractWindowBorders(Handle, ref r);
                int  c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
                Size s = core.VideoSize;

                if (s == Size.Empty)
                {
                    s = new Size(16, 9);
                }

                float aspect = s.Width / (float)s.Height;
                int   d_w    = (int)(c_h * aspect - c_w);
                int   d_h    = (int)(c_w / aspect - c_h);

                Debug.WriteLine(d_w);
                Debug.WriteLine(d_h);

                int d_w2 = (int)(c_h * aspect - c_w);
                int d_h2 = (int)(c_w / aspect - c_h);

                Debug.WriteLine(d_w2);
                Debug.WriteLine(d_h2);

                int[] d_corners = { d_w, d_h, -d_w, -d_h };
                int[] corners   = { rc.Left, rc.Top, rc.Right, rc.Bottom };
                int   corner    = NativeHelp.GetResizeBorder(m.WParam.ToInt32());

                if (corner >= 0)
                {
                    corners[corner] -= d_corners[corner];
                }

                Marshal.StructureToPtr <WinAPI.RECT>(new WinAPI.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
                m.Result = new IntPtr(1);
            }
                return;

            case 0x004A:     // WM_COPYDATA
            {
                var      copyData = (WinAPI.COPYDATASTRUCT)m.GetLParam(typeof(WinAPI.COPYDATASTRUCT));
                string[] files    = copyData.lpData.Split('\n');
                string   mode     = files[0];
                files = files.Skip(1).ToArray();

                switch (mode)
                {
                case "single":
                    core.LoadFiles(files, true, Control.ModifierKeys.HasFlag(Keys.Control));
                    break;

                case "queue":
                    foreach (string file in files)
                    {
                        core.commandv("loadfile", file, "append");
                    }
                    break;
                }

                Activate();
            }
                return;
            }

            if (m.Msg == TaskbarButtonCreatedMessage && core.TaskbarProgress)
            {
                Taskbar = new Taskbar(Handle);
                ProgressTimer.Start();
            }

            // beep sound when closed using taskbar due to exception
            if (!IsDisposed)
            {
                base.WndProc(ref m);
            }
        }
Esempio n. 10
0
 private void CM_Popup(object sender, EventArgs e)
 {
     CursorHelp.Show();
 }
Esempio n. 11
0
 private void CMS_Opened(object sender, EventArgs e)
 {
     CursorHelp.Show();
 }
Esempio n. 12
0
        protected override void WndProc(ref Message m)
        {
            //Debug.WriteLine(m);

            switch (m.Msg)
            {
            case 0x0201:     // WM_LBUTTONDOWN
            case 0x0202:     // WM_LBUTTONUP
            case 0x0100:     // WM_KEYDOWN
            case 0x0101:     // WM_KEYUP
            case 0x0104:     // WM_SYSKEYDOWN
            case 0x0105:     // WM_SYSKEYUP
            case 0x020A:     // WM_MOUSEWHEEL
                if (mp.WindowHandle != IntPtr.Zero)
                {
                    Native.SendMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
                }
                break;

            case 0x0200:     // WM_MOUSEMOVE
                Point pos = PointToClient(Cursor.Position);
                mp.command_string($"mouse {pos.X} {pos.Y}");
                if (CursorHelp.IsPosDifferent(LastCursorPosChanged))
                {
                    CursorHelp.Show();
                }
                break;

            case 0x319:     // WM_APPCOMMAND
                if (mp.WindowHandle != IntPtr.Zero)
                {
                    Native.PostMessage(mp.WindowHandle, m.Msg, m.WParam, m.LParam);
                }
                break;

            case 0x203:     // Native.WM.LBUTTONDBLCLK
                if (!IsMouseInOSC())
                {
                    mp.command_string("cycle fullscreen");
                }
                break;

            case 0x02E0:     // WM_DPICHANGED
                if (IgnoreDpiChanged)
                {
                    break;
                }
                var r2 = Marshal.PtrToStructure <Native.RECT>(m.LParam);
                Native.SetWindowPos(Handle, IntPtr.Zero, r2.Left, r2.Top, r2.Width, r2.Height, 0);
                break;

            case 0x0214:     // WM_SIZING
                var rc = Marshal.PtrToStructure <Native.RECT>(m.LParam);
                var r  = rc;
                NativeHelp.SubtractWindowBorders(Handle, ref r);
                int   c_w = r.Right - r.Left, c_h = r.Bottom - r.Top;
                float aspect    = mp.VideoSize.Width / (float)mp.VideoSize.Height;
                int   d_w       = Convert.ToInt32(c_h * aspect - c_w);
                int   d_h       = Convert.ToInt32(c_w / aspect - c_h);
                int[] d_corners = { d_w, d_h, -d_w, -d_h };
                int[] corners   = { rc.Left, rc.Top, rc.Right, rc.Bottom };
                int   corner    = NativeHelp.GetResizeBorder(m.WParam.ToInt32());

                if (corner >= 0)
                {
                    corners[corner] -= d_corners[corner];
                }

                Marshal.StructureToPtr <Native.RECT>(new Native.RECT(corners[0], corners[1], corners[2], corners[3]), m.LParam, false);
                m.Result = new IntPtr(1);
                return;
            }

            if (m.Msg == SingleProcess.Message)
            {
                object filesObject = RegHelp.GetObject(App.RegPath, "ShellFiles");

                if (filesObject is string[] files)
                {
                    switch (RegHelp.GetString(App.RegPath, "ProcessInstanceMode"))
                    {
                    case "single":
                        mp.Load(files, true, Control.ModifierKeys.HasFlag(Keys.Control));
                        break;

                    case "queue":
                        foreach (string file in files)
                        {
                            mp.commandv("loadfile", file, "append");
                        }
                        break;
                    }
                }

                RegHelp.RemoveValue(App.RegPath, "ShellFiles");
                Activate();
                return;
            }

            base.WndProc(ref m);
        }