Esempio n. 1
0
        public MainForm()
        {
            InitializeComponent();

            try
            {
                Instance = this;
                Hwnd     = Handle;
                mp.Init();
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
                Application.ThreadException += Application_ThreadException;
                Msg.SupportURL = "https://github.com/stax76/mpv.net#support";
                WPF.WPF.Init();
                System.Windows.Application.Current.ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown;
                Text += " " + Application.ProductVersion;

                object recent = RegHelp.GetObject(App.RegPath, "Recent");

                if (recent is string[] r)
                {
                    RecentFiles = new List <string>(r);
                }
                else
                {
                    RecentFiles = new List <string>();
                }

                var   wpfColor = WPF.WPF.ThemeColor;
                Color color    = Color.FromArgb(wpfColor.A, wpfColor.R, wpfColor.G, wpfColor.B);
                ToolStripRendererEx.InitColors(color, App.IsDarkMode);

                ContextMenu          = new ContextMenuStripEx(components);
                ContextMenu.Opened  += ContextMenu_Opened;
                ContextMenu.Opening += ContextMenu_Opening;

                App.ProcessCommandLineEarly();

                if (mp.Screen == -1)
                {
                    mp.Screen = Array.IndexOf(Screen.AllScreens, Screen.PrimaryScreen);
                }
                int      targetIndex = mp.Screen;
                Screen[] screens     = Screen.AllScreens;
                if (targetIndex < 0)
                {
                    targetIndex = 0;
                }
                if (targetIndex > screens.Length - 1)
                {
                    targetIndex = screens.Length - 1;
                }
                Screen    screen = screens[Array.IndexOf(screens, screens[targetIndex])];
                Rectangle target = screen.Bounds;
                Left = target.X + (target.Width - Width) / 2;
                Top  = target.Y + (target.Height - Height) / 2;

                int posX = RegHelp.GetInt(App.RegPath, "PosX");
                int posY = RegHelp.GetInt(App.RegPath, "PosY");

                if (posX != 0 && posY != 0 && App.RememberPosition)
                {
                    Left = posX - Width / 2;
                    Top  = posY - Height / 2;
                }

                mp.Shutdown         += Shutdown;
                mp.VideoSizeChanged += VideoSizeChanged;
                mp.FileLoaded       += FileLoaded;
                mp.Idle             += Idle;
                mp.VideoSizeAutoResetEvent.WaitOne(1500);
                if (Height < FontHeight * 4)
                {
                    SetFormPosAndSize();
                }
                mp.observe_property_bool("fullscreen", PropChangeFullscreen);
                mp.observe_property_bool("ontop", PropChangeOnTop);
                mp.observe_property_bool("border", PropChangeBorder);
                mp.observe_property_string("sid", PropChangeSid);
                mp.observe_property_string("aid", PropChangeAid);
                mp.observe_property_string("vid", PropChangeVid);
                mp.observe_property_int("edition", PropChangeEdition);
            }
            catch (Exception ex)
            {
                Msg.ShowException(ex);
            }
        }
Esempio n. 2
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);
     }));
 }
Esempio n. 3
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);
     }));
 }
Esempio n. 4
0
 protected override void OnClosed(EventArgs e)
 {
     base.OnClosed(e);
     WriteToDisk();
     RegHelp.SetObject(App.RegPath, "config editor search", SearchControl.Text);
 }