//Added by Aaron 07/20/2014
        //this function looks at all the objects on the canvas recursively (for subdialogs) that contain the Overwrite settings property
        //The overwrite setting value controls whether the user should be prompted when creating a new variable or dataset and that variable or dataset already exists.
        public Boolean CheckForOverwrittenVars(BSkyCanvas cs)
        {
            System.Windows.Forms.DialogResult result;
            Boolean stopexecution = false;
            string  message;

            foreach (object obj in cs.Children)
            {
                if (obj.GetType().Name == "BSkyTextBox")
                {
                    BSkyTextBox tb = obj as BSkyTextBox;
                    if (tb.OverwriteSettings == "PromptBeforeOverwritingVariables")
                    {
                        List <DataSourceVariable> varlst = UIController.GetActiveDocument().Variables;
                        // UIController.
                        //as=UIController.Re
                        // List<DataSourceVariable> varlst = UIController.
                        foreach (DataSourceVariable dsv in varlst)
                        {
                            // varnames = varnames + ", " + dsv.Name;
                            if (dsv.Name == tb.Text)
                            {
                                message = "Do you want to overwrite variable " + tb.Text;
                                result  = System.Windows.Forms.MessageBox.Show(message, "Save Changes", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Question);
                                if (result == System.Windows.Forms.DialogResult.Yes)//save
                                {
                                }
                                if (result == System.Windows.Forms.DialogResult.Cancel)//save
                                {
                                    return(stopexecution = true);
                                }
                                if (result == System.Windows.Forms.DialogResult.No)//save
                                {
                                    return(stopexecution = true);
                                }
                            }
                        }
                    }


                    if (tb.OverwriteSettings == "PromptBeforeOverwritingDatasets")
                    {
                        // List<DataSourceVariable> varlst = UIController.GetActiveDocument().Variables;
                        // UIController.
                        //as=UIController.Re
                        // List<DataSourceVariable> varlst = UIController.
                        List <string> datasetnames;
                        datasetnames = UIController.GetDatasetNames();

                        foreach (string dataset in datasetnames)
                        {
                            if (dataset == tb.Text)
                            {
                                message = "Do you want to overwrite dataset " + tb.Text;
                                result  = System.Windows.Forms.MessageBox.Show(message, "Save Changes", System.Windows.Forms.MessageBoxButtons.YesNoCancel, System.Windows.Forms.MessageBoxIcon.Question);
                                if (result == System.Windows.Forms.DialogResult.Yes)//save
                                {
                                }
                                if (result == System.Windows.Forms.DialogResult.Cancel)//save
                                {
                                    return(stopexecution = true);
                                }
                                if (result == System.Windows.Forms.DialogResult.No)//save
                                {
                                    return(stopexecution = true);
                                }
                            }
                        }
                    }
                }
                else if (obj.GetType().Name == "BSkyButton")
                {
                    BSkyButton       btn  = obj as BSkyButton;
                    FrameworkElement fe   = obj as FrameworkElement;
                    BSkyCanvas       cnvs = fe.Resources["dlg"] as BSkyCanvas;
                    // if (cs != null) ls.AddRange(gethelpfilenames(cs));
                    stopexecution = CheckForOverwrittenVars(cnvs);
                }
            }
            return(stopexecution);
        }
        private void PreExecuteSub()//16May2013
        {
            UIController = LifetimeService.Instance.Container.Resolve<IUIController>();

            ds = UIController.GetActiveDocument();

            if (ds != null) //24Apr2014 
            {
                List<string> datasetnames = new List<string>();
                int i = 0;

                Variables = new ObservableCollection<DataSourceVariable>(ds.Variables);
                datasetnames = UIController.GetDatasetNames();
                int count = datasetnames.Count;
                Datasets = new List<DatasetDisplay>();
                for (i = 0; i < count; i++)
                {
                    DatasetDisplay temp = new DatasetDisplay();
                    temp.Name = datasetnames[i];
                    temp.ImgURL = "../Resources/ordinal.png";
                    Datasets.Add(temp);


                }
            }
        }