Exemple #1
0
        public async Task GetBluetoothClients()
        {
            BluetoothClient client = new BluetoothClient();

            if (InTheHand.Net.Bluetooth.BluetoothRadio.PrimaryRadio == null)
            {
                MessageBox.Show("Failed to discover Bluetooth devices", "Can't find Devices", MessageBoxButton.OK);

                return;
            }
            //client.BeginDiscoverDevices(10, false, false, true, true, null, null);
            if (localComponent != null)
            {
                localComponent.Dispose();
                App.Current.Dispatcher.Invoke((Action) delegate
                {
                    observableCollection.Clear();
                    latestsearch.Clear();
                });
            }
            localComponent = new BluetoothComponent(client);
            localComponent.DiscoverDevicesProgress += LocalComponent_DiscoverDevicesProgress;
            localComponent.DiscoverDevicesComplete += LocalComponent_DiscoverDevicesComplete;
            localComponent.DiscoverDevicesAsync(255, false, false, true, false, null);

            return;
            //return null;
        }
        /// <summary>
        /// Disposes the Bluetooth connection
        /// </summary>
        private static void DisposeBTConnection()
        {
            localComponent.DiscoverDevicesProgress -= new EventHandler <DiscoverDevicesEventArgs>(DiscoverDevices);
            localComponent.DiscoverDevicesComplete -= new EventHandler <DiscoverDevicesEventArgs>(DiscoverDevicesComplete);
            localComponent.Dispose();

            localClient.Close();
            localClient.Dispose();
            connected  = false;
            connecting = false;
        }
Exemple #3
0
 // Arrêtre la recherche
 public void StopSearchDevicesAsync()
 {
     localComponent.Dispose();
     searchCompleted.Invoke(this, new EventArgs());
 }
Exemple #4
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);
        }
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);
        }