Пример #1
0
        public Form1()
        {
            MulticamLog.Log(0, String.Format("MultiCam application version {0}", this.ProductVersion));

            ForceClosed = false;
            InitializeComponent();

            CheckAdminPrivileges();
            //CheckSkypeRunning();

            filterCommunicator = new MCFilterCommunicator();

            filterCommunicator.Message           += new MessageEventHandler(filterCommunicator_Message);
            filterCommunicator.ConnectHandler    += new EventHandler(filterCommunicator_Connect);
            filterCommunicator.DisconnectHandler += new EventHandler(filterCommunicator_Disconnect);
            filterCommunicator.NumCamerasHandler += new MCFilterNumCamerasHandler(filterCommunicator_NumCameras);

            skypeProxy.SkypeAttach              += new SkypeAttachHandler(skypeProxy_SkypeAttach);
            skypeProxy.SkypeResponse            += new SkypeResponseHandler(skypeProxy_SkypeResponse);
            skypeProxy.SkypeCommand             += new SkypeCommandHandler(skypeProxy_SkypeCommand);
            skypeProxy.SkypeProxyMessage        += new SkypeProxyMessageHandler(skypeProxy_SkypeProxyMessage);
            skypeProxy.AdvanceCameraHandler     += new EventHandler(skypeProxy_AdvanceCamera);
            skypeProxy.Ap2ApConnectHandler      += new EventHandler(skypeProxy_Ap2ApConnect);
            skypeProxy.NumCamerasHandler        += new SkypeProxyNumCamerasHandler(skypeProxy_NumCameras);
            skypeProxy.NumCamerasRequestHandler += new EventHandler(skypeProxy_NumCamerasRequest);
            skypeProxy.VersionRequestHandler    += new EventHandler(skypeProxy_VersionRequest);
            //skypeProxy.Connect();
            //skypeProxy.ConnectAp2Ap();

            HookManager.KeyDown += HookManager_KeyDown;

            GetStatus();
            UpdateStatus(status.ToString());
            CheckStatusInNewThread();
        }
Пример #2
0
        static void Main()
        {
            Form1 form1 = null;

            MulticamLog.Open();
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException);
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            bool done = false;

            while (!done)
            {
                try
                {
                    form1 = new Form1();
                    Application.Run(form1);
                    done = true;
                }
                catch (Exception e)
                {
                    MulticamLog.Log(e);
                    MessageBox.Show("MultiCam encountered an unexpected problem, " +
                                    "and will now close.\r\n" +
                                    "Please accept our apologies!");
                    // Application.Restart() caused problems, so gave up on it.
                    form1.Close();
                    form1.ForceClosed = true;
                    Application.Exit();
                    MulticamLog.Log(0, "*********** MultiCam restarting ****************");
                }
            }
            MulticamLog.Close();
        }
Пример #3
0
        private void CheckStatus()
        {
            bool done = false;

            while (!done)
            {
                try
                {
                    if (ForceClosed)
                    {
                        break;
                    }
                    filterCommunicator.CheckStatus();
                    if (ForceClosed)
                    {
                        break;
                    }
                    skypeProxy.CheckStatus();

                    Status prevStatus = status;
                    GetStatus();
                    if (!status.Equals(prevStatus))
                    {
                        UpdateStatus(status.ToString());
                    }

                    if (ForceClosed)
                    {
                        break;
                    }
                    done = FormClosingNow.WaitOne(5000);
                    if (ForceClosed)
                    {
                        break;
                    }
                }
                catch (Exception e)
                {
                    if (!ForceClosed)
                    {
                        MulticamLog.Log(e);
                        //MessageBox.Show(
                        //"MultiCam encountered an unexpected problem " +
                        //"while checking its connections,\r\n" +
                        //"but this is probably a temporary problem, so MultiCam will continue as normal.");
                    }
                }
            }
        }
Пример #4
0
        //private static void CheckSkypeRunning()
        //{
        //    bool done = false;
        //    while (!done)
        //    {
        //        Process[] processes = Process.GetProcessesByName("Skype");
        //        if (processes.Length == 0)
        //        {
        //            var result = MessageBox.Show("Skype does not appear to be running on this computer.\r\n" +
        //                "Please start Skype before continuing.",
        //                "MultiCam",
        //                MessageBoxButtons.OKCancel);
        //            if (result == DialogResult.Cancel)
        //            {
        //                Environment.Exit(0);
        //            }
        //        }
        //        else
        //        {
        //            done = true;
        //        }
        //    }
        //}

        private void AppendText(string text)
        {
            //if (this.textBox1.InvokeRequired)
            //{
            //    AlterTextCallback d = new AlterTextCallback(AppendText);
            //    this.Invoke(d, new object[] { text });
            //}
            //else
            //{
            MulticamLog.Log(20, text);
            //    try
            //    {
            //        textBox1.AppendText(text);
            //    }
            //    catch (ObjectDisposedException)
            //    {
            //        // Deliberately do nothing -- the UI is gone anyway
            //    }
            //}
        }
Пример #5
0
        private static void CheckAdminPrivileges()
        {
            bool elevated = false;

            // UacHelper.IsProcessElevated throws an exception on Windows XP,
            // which we don't care too much about, so log it and continue
            try
            {
                elevated = UacHelper.IsProcessElevated;
            }
            catch (Exception e)
            {
                MulticamLog.Log(e);
            }

            if (elevated)
            {
                MessageBox.Show("This program is running with administrator privileges,\r\n" +
                                "and Skype will therefore refuse to connect to it.\r\n" +
                                "Please run the program again, without administrator privileges.",
                                "MultiCam");
                Environment.Exit(0);
            }
        }