private void MyWindow_Loaded(object sender, RoutedEventArgs e)
        {
            // Capture the UI synchronization context
            _uiSyncContext = SynchronizationContext.Current;

            //Fill in the IP address from IP config file
            string[] lineOfContents = File.ReadAllLines(@"..\..\..\..\IPConfigFile.txt");
            this.txtCodingSvcIP.Text = lineOfContents[3].Trim();

            //Check whether CodingIP exist
            if (Properties.Settings.Default.CodingIP != null && Properties.Settings.Default.CodingIP != "")
            {
                this.txtCodingSvcIP.Text      = Properties.Settings.Default.CodingIP;
                this.txtCodingSvcIP.IsEnabled = false;

                _isCodingSvcIPSet     = true;
                this.btnSetIP.Content = "Unset IP";

                string          endpointaddress = "net.tcp://" + this.txtCodingSvcIP.Text.Trim() + ":8000/CallOut_CodingService/service";
                EndpointAddress endpointaddr    = new EndpointAddress(new Uri(endpointaddress));
                _CallOut_CodingService = new ServiceReference1.CallOut_CodingServiceClient(new InstanceContext(this), "NetTcpBinding_CallOut_CodingService", endpointaddr);
                Log("open new coding service proxy from setting window");
                _CallOut_CodingService.Open();

                //Connection is UP!!!

                //Fill up the combobox items
                foreach (StationStatus station in _CallOut_CodingService.GetStationStatus())
                {
                    this.comboID.Items.Add(station.Station);
                }

                //Fill the combobox selected text
                this.comboID.Text = Properties.Settings.Default.CurrentID;

                //DataGrid Bind
                _ConsoleLogList.Clear();

                //Load out the console log status from configfile
                if (this.comboID.Text != "")
                {
                    this.comboID.IsEnabled = false;
                    _isStationIDSet        = true;
                    this.btnSetID.Content  = "Unset";

                    if (Properties.Settings.Default.ConsoleLogList != null)
                    {
                        foreach (string log in Properties.Settings.Default.ConsoleLogList)
                        {
                            string[] parts = log.Split(',');
                            //Check is it corresponding stationID
                            if (parts[0] == this.comboID.Text)
                            {
                                ConsoleLog consolelog = new ConsoleLog();
                                consolelog.CodingID     = parts[1];
                                consolelog.AckTimeStamp = parts[2];
                                consolelog.AckFrom      = parts[3];
                                consolelog.AckStatus    = parts[4];
                                _ConsoleLogList.Add(consolelog);
                            }
                        }
                    }
                }
                this.lvConsoleLog.ItemsSource = _ConsoleLogList;
            }
        }
        private void btnSetIP_Click(object sender, RoutedEventArgs e)
        {
            if (isInternetup)
            {
                if (_isCodingSvcIPSet)
                {
                    if (!_isStationIDSet)
                    {
                        //UnSetIP

                        //Clear ComboBox and Console Log
                        this.comboID.Items.Clear();

                        //_ConsoleLogList.Clear();
                        //this.lvConsoleLog.ItemsSource = _ConsoleLogList;

                        //Cut off the proxy / channel
                        _CallOut_CodingService.Close();
                        _CallOut_CodingService = null;

                        //Remove the IP Address in config file
                        Properties.Settings.Default.CodingIP = "";
                        Properties.Settings.Default.Save();

                        this.txtCodingSvcIP.IsEnabled = true;
                        _isCodingSvcIPSet             = false;
                        this.btnSetIP.Content         = "Set IP";
                    }
                    else
                    {
                        MessageBox.Show("Unset Station ID before unset IP address...");
                    }
                }
                else
                {
                    //Set IP

                    //Trigger to create Coding Service Client with the input IP
                    try
                    {
                        string endpointaddress = "net.tcp://" + this.txtCodingSvcIP.Text.Trim() + ":8000/CallOut_CodingService/service";
                        _CallOut_CodingService = new ServiceReference1.CallOut_CodingServiceClient(new InstanceContext(this), "NetTcpBinding_CallOut_CodingService", endpointaddress);
                        Log("Open coding service proxy");
                        _CallOut_CodingService.Open();

                        //Save the IP address that is confirm
                        Properties.Settings.Default.CodingIP = this.txtCodingSvcIP.Text.Trim();
                        Properties.Settings.Default.Save();

                        //Fill up the combobox items
                        foreach (StationStatus station in _CallOut_CodingService.GetStationStatus())
                        {
                            this.comboID.Items.Add(station.Station);
                        }

                        //Fill the combobox selected text
                        this.comboID.Text = Properties.Settings.Default.CurrentID;

                        //DataGrid Bind
                        //_ConsoleLogList.Clear();

                        //Load out the console log status from configfile
                        if (this.comboID.Text != "")
                        {
                            this.comboID.IsEnabled = false;

                            if (Properties.Settings.Default.ConsoleLogList != null)
                            {
                                foreach (string log in Properties.Settings.Default.ConsoleLogList)
                                {
                                    string[] parts = log.Split(',');
                                    //Check is it corresponding stationID
                                    if (parts[0] == this.comboID.Text)
                                    {
                                        ConsoleLog consolelog = new ConsoleLog();
                                        consolelog.CodingID     = parts[1];
                                        consolelog.AckTimeStamp = parts[2];
                                        consolelog.AckFrom      = parts[3];
                                        consolelog.AckStatus    = parts[4];
                                        _ConsoleLogList.Add(consolelog);
                                    }
                                }
                            }
                        }

                        this.lvConsoleLog.ItemsSource = _ConsoleLogList;

                        this.txtCodingSvcIP.IsEnabled = false;
                        _isCodingSvcIPSet             = true;
                        this.btnSetIP.Content         = "Unset IP";
                    }
                    catch (Exception E)
                    {
                        _CallOut_CodingService = null;
                        MessageBox.Show("Invalid IP address...");
                    }
                }
            }
            else
            {
                ShowMessageBox("Please check the internet connection to continue");
            }
        }