Exemple #1
0
 public LocationServices()
 {
     MSE = new QueryMSE();
     myMacs = getWIFIMACAddresses();
     if (myMacs.Count == 0)
         myMacs.Add("00:00:00:00:00:00");
 }
Exemple #2
0
 public LocationServices()
 {
     MSE    = new QueryMSE();
     myMacs = getWIFIMACAddresses();
     if (myMacs.Count == 0)
     {
         myMacs.Add("00:00:00:00:00:00");
     }
 }
Exemple #3
0
        static void Main() {
            // Catchall for all uncaught exceptions !!
            AppDomain.CurrentDomain.UnhandledException += delegate(object sender, UnhandledExceptionEventArgs args) {
                // Application.Restart();

                var exception = (Exception)args.ExceptionObject;
                MessageBox.Show("FATAL: Unhandled - " + exception.Message, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(1);
            };

            try {
                TXTrecords.Add("machineName", System.Environment.MachineName);
                TXTrecords.Add("osVersion", System.Environment.OSVersion.VersionString);
                TXTrecords.Add("userid", System.Environment.UserName);
#if USE_BLUETOOTH
                if (BluetoothRadio.IsSupported) {
                    try {
                        TXTrecords.Add("bluetooth", BluetoothRadio.PrimaryRadio.LocalAddress.ToString("C").Replace(":", "-").ToLower());
                    } catch {
                        TXTrecords.Add("bluetooth", "NotSupported");
                    }
                } else
#endif
                    TXTrecords.Add("bluetooth", "NotSupported");
                allScreen = Screen.AllScreens;
                for (int i=0; i < allScreen.Length; i++)
                    TXTrecords.Add("screen" + i,  allScreen[i].Bounds.X + "x" + allScreen[i].Bounds.Y + "x" + allScreen[i].Bounds.Width + "x" + allScreen[i].Bounds.Height);

                // TXTrecords.Add("screenWidth", System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width.ToString());
                // TXTrecords.Add("screenHeight", System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height.ToString());

                TcpListener ctrlAddr = new TcpListener(IPAddress.Any,  0 );
                ctrlAddr.Start();

                IPEndPoint sep = (IPEndPoint)ctrlAddr.LocalEndpoint;
                Debug.Assert(sep.Port != 0);

                String id, nm;
                using (RegistryKey dcs = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("FXPAL").CreateSubKey("DisplayCast").CreateSubKey("Player")) {
                    if (dcs.GetValue("uid") == null)
                        dcs.SetValue("uid", System.Guid.NewGuid().ToString("D"));
                    id = dcs.GetValue("uid").ToString();

                    if (dcs.GetValue("name") == null)
                        dcs.SetValue("name", System.Environment.UserName);
                    nm = dcs.GetValue("Name").ToString();
                    TXTrecords.Remove("name");
                    TXTrecords.Add("name", nm);
                }

                try {
                    nsPublisher = new NetService(Shared.DisplayCastGlobals.BONJOURDOMAIN, Shared.DisplayCastGlobals.PLAYER, id, sep.Port);
                    nsPublisher.DidPublishService += new NetService.ServicePublished(publishService_DidPublishService);
                    nsPublisher.DidNotPublishService += new NetService.ServiceNotPublished(publishService_DidNotPublishService);
                    nsPublisher.TXTRecordData = NetService.DataFromTXTRecordDictionary(TXTrecords);
                    nsPublisher.AllowApplicationForms = true;
                    nsPublisher.Publish();
                } catch {
                    MessageBox.Show("Apple Bonjour not installed. Pick up a local copy from https://developer.apple.com/opensource/", "FATAL", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Environment.Exit(1);
                }
                
                // PlayerRemoteControl rc = new PlayerRemoteControl(ctrlAddr);
                // Thread ctrlThread = new Thread(new ThreadStart(rc.process));
                // ctrlThread.Name = "processNewControl";
                // ctrlThread.Start();

                ctrlAddr.BeginAcceptTcpClient(ctrlBeginAcceptTcpClient, ctrlAddr);

                MSE = new QueryMSE();
                myMac = getWIFIMACAddress();
                // if (myMac == null)
                //    myMac = displaycast;

                if (myMac != null) {
                    using (RegistryKey dcs = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("FXPAL").CreateSubKey("DisplayCast").CreateSubKey("Player")) {
                        discloseLocation = Convert.ToBoolean(dcs.GetValue("discloseLocation", false));
                    }

                    locThread = new Thread(new ThreadStart(monitorMyLocation));
                    locThread.Start();
                }

            } catch (Exception e) {
                MessageBox.Show("FATAL: Unhandled - " + e.StackTrace ,
                   "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Environment.Exit(1);
            }
            try {
                streamerList = new StreamerList();
                Application.Run(streamerList);
            } catch (Exception e) {
                MessageBox.Show("FATAL: Cannot start streamerList - " + e.StackTrace);
                Environment.Exit(1);
            }
        }
Exemple #4
0
        /// <summary>
        /// 
        /// </summary>
        public StreamerList() {
            InitializeComponent();

#if PLAYER_TASKBAR
            this.ShowInTaskbar = false;

            streamersItem = new System.Windows.Forms.MenuItem();
            streamersItem.Text = "W&atch Streamer";
            streamersItem.MenuItems.Add("-");

            MSE = new QueryMSE();
            myMac = getWIFIMACAddress();
            /* if (myMac == null)
                myMac = displaycast; */
            if (myMac != null) {
                locationItem = new System.Windows.Forms.MenuItem();
                locationItem.Text = "Disclose location?";
                // locationItem.Index = 4;
                // playersItem.Index++;
                // archiversItem.Index++;
                locationItem.Click += new System.EventHandler(locationChecked);
                using (RegistryKey dcs = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("FXPAL").CreateSubKey("DisplayCast").CreateSubKey("Streamer")) {
                    locationItem.Checked = Convert.ToBoolean(dcs.GetValue("discloseLocation"));
                }
                discloseLocation = locationItem.Checked;

                locThread = new Thread(new ThreadStart(monitorMyLocation));
                locThread.Start();
            }

            changeNameItem = new System.Windows.Forms.MenuItem();
            changeNameItem.Text = "C&hange Name";
            changeNameItem.Click += new System.EventHandler(changeName);

            aboutItem = new System.Windows.Forms.MenuItem();
            aboutItem.Text = "A&bout...";
            aboutItem.Click += new System.EventHandler(about);

            exitItem = new System.Windows.Forms.MenuItem();
            exitItem.Text = "E&xit";
            exitItem.Click += new System.EventHandler(exitItem_Click);

            contextMenu = new System.Windows.Forms.ContextMenu();

            contextMenu.MenuItems.Add(streamersItem);
            contextMenu.MenuItems.Add("-");

            if (locationItem != null)
                contextMenu.MenuItems.Add(locationItem);

            contextMenu.MenuItems.Add(changeNameItem);

            contextMenu.MenuItems.Add("-");
            contextMenu.MenuItems.Add(aboutItem);

            contextMenu.MenuItems.Add("-");
            contextMenu.MenuItems.Add(exitItem);

            iComponents = new System.ComponentModel.Container();
            notifyIcon = new NotifyIcon(iComponents);
            notifyIcon.Icon = new Icon("Player.ico");
            // notifyIcon.Icon = Streamer.Properties.Resources.Streamer;
            // notifyIcon.Icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("FXPAL.DisplayCast.Streamer.Streamer.ico"));

            notifyIcon.ContextMenu = contextMenu;
            notifyIcon.Text = "FXPAL Displaycast Player";
            notifyIcon.Visible = true;
            notifyIcon.DoubleClick += new System.EventHandler(this.notifyIcon_DoubleClick);

            nsBrowser = new NetServiceBrowser();
            nsBrowser.InvokeableObject = this;
            nsBrowser.DidFindService += new NetServiceBrowser.ServiceFound(nsBrowser_DidFindService);
            nsBrowser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(nsBrowser_DidRemoveService);
            nsBrowser.AllowApplicationForms = true;
            nsBrowser.SearchForService(Shared.DisplayCastGlobals.STREAMER, Shared.DisplayCastGlobals.BONJOURDOMAIN);
#endif
        }
Exemple #5
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="publishService"></param>
        /// <param name="TXTrecords"></param>
        /// <param name="id"></param>
        public Console(NetService publishService, Hashtable TXTrecords, String id)
        {
            InitializeComponent();

            #if USE_BLUETOOTH
            // If Bluetooth is supported, then scan for nearby players
            if (BluetoothRadio.IsSupported) {
                try {
                    bt = new BluetoothComponent();

                    bt.DiscoverDevicesComplete += new EventHandler<DiscoverDevicesEventArgs>(discoverComplete);
                    bt.DiscoverDevicesAsync(100, true, true, true, true, null);
                } catch {
                    if (bt != null)
                        bt.Dispose();
                    // Something is wrong with bluetooth module
                }
            }
            #endif

            this.publishService = publishService;
            this.TXTrecords = TXTrecords;
            this.id = id;

            playersItem = new System.Windows.Forms.MenuItem();
            playersItem.Text = "P&roject Me";
            playersItem.MenuItems.Add("-");

            archiversItem = new System.Windows.Forms.MenuItem();
            archiversItem.Text = "A&rchive Me";
            archiversItem.MenuItems.Add("-");

            #if USE_WIFI_LOCALIZATION
            MSE = new QueryMSE();
            myMac = getWIFIMACAddress();
            /* if (myMac == null)
                myMac = displaycast; */
            if (myMac != null) {
                locationItem = new System.Windows.Forms.MenuItem();
                locationItem.Text = "Disclose location?";
                // locationItem.Index = 4;
                // playersItem.Index++;
                // archiversItem.Index++;
                locationItem.Click += new System.EventHandler(locationChecked);
                using (RegistryKey dcs = Registry.CurrentUser.CreateSubKey("Software").CreateSubKey("FXPAL").CreateSubKey("DisplayCast").CreateSubKey("Streamer")) {
                    locationItem.Checked = Convert.ToBoolean(dcs.GetValue("discloseLocation"));
                }
                discloseLocation = locationItem.Checked;

                locThread = new Thread(new ThreadStart(monitorMyLocation));
                locThread.Start();
            }
            #endif

            Screen[] screens = Screen.AllScreens;
            if (screens.Length > 1) {
                desktopItem = new System.Windows.Forms.MenuItem();
                desktopItem.Text = "D&esktop to stream";

                desktopItem.MenuItems.Add("-");
                foreach (Screen screen in screens) {
                    MenuItem item = new MenuItem();
                    System.Drawing.Rectangle bounds = screen.Bounds;

                    item.Text = "DESKTOP: " + bounds.X + "x" + bounds.Y + " " + bounds.Width + "x" + bounds.Height;
                    item.Click += new System.EventHandler(selectDesktop);
                    item.Select += new System.EventHandler(selectDesktop);
                    item.Tag = screen;

                    desktopItem.MenuItems.Add(item);
                }
            }

            changeNameItem = new System.Windows.Forms.MenuItem();
            changeNameItem.Text = "C&hange Name";
            changeNameItem.Click += new System.EventHandler(changeName);

            aboutItem = new System.Windows.Forms.MenuItem();
            aboutItem.Text = "A&bout...";
            aboutItem.Click += new System.EventHandler(about);

            exitItem = new System.Windows.Forms.MenuItem();
            exitItem.Text = "E&xit";
            exitItem.Click += new System.EventHandler(exitItem_Click);

            contextMenu = new System.Windows.Forms.ContextMenu();

            contextMenu.MenuItems.Add(playersItem);
            contextMenu.MenuItems.Add(archiversItem);
            contextMenu.MenuItems.Add("-");

            if (locationItem != null)
                contextMenu.MenuItems.Add(locationItem);

            if (desktopItem != null)
                contextMenu.MenuItems.Add(desktopItem);
            contextMenu.MenuItems.Add(changeNameItem);

            contextMenu.MenuItems.Add("-");
            contextMenu.MenuItems.Add(aboutItem);

            contextMenu.MenuItems.Add("-");
            contextMenu.MenuItems.Add(exitItem);

            iComponents = new System.ComponentModel.Container();
            notifyIcon = new NotifyIcon(iComponents);
            notifyIcon.Icon = new Icon("Streamer.ico");
            // notifyIcon.Icon = Streamer.Properties.Resources.Streamer;
            // notifyIcon.Icon = new Icon(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("FXPAL.DisplayCast.Streamer.Streamer.ico"));

            notifyIcon.ContextMenu = contextMenu;
            notifyIcon.Text = "FXPAL Displaycast Streamer";
            notifyIcon.Visible = true;
            notifyIcon.DoubleClick += new System.EventHandler(this.notifyIcon_DoubleClick);

            player = new NetServiceBrowser();
            //player.InvokeableObject = this;
            player.AllowMultithreadedCallbacks = true;
            player.DidFindService += new NetServiceBrowser.ServiceFound(nsBrowser_DidFindService);
            player.DidRemoveService += new NetServiceBrowser.ServiceRemoved(nsBrowser_DidRemoveService);
            player.SearchForService(Shared.DisplayCastGlobals.PLAYER, Shared.DisplayCastGlobals.BONJOURDOMAIN);

            archiver = new NetServiceBrowser();
            // archiver.InvokeableObject = this;
            archiver.AllowMultithreadedCallbacks = true;
            archiver.DidFindService += new NetServiceBrowser.ServiceFound(nsBrowser_DidFindService);
            archiver.DidRemoveService += new NetServiceBrowser.ServiceRemoved(nsBrowser_DidRemoveService);
            archiver.SearchForService(Shared.DisplayCastGlobals.ARCHIVER, Shared.DisplayCastGlobals.BONJOURDOMAIN);
        }