void tbi_Drop(object sender, DragEventArgs e)
        {
            try
            {

                if (e.Data.GetData(typeof(Label)) != null)
                {
                    if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Label lbl = new Label();
                        lbl.Content = "Label";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }

                    else if ((((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                    }
                }

                else if (e.Data.GetData(typeof(TextBox)) != null)
                {
                    if (((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        TextBox txt = new TextBox();
                        txt.IsReadOnly = true;
                        txt.Cursor = Cursors.Arrow;
                        txt.Height = 25;
                        txt.Width = 100;
                        txt.Text = "TextBox";
                        txt.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
                        txt.SetValue(Canvas.LeftProperty, 10.0);
                        txt.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(txt);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }



                newDrag = 1;
                r1.Visibility = Visibility.Collapsed;
                MyPropGrid.ControlToBind = currentControl;
            }

            catch (Exception ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "tbi_Drop()", "ctlCRMDesigner.xaml.cs");
            }
        }
        void FncSetCanvas()
        {
            int flag = 0;

            try
            {
                for (int k = 0; k < t1.Length; k++)
                {
                    //if(t1[k].Name=="MainPage")
                    if(t1[k].Name=="UserControl"+1)
                    //if (t1[k].Name == "UserControl" + objQueCollection[CurrentQueCount].ID.ToString())
                    {

                        flag = 1;
                        try
                        {
                            UserControl usrCtl = (UserControl)(Activator.CreateInstance(t1[k], null));
                            usrCtl.SetValue(Canvas.LeftProperty, 0.0);
                            MethodInfo[] mis = t1[k].GetMethods();//GetMethod("GetCanvas");//(MemberTypes.Method,BindingFlags.Public
                            Object[] args = new Object[0];
                            MethodInfo mi = t1[k].GetMethod("GetCanvas");
                            Canvas cnvPage = (Canvas)mi.Invoke(usrCtl, args);
                            usrCtl.SetValue(Canvas.TopProperty, 0.0);

                            cnvPaint.Background = cnvPage.Background;


                            int cnt = cnvPage.Children.Count;
                            // need a for loop get all ctls of page
                            for (int i = cnt - 1; i >= 0; i--)
                            {
                                if (cnvPage.Children[i].GetType() == typeof(TabControl))
                                {
                                    TabControl TbControl = (TabControl)cnvPage.Children[i];
                                    for (int j = 0; j < TbControl.Items.Count; j++)
                                    {
                                        TabItem tbItem = (TabItem)TbControl.Items[j];
                                        Canvas objCnv = (Canvas)tbItem.GetValue(ContentProperty);
                                        int cnt1 = objCnv.Children.Count;
                                        //for (int cnvChild = 0; cnvChild < objCnv.Children.Count; cnvChild++)
                                        Canvas cnvPaintTe = new Canvas();
                                        for (int m = cnt1-1; m >= 0; m--)
                                        {
                                            if (objCnv.Children[m].GetType() == typeof(TextBox))
                                            {
                                                TextBox uiCurr = (TextBox)objCnv.Children[m];
                                                ctlPOD ctlCurr = new ctlPOD();

                                                ctlCurr.AllowDrop = true;
                                                ctlCurr.Height = (Double)uiCurr.GetValue(HeightProperty);
                                                ctlCurr.Width = (Double)uiCurr.GetValue(WidthProperty);

                                                ctlCurr.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                                                ctlCurr.SetValue(Canvas.LeftProperty, uiCurr.GetValue(Canvas.LeftProperty));
                                                ctlCurr.SetValue(Canvas.TopProperty, uiCurr.GetValue(Canvas.TopProperty));
                                                MyPropGrid.ControlToBind = ctlCurr;

                                                //uiCurr.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
                                                uiCurr.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
                                                objCnv.Children.Remove(uiCurr);
                                                ctlCurr.cnvPOD.Children.Add(uiCurr);

                                                currentControl = ctlCurr;
                                                cnvPaintTe.Children.Add(ctlCurr);
                                            }

                                            else if (objCnv.Children[m].GetType() == typeof(Button))
                                            {
                                                //if (cnvPage.Children[i].GetType() == typeof(Button))
                                                //{
                                                Button uiCurr = (Button)objCnv.Children[m];
                                                ctlPOD ctlCurr = new ctlPOD();

                                                ctlCurr.AllowDrop = true;
                                                ctlCurr.Height = (Double)uiCurr.GetValue(HeightProperty);
                                                ctlCurr.Width = (Double)uiCurr.GetValue(WidthProperty);

                                                ctlCurr.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                                                ctlCurr.SetValue(Canvas.LeftProperty, uiCurr.GetValue(Canvas.LeftProperty));
                                                ctlCurr.SetValue(Canvas.TopProperty, uiCurr.GetValue(Canvas.TopProperty));
                                                MyPropGrid.ControlToBind = ctlCurr;

                                                uiCurr.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
                                                objCnv.Children.Remove(uiCurr);
                                                ctlCurr.cnvPOD.Children.Add(uiCurr);

                                                currentControl = ctlCurr;
                                                cnvPaintTe.Children.Add(ctlCurr);



                                            }

                                            //else if (cnvPage.Children[m].GetType() == typeof(Label))
                                            else if (objCnv.Children[m].GetType() == typeof(Label))
                                            {
                                                Label uiCurr = (Label)objCnv.Children[m];
                                                ctlPOD ctlCurr = new ctlPOD();



                                                ctlCurr.AllowDrop = true;
                                                ctlCurr.Height = (Double)uiCurr.GetValue(HeightProperty);
                                                ctlCurr.Width = (Double)uiCurr.GetValue(WidthProperty);

                                                ctlCurr.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                                                ctlCurr.SetValue(Canvas.LeftProperty, uiCurr.GetValue(Canvas.LeftProperty));
                                                ctlCurr.SetValue(Canvas.TopProperty, uiCurr.GetValue(Canvas.TopProperty));
                                                MyPropGrid.ControlToBind = ctlCurr;

                                                uiCurr.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
                                                objCnv.Children.Remove(uiCurr);
                                                ctlCurr.cnvPOD.Children.Add(uiCurr);
                                                currentControl = ctlCurr;

                                                cnvPaintTe.Children.Add(ctlCurr);
                                            }

                                            else if (objCnv.Children[m].GetType() == typeof(TextBlock))
                                            {
                                                TextBlock uiCurr = (TextBlock)objCnv.Children[m];
                                                ctlPOD ctlCurr = new ctlPOD();



                                                ctlCurr.AllowDrop = true;
                                                ctlCurr.Height = (Double)uiCurr.GetValue(HeightProperty);
                                                ctlCurr.Width = (Double)uiCurr.GetValue(WidthProperty);
                                                string str1 = (string)uiCurr.GetValue(ContentProperty);
                                                ctlCurr.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                                                ctlCurr.SetValue(Canvas.LeftProperty, uiCurr.GetValue(Canvas.LeftProperty));
                                                ctlCurr.SetValue(Canvas.TopProperty, uiCurr.GetValue(Canvas.TopProperty));
                                                MyPropGrid.ControlToBind = ctlCurr;


                                                uiCurr.PreviewMouseDown += new MouseButtonEventHandler(txbDrag999_PreviewMouseDown);//lblDrag_PreviewMouseDown);
                                                objCnv.Children.Remove(uiCurr);
                                                ctlCurr.cnvPOD.Children.Add(uiCurr);

                                                currentControl = ctlCurr;
                                                cnvPaintTe.Children.Add(ctlCurr);

                                            }
                                            else if (objCnv.Children[m].GetType() == typeof(ComboBox))
                                            {
                                                ComboBox uiCurr = (ComboBox)objCnv.Children[m];
                                                ctlPOD ctlCurr = new ctlPOD();

                                                ctlCurr.AllowDrop = true;
                                                ctlCurr.Height = (Double)uiCurr.GetValue(HeightProperty);
                                                ctlCurr.Width = (Double)uiCurr.GetValue(WidthProperty);
                                                string str1 = (string)uiCurr.GetValue(ContentProperty);
                                                ctlCurr.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                                                ctlCurr.SetValue(Canvas.LeftProperty, uiCurr.GetValue(Canvas.LeftProperty));
                                                ctlCurr.SetValue(Canvas.TopProperty, uiCurr.GetValue(Canvas.TopProperty));
                                                MyPropGrid.ControlToBind = ctlCurr;

                                                uiCurr.PreviewMouseDown += new MouseButtonEventHandler(cmbDrag999_PreviewMouseDown);
                                                objCnv.Children.Remove(uiCurr);
                                                ctlCurr.cnvPOD.Children.Add(uiCurr);



                                                currentControl = ctlCurr;

                                                cnvPaintTe.Children.Add(ctlCurr);
                                            }
                                            else if (objCnv.Children[m].GetType() == typeof(ListBox))
                                            {
                                                ListBox uiCurr = (ListBox)objCnv.Children[m];
                                                ctlPOD ctlCurr = new ctlPOD();

                                                ctlCurr.AllowDrop = true;
                                                ctlCurr.Height = (Double)uiCurr.GetValue(HeightProperty);
                                                ctlCurr.Width = (Double)uiCurr.GetValue(WidthProperty);
                                                string str1 = (string)uiCurr.GetValue(ContentProperty);
                                                ctlCurr.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                                                ctlCurr.SetValue(Canvas.LeftProperty, uiCurr.GetValue(Canvas.LeftProperty));
                                                ctlCurr.SetValue(Canvas.TopProperty, uiCurr.GetValue(Canvas.TopProperty));
                                                MyPropGrid.ControlToBind = ctlCurr;

                                                uiCurr.PreviewMouseDown += new MouseButtonEventHandler(lstDrag999_PreviewMouseDown);
                                                objCnv.Children.Remove(uiCurr);
                                                ctlCurr.cnvPOD.Children.Add(uiCurr);



                                                currentControl = ctlCurr;
                                                cnvPaintTe.Children.Add(ctlCurr);
                                            }
                                            else if (objCnv.Children[m].GetType() == typeof(RadioButton))
                                            {
                                                RadioButton uiCurr = (RadioButton)objCnv.Children[m];

                                                ctlPOD ctlCurr = new ctlPOD();

                                                ctlCurr.AllowDrop = true;
                                                ctlCurr.Height = (Double)uiCurr.GetValue(HeightProperty);
                                                ctlCurr.Width = (Double)uiCurr.GetValue(WidthProperty);
                                                string str1 = (string)uiCurr.GetValue(ContentProperty);
                                                ctlCurr.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                                                ctlCurr.SetValue(Canvas.LeftProperty, uiCurr.GetValue(Canvas.LeftProperty));
                                                ctlCurr.SetValue(Canvas.TopProperty, uiCurr.GetValue(Canvas.TopProperty));
                                                MyPropGrid.ControlToBind = ctlCurr;

                                                uiCurr.PreviewMouseDown += new MouseButtonEventHandler(radDrag999_PreviewMouseDown);
                                                objCnv.Children.Remove(uiCurr);
                                                ctlCurr.cnvPOD.Children.Add(uiCurr);


                                                currentControl = ctlCurr;

                                                cnvPaintTe.Children.Add(ctlCurr);
                                            }

                                            else if (objCnv.Children[m].GetType() == typeof(CheckBox))
                                            {
                                                CheckBox uiCurr = (CheckBox)objCnv.Children[m];
                                                ctlPOD ctlCurr = new ctlPOD();

                                                ctlCurr.AllowDrop = true;
                                                ctlCurr.Height = (Double)uiCurr.GetValue(HeightProperty);
                                                ctlCurr.Width = (Double)uiCurr.GetValue(WidthProperty);
                                                string str1 = (string)uiCurr.GetValue(ContentProperty);
                                                ctlCurr.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                                                ctlCurr.SetValue(Canvas.LeftProperty, uiCurr.GetValue(Canvas.LeftProperty));
                                                ctlCurr.SetValue(Canvas.TopProperty, uiCurr.GetValue(Canvas.TopProperty));
                                                MyPropGrid.ControlToBind = ctlCurr;
                                                uiCurr.PreviewMouseDown += new MouseButtonEventHandler(chkDrag999_PreviewMouseDown);

                                                objCnv.Children.Remove(uiCurr);
                                                ctlCurr.cnvPOD.Children.Add(uiCurr);



                                                currentControl = ctlCurr;
                                                cnvPaintTe.Children.Add(ctlCurr);
                                            }
                                        }
                                        //cnvPaint = cnvPaintTe;
                                        TabItem tabTi = new TabItem();
                                        tabTi.Tag = j + 2;
                                        tabTi.Header = tbItem.Header;
                                        tabTi.GotFocus += new RoutedEventHandler(tabTi_GotFocus);
                                        tabTi.Content = cnvPaintTe;
                                        //tabTi.Tag = j + 1;
                                        //tabTi.Header = tbItem.Header;
                                        //tabTi.GotFocus += new RoutedEventHandler(tabTi_GotFocus);
                                        //tabTi.Content = cnvPaintTemp[j];
                                        tbiLst.Add(tabTi);

                                        ((Canvas)((TabItem)tbiLst[j]).Content).Height = double.Parse(objCnv.Height.ToString());
                                        ((Canvas)((TabItem)tbiLst[j]).Content).Width = double.Parse(objCnv.Width.ToString());
                                        tbcMain.Height = double.Parse(objCnv.Height.ToString());
                                        tbcMain.Width = double.Parse(objCnv.Width.ToString());
                                        myExpander1.SetValue(Canvas.LeftProperty, double.Parse(objCnv.Width.ToString()) - 1);
                                        ExpanderLeftProperty = double.Parse(objCnv.Width.ToString()) - 1;
                                        txtHeight.Text = objCnv.Height.ToString();
                                        txtWidth.Text = objCnv.Width.ToString();
                                    }
                                }

                            }
                            if (tbiLst.Count > 1)
                            {
                                tbiLst.RemoveAt(0);
                            }
                            FncRefreshProperits();
                        }
                        catch (Exception exp)
                        {
                            VMuktiHelper.ExceptionHandler(exp, "FncSetCanvas(Inner)", "ctlCRMDesigner.xaml.cs");
                        }
                    }

                }
            }
            catch (Exception er)
            {
                FncRefreshProperits();
                // MessageBox.Show(er.Message + "   set canvas");
                //MessageBox.Show(er.ToString());
                VMuktiHelper.ExceptionHandler(er, "FncSetCanvas(Outer)", "ctlCRMDesigner.xaml.cs");
            }

            //int cntCount = 0;
            if (flag == 0)
            {
                try
                {
                    //for (int k = 0; k < t1.Length; k++)
                    //{
                    //    if (t1[k].Name.Contains("UserControl"))
                    //    {
                    //        cntCount++;
                    //    }
                    //}
                    //if (cntCount <= objQueCollection.Count)
                 //FncSetInnerCanvas();
                    //int flag2=0;
                    //for (int m = 0; m < objQueCollection.Count; m++)
                    //{
                    //    for (int k = 0; k < t1.Length; k++)
                    //    {
                    //        if ("UserControl" + objQueCollection[m].ID.ToString() == t1[k].Name )
                    //        {
                    //            break;
                    //        }
                    //        else
                    //        {
                    //            flag2 = 1;
                    //        }
                    //    }
                    //}
                }
                catch (Exception ex)
                {
                    VMuktiHelper.ExceptionHandler(ex, "FncSetCanvas()", "ctlCRMDesigner.xaml.cs");
                }

            }
            else
            {
                //do nothing
            }

        }
        void cnvPaint_Drop(object sender, DragEventArgs e)
        {
            try
            {
                if (e.Data.GetData(typeof(Button)) != null)
                {
                    if (((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Name.ToString() == "cnvControls")
                    {

                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Button btn = new Button();
                        btn.Height = 25;
                        btn.Width = 100;
                        btn.Content = "Button";
                        btn.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
                        btn.SetValue(Canvas.LeftProperty, 10.0);
                        btn.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(btn);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        if (currentControl.rect.Visibility == Visibility.Visible)
                        {
                            Point p = e.GetPosition((IInputElement)cnvPaint);
                            ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                            ((Canvas)((Button)e.Data.GetData(typeof(Button))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                        }
                    }
                }
                else if (e.Data.GetData(typeof(TabControl)) != null)
                {
                    if (((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        TabControl lbl = new TabControl();
                        //lbl.Content = "TabControl";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(tabDrag999_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }

                    else if ((((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((TabControl)e.Data.GetData(typeof(TabControl))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                    }

                }
                else if (e.Data.GetData(typeof(Label)) != null)
                {
                    if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Label lbl = new Label();
                        lbl.Content = "Label";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }

                    else if ((((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                    }
                }

                else if (e.Data.GetData(typeof(TextBox)) != null)
                {
                    if (((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        TextBox txt = new TextBox();
                        txt.IsReadOnly = true;
                        txt.Cursor = Cursors.Arrow;
                        txt.Height = 25;
                        txt.Width = 100;
                        txt.Text = "TextBox";
                        txt.MouseDown += new MouseButtonEventHandler(txt_MouseDown);
                        txt.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
                        txt.SetValue(Canvas.LeftProperty, 10.0);
                        txt.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(txt);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }


                else if (e.Data.GetData(typeof(ComboBox)) != null)
                {
                    if (((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ComboBox cmb = new ComboBox();
                        cmb.Cursor = Cursors.Arrow;
                        cmb.Height = 25;
                        cmb.Width = 100;
                        cmb.Text = "ComboBox";
                        cmb.PreviewMouseDown += new MouseButtonEventHandler(cmb_PreviewMouseDown);
                        cmb.SetValue(Canvas.LeftProperty, 10.0);
                        cmb.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(cmb);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((ComboBox)e.Data.GetData(typeof(ComboBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                else if (e.Data.GetData(typeof(ListBox)) != null)
                {
                    if (((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ListBox lst = new ListBox();
                        lst.Cursor = Cursors.Arrow;
                        lst.Height = 25;
                        lst.Width = 100;
                        lst.PreviewMouseDown += new MouseButtonEventHandler(lst_PreviewMouseDown);
                        lst.SetValue(Canvas.LeftProperty, 10.0);
                        lst.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(lst);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((ListBox)e.Data.GetData(typeof(ListBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                else if (e.Data.GetData(typeof(CheckBox)) != null)
                {
                    if (((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        CheckBox chk = new CheckBox();
                        chk.Cursor = Cursors.Arrow;
                        chk.Height = 25;
                        chk.Width = 100;
                        chk.Content = "Check Box";
                        chk.PreviewMouseDown += new MouseButtonEventHandler(chk_PreviewMouseDown);
                        chk.SetValue(Canvas.LeftProperty, 10.0);
                        chk.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(chk);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((CheckBox)e.Data.GetData(typeof(CheckBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                else if (e.Data.GetData(typeof(RadioButton)) != null)
                {
                    if (((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        RadioButton rad = new RadioButton();
                        rad.Cursor = Cursors.Arrow;
                        rad.Height = 25;
                        rad.Width = 100;
                        rad.Content = "Radio Button";
                        rad.PreviewMouseDown += new MouseButtonEventHandler(rad_PreviewMouseDown);
                        rad.SetValue(Canvas.LeftProperty, 10.0);
                        rad.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(rad);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((RadioButton)e.Data.GetData(typeof(RadioButton))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }

                newDrag = 1;
                r1.Visibility = Visibility.Collapsed;
                MyPropGrid.ControlToBind = currentControl;
            }
            catch (Exception ex)
            {
                VMuktiHelper.ExceptionHandler(ex, "cnvPaint_Drop()", "ctlCRMDesigner.xaml.cs");
            }
        }
        void FncSetInnerCanvas()
        {
            //cnvPaint.Height = 280;
            //cnvPaint.Width = 700;

            Label lblHeader = new Label();
            lblHeader.Content = "KLSCRM Designer";
            lblHeader.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
            lblHeader.FontSize = 19;

            ctlPOD objPOD1 = new ctlPOD();
            objPOD1.AllowDrop = true;
            objPOD1.Height = 45;
            objPOD1.Width = 700;
            objPOD1.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
            objPOD1.SetValue(Canvas.LeftProperty, 25.0);
            objPOD1.SetValue(Canvas.TopProperty, 0.0);
            MyPropGrid.ControlToBind = objPOD1;
            objPOD1.cnvPOD.Children.Add(lblHeader);
            currentControl = objPOD1;
            cnvPaint.Children.Add(objPOD1);

            Label lblQuestion = new Label();
            lblQuestion.Content = "KLSCRM Designer2";
            lblQuestion.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
            lblQuestion.FontSize = 17;

            ctlPOD objPOD2 = new ctlPOD();
            objPOD2.AllowDrop = true;
            objPOD2.Height = 45;
            objPOD2.Width = 700;
            objPOD2.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
            objPOD2.SetValue(Canvas.LeftProperty, 0.0);
            objPOD2.SetValue(Canvas.TopProperty, 60.0);
            MyPropGrid.ControlToBind = objPOD2;
            objPOD2.cnvPOD.Children.Add(lblQuestion);
            currentControl = objPOD2;
            cnvPaint.Children.Add(objPOD2);

            ClsOptionCollection objOptCollection = ClsOptionCollection.GetAll(objQueCollection[CurrentQueCount].ID);

            varType = objQueCollection[CurrentQueCount].Category;

            if (varType == "CheckBox")
            {
                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    CheckBox chk = new CheckBox();
                    chk.Content = objOptCollection[i].Options;
                    chk.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    chk.PreviewMouseDown += new MouseButtonEventHandler(chkDrag999_PreviewMouseDown);
                    chk.Height = 18;
                    chk.FontSize = 14;
                    varTop = 120 + (30 * i);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 700;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, 25.0);
                    objPOD.SetValue(Canvas.TopProperty, varTop);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(chk);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
            }
            else if (varType == "RadioButton")
            {
                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    RadioButton chk = new RadioButton();
                    chk.Content = objOptCollection[i].Options;
                    chk.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    chk.PreviewMouseDown += new MouseButtonEventHandler(radDrag999_PreviewMouseDown);
                    chk.Height = 18;
                    chk.FontSize = 14;
                    varTop = 120 + (30 * i);

                    ctlPOD objPOD = new ctlPOD();
                    objPOD.AllowDrop = true;
                    objPOD.Height = 25;
                    objPOD.Width = 700;
                    objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                    objPOD.SetValue(Canvas.LeftProperty, 25.0);
                    objPOD.SetValue(Canvas.TopProperty, varTop);
                    MyPropGrid.ControlToBind = objPOD;
                    objPOD.cnvPOD.Children.Add(chk);
                    currentControl = objPOD;
                    cnvPaint.Children.Add(objPOD);
                }
            }
            else if (varType == "ListBox")
            {
                ListBox lst = new ListBox();
                lst.Height = 250;
                lst.Width = 700;
                lst.Tag = "code";
                lst.SetValue(Canvas.LeftProperty, 0.0);
                lst.SetValue(Canvas.TopProperty, 0.0);
                lst.PreviewMouseDown += new MouseButtonEventHandler(lstDrag999_PreviewMouseDown);
                //cnvMain.Children.Add(lst);

                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    ListBoxItem lbi = new ListBoxItem();
                    //lbi.IsEnabled = false;
                    lbi.Content = objOptCollection[i].Options;
                    lbi.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    lst.Items.Add(lbi);
                }

                ctlPOD objPOD = new ctlPOD();
                objPOD.AllowDrop = true;
                objPOD.Height = 250;
                objPOD.Width = 700;
                objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                objPOD.SetValue(Canvas.LeftProperty, 25.0);
                objPOD.SetValue(Canvas.TopProperty, 120.0);
                MyPropGrid.ControlToBind = objPOD;
                objPOD.cnvPOD.Children.Add(lst);
                currentControl = objPOD;
                cnvPaint.Children.Add(objPOD);
            }
            else if (varType == "ComboBox")
            {
                ComboBox cmb = new ComboBox();
                cmb.Height = 25;
                cmb.Width = 700;
                cmb.Tag = "code";
                cmb.PreviewMouseDown += new MouseButtonEventHandler(cmbDrag999_PreviewMouseDown);
                //lst.PreviewMouseDown += new MouseButtonEventHandler(lstDrag999_PreviewMouseDown);
                //cnvMain.Children.Add(lst);

                for (int i = 0; i < objOptCollection.Count; i++)
                {
                    ComboBoxItem cbi = new ComboBoxItem();
                    //cbi.IsEnabled = false;
                    cbi.Content = objOptCollection[i].Options;
                    cbi.Tag = objOptCollection[i].ActionQueueID.ToString() + "," + objOptCollection[i].ID.ToString();
                    cmb.Items.Add(cbi);
                }

                ctlPOD objPOD = new ctlPOD();
                objPOD.AllowDrop = true;
                objPOD.Height = 25;
                objPOD.Width = 700;
                objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                objPOD.SetValue(Canvas.LeftProperty, 25.0);
                objPOD.SetValue(Canvas.TopProperty, 120.0);
                MyPropGrid.ControlToBind = objPOD;
                objPOD.cnvPOD.Children.Add(cmb);
                currentControl = objPOD;
                cnvPaint.Children.Add(objPOD);
            }

            Button btnNext = new Button();
            btnNext.Content = "Next >> ";
            // To Identify That is has some coding and it's Next Button //
            btnNext.Tag = varType.ToString().ToLower();
            btnNext.PreviewMouseDown += new MouseButtonEventHandler(btnDrag_PreviewMouseDown);
            btnNext.FontSize = 16;

            ctlPOD objPOD3 = new ctlPOD();
            objPOD3.AllowDrop = true;
            objPOD3.Height = 35;
            objPOD3.Width = 100;
            objPOD3.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
            objPOD3.SetValue(Canvas.LeftProperty, 25.0);

            if (varType.ToLower() != "listbox" && varType.ToLower() != "combobox")
            {
                objPOD3.SetValue(Canvas.TopProperty, varTop + 35.0);
            }
            else if (varType.ToLower() == "listbox")
            {
                objPOD3.SetValue(Canvas.TopProperty, 400.0);
            }
            else if (varType.ToLower() == "combobox")
            {
                objPOD3.SetValue(Canvas.TopProperty, 200.0);
            }

            MyPropGrid.ControlToBind = objPOD3;
            objPOD3.cnvPOD.Children.Add(btnNext);
            currentControl = objPOD3;
            cnvPaint.Children.Add(objPOD3);
            varTop = 0;
        }
        void tbi_Drop(object sender, DragEventArgs e)
        {
            try
            {

                if (e.Data.GetData(typeof(Label)) != null)
                {
                    if (((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        Label lbl = new Label();
                        lbl.Content = "Label";
                        lbl.HorizontalContentAlignment = HorizontalAlignment.Center;
                        lbl.Height = 25;
                        lbl.Width = 100;
                        lbl.PreviewMouseDown += new MouseButtonEventHandler(lblDrag_PreviewMouseDown);
                        lbl.SetValue(Canvas.LeftProperty, 10.0);
                        lbl.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.cnvPOD.Children.Add(lbl);
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.KeyDown += new KeyEventHandler(objPOD_KeyDown);
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }

                    else if ((((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((Label)e.Data.GetData(typeof(Label))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);

                    }
                }

                else if (e.Data.GetData(typeof(TextBox)) != null)
                {
                    if (((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Name.ToString() == "cnvControls")
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        TextBox txt = new TextBox();
                        txt.IsReadOnly = true;
                        txt.Cursor = Cursors.Arrow;
                        txt.Height = 25;
                        txt.Width = 100;
                        txt.Text = "TextBox";
                        txt.PreviewMouseDown += new MouseButtonEventHandler(txtDrag_PreviewMouseDown);
                        txt.SetValue(Canvas.LeftProperty, 10.0);
                        txt.SetValue(Canvas.TopProperty, 10.0);

                        ctlPOD objPOD = new ctlPOD();
                        objPOD.AllowDrop = true;
                        objPOD.Height = 25;
                        objPOD.Width = 100;
                        objPOD.PreviewMouseDown += new MouseButtonEventHandler(objPOD_PreviewMouseDown);
                        objPOD.SetValue(Canvas.LeftProperty, p.X);
                        objPOD.SetValue(Canvas.TopProperty, p.Y);
                        MyPropGrid.ControlToBind = objPOD;
                        objPOD.cnvPOD.Children.Add(txt);
                        currentControl = objPOD;
                        cnvPaint.Children.Add(objPOD);
                    }
                    else if ((((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent).GetType() == typeof(ctlPOD))
                    {
                        Point p = e.GetPosition((IInputElement)cnvPaint);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.LeftProperty, p.X - PrePoint.X);
                        ((Canvas)((TextBox)e.Data.GetData(typeof(TextBox))).Parent).Parent.SetValue(Canvas.TopProperty, p.Y - PrePoint.Y);
                    }
                }



                newDrag = 1;
                r1.Visibility = Visibility.Collapsed;
                MyPropGrid.ControlToBind = currentControl;
            }

            catch (Exception ex)
            {
                ex.Data.Add("My Key", "VMukti--:--VmuktiModules--:--Call Center--:--CRMDesigner--:--CRMDesigner.Presentation--:--ctlCRMDesigner.xaml.cs--:--tbi_Drop()--");
                //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);
            }
        }