//public ctlCRMDesigner(ModulePermissions[] MyPermissions)
        //{
        //    try
        //    {
        //        //InitializeComponent();
        //        this.Loaded += new RoutedEventHandler(ctlCRMDesigner_Loaded);

        //        _MyPermissions = MyPermissions;
        //        FncPermissionsReview();
        //        currentControl = new ctlPOD();
        //        MyPropGrid = new ctlPropertyGrid();

        //        FncFillCombo();
        //        //cmbScript.SelectionChanged += new SelectionChangedEventHandler(cmbScript_SelectionChanged);


        //        txtDrag999.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
        //        lblDrag999.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);

        //        btnNewTab.Click += new RoutedEventHandler(btnNewTab_Click);
        //        cnvPaint.Drop += new DragEventHandler(cnvPaint_Drop);
        //        //tbi.Drop += new DragEventHandler(tbi_Drop);
        //        cnvPaint.DragOver += new DragEventHandler(cnvPaint_DragOver);
        //        cnvPaint.PreviewMouseUp += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseUp);
        //        cnvPaint.PreviewMouseDown += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseDown);
        //        cnvPaint.PreviewMouseMove += new MouseEventHandler(ctlCRMDesigner_MouseMove);
        //        cnvPaint.MouseMove += new MouseEventHandler(cnvPaint_MouseMove);
        //        currentControl.SizeChanged += new SizeChangedEventHandler(currentControl_SizeChanged);

        //        cmbLeadFormat.SelectionChanged += new SelectionChangedEventHandler(cmbLeadFormat_SelectionChanged);

        //        r1.Stroke = Brushes.White;

        //        r1.StrokeThickness = 3.0;
        //        r1.Fill = Brushes.Transparent;
        //        r1.StrokeDashArray = new DoubleCollection(2);
        //        MyPropGrid.Height = 500;
        //        MyPropGrid.Width = 200;
        //        MyPropGrid.SetValue(Canvas.LeftProperty, 650.0);
        //        MyPropGrid.SetValue(Canvas.TopProperty, 0.0);
        //        myExpander1.Content = MyPropGrid;
        //        myExpander1.Expanded += new RoutedEventHandler(myExpander1_Expanded);
        //        myExpander1.Collapsed += new RoutedEventHandler(myExpander1_Collapsed);
        //        //cnvPaint.Children.Add(MyPropGrid);
        //        cnvPaint.Children.Add(r1);

        //        r1.SizeChanged += new SizeChangedEventHandler(r1_SizeChanged);

        //        this.PreviewKeyDown += new KeyEventHandler(ctlCRMDesigner_PreviewKeyDown);

        //        FncCreateTabItems();

        //        txtHeight.KeyDown += new KeyEventHandler(txtHeight_KeyDown);
        //        txtWidth.KeyDown += new KeyEventHandler(txtWidth_KeyDown);

        //        txtHeight.LostFocus += new RoutedEventHandler(txtHeight_LostFocus);
        //        txtWidth.LostFocus += new RoutedEventHandler(txtWidth_LostFocus);
        //        txtHeader.GotFocus += new RoutedEventHandler(txtHeader_GotFocus);

        //        txtHeight.Text = int.Parse(tbcMain.Height.ToString()).ToString();
        //        txtWidth.Text = int.Parse(tbcMain.Width.ToString()).ToString();

        //        ClsCRMCollection objClsCRMCollection = ClsCRMCollection.GetAll();
        //        for (int i = 0; i < objClsCRMCollection.Count; i++)
        //        {
        //            ComboBoxItem cmb1 = new ComboBoxItem();
        //            cmb1.Content = objClsCRMCollection[i].CRMName;
        //            cmb1.Tag = objClsCRMCollection[i].ID;
        //            cmbCRM.Items.Add(cmb1);
        //        }
        //        try
        //        {

        //            BasicHttpClient bhcFts = new BasicHttpClient();
        //            clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService");
        //            clientHttpFileTransfer.svcHTTPFileTransferServiceJoin();
        //        }
        //        catch (Exception ex)
        //        {
        //            ex.Data.Add("My Key", "VMukti--:--VmuktiModules--:--Call Center--:--CRMDesigner--:--CRMDesigner.Presentation--:--ctlCRMDesigner.xaml.cs--:--ctlCRMDesigner()--");
        //            //ClsException.LogError(ex);
        //            //ClsException.WriteToErrorLogFile(ex);
        //            System.Text.StringBuilder sb = new StringBuilder();
        //            sb.AppendLine(ex.Message);
        //            sb.AppendLine();
        //            sb.AppendLine("StackTrace : " + ex.StackTrace);
        //            sb.AppendLine();
        //            sb.AppendLine("Location : " + ex.Data["My Key"].ToString());
        //            sb.AppendLine();
        //            sb1 = CreateTressInfo();
        //            sb.Append(sb1.ToString());
        //            VMuktiAPI.ClsLogging.WriteToTresslog(sb);
        //        }
        //    }
        //    catch (Exception ex)
        //    {
        //        MessageBox.Show(ex.Message);
        //    }

        //}

        public ctlCRMDesigner(string TempCRM)
        {
            InitializeComponent();
            CRMName = TempCRM;
            currentControl = new ctlPOD();
            MyPropGrid = new ctlPropertyGrid();
            this.Loaded+=new RoutedEventHandler(ctlCRMDesigner_Loaded);
            FncFillCombo();
            flag = false;
            
            txtDrag999.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
            lblDrag999.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);

            btnNewTab.Click += new RoutedEventHandler(btnNewTab_Click);
            cnvPaint.Drop += new DragEventHandler(cnvPaint_Drop);
            //tbi.Drop += new DragEventHandler(tbi_Drop);
            cnvPaint.DragOver += new DragEventHandler(cnvPaint_DragOver);
            cnvPaint.PreviewMouseUp += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseUp);
            cnvPaint.PreviewMouseDown += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseDown);
            cnvPaint.PreviewMouseMove += new MouseEventHandler(ctlCRMDesigner_MouseMove);
            cnvPaint.MouseMove += new MouseEventHandler(cnvPaint_MouseMove);
            currentControl.SizeChanged += new SizeChangedEventHandler(currentControl_SizeChanged);


            r1.Stroke = Brushes.White;

            r1.StrokeThickness = 3.0;
            r1.Fill = Brushes.Transparent;
            r1.StrokeDashArray = new DoubleCollection(2);
            MyPropGrid.Height = 500;
            MyPropGrid.Width = 200;
            MyPropGrid.SetValue(Canvas.LeftProperty, 650.0);
            MyPropGrid.SetValue(Canvas.TopProperty, 0.0);
            myExpander1.Content = MyPropGrid;
            myExpander1.Expanded += new RoutedEventHandler(myExpander1_Expanded);
            myExpander1.Collapsed += new RoutedEventHandler(myExpander1_Collapsed);
            //cnvPaint.Children.Add(MyPropGrid);
            cnvPaint.Children.Add(r1);

            r1.SizeChanged += new SizeChangedEventHandler(r1_SizeChanged);

            this.PreviewKeyDown += new KeyEventHandler(ctlCRMDesigner_PreviewKeyDown);

            FncCreateTabItems();

            txtHeight.KeyDown += new KeyEventHandler(txtHeight_KeyDown);
            txtWidth.KeyDown += new KeyEventHandler(txtWidth_KeyDown);

            txtHeight.LostFocus += new RoutedEventHandler(txtHeight_LostFocus);
            txtWidth.LostFocus += new RoutedEventHandler(txtWidth_LostFocus);
            txtHeader.GotFocus += new RoutedEventHandler(txtHeader_GotFocus);

            txtHeight.Text = int.Parse(tbcMain.Height.ToString()).ToString();
            txtWidth.Text = int.Parse(tbcMain.Width.ToString()).ToString();


            //lblCRM.Visibility = Visibility.Collapsed;
            //cmbCRM.Visibility = Visibility.Collapsed;
            //btnGetQuestions.Visibility = Visibility.Collapsed;
            
            ClsCRMCollection objClsCRMCollection = ClsCRMCollection.GetAll();
            for (int i = 0; i < objClsCRMCollection.Count; i++)
            {
                ComboBoxItem cmb1 = new ComboBoxItem();
                cmb1.Content = objClsCRMCollection[i].CRMName;
                cmb1.Tag = objClsCRMCollection[i].ID;
                cmbCRM.Items.Add(cmb1);
                if (objClsCRMCollection[i].ID.ToString() == CRMName)
                {
                    cmbCRM.Text = cmb1.Content.ToString();
                }
            }
            //cmbCRM.Text = CRMName;
            cmbCRM.IsEnabled = false;
            cmbCRM.SelectionChanged+=new SelectionChangedEventHandler(cmbCRM_SelectionChanged);
            
            cmbLeadFormat.SelectionChanged += new SelectionChangedEventHandler(cmbLeadFormat_SelectionChanged);

            try
            {
                BasicHttpClient bhcFts = new BasicHttpClient();
                clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService");
                clientHttpFileTransfer.svcHTTPFileTransferServiceJoin();
            }
            catch (Exception ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "ctlCRMDesigner()", "ctlCRMDesigner.xaml.cs");
            }
            GetQuestions();
            

            //return 0;
        }
        public ctlCRMDesigner(ModulePermissions[] MyPermissions)
        {
            try
            {
                InitializeComponent();
                this.Loaded += new RoutedEventHandler(ctlCRMDesigner_Loaded);

                _MyPermissions = MyPermissions;
                FncPermissionsReview();
                currentControl = new ctlPOD();
                MyPropGrid = new ctlPropertyGrid();

                FncFillCombo();
                //cmbScript.SelectionChanged += new SelectionChangedEventHandler(cmbScript_SelectionChanged);


                txtDrag999.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
                lblDrag999.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);

                btnNewTab.Click += new RoutedEventHandler(btnNewTab_Click);
                cnvPaint.Drop += new DragEventHandler(cnvPaint_Drop);
                //tbi.Drop += new DragEventHandler(tbi_Drop);
                cnvPaint.DragOver += new DragEventHandler(cnvPaint_DragOver);
                cnvPaint.PreviewMouseUp += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseUp);
                cnvPaint.PreviewMouseDown += new MouseButtonEventHandler(ctlCRMDesigner_PreviewMouseDown);
                cnvPaint.PreviewMouseMove += new MouseEventHandler(ctlCRMDesigner_MouseMove);
                cnvPaint.MouseMove += new MouseEventHandler(cnvPaint_MouseMove);
                currentControl.SizeChanged += new SizeChangedEventHandler(currentControl_SizeChanged);

                cmbLeadFormat.SelectionChanged += new SelectionChangedEventHandler(cmbLeadFormat_SelectionChanged);

                r1.Stroke = Brushes.White;

                r1.StrokeThickness = 3.0;
                r1.Fill = Brushes.Transparent;
                r1.StrokeDashArray = new DoubleCollection(2);
                MyPropGrid.Height = 500;
                MyPropGrid.Width = 200;
                MyPropGrid.SetValue(Canvas.LeftProperty, 650.0);
                MyPropGrid.SetValue(Canvas.TopProperty, 0.0);
                myExpander1.Content = MyPropGrid;
                myExpander1.Expanded += new RoutedEventHandler(myExpander1_Expanded);
                myExpander1.Collapsed += new RoutedEventHandler(myExpander1_Collapsed);
                //cnvPaint.Children.Add(MyPropGrid);
                cnvPaint.Children.Add(r1);

                r1.SizeChanged += new SizeChangedEventHandler(r1_SizeChanged);

                this.PreviewKeyDown += new KeyEventHandler(ctlCRMDesigner_PreviewKeyDown);

                FncCreateTabItems();

                txtHeight.KeyDown += new KeyEventHandler(txtHeight_KeyDown);
                txtWidth.KeyDown += new KeyEventHandler(txtWidth_KeyDown);

                txtHeight.LostFocus += new RoutedEventHandler(txtHeight_LostFocus);
                txtWidth.LostFocus += new RoutedEventHandler(txtWidth_LostFocus);
                txtHeader.GotFocus += new RoutedEventHandler(txtHeader_GotFocus);

                txtHeight.Text = int.Parse(tbcMain.Height.ToString()).ToString();
                txtWidth.Text = int.Parse(tbcMain.Width.ToString()).ToString();

                ClsCRMCollection objClsCRMCollection = ClsCRMCollection.GetAll();
                for (int i = 0; i < objClsCRMCollection.Count; i++)
                {
                    ComboBoxItem cmb1 = new ComboBoxItem();
                    cmb1.Content = objClsCRMCollection[i].CRMName;
                    cmb1.Tag = objClsCRMCollection[i].ID;
                    cmbCRM.Items.Add(cmb1);
                }
                try
                {

                    BasicHttpClient bhcFts = new BasicHttpClient();
                    clientHttpFileTransfer = (IHTTPFileTransferService)bhcFts.OpenClient<IHTTPFileTransferService>("http://" + VMuktiAPI.VMuktiInfo.BootStrapIPs[0] + ":80/VMukti/HttpFileTransferService");
                    clientHttpFileTransfer.svcHTTPFileTransferServiceJoin();
                }
                catch (Exception ex)
                {
                    ex.Data.Add("My Key", "VMukti--:--VmuktiModules--:--Call Center--:--CRMDesigner--:--CRMDesigner.Presentation--:--ctlCRMDesigner.xaml.cs--:--ctlCRMDesigner()--");
                    //ClsException.LogError(ex);
                    //ClsException.WriteToErrorLogFile(ex);
                    System.Text.StringBuilder sb = new StringBuilder();
                    sb.AppendLine(ex.Message);
                    sb.AppendLine();
                    sb.AppendLine("StackTrace : " + ex.StackTrace);
                    sb.AppendLine();
                    sb.AppendLine("Location : " + ex.Data["My Key"].ToString());
                    sb.AppendLine();
                    sb1 = CreateTressInfo();
                    sb.Append(sb1.ToString());
                    VMuktiAPI.ClsLogging.WriteToTresslog(sb);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

        }