Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <param name="evt"></param>
        private static void iconifyUI(object o, System.EventArgs evt)
        {
            cmdArgs       cmd       = (cmdArgs)o;
            String        retString = DisplayCastGlobals.PLAYER_CMD_SYNTAX_ERROR;
            NetworkStream strm      = cmd.clnt.GetStream();
            Boolean       iconify   = cmd.args.Equals("ICON");

#if !PLAYER_TASKBAR
            browserList.BeginUpdate();
#endif
            foreach (Streamer item in streamers)
            {
                String id = item.GetHashCode().ToString();

                if (cmd.streamer.Equals(id))
                {
                    if (iconify)
                    {
                        item.WindowState = FormWindowState.Minimized;
                    }
                    else
                    {
                        item.WindowState = FormWindowState.Normal;
                    }
                    retString = DisplayCastGlobals.PLAYER_CMD_SUCCESS;
                }
            }
#if !PLAYER_TASKBAR
            browserList.EndUpdate();
#endif

            byte[] bytes = Encoding.ASCII.GetBytes(retString);
            strm.Write(bytes, 0, bytes.Length);
            strm.Close();
        }
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (args != null && args.Length != 0)
            {
                cmdArgs tmpArgs = new cmdArgs(args);

                string   WaitForWindowName       = string.Empty;
                bool     WaitForForeGroundWindow = false;
                int      WaitTimeOut             = -1;
                DateTime startTime = DateTime.Now;

                if (tmpArgs.ArgExists("WindowName"))
                {
                    WaitForWindowName = tmpArgs.Values[tmpArgs.FindArgPos("WindowName")];
                }
                if (tmpArgs.ArgExists("ForeGroundWindowName"))
                {
                    WaitForWindowName       = tmpArgs.Values[tmpArgs.FindArgPos("ForeGroundWindowName")];
                    WaitForForeGroundWindow = true;
                }

                if (tmpArgs.ArgExists("WaitTimeOut"))
                {
                    int.TryParse(tmpArgs.Values[tmpArgs.FindArgPos("WaitTimeOut")], out WaitTimeOut);
                }

                if (WaitForWindowName != string.Empty)
                {
                    IntPtr tmpFoundWindowHandle = IntPtr.Zero;
                    WindowManagement.GetHandleFromPartialCaption(ref tmpFoundWindowHandle, WaitForWindowName);

                    while (tmpFoundWindowHandle == IntPtr.Zero || (WaitForForeGroundWindow && WindowManagement.GetForegroundWindow() != tmpFoundWindowHandle))
                    {
                        System.Threading.Thread.Sleep(250);
                        WindowManagement.GetHandleFromPartialCaption(ref tmpFoundWindowHandle, WaitForWindowName);

                        if (WaitTimeOut != -1)
                        {
                            TimeSpan tmpSpan = DateTime.Now - startTime;
                            if (WaitTimeOut <= tmpSpan.TotalMilliseconds)
                            {
                                System.Environment.Exit(1);
                            }
                        }
                    }
                }
            }

            System.Environment.Exit(0);
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <param name="evt"></param>
        private static void moveUI(object o, System.EventArgs evt)
        {
            cmdArgs       cmd       = (cmdArgs)o;
            String        retString = Shared.DisplayCastGlobals.PLAYER_CMD_SYNTAX_ERROR;
            NetworkStream strm      = cmd.clnt.GetStream();

            char[]   delimiters = { 'x' };
            String[] words      = cmd.args.Split(delimiters);
            if (words.Length != 4)
            {
                retString = Shared.DisplayCastGlobals.PLAYER_USAGE_MOVE + cmd.args;
            }
            else
            {
                int       x = Convert.ToInt32(words[0]), y = Convert.ToInt32(words[1]), w = Convert.ToInt32(words[2]), h = Convert.ToInt32(words[3]);
                Rectangle newLoc = new Rectangle(x, y, w, h);

#if !PLAYER_TASKBAR
                browserList.BeginUpdate();
#endif
                foreach (Streamer item in streamers)
                {
                    String id = item.GetHashCode().ToString();

                    if (cmd.streamer.Equals(id))
                    {
                        item.DesktopBounds = newLoc;
                        item.Show();

                        retString = DisplayCastGlobals.PLAYER_CMD_SUCCESS;
                    }
                }
#if !PLAYER_TASKBAR
                browserList.EndUpdate();
#endif
            }

            byte[] bytes = Encoding.ASCII.GetBytes(retString);
            strm.Write(bytes, 0, bytes.Length);
            strm.Close();
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <param name="evt"></param>
        private static void createUI(object o, System.EventArgs evt)
        {
            cmdArgs       cmd       = (cmdArgs)o;
            String        retString = DisplayCastGlobals.PLAYER_CMD_SYNTAX_ERROR;
            NetworkStream strm      = cmd.clnt.GetStream();
            Boolean       fs        = cmd.args.ToUpper().Equals("FULLSCREEN");

#if PLAYER_TASKBAR
            foreach (MenuItem item in streamersItem.MenuItems)
            {
#else
            browserList.BeginUpdate();
            foreach (ListViewItem item in browserList.Items)
            {
#endif
                NetService service = (NetService)item.Tag;

                if (service == null)
                {
                    continue;
                }

                if (service.Name.Equals(cmd.streamer))
                {
                    retString = showService(service, fs);

                    break;
                }
            }
#if !PLAYER_TASKBAR
            browserList.EndUpdate();
#endif
            byte[] bytes = Encoding.ASCII.GetBytes(retString);
            strm.Write(bytes, 0, bytes.Length);
            strm.Close();
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="o"></param>
        /// <param name="evt"></param>
        private static void closeUI(object o, System.EventArgs evt)
        {
            cmdArgs       cmd       = (cmdArgs)o;
            String        retString = DisplayCastGlobals.PLAYER_CMD_SYNTAX_ERROR;
            NetworkStream strm      = cmd.clnt.GetStream();
            Streamer      toDelete  = null;

#if !PLAYER_TASKBAR
            browserList.BeginUpdate();
#endif
            foreach (Streamer item in streamers)
            {
                String id = item.GetHashCode().ToString();

                // if (cmd.streamer.Equals("ALL") || cmd.streamer.Equals(id)) {
                if (cmd.streamer.StartsWith(id))
                {
                    item.Close();
                    toDelete = item;

                    retString = DisplayCastGlobals.PLAYER_CMD_SUCCESS;
                }
            }
#if !PLAYER_TASKBAR
            browserList.EndUpdate();
#endif

            if (toDelete != null)
            {
                streamers.Remove(toDelete);
            }

            byte[] bytes = Encoding.ASCII.GetBytes(retString);
            strm.Write(bytes, 0, bytes.Length);
            strm.Close();
        }
        public void ProcessParameters(object sender, string[] args)
        {
            // The form has loaded, and initialization will have been be done.

            // Add the command-line arguments to our textbox, just to confirm that
            // it reached here.

            lock (args)
            {
                if (args != null && args.Length != 0)
                {
                    txtArgs.Text += DateTime.Now.ToString("mm:ss.ff") + " ";

                    for (int i = 0; i < args.Length; i++)
                    {
                        txtArgs.Text += args[i] + " ";
                    }
                    txtArgs.Text += "\r\n";

                    if (FullScreenForm == null) // create the fullscreen form instance if she does not exist
                    {
                        FullScreenForm                     = new frmFullScreen();
                        this.Owner                         = FullScreenForm;
                        this.FormBorderStyle               = FormBorderStyle.None;
                        this.Left                          = (Screen.PrimaryScreen.Bounds.Width / 2 - this.Width / 2) + 1;
                        this.Top                           = (Screen.PrimaryScreen.Bounds.Height / 2 - this.Height / 2) + 1;
                        FullScreenForm.lblMainLable.Text   = "";
                        FullScreenForm.lblMainLable.Parent = FullScreenForm.pbBackground;
                        FullScreenForm.MainFormObj         = this;
                        FullScreenForm.Show();

                        Cursor.Position = new System.Drawing.Point(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);

                        _bFullScreenMode = true;
                    }

                    lock (FullScreenForm)
                    {
                        cmdArgs tmpArgs = new cmdArgs(args);

                        if (tmpArgs.ArgExists("Text"))
                        {
                            FullScreenForm.lblMainLable.Text = tmpArgs.Values[tmpArgs.FindArgPos("Text")];
                        }
                        if (tmpArgs.ArgExists("TextColor"))
                        {
                            FullScreenForm.lblMainLable.ForeColor = System.Drawing.ColorTranslator.FromHtml(tmpArgs.Values[tmpArgs.FindArgPos("TextColor")]);
                        }
                        if (tmpArgs.ArgExists("TextSize"))
                        {
                            FullScreenForm.lblMainLable.Font = new Font(FullScreenForm.lblMainLable.Font.FontFamily, float.Parse(tmpArgs.Values[tmpArgs.FindArgPos("TextSize")]), FullScreenForm.lblMainLable.Font.Style);
                        }
                        if (tmpArgs.ArgExists("BgImage"))
                        {
                            FullScreenForm.pbBackground.Image = new Bitmap(tmpArgs.Values[tmpArgs.FindArgPos("BgImage")]);
                            if (!FullScreenForm.Visible || FullScreenForm.Opacity == 0)
                            {
                                FullScreenForm.Update();
                                FullScreenForm.Opacity = 100;
                                this.Visible           = false;
                            }
                        }
                        if (tmpArgs.ArgExists("ReadMpBackground"))
                        {
                            if (FullScreenForm.RetrieveSplashBackground())
                            {
                                FullScreenForm.Update();
                                FullScreenForm.Opacity = 100;
                                this.Visible           = false;
                            }
                        }
                        if (tmpArgs.ArgExists("ObservateMpStartup"))
                        {
                            bool.TryParse(tmpArgs.Values[tmpArgs.FindArgPos("ObservateMpStartup")], out FullScreenForm.OberservateMPStartup);
                        }
                        if (tmpArgs.ArgExists("ForceForeground"))
                        {
                            bool.TryParse(tmpArgs.Values[tmpArgs.FindArgPos("ForceForeground")], out FullScreenForm.ForceForeground);
                        }
                        if (tmpArgs.ArgExists("CloseOnWindowName"))
                        {
                            FullScreenForm.CloseOnWindowName = tmpArgs.Values[tmpArgs.FindArgPos("CloseOnWindowName")];
                        }
                        if (tmpArgs.ArgExists("CloseOnForegroundWindowName"))
                        {
                            FullScreenForm.CloseOnForegroundWindowName = tmpArgs.Values[tmpArgs.FindArgPos("CloseOnForegroundWindowName")];
                        }
                        if (tmpArgs.ArgExists("CloseTimeOut"))
                        {
                            int.TryParse(tmpArgs.Values[tmpArgs.FindArgPos("CloseTimeOut")], out FullScreenForm.CloseTimeOut);
                        }

                        if (tmpArgs.ArgExists("Close"))
                        {
                            FullScreenForm.Close();
                        }
                    }
                }
                else
                {
                    Stream stream = this.GetType().Assembly.GetManifestResourceStream("FullScreenMsg.help.rtf");
                    txtArgs.LoadFile(stream, RichTextBoxStreamType.RichText);

                    this.ShowInTaskbar = true;
                    this.WindowState   = FormWindowState.Normal;
                    this.Show();
                }
            }
        }
Esempio n. 7
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="ar"></param>
        public static void ctrlBeginAcceptTcpClient(IAsyncResult ar) {
            TcpListener ctrlAddr = (TcpListener)ar.AsyncState;
            TcpClient clnt = ctrlAddr.EndAcceptTcpClient(ar);
            NetworkStream strm = clnt.GetStream();
            char[] delimiters = { ' ', '\t', '\r', '\n' };
            byte[] bytes = new byte[clnt.ReceiveBufferSize];

            ctrlAddr.BeginAcceptTcpClient(ctrlBeginAcceptTcpClient, ctrlAddr);
            // strm.BeginRead(bytes, 0, clnt.ReceiveBufferSize, ctrlCmdRead, state);

            strm.ReadTimeout = 5000;
            try {
                strm.Read(bytes, 0, clnt.ReceiveBufferSize);
            } catch (System.IO.IOException ioe) {
                Trace.WriteLine("FATAL: Timeout waiting for remote control: " + ioe.Message);
                strm.Close();
                return;
            }

            String cmdString = Encoding.UTF8.GetString(bytes);
            String[] words = cmdString.Split(delimiters);
            String cmd = words[0].ToUpper();

            switch (cmd) {
                case "SHOW": {
                        cmdArgs args = new cmdArgs(clnt, words[1], words[2]);
                        object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                        streamerList.BeginInvoke(new System.EventHandler(createUI), pList);
#else
                 browserList.BeginInvoke(new System.EventHandler(createUI), pList);
#endif
                    }
                    return;

                case "CLOSE": {
                        cmdArgs args = new cmdArgs(clnt, words[1]);
                        object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                        streamerList.BeginInvoke(new System.EventHandler(closeUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(closeUI), pList);
#endif
                    }
                    return;

                case "CLOSEALL": {
                        cmdArgs args = new cmdArgs(clnt, "ALL");
                        object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                        streamerList.BeginInvoke(new System.EventHandler(closeUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(closeUI), pList);
#endif
                    }
                    return;

                case "ICON": {
                        cmdArgs args = new cmdArgs(clnt, words[1], "ICON");
                        object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                        streamerList.BeginInvoke(new System.EventHandler(iconifyUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(iconifyUI), pList);
#endif
                    }
                    return;

                case "DICO": {
                        cmdArgs args = new cmdArgs(clnt, words[1], "DICO");
                        object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                        streamerList.BeginInvoke(new System.EventHandler(iconifyUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(iconifyUI), pList);
#endif
                    }
                    return;

                case "MOVE": {
                        cmdArgs args = new cmdArgs(clnt, words[1], words[2]);
                        object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                        streamerList.BeginInvoke(new System.EventHandler(moveUI), pList);
#else    
                browserList.BeginInvoke(new System.EventHandler(moveUI), pList);
#endif
                    }
                    return;

                default:
                    bytes = Encoding.ASCII.GetBytes(DisplayCastGlobals.PLAYER_CMD_SYNTAX_ERROR);
                    strm.Write(bytes, 0, bytes.Length);
                    strm.Close();
                    return;
            }
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ar"></param>
        public static void ctrlBeginAcceptTcpClient(IAsyncResult ar)
        {
            TcpListener   ctrlAddr = (TcpListener)ar.AsyncState;
            TcpClient     clnt     = ctrlAddr.EndAcceptTcpClient(ar);
            NetworkStream strm     = clnt.GetStream();

            char[] delimiters = { ' ', '\t', '\r', '\n' };
            byte[] bytes      = new byte[clnt.ReceiveBufferSize];

            ctrlAddr.BeginAcceptTcpClient(ctrlBeginAcceptTcpClient, ctrlAddr);
            // strm.BeginRead(bytes, 0, clnt.ReceiveBufferSize, ctrlCmdRead, state);

            strm.ReadTimeout = 5000;
            try {
                strm.Read(bytes, 0, clnt.ReceiveBufferSize);
            } catch (System.IO.IOException ioe) {
                Trace.WriteLine("FATAL: Timeout waiting for remote control: " + ioe.Message);
                strm.Close();
                return;
            }

            String cmdString = Encoding.UTF8.GetString(bytes);

            String[] words = cmdString.Split(delimiters);
            String   cmd   = words[0].ToUpper();

            switch (cmd)
            {
            case "SHOW": {
                cmdArgs  args  = new cmdArgs(clnt, words[1], words[2]);
                object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                streamerList.BeginInvoke(new System.EventHandler(createUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(createUI), pList);
#endif
            }
                return;

            case "CLOSE": {
                cmdArgs  args  = new cmdArgs(clnt, words[1]);
                object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                streamerList.BeginInvoke(new System.EventHandler(closeUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(closeUI), pList);
#endif
            }
                return;

            case "CLOSEALL": {
                cmdArgs  args  = new cmdArgs(clnt, "ALL");
                object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                streamerList.BeginInvoke(new System.EventHandler(closeUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(closeUI), pList);
#endif
            }
                return;

            case "ICON": {
                cmdArgs  args  = new cmdArgs(clnt, words[1], "ICON");
                object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                streamerList.BeginInvoke(new System.EventHandler(iconifyUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(iconifyUI), pList);
#endif
            }
                return;

            case "DICO": {
                cmdArgs  args  = new cmdArgs(clnt, words[1], "DICO");
                object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                streamerList.BeginInvoke(new System.EventHandler(iconifyUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(iconifyUI), pList);
#endif
            }
                return;

            case "MOVE": {
                cmdArgs  args  = new cmdArgs(clnt, words[1], words[2]);
                object[] pList = { args, System.EventArgs.Empty };
#if PLAYER_TASKBAR
                streamerList.BeginInvoke(new System.EventHandler(moveUI), pList);
#else
                browserList.BeginInvoke(new System.EventHandler(moveUI), pList);
#endif
            }
                return;

            default:
                bytes = Encoding.ASCII.GetBytes(DisplayCastGlobals.PLAYER_CMD_SYNTAX_ERROR);
                strm.Write(bytes, 0, bytes.Length);
                strm.Close();
                return;
            }
        }