void nsBrowser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            Debug.WriteLine(String.Format("{0}: nsBrowser_DidFindService: {1}", System.Threading.Thread.CurrentThread.ManagedThreadId, service.Name));

            service.DidUpdateTXT += new NetService.ServiceTXTUpdated(ns_DidUpdateTXT);
            service.DidResolveService += new NetService.ServiceResolved(ns_DidResolveService);

            service.StartMonitoring();

            ListViewItem item = new ListViewItem(service.Name);
            item.Tag = service;

            if (moreComing)
            {
                waitingAdd.Add(item);
            }
            else
            {
                servicesList.BeginUpdate();
                while (waitingAdd.Count > 0)
                {
                    servicesList.Items.Add((ListViewItem)waitingAdd[0]);
                    waitingAdd.RemoveAt(0);
                }
                servicesList.Items.Add(item);
                servicesList.EndUpdate();
            }
        }
Exemple #2
0
        private void PrepareService()
        {
            m_publishService = new NetService(DOMAIN, TYPE, m_name, SERVICE_PORT);


            string macAddr = Utils.GetMacAddress();
            
            // AirPlay now shows everywhere :) not only in "Photos.app" and "Videos.app"
            var dicTXTRecord = new Dictionary<string, string>();
            dicTXTRecord.Add("model", "AppleTV2,1");

            dicTXTRecord.Add("deviceid", "58:55:CA:06:BD:9E");
            //dicTXTRecord.Add("deviceid", macAddr);

            // Bit field -> http://nto.github.com/AirPlay.html#servicediscovery-airplayservice
            dicTXTRecord.Add("features", "0x39f7");

            dicTXTRecord.Add("protovers", "1.0");
            dicTXTRecord.Add("srcvers", "101.10");

            // set to 1 to enable
            dicTXTRecord.Add("pw", "0");
            m_publishService.TXTRecordData = NetService.DataFromTXTRecordDictionary(dicTXTRecord);


            //add delegates for success/false
            m_publishService.DidPublishService += publishService_DidPublishService;
            m_publishService.DidNotPublishService += publishService_DidNotPublishService;

            m_isPrepared = true;
        }
        public void StartServer()
        {
            webServerKayak.StartServer();

            publishService = new NetService(_domain, _serviceName, _hostName, _port);
            publishService.DidPublishService += new NetService.ServicePublished(publishService_DidPublishService);
            publishService.DidNotPublishService += new NetService.ServiceNotPublished(publishService_DidNotPublishService);
            publishService.TXTRecordData = NetService.DataFromTXTRecordDictionary(ResponseMessageHelper.GetServerInfo());
            publishService.Publish();
        }
Exemple #4
0
        /// <summary>
        /// Called with the result of the call to DNSServiceResolve().
        ///
        /// If this object instance is configured with an <see cref="DNSService.InvokeableObject">InvokeableObject</see>,
        /// this method is called in a thread safe manner. Typically, this means it's called on the application main loop.
        /// </summary>
        /// <param name="sdRef">
        ///		The DNSServiceRef initialized by DNSServiceResolve().
        /// </param>
        /// <param name="flags">
        ///		Currently unused, reserved for future use.
        /// </param>
        /// <param name="interfaceIndex">
        ///		The interface on which the service was resolved.
        /// </param>
        /// <param name="errorCode">
        ///		Will be NoError (0) on success, otherwise will indicate the failure that occurred.
        ///		Other parameters are undefined if the errorCode is nonzero.
        /// </param>
        /// <param name="fullname">
        ///		The full service domain name, in the form [servicename].[protocol].[domain].
        ///		(This name is escaped following standard DNS rules, making it suitable for
        ///		passing to standard system DNS APIs such as res_query(), or to the
        ///		special-purpose functions included in this API that take fullname parameters.)
        /// </param>
        /// <param name="hosttarget">
        ///		The target hostname of the machine providing the service.  This name can
        ///		be passed to functions like gethostbyname() to identify the host's IP address.
        /// </param>
        /// <param name="port">
        ///		The port, in network byte order, on which connections are accepted for this service.
        /// </param>
        /// <param name="txtLen">
        ///		The length of the txt record, in bytes.
        /// </param>
        /// <param name="txtRecord">
        ///		The service's primary txt record, in standard txt record format.
        /// </param>
        /// <param name="context">
        ///		The context pointer that was passed to the callout.
        ///	</param>
        private void ResolveReply(IntPtr sdRef,
                                  DNSServiceFlags flags,
                                  UInt32 interfaceIndex,
                                  DNSServiceErrorType errorCode,
                                  String fullname,
                                  String hosttarget,
                                  UInt16 port,
                                  UInt16 txtLen,
                                  byte[] txtRecord,
                                  IntPtr context)
        {
            if (errorCode == DNSServiceErrorType.NoError)
            {
                // Update internal variables
                mHostName = hosttarget;
                mPort     = ((int)System.Net.IPAddress.NetworkToHostOrder((short)port) & 0x0000ffff);

                // We may want to update the txt record.
                // The service may not have a txt record yet if it's never been monitored or resolved before.
                // Also, if it's not currently being monitored, then the returned txt record may include updates
                if (mTXTRecordData == null || !NetService.ByteArrayCompare(mTXTRecordData, txtRecord))
                {
                    mTXTRecordData = txtRecord;

                    // Invoke delegate if set
                    if (DidUpdateTXT != null)
                    {
                        DidUpdateTXT(this);
                    }
                }

                // At this point we have a host name, but we don't have the actual IP address.
                // We could use the Windows API's (System.Net.Dns.BeginGetHostEntry) to
                // convert from host name to IP, but they're painfully slow.
                // According to the following website (and my own personal testing),
                // using DNSServiceQueryRecord is much faster:
                // http://lists.apple.com/archives/Bonjour-dev/2006/Jan/msg00008.html

                //AsyncCallback cb = new AsyncCallback(c.AsyncGetHostEntryCallback);
                //IAsyncResult ar = System.Net.Dns.BeginGetHostEntry(hosttarget, cb, c);

                // Begin the process of looking up the IP address(es)
                IPLookup();
            }
            else
            {
                Stop();
                if (DidNotResolveService != null)
                {
                    DNSServiceException exception = new DNSServiceException("DNSServiceResolve", errorCode);
                    DidNotResolveService(this, exception);
                }
            }
        }
        void publishService_DidNotPublishService(NetService service, DNSServiceException exception)
        {
            MessageBox.Show(String.Format("A DNSServiceException occured: {0}", exception.Message), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);

            serviceNameTextBox.Enabled = true;
            serviceTypeTextBox.Enabled = true;
            portTextBox.Enabled = true;

            startStopButton.Text = "Publish";
            startStopButton.Enabled = true;

            mPublishing = false;
        }
        public bool Publish()
        {
            // old style services
            foreach (var srv in Installation.GetInstalledServices())
            {
                if (srv.ToWebService() == null || !ZeroconfDiscoverer.serviceTypes.ContainsKey(srv.ToWebService().Value))
                    continue;

                Dictionary<string, string> additionalData = new Dictionary<string, string>();
                additionalData["hwAddr"] = String.Join(";", NetworkInformation.GetMACAddresses());
                additionalData["netbios-name"] = System.Environment.MachineName;
                if (ExternalAddress.GetAddress() != null)
                    additionalData["external-ip"] = ExternalAddress.GetAddress();

                NetService net = new NetService(ZeroconfDiscoverer.DOMAIN, ZeroconfDiscoverer.serviceTypes[srv.ToWebService().Value], Configuration.Services.GetServiceName(), srv.Port);
                net.AllowMultithreadedCallbacks = true;
                net.TXTRecordData = NetService.DataFromTXTRecordDictionary(additionalData);
                net.DidPublishService += new NetService.ServicePublished(PublishedService);
                net.DidNotPublishService += new NetService.ServiceNotPublished(FailedToPublishService);
                net.Publish();
                publishedServices.Add(net);
            }

            // new style service sets
            foreach (WebServiceSet set in Detector.CreateSetComposer().ComposeUnique())
            {
                Log.Debug("Publishing service set {0}", set);
                Dictionary<string, string> additionalData = new Dictionary<string, string>();
                additionalData["mac"] = String.Join(";", NetworkInformation.GetMACAddresses());
                additionalData["netbios-name"] = Environment.MachineName != null ? Environment.MachineName : String.Empty;
                additionalData["external-ip"] = ExternalAddress.GetAddress() != null ? ExternalAddress.GetAddress() : String.Empty;
                additionalData["meta"] = WCFUtil.GetCurrentRoot().Remove(WCFUtil.GetCurrentRoot().LastIndexOf("/MPExtended/") + 1);
                additionalData["mas"] = set.MAS != null ? set.MAS : String.Empty;
                additionalData["masstream"] = set.MASStream != null ? set.MASStream : String.Empty;
                additionalData["tas"] = set.TAS != null ? set.TAS : String.Empty;
                additionalData["tasstream"] = set.TASStream != null ? set.TASStream : String.Empty;
                additionalData["ui"] = set.UI != null ? set.UI : String.Empty;

                NetService net = new NetService(ZeroconfDiscoverer.DOMAIN, SET_SERVICE_TYPE, Configuration.Services.GetServiceName(), Configuration.Services.Port);
                net.AllowMultithreadedCallbacks = true;
                net.TXTRecordData = NetService.DataFromTXTRecordDictionary(additionalData);
                net.DidPublishService += new NetService.ServicePublished(PublishedService);
                net.DidNotPublishService += new NetService.ServiceNotPublished(FailedToPublishService);
                net.Publish();
                publishedServices.Add(net);
            }

            return true;
        }
        void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            servicesList.BeginUpdate();

            foreach (ServiceListEntry item in servicesList.Items)
            {
                if (item.Service == service)
                {
                    servicesList.Items.Remove(item);
                    break;
                }
            }

            servicesList.EndUpdate();
        }
Exemple #8
0
        private void BrowseReply(IntPtr sdRef,
                                 DNSServiceFlags flags,
                                 UInt32 interfaceIndex,
                                 DNSServiceErrorType errorCode,
                                 String serviceName,
                                 String regtype,
                                 String replyDomain,
                                 IntPtr context)
        {
            bool moreComing = ((flags & DNSServiceFlags.MoreComing) != 0);

            if ((flags & DNSServiceFlags.Add) != 0)
            {
                // Add
                NetService newService = new NetService(replyDomain, regtype, serviceName);
                newService.InheritInvokeOptions(this);

                foundServices.Add(newService);

                if (DidFindService != null)
                {
                    DidFindService(this, newService, moreComing);
                }
            }
            else
            {
                // Remove
                foreach (NetService service in foundServices)
                {
                    if (service.Name == serviceName && service.Type == regtype && service.Domain == replyDomain)
                    {
                        foundServices.Remove(service);
                        if (DidRemoveService != null)
                        {
                            DidRemoveService(this, service, moreComing);
                        }
                        break;
                    }
                }
            }
        }
Exemple #9
0
        public void PublishServices(List<Service> services)
        {
            if (!Configuration.Services.BonjourEnabled || !CheckBonjourInstallation())
            {
                return;
            }

            serviceName = GetServiceName();
            foreach (Service srv in services)
            {
                // We also send a list of usernames and password hashes, so that clients can detect if they match across MPExtended
                // installations.
                // Note: this is specifically introduced for aMPdroid. It will probably be changed to something more advanced in the
                // next release where we don't keep backwards-compatibility for this part. Please do not depend on the presence of
                // this property.
                HashAlgorithm hashAlg = MD5.Create();
                Dictionary<string, string> sendUsers = new Dictionary<string,string>();
                foreach(var user in Configuration.Services.Users)
                {
                    byte[] hash = hashAlg.ComputeHash(Encoding.UTF8.GetBytes(user.EncryptedPassword));
                    for (int i = 1; i < 1000; i++)
                    {
                        hash = hashAlg.ComputeHash(hash);
                    }
                    sendUsers.Add(user.Username, Convert.ToBase64String(hash, 0, 12));
                }

                // also publish IP address and username list
                Dictionary<string, string> additionalData = new Dictionary<string, string>();
                additionalData["hwAddr"] = String.Join(";", NetworkInformation.GetMACAddresses());
                additionalData["users"] = String.Join(";", sendUsers.Select(x => x.Key + ":" + x.Value));

                NetService net = new NetService(DOMAIN, srv.ZeroconfServiceType, serviceName, srv.Port);
                net.AllowMultithreadedCallbacks = true;
                net.TXTRecordData = NetService.DataFromTXTRecordDictionary(additionalData);
                net.DidNotPublishService += new NetService.ServiceNotPublished(FailedToPublishService);
                net.DidPublishService += new NetService.ServicePublished(PublishedService);
                net.Publish();
            }
            Log.Info("Published bonjour services");
        }
        private void DoPublish()
        {
            try
            {
                Debug.WriteLine(String.Format("Bonjour Version: {0}", NetService.DaemonVersion));
            }
            catch (Exception ex)
            {
                String message = ex is DNSServiceException ? "Bonjour is not installed!" : ex.Message;
                MessageBox.Show(message, "Critical Error", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Application.Exit();
            }

            String domain = "";
            String type = serviceTypeTextBox.Text;
            String name = serviceNameTextBox.Text;
            int port = Int32.Parse(portTextBox.Text);

            publishService = new NetService(domain, type, name, port);

            publishService.DidPublishService += new NetService.ServicePublished(publishService_DidPublishService);
            publishService.DidNotPublishService += new NetService.ServiceNotPublished(publishService_DidNotPublishService);

            /* HARDCODE TXT RECORD */
            System.Collections.Hashtable dict = new System.Collections.Hashtable();
            dict.Add("txtvers", "1");
            publishService.TXTRecordData = NetService.DataFromTXTRecordDictionary(dict);

            publishService.Publish();

            serviceNameTextBox.Enabled = false;
            serviceTypeTextBox.Enabled = false;
            portTextBox.Enabled = false;

            startStopButton.Enabled = false;
            startStopButton.Text = "Publishing...";

            mPublishing = true;
        }
Exemple #11
0
        public PlexServer(string ServerTestUrl)
        {
            Router router = new Router();
            router.AddController("library", new Library());
            router.AddController("resources", new Resources());
            router.AddController("manage", new Manage());
            listener = new WebServer(ServerTestUrl, router);
            listener.Start();

            String domain = "";
            String type = "_plexmediasvr._tcp";
            String name = "WinPlex Media Server";
            int port = 32400;

            NetService publishService = new NetService(domain, type, name, port);

            /* HARDCODE TXT RECORD */
            System.Collections.Hashtable dict = new System.Collections.Hashtable();
            dict.Add("txtvers", "1");
            publishService.TXTRecordData = NetService.DataFromTXTRecordDictionary(dict);

            publishService.Publish();
        }
 protected void NetServiceDidUpdateTXTRecordData(NetService sender)
 {
     logger.TraceEvent(TraceEventType.Verbose, 0, String.Format("{0}: didUpdateTXTRecordData", sender));
 }
 protected void NetServiceDidResolveAddress(NetService sender)
 {
     logger.TraceEvent(TraceEventType.Information, 0, String.Format("{0}: didResolveAddress", sender));
     SDService service = new SDService(sender.Name, sender.HostName, (ushort) sender.Port, sender.Type, null);
     bool ownService = false;
     foreach (NetService netService in this.netServices.Values)
     {
         if (netService.Name.Equals(sender.Name))
         {
             ownService = true;
             break;
         }
     }
     OnServiceFound(service, ownService);
 }
 protected void NetServiceDidPublish(NetService sender)
 {
     logger.TraceEvent(TraceEventType.Verbose, 0, String.Format("{0}: didPublish", sender));
 }
Exemple #15
0
        void nsBrowser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            ListViewItem item = new ListViewItem(service.Name);
            item.Tag = service;

            if (moreComing)
            {
                waitingAdd.Add(item);
            }
            else
            {
                servicesList.BeginUpdate();
                while (waitingAdd.Count > 0)
                {
                    servicesList.Items.Add((ListViewItem)waitingAdd[0]);
                    waitingAdd.RemoveAt(0);
                }
                servicesList.Items.Add(item);
                servicesList.EndUpdate();
            }
        }
 private void DiscoverRemovedService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     HandleDiscoverEvent(service, "Disappearing", ServiceDisappeared);
 }
 private void DiscoverResolvedService(NetService service)
 {
     HandleDiscoverEvent(service, "Found", ServiceFound);
 }
Exemple #18
0
 /// <summary>
 /// Detected bonjour service was resolved
 /// </summary>
 /// <param name="service"></param>
 void Remote_DidResolveService(NetService service)
 {
     servers.Add(service);
     if (!buttonConnectDetected.Enabled)
     {
         buttonConnectDetected.Enabled = true;
     }
 }
 void _browser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     service.DidResolveService += new NetService.ServiceResolved(service_DidResolveService);
     service.ResolveWithTimeout(60);
 }
        void service_DidResolveService(NetService service)
        {
            IPEndPoint addr = (IPEndPoint)service.Addresses[0];

            int idx = comboBox1.Items.Add(service.HostName + "(" + addr.Address.ToString() + ")" );
        }
Exemple #21
0
 void resolve_DidResolveService(NetService service)
 {
     selectedService = service;
 }
Exemple #22
0
        private void Resolve(NetService resolve)
        {
            if (resolving != null)
            {
                resolving.Stop();
            }

            resolve.DidResolveService += new NetService.ServiceResolved(resolve_DidResolveService);
            resolve.ResolveWithTimeout(10); /* FIXME timeout doesn't work */
        }
Exemple #23
0
        void nsBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing)
        {
            servicesList.BeginUpdate();

            foreach (ListViewItem item in servicesList.Items)
            {
                if (item.Tag == service)
                    servicesList.Items.Remove(item);
            }

            servicesList.EndUpdate();
        }
Exemple #24
0
 /// <summary>
 /// Did find bonjour service
 /// </summary>
 /// <param name="browser"></param>
 /// <param name="service"></param>
 /// <param name="moreComing"></param>
 void bonjourBrowser_DidFindService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     service.DidResolveService += new NetService.ServiceResolved(Remote_DidResolveService);
     service.ResolveWithTimeout(5);
 }
Exemple #25
0
 /// <summary>
 /// Bonjour service vanished
 /// </summary>
 /// <param name="browser"></param>
 /// <param name="service"></param>
 /// <param name="moreComing"></param>
 void bonjourBrowser_DidRemoveService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     servers.Remove(service);
     if (servers.Count == 0)
     {
         buttonConnectDetected.Enabled = false;
     }
 }
        /// <summary>
        /// Publish a service.
        /// </summary>
        /// <param name="type">
        /// Type of the service to publish.
        /// <para>
        /// `type` must contain both the service type and transport layer information. To
        /// ensure that the mDNS responder searches for services, as opposed to hosts,
        /// prefix both the service name and transport layer name with an underscore
        /// character ("_"). For example, to publish an HTTP service on TCP, you would
        /// use the type string `@"_http._tcp."`. Note that the period character at the end
        /// of the string, which indicates that the domain name is an absolute name, is
        /// required. It will be automatically set if it does not exists.
        /// </para>
        /// </param>
        /// <param name="port">Port of the service to publish.</param>
        /// <param name="name">Name of the service to publish.</param>
        /// <param name="domain">Domain in which to publish the service.</param>
        /// <param name="TXTRecord">TXT record of the service to publish.</param>
        public bool PublishService(String type, ushort port, String name, String domain, Dictionary<String, String> TXTRecord)
        {
            if (!type.EndsWith("."))
            {
                type += ".";
            }

            String key = this.KeyForPublish(type, domain, port);

            if (this.IsPublishing)
            {
                if (netServices.ContainsKey(key))
                {
                    logger.TraceEvent(TraceEventType.Warning, 0, String.Format("Already publishing service of type {0} in domain {1} on port {2}", type, domain, port));
                    return false;
                }
            }

            this.IsPublishing = true;

            NetService netService = new NetService(domain, type, name, port);
            netService.AllowApplicationForms = false;
            netService.AllowMultithreadedCallbacks = true;

            netService.DidPublishService += new NetService.ServicePublished(NetServiceDidPublish);
            netService.DidNotPublishService += new NetService.ServiceNotPublished(NetServiceDidNotPublish);

            /* HARDCODE TXT RECORD */
            System.Collections.Hashtable dict = new System.Collections.Hashtable();
            dict.Add("txtvers", "1");
            netService.TXTRecordData = NetService.DataFromTXTRecordDictionary(dict);

            netServices[key] = netService;

            netService.Publish();

            logger.TraceEvent(TraceEventType.Information, 0, String.Format("Published service of type {0} in domain {1} on port {2}", type, domain, port));

            return true;
        }
 private void DiscoverFoundService(NetServiceBrowser browser, NetService service, bool moreComing)
 {
     service.DidResolveService += new NetService.ServiceResolved(DiscoverResolvedService);
     service.ResolveWithTimeout(TIMEOUT);
 }
 protected void NetServiceBrowserDidRemoveService(NetServiceBrowser aNetServiceBrowser, NetService netService, bool moreComing)
 {
     logger.TraceEvent(TraceEventType.Verbose, 0, String.Format("{0}: didRemoveService: {1}", aNetServiceBrowser, netService));
     SDService service = new SDService(netService.Name, netService.HostName, (ushort)netService.Port, netService.Type, null);
     OnServiceLost(service);
 }
        private void HandleDiscoverEvent(NetService service, string logText, EventHandler<ServiceEventArgs> eventHandler)
        {
            foreach (var address in service.Addresses)
            {
                IPEndPoint endpoint = (IPEndPoint)address;
                if (NetworkInformation.IsLocalAddress(endpoint.Address) || !NetworkInformation.IsValid(endpoint.Address))
                    continue;

                if (serviceTypes.ContainsValue(service.Type))
                {
                    WebService webService = serviceTypes.Where(x => x.Value == service.Type).First().Key;
                    Log.Debug("Zeroconf: {0} {1} ({2}) at {3}:{4}", logText, webService, service.Type, endpoint.Address, endpoint.Port);
                    if (eventHandler != null)
                    {
                        eventHandler(this, new ServiceEventArgs()
                        {
                            Service = webService,
                            Endpoint = endpoint
                        });
                    }
                }
            }
        }
 protected void NetServiceDidNotResolve(NetService sender, DNSServiceException exception)
 {
     logger.TraceEvent(TraceEventType.Verbose, 0, String.Format("{0}: didNotResolve: {1}", sender, exception));
 }
 protected void NetServiceBrowserDidFindService(NetServiceBrowser aNetServiceBrowser, NetService netService, bool moreComing)
 {
     logger.TraceEvent(TraceEventType.Information, 0, String.Format("{0}: didFindService: {1}", aNetServiceBrowser, netService));
     netService.DidUpdateTXT += new NetService.ServiceTXTUpdated(NetServiceDidUpdateTXTRecordData);
     netService.DidResolveService += new NetService.ServiceResolved(NetServiceDidResolveAddress);
     netService.DidNotResolveService += new NetService.ServiceNotResolved(NetServiceDidNotResolve);
     netService.ResolveWithTimeout(10);
 }
Exemple #32
0
        private void Main_Load(object sender, EventArgs e)
        {
            //this.Hide();
            nsBrowser.InvokeableObject = this;
            nsBrowser.DidFindService += new NetServiceBrowser.ServiceFound(nsBrowser_DidFindService);
            nsBrowser.DidRemoveService += new NetServiceBrowser.ServiceRemoved(nsBrowser_DidRemoveService);

            if (!mBrowsing)
            {

                nsBrowser.SearchForService("_raop._tcp", "");

                mBrowsing = true;
            }
            else
            {
                nsBrowser.Stop();

                if (resolving != null)
                {
                    resolving.Stop();
                    resolving = null;
                }
                ClearResolveInfo();
                servicesList.BeginUpdate();
                servicesList.Items.Clear();
                servicesList.EndUpdate();

                mBrowsing = false;
            }

            VolumeBar.Value = int.Parse(DSInfo.Tables[0].Rows[0].ItemArray[1].ToString());

            notifyIcon.Text = "";

            contextMenu.Items[0].Visible = true;
            contextMenu.Items[1].Visible = false;
            contextMenu.Items[3].Enabled = true;
            VolumeGB.Enabled = false;
            ConnectionGB.Enabled = true;
            StartButton.Enabled = true;
            StopButton.Enabled = false;
        }