Beispiel #1
0
        public ConfWindow()
        {
            InitializeComponent();
            DataContext = this;
            SearchControl.SearchTextBox.TextChanged += SearchTextBox_TextChanged;
            LoadSettings(SettingsDefinitions, Conf);
            LoadSettings(NetSettingsDefinitions, NetConf);
            SearchControl.Text = RegHelp.GetString(App.RegPath, "config editor search");

            if (App.IsDarkMode)
            {
                Foreground  = Brushes.White;
                Foreground2 = Brushes.Silver;
                Background  = Brushes.Black;
            }
        }
Beispiel #2
0
        void CheckClipboardForURL()
        {
            string clipboard = Clipboard.GetText();

            foreach (string url in App.UrlWhitelist)
            {
                if (clipboard.Contains("://") && !clipboard.Contains("\n") &&
                    !clipboard.Contains(" ") && clipboard.Contains(url.ToLower().Trim()) &&
                    RegHelp.GetString(App.RegPath, "LastURL") != clipboard && Visible)
                {
                    RegHelp.SetObject(App.RegPath, "LastURL", clipboard);

                    if (Msg.ShowQuestion("Play URL?", clipboard) == MsgResult.OK)
                    {
                        mp.Load(new[] { clipboard }, true, Control.ModifierKeys.HasFlag(Keys.Control));
                    }
                }
            }
        }
Beispiel #3
0
 public static void ExecuteMpvCommand() // deprecated 2019
 {
     InvokeOnMainThread(new Action(() => {
         string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegHelp.GetString(App.RegPath, "RecentExecutedCommand"));
         if (string.IsNullOrEmpty(command))
         {
             return;
         }
         RegHelp.SetObject(App.RegPath, "RecentExecutedCommand", command);
         mp.command(command, false);
     }));
 }
Beispiel #4
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);
        }
Beispiel #5
0
 public static void execute_mpv_command(string[] args)
 {
     MainForm.Instance.Invoke(new Action(() => {
         string command = VB.Interaction.InputBox("Enter a mpv command to be executed.", "Execute Command", RegHelp.GetString(App.RegPath, "RecentExecutedCommand"));
         if (string.IsNullOrEmpty(command))
         {
             return;
         }
         RegHelp.SetObject(App.RegPath, "RecentExecutedCommand", command);
         mp.command_string(command, false);
     }));
 }