private void OnPremiseLogin_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txtServerOnPremise.Text.Equals(string.Empty) ||
             txtDomainOnPremise.Text.Equals(string.Empty) ||
             txtUserNameOnPremise.Text.Equals(string.Empty) ||
             txtPasswordOnPremise.Password.Equals(string.Empty))
         {
             MessageBox.Show("Unable to login, please provide required details.");
         }
         else
         {
             string strAuthType  = cmbAuthType.SelectedValue.ToString();
             string strServerUrl = txtServerOnPremise.Text;
             AppendOrgnaisationName(ref strServerUrl);
             string strDomain            = txtDomainOnPremise.Text;
             string strUserName          = txtUserNameOnPremise.Text;
             string strPassword          = txtPasswordOnPremise.Password.ToString();
             string strConnectionString  = $"AuthType={strAuthType};Url={strServerUrl};Domain={strDomain};Username={strUserName};Password={strPassword}";
             string strConStringKeyValue = ConfigurationManager.AppSettings["DynamicsConnectionStringOnPremise"];
             if (strConStringKeyValue != strConnectionString)
             {
                 UpdateConnectionStringValue(strConnectionString, ConnectionType.OnPremise);
             }
             PBOnpremiseLogin.Visibility = Visibility.Visible;
             Tuple <string> strErrorMessage = new Tuple <string>(string.Empty);
             Task <bool>    TaskConnection  = Task.Run((async() => await CrmHelper.ConnectUsingConnectionStringAsync(strConnectionString, strErrorMessage)));
             if (TaskConnection.Result)
             {
                 var parentWindow = Window.GetWindow(this) as MainWindow;
                 parentWindow.dockPanel.Children.Clear();
                 FaceIdentify cntrlFaceIdentify = new FaceIdentify();
                 cntrlFaceIdentify.CloseInitiated += new Close(parentWindow.ClosePanel);
                 parentWindow.dockPanel.Children.Add(cntrlFaceIdentify);
                 parentWindow.dockPanel.Visibility = Visibility.Visible;
                 PBOnpremiseLogin.Visibility       = Visibility.Hidden;
             }
             else
             {
                 MessageBox.Show("Unable to login :"******"\r\n" + strErrorMessage);
                 PBOnpremiseLogin.Visibility = Visibility.Hidden;
             }
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:
                this.FaceIdentificationPane = ((Hsl.CognitiveServices.Demo.UserControl.FaceIdentify)(target));
                return;

            case 2:
                this.btnClose = ((System.Windows.Controls.Button)(target));

            #line 14 "..\..\..\UserControl\FaceIdentify.xaml"
                this.btnClose.Click += new System.Windows.RoutedEventHandler(this.BtnClose_Click);

            #line default
            #line hidden
                return;

            case 3:
                this.gridFaceAPIKeyManagement = ((System.Windows.Controls.Grid)(target));
                return;

            case 4:
                this.txtSubscriptionKey = ((System.Windows.Controls.TextBox)(target));
                return;

            case 5:
                this.txtEndpoint = ((System.Windows.Controls.TextBox)(target));
                return;

            case 6:
                this.btnSaveFaceSubScription = ((System.Windows.Controls.Button)(target));
                return;

            case 7:
                this.btnNextFaceSubScription = ((System.Windows.Controls.Button)(target));

            #line 41 "..\..\..\UserControl\FaceIdentify.xaml"
                this.btnNextFaceSubScription.Click += new System.Windows.RoutedEventHandler(this.BtnNextKeyManagement_Click);

            #line default
            #line hidden
                return;

            case 8:
                this.gridTrainPersonGroup = ((System.Windows.Controls.Grid)(target));
                return;

            case 9:
                this.btnTrain = ((System.Windows.Controls.Button)(target));

            #line 59 "..\..\..\UserControl\FaceIdentify.xaml"
                this.btnTrain.Click += new System.Windows.RoutedEventHandler(this.BtnTrain_Click);

            #line default
            #line hidden
                return;

            case 10:
                this.btnTrainSkip = ((System.Windows.Controls.Button)(target));

            #line 60 "..\..\..\UserControl\FaceIdentify.xaml"
                this.btnTrainSkip.Click += new System.Windows.RoutedEventHandler(this.BtnTrainSkip_Click);

            #line default
            #line hidden
                return;

            case 11:
                this.PBTrainFaceApi = ((System.Windows.Controls.ProgressBar)(target));
                return;

            case 12:
                this.gridIdentifyPerson = ((System.Windows.Controls.Grid)(target));

            #line 67 "..\..\..\UserControl\FaceIdentify.xaml"
                this.gridIdentifyPerson.MouseLeftButtonDown += new System.Windows.Input.MouseButtonEventHandler(this.gridIdentifyPerson_MouseLeftButtonDown);

            #line default
            #line hidden
                return;

            case 13:
                this.ImageDisplay = ((System.Windows.Controls.Image)(target));
                return;

            case 14:

            #line 100 "..\..\..\UserControl\FaceIdentify.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.UploadImage_Click);

            #line default
            #line hidden
                return;

            case 15:
                this.btnIdentify = ((System.Windows.Controls.Button)(target));

            #line 101 "..\..\..\UserControl\FaceIdentify.xaml"
                this.btnIdentify.Click += new System.Windows.RoutedEventHandler(this.BtnIdentify_Click);

            #line default
            #line hidden
                return;

            case 16:
                this.PBIdentify = ((System.Windows.Controls.ProgressBar)(target));
                return;
            }
            this._contentLoaded = true;
        }