private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (okayButtonSkiped)
            {
                LSV2Caller.SetToolBreakage(tempToolBreakage);
                LSV2Caller.SetAdaptiveControl(tempAdaptiveCont);
                LSV2Caller.SetVirtualRealConnection(tempVirtualReal);
                LSV2Caller.SetFeedbacktoReal(tempFeedback);

                isCustomizationOn = mainWindow.currCustomizationStatus;
            }
            //Console.WriteLine("Closing");
        }
        //----------------------------------------------------------------------------
        // CLICK procedures
        //----------------------------------------------------------------------------
        //
        private void OkayButton_Click(object sender, RoutedEventArgs e)
        {
            LSV2Caller.SetToolBreakage((bool)ToolBreakageCheckBox.IsChecked);
            if ((bool)ToolBreakageCheckBox.IsChecked)
            {
                mainWindow.TabItemToolProcessButton.Background = Brushes.LightSeaGreen;
            }
            else
            {
                mainWindow.TabItemToolProcessButton.Background = Brushes.Gray;
            }

            LSV2Caller.SetAdaptiveControl((bool)AdaptiveContCheckBox.IsChecked);
            if ((bool)AdaptiveContCheckBox.IsChecked)
            {
                mainWindow.TabItemAdaptProcessButton.Background = Brushes.LightSeaGreen;
            }
            else
            {
                mainWindow.TabItemAdaptProcessButton.Background = Brushes.Gray;
            }

            LSV2Caller.SetVirtualRealConnection((bool)VirtualRealConnCheckBox.IsChecked);
            if ((bool)VirtualRealConnCheckBox.IsChecked)
            {
                mainWindow.TabItemVirtualFeedButton.Background = Brushes.LightSeaGreen;
            }
            else
            {
                mainWindow.TabItemVirtualFeedButton.Background = Brushes.Gray;
            }
            // Note: When Chatter is ready, add a line just like above

            // We need to combine this with Virtual Real Connection
            LSV2Caller.SetFeedbacktoReal((bool)FeedBackCheckBox.IsChecked);

            LSV2Caller.SetIsPeekForceUsed((bool)PeekForceCheckBox.IsChecked);

            //if (eta1LimitTextBox.Text != "") LSV2Caller.SetEta1Reference(Convert.ToDouble(eta1LimitTextBox.Text)); else return;
            //if (eta2LimitTextBox.Text != "") LSV2Caller.SetEta2Reference(Convert.ToDouble(eta2LimitTextBox.Text)); else return;
            //if (thresholdTextBox.Text != "") LSV2Caller.SetThresholdPercentage(Convert.ToInt16(thresholdTextBox.Text)); else return;
            //if (LambdaTextBox.Text != "") LSV2Caller.SetLambda(Convert.ToDouble(LambdaTextBox.Text)); else return;
            //if (AbarValueTextBox.Text != "") LSV2Caller.SetAbarvalue(Convert.ToDouble(AbarValueTextBox.Text)); else return;
            //if (GPCforceTextBox.Text != "") LSV2Caller.SetGPCforce(Convert.ToDouble(GPCforceTextBox.Text)); else return;
            //if (SpindleExhaustTextBox.Text != "") LSV2Caller.SetSpindleExhaustion(Convert.ToDouble(SpindleExhaustTextBox.Text)); else return;
            //if (ForceOvershootTextBox.Text != "") LSV2Caller.SetForceOvershootTolPer(Convert.ToDouble(ForceOvershootTextBox.Text)); else return;
            //if (GoToCheckTextBox.Text != "") LSV2Caller.SetFeatureCheckTime(Convert.ToDouble(GoToCheckTextBox.Text)); else return;
            //if (DelayCompTextBox.Text != "") LSV2Caller.SetCompCheckTime(Convert.ToDouble(DelayCompTextBox.Text)); else return;

            if ((thresholdTextBox.Text == "") || (LambdaTextBox.Text == "") || (SamplingTimeTextBox.Text == "") ||
                (GPCforceTextBox.Text == "") || (SpindleExhaustTextBox.Text == "") || (ForceOvershootTextBox.Text == "") ||
                (GoToCheckTextBox.Text == "") || (DelayCompTextBox.Text == "") || (TrackTolTextBox.Text == ""))
            {
                return;
            }

            LSV2Caller.SetThresholdPercentage(Convert.ToInt16(thresholdTextBox.Text));
            LSV2Caller.SetLambda(Convert.ToDouble(LambdaTextBox.Text));
            LSV2Caller.SetGPCforce(Convert.ToDouble(GPCforceTextBox.Text));
            LSV2Caller.SetSamplingTime(Convert.ToDouble(SamplingTimeTextBox.Text));
            LSV2Caller.SetSpindleExhaustion(Convert.ToDouble(SpindleExhaustTextBox.Text));
            LSV2Caller.SetForceOvershootTolPer(Convert.ToDouble(ForceOvershootTextBox.Text));
            LSV2Caller.SetFeatureCheckTime(Convert.ToDouble(GoToCheckTextBox.Text));
            LSV2Caller.SetCompCheckTime(Convert.ToDouble(DelayCompTextBox.Text));
            mainWindow.trackTolerans = Convert.ToDouble(TrackTolTextBox.Text);

            switch (ToolBreakageActionsComboBox.SelectedIndex)
            {
            case 0:
                LSV2Caller.SetToolBreakageAction(toolBreakageActionType.alarmAndStop);
                break;

            case 1:
                LSV2Caller.SetToolBreakageAction(toolBreakageActionType.alarmAndDelayStop);
                break;

            case 2:
                LSV2Caller.SetToolBreakageAction(toolBreakageActionType.alarmAndContinue);
                break;
            }

            // Check whether any field is changed
            //
            isCustomizationOn = false;

            if (!(ToolBreakageCheckBox.IsChecked == true))
            {
                isCustomizationOn = true;
            }
            if (!(AdaptiveContCheckBox.IsChecked == true))
            {
                isCustomizationOn = true;
            }
            if (!(VirtualRealConnCheckBox.IsChecked == true))
            {
                isCustomizationOn = true;
            }
            if (!(FeedBackCheckBox.IsChecked == true))
            {
                isCustomizationOn = true;
            }

            if (!(PeekForceCheckBox.IsChecked == true))
            {
                isCustomizationOn = true;
            }

            if (Convert.ToInt16(thresholdTextBox.Text) != thresholdDefault)
            {
                isCustomizationOn = true;
            }
            if (Convert.ToDouble(SamplingTimeTextBox.Text) != samplingTimeDefault)
            {
                isCustomizationOn = true;
            }
            if (Convert.ToDouble(TrackTolTextBox.Text) != trackingToleranceDefault)
            {
                isCustomizationOn = true;
            }
            if (Convert.ToDouble(SpindleExhaustTextBox.Text) != spindleExhaustDefault)
            {
                isCustomizationOn = true;
            }
            if (Convert.ToDouble(GPCforceTextBox.Text) != gpcForceDefault)
            {
                isCustomizationOn = true;
            }
            if (Convert.ToDouble(LambdaTextBox.Text) != lambdaDefault)
            {
                isCustomizationOn = true;
            }
            if (Convert.ToDouble(ForceOvershootTextBox.Text) != forceOverShootDefault)
            {
                isCustomizationOn = true;
            }
            if (Convert.ToDouble(GoToCheckTextBox.Text) != goToCheckDefault)
            {
                isCustomizationOn = true;
            }
            if (Convert.ToDouble(DelayCompTextBox.Text) != delayCompensationDefault)
            {
                isCustomizationOn = true;
            }

            mainWindow.currCustomizationStatus = isCustomizationOn;

            // Okay button is not skiped. This is required for Clicks
            okayButtonSkiped = false;

            this.Close();
        }