Beispiel #1
0
        public EVRPlayListener(MainForm parent)
        {
            m_parent = parent;
            m_KeepMe = new WndProc(CustomWndProc);
            IntPtr hInstance = Marshal.GetHINSTANCE(this.GetType().Module);

            WNDCLASSEX wndClassEx = new WNDCLASSEX();
            wndClassEx.cbSize = Marshal.SizeOf(typeof(WNDCLASSEX));
            wndClassEx.style = ClassStyle.GLOBALCLASS;
            wndClassEx.cbClsExtra = 0;
            wndClassEx.cbWndExtra = 0;
            wndClassEx.hbrBackground = IntPtr.Zero;
            wndClassEx.hCursor = IntPtr.Zero;
            wndClassEx.hIcon = IntPtr.Zero;
            wndClassEx.hIconSm = IntPtr.Zero;
            wndClassEx.lpszClassName = EVR_CLASS;
            wndClassEx.lpszMenuName = null;
            wndClassEx.hInstance = hInstance;
            wndClassEx.lpfnWndProc = m_KeepMe;

            ushort atom = RegisterClassEx(ref wndClassEx);

            //WNDCLASSEX lpwcx;
            //bool isReg = GetClassInfoEx(hInstance, EVR_CLASS, out lpwcx);

            if (atom == 0)
            {
                int error = Marshal.GetLastWin32Error();
                throw new Win32Exception(error);
            }            

            // Create window
            //m_hwnd = CreateWindowEx(
            //    WindowStyle.EX_NOACTIVATE,
            //    atom,
            //    EVR_WIN,
            //    0,
            //    0,
            //    0,
            //    0,
            //    0,
            //    IntPtr.Zero,
            //    IntPtr.Zero,
            //    Marshal.GetHINSTANCE(parent.GetType().Module),
            //    IntPtr.Zero
            //);

            m_hwnd = CreateWindowEx(
                WindowStyle.EX_NOACTIVATE,
                EVR_CLASS,
                EVR_WIN,
                0,
                0,
                0,
                0,
                0,
                IntPtr.Zero,
                IntPtr.Zero,
                hInstance,
                IntPtr.Zero
            );            
                
            if (m_hwnd == IntPtr.Zero)
            {
                int error = Marshal.GetLastWin32Error();
                throw new Win32Exception(error);
            }
        }
Beispiel #2
0
        public MessageForm(MainForm mf)
        {
            this.mf = mf;

            //RAWINPUTDEVICE[] Rid = new RAWINPUTDEVICE[2];

            //Rid[0].UsagePage = 0xFFBC;
            //Rid[0].Usage = 0x88;
            //Rid[0].Flags = RawInputDeviceFlags.None;
            //Rid[0].WindowHandle = this.Handle;

            //Rid[1].UsagePage = 0x0C;
            //Rid[1].Usage = 0x01;
            //Rid[1].Flags = RawInputDeviceFlags.None;
            //Rid[1].WindowHandle = this.Handle;

            RAWINPUTDEVICE[] rid = new RAWINPUTDEVICE[3];

            rid[0].UsagePage = 0xFFBC;
            rid[0].Usage = 0x88;
            rid[0].Flags = RawInputDeviceFlags.None;

            rid[1].UsagePage = 0x0C;
            rid[1].Usage = 0x01;
            rid[1].Flags = RawInputDeviceFlags.None;

            rid[2].UsagePage = 0x0C;
            rid[2].Usage = 0x80;
            rid[2].Flags = RawInputDeviceFlags.None;

            if (!RegisterRawInputDevices(rid, rid.Length, Marshal.SizeOf(rid[0])))
            {
                FileLogger.Log("Couldn't register eHome remote");
            }
            else
            {
                FileLogger.Log("Registered eHome remote");
            }
        }
Beispiel #3
0
 private static void ParsePls(MainForm form, string plsPath)
 {
     if (File.Exists(plsPath))
     {
         using (StreamReader sr = File.OpenText(plsPath))
         {
             string plsText = sr.ReadToEnd();
             ParsePlsText(form, plsText);
         }
     }
 }
Beispiel #4
0
        internal static void ParsePlsText(MainForm form, string plsText)
        {
            form.filename.Clear();

            MatchCollection mc = Regex.Matches(plsText, @"File\d=(.+)$", RegexOptions.IgnoreCase | RegexOptions.Multiline);
            foreach (Match m in mc)
            {
                if (m.Success)
                {
                    string mPath = m.Groups[1].Value.Trim();
                    if (File.Exists(mPath) || (mPath.ToLower().IndexOf(@"video_ts") > 0 && Directory.Exists(mPath)))
                        form.filename.Add(mPath);
                    else
                    {
                        if (form.ps.ReplacePaths != null && form.ps.ReplacePaths.Count > 0)
                        {
                            foreach (string rPath in form.ps.ReplacePaths)
                            {
                                string[] aRepPath = rPath.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                                if (aRepPath.Length > 1)
                                {
                                    string nmPath = mPath.ToLower().Replace(aRepPath[0].ToLower(), aRepPath[1]);
                                    if (File.Exists(nmPath))
                                    {
                                        form.filename.Add(nmPath);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #5
0
        static void Main(string[] args)
        {
            string mutexName = "EVRPlay";
            bool grantedOwnership = false;
            Mutex singleInstanceMutex = null;

            // Enable XP style controls
            Application.EnableVisualStyles();
            Application.DoEvents();            
                        
            try
            {
                theForm = new MainForm();
                //using (MainForm form = new MainForm())
                //{
                    if (theForm.ps.SingleInstance)
                    {
                        FileLogger.Log("Single Instance Mode");
                        
                        try
                        {
                            singleInstanceMutex = new Mutex(true, mutexName, out grantedOwnership);
                            FileLogger.Log("grantedOwnership: {0}", grantedOwnership);
                        }
                        catch (Exception ex)
                        {
                            FileLogger.Log("Error getting mutex: {0}", ex.ToString());
                        }
                        
                        if (!(grantedOwnership))
                        {
                            using (EpClient epc = new EpClient())
                            {
                                if (args.Length > 0)
                                    epc.PlayFile(args[0]);
                                else
                                    epc.Focus();
                            }
                            return;
                        }
                        else
                        {
                            theForm.eps = new EpServer();
                        }
                    }

                    if (theForm.ps.PriorityClass > 0)
                    {
                        using (Process cp = Process.GetCurrentProcess())
                            cp.PriorityClass = (ProcessPriorityClass)theForm.ps.PriorityClass;
                    }

                    if (args.Length > 0)
                    {
                        List<string> lArgs = new List<string>();
                        lArgs.AddRange(args);
                        bool hasMedia = true;

                        if (lArgs.Contains("-d"))
                        {
                            FileLogger.Log("In Debug Mode");
                            DebugMode = true;
                            if (args.Length == 1)
                                hasMedia = false;
                        }

                        if (hasMedia)
                        {
                            FileLogger.Log("arg[0] = {0}", args[0]);
                            string mediaPath = args[0];

                            if (Path.GetExtension(mediaPath).ToLower() == ".pls")
                                ParsePls(theForm, mediaPath);
                            else
                                theForm.filename.Add(mediaPath);
                        }
                    }

                    theForm.Show();
                    ThreadPool.QueueUserWorkItem(new WaitCallback(theForm.OpenFile), OpenClipMode.None);

                    Application.Run(theForm);
                //}
            }
            catch (Exception ex)
            {
                FileLogger.Log("Main Error: {0}", ex.ToString());
            }
            finally
            {
                if (singleInstanceMutex != null)
                {
                    FileLogger.Log("Release mutex");
                    singleInstanceMutex.Close();
                }
                if (theForm != null)
                    theForm.Dispose();
            }
        }