//05-06-2008@Scott
        public static byte[] GetBytesFromMsg(IRMSG msg, IRPLAY[] plays)
        {
            int len = 0, offset = 0;

            byte[] allByteArray = new byte[MSG_Length + MAX_LEN * PLAY_Length];

            byte[] byteArray = ProcessInfo.MakeIRMSGToBytes(msg);

            len = ProcessInfo.MSG_Length;

            Buffer.BlockCopy(byteArray, 0, allByteArray, offset, len);

            offset += MSG_Length;

            for (int i = 0; i < MAX_LEN; i++)
            {
                byte[] bytePlayArray = ProcessInfo.MakeIRPLAYToBytes(plays[i]);

                len = ProcessInfo.PLAY_Length;

                Buffer.BlockCopy(bytePlayArray, 0, allByteArray, offset, len);

                offset += PLAY_Length;
            }

            return(allByteArray);
        }
        public static byte[] GetBytesFromMsg(IRMSG msg, IREDIT[] edits)
        {
            int len = 0, offset = 0;

            byte[] allByteArray = new byte[MSG_Length + MAX_LEN * EDIT_Length];

            byte[] byteArray = ProcessInfo.MakeIRMSGToBytes(msg);

            len = ProcessInfo.MSG_Length;

            Buffer.BlockCopy(byteArray, 0, allByteArray, offset, len);

            offset += MSG_Length;

            for (int i = 0; i < MAX_LEN; i++)
            {
                byte[] byteEditArray = ProcessInfo.MakeIREDITToBytes(edits[i]);

                len = ProcessInfo.EDIT_Length;

                Buffer.BlockCopy(byteEditArray, 0, allByteArray, offset, len);

                offset += EDIT_Length;
            }

            return(allByteArray);
        }
 public static void SetMsg(ref IRMSG msg, int nHwnd, int nMessage, int nWParam, int nLParam, string strDisc)
 {
     msg.nHwnd    = nHwnd;
     msg.nMessage = nMessage;
     msg.nWParam  = nWParam;
     msg.nLParam  = nLParam;
     msg.strDisc  = strDisc;
 }
 public static void SetMsg(ref IRMSG msg)
 {
     msg.nHwnd    = 0;
     msg.nMessage = 0;
     msg.nWParam  = 0;
     msg.nLParam  = 0;
     msg.strDisc  = null;
 }
        //05-06-2008@Scott
        public static void SendMemoryMessage(IRMSG msg, IRPLAY[] plays)
        {
            ProcessInfo.O_ShareMemoryFile.SetMemoryName(O_MemoryName);

            //byte[] byteArray = ProcessInfo.RawSerialize(msg);

            byte[] byteArray = ProcessInfo.GetBytesFromMsg(msg, plays);

            ProcessInfo.O_ShareMemoryFile.WriteMemoryInfo(ref byteArray[0], byteArray.Length);
        }
        public static void GetMessage(ref IRMSG msg)
        {
            int address = 0;

            ProcessInfo.I_ShareMemoryFile.ReadMemoryInfo(out address);

            ProcessInfo.SetMsg(ref msg);

            IntPtr ptr = new IntPtr(address);

            msg = (IRMSG)Marshal.PtrToStructure(ptr, typeof(IRMSG));

            Marshal.Release(ptr);
        }
        public static byte[] MakeIRMSGToBytes(IRMSG msg)
        {
            int len = 0, offset = 0, size = ProcessInfo.MSG_Length;

            byte[] allBytes = new byte[size];

            byte[] bytesHwnd = BitConverter.GetBytes(msg.nHwnd);

            len = bytesHwnd.Length;

            Buffer.BlockCopy(bytesHwnd, 0, allBytes, offset, len);

            offset += len;

            byte[] bytesMessage = BitConverter.GetBytes(msg.nMessage);

            len = bytesMessage.Length;

            Buffer.BlockCopy(bytesMessage, 0, allBytes, offset, len);

            offset += len;

            byte[] bytesWParam = BitConverter.GetBytes(msg.nWParam);

            len = bytesWParam.Length;

            Buffer.BlockCopy(bytesWParam, 0, allBytes, offset, len);

            offset += len;

            byte[] bytesLParam = BitConverter.GetBytes(msg.nLParam);

            len = bytesLParam.Length;

            Buffer.BlockCopy(bytesLParam, 0, allBytes, offset, len);

            offset += len;

            byte[] byteArray = System.Text.Encoding.Default.GetBytes(msg.strDisc);

            len = msg.strDisc.Length;

            Buffer.BlockCopy(byteArray, 0, allBytes, offset, len);

            return(allBytes);
        }
        //05-06-2008@Scott
        public static void OnSaveToEdl(object Sender, EventArgs e)
        {
            VideoInfoCollection m_videoInfo = PublicDBProvider.LoadVideoInfo(VideoPlayBackManager.DataSource, CurVideoPlayBackArgs.RowIndicators);

            if (m_videoInfo == null || m_videoInfo.Count == 0)
            {
                Webb.Utilities.WaitingForm.CloseWaitingForm();

                Webb.Utilities.TopMostMessageBox.ShowMessage("No Associated Plays", MessageBoxButtons.OK);

                mouse_event(0x0004, 0, 0, 0, 0);

                return;
            }

            if (VideoPlayBackManager.PublicDBProvider == null)
            {
                Webb.Utilities.TopMostMessageBox.ShowMessage("Can't find Data Provider.", MessageBoxButtons.OK);

                return;
            }

            int type = (int)VideoPlayBackManager.PublicDBProvider.DBSourceConfig.WebbDBType;

            if (type == (int)WebbDBTypes.WebbAdvantageFootball || (type > 0 && type < 9))
            {
                IRMSG msg = new IRMSG();

                ProcessInfo.SetMsg(ref msg, 0, 0x0204, 0, 0, "Save As EDL");

                IRPLAY[] plays = MakeSaveToEdl(m_videoInfo);

                ProcessInfo.SendMemoryMessage(msg, plays);

                return;
            }
        }
        public static void OnClickEvent(object Sender, EventArgs e)
        {
            if (IsDoubleClick(Sender))
            {
                return;
            }

            if (!CheckClickArgs(e))
            {
                return;
            }

            VideoPlayBackArgs m_Arg = e as VideoPlayBackArgs;

            CurVideoPlayBackArgs = m_Arg;

            if (CurEventArgs != null && CurEventArgs.Button == MouseButtons.Right)
            {            //Right click
                if (PublicBrowser == null)
                {
                    return;
                }

                ContextMenu menu = new ContextMenu(new MenuItem[] { new MenuItem("Save As Cutup", new EventHandler(OnSaveToEdl)) });

                System.Drawing.Point pos = Cursor.Position;

                menu.Show(PublicBrowser, pos);
            }
            else
            {            //left click
                Webb.Utilities.WaitingForm.ShowWaitingForm();

                try
                {
                    VideoInfoCollection m_videoInfo = PublicDBProvider.LoadVideoInfo(VideoPlayBackManager.DataSource, m_Arg.RowIndicators);

                    if (m_videoInfo == null || m_videoInfo.Count == 0)
                    {
                        Webb.Utilities.WaitingForm.CloseWaitingForm();

                        Webb.Utilities.TopMostMessageBox.ShowMessage("No Associated Video", MessageBoxButtons.OK);

                        mouse_event(0x0004, 0, 0, 0, 0);

                        return;
                    }
                    //If advantage report , don't play video , send message back to advantage.
                    if (VideoPlayBackManager.PublicDBProvider == null)
                    {
                        Webb.Utilities.TopMostMessageBox.ShowMessage("Can't find Data Provider.", MessageBoxButtons.OK);

                        return;
                    }

                    int type = (int)VideoPlayBackManager.PublicDBProvider.DBSourceConfig.WebbDBType;

                    if (type == (int)WebbDBTypes.WebbAdvantageFootball || (type > 0 && type < 9))
                    {
                        IRMSG msg = new IRMSG();

                        ProcessInfo.SetMsg(ref msg, 0, 0x0201, 0, 0, "Video Playback");

                        IREDIT[] edits = MakeEdits(m_videoInfo);

                        ProcessInfo.SendMemoryMessage(msg, edits);

                        Webb.Utilities.WaitingForm.CloseWaitingForm();

                        return;
                    }

//					MoviePlayer.VPManager.MoviePlayer.AddVideos(m_videoInfo);
//
//					if(m_videoInfo.Count > 0)
//					{
//						MoviePlayer.VPManager.MoviePlayer.ShowWindow();
//
//						MoviePlayer.VPManager.MoviePlayer.Play(PlayTypes.Play);
//					}
                }
                catch (Exception ex)
                {
                    Webb.Utilities.TopMostMessageBox.ShowMessage(string.Format("Click event error. Please contact Webb for help. Error message:{0}", ex.Message), MessageBoxButtons.OK);
                }
                finally
                {
                    Webb.Utilities.WaitingForm.CloseWaitingForm();
                }
            }
        }