public FrameworkElement CreateControl(string objtype)
        {
            FrameworkElement b = null;

            switch (objtype)
            {
            case "SourceListBox":
                //When invoked from the dialog creator, renderVars is set to true
                //   CommonFunctions cf = new CommonFunctions();
                b = new BSkySourceList(true, true);
                BSkySourceList c = b as BSkySourceList;
                //  cf.DisplayNameGridProperty(c, "Type", "The source variable list displays all the variables in the active dataset.");
                //  cf.DisplayNameGridProperty(c, "CanExecute", "Default value is True. This property controls whether the OK button on the dialog is enabled or disabled.If CanExecute =true for all controls on the dialog and contained sub-dialogs, the OK button is enabled, if CanExecute =false for any one control on the dialog or contained sub-dialogs, the OK button is disabled.");
                //cf.DisplayNameGridProperty(c, "SelectionChangeBehaviour", "Default is empty(no rule). Use this optional property to define rules that trigger property changes in this or other controls, based on the change in state of this variable list control.");

                //     [Description("Default is empty(no rule). Use this optional property to define rules that trigger property changes in this or other controls, based on the change in state of this checkbox control. For example, if a user checks the checkbox, enable a textbox control to capture additional parameters. To define a rule, click in the property and click the elipses button.")]
                b.Width  = 135;
                b.Height = 240;
                break;

            case "TargetListBox":
                b = new BSkyTargetList(false, true);
                BSkyTargetList c1 = b as BSkyTargetList;
                //CommonFunctions cf1 = new CommonFunctions();
                //cf1.DisplayNameGridProperty(c1, "Type", "The target variable list contains the variables you want to analyze. Drag and drop the variables you want to analyze from the source variable list to one or more target variable lists.");

                //cf1.DisplayNameGridProperty(c1, "CanExecute", "Default value is True. This property controls whether the OK button on the dialog is enabled or disabled. If CanExecute =true for all controls on the dialog and contained sub-dialogs, the OK button is enabled, if CanExecute =false for any one control on the dialog or contained sub-dialogs, the OK button is disabled. For example, if a user adds a variable to this variable list, set the canexecute property to 'true', which enables the OK button on the dialog (remember to set another rule to set canexecute to false when All items are removed from this variable list and the value of the itemscount property is 0). This ensures that the dialog cannot be executed unless one or more items are dragged and dropped into this variable list control. To define a rule, click in the property and then click the elipses button.");

                //cf1.DisplayNameGridProperty(c1, "SelectionChangeBehaviour", "Default is empty(no rule). Use this optional property to define rules that trigger property changes in this or other controls, based on the change in state of this variable list control.For example, if a user adds a variable to this variable list, set the canexecute property to 'true', which enables the OK button on the dialog (remember to set another rule to set canexecute to false when All items are removed from this variable list and the value of the itemscount property is 0). This ensures that the dialog cannot be executed unless one or more items are dragged and dropped into this variable list control. To define a rule, click in the property and then click the elipses button.");
                b.Width  = 135;
                b.Height = 240;
                break;

            case "Button":
                b        = new BSkyButton();
                b.Width  = 100;
                b.Height = 30;
                break;

            case "textbox":
                b        = new BSkyTextBox();
                b.Width  = 135;
                b.Height = 30;
                break;

            case "GrpBox":
                b        = new BSkyGroupBox();
                b.Width  = 150;
                b.Height = 100;
                break;

            case "ChkBox":
                b        = new BSkyCheckBox();
                b.Width  = 75;
                b.Height = 20;
                break;

            case "RdBtn":
                b        = new BSkyRadioButton();
                b.Width  = 75;
                b.Height = 20;
                break;

            case "EditCombo":
                b        = new BSkyEditableComboBox();
                b.Width  = 100;
                b.Height = 25;
                break;

            case "NonEditCombo":
                b        = new BSkyNonEditableComboBox();
                b.Width  = 100;
                b.Height = 25;
                break;

            case "Label":
                b        = new BSkyLabel();
                b.Width  = 50;
                b.Height = 25;
                break;

            case "MultiLabel":
                b        = new BSkyMultiLineLabel();
                b.Width  = 100;
                b.Height = 25;
                break;

            case "Canvas":
                b = new BSkyCanvas();
                BSkyCanvas.dialogMode = true;
                b.Width  = 470;
                b.Height = 300;
                //    b.Width = 0;
                //  b.Height = 0;
                break;

            case "MoveButton":
                // b = new BSkyVariableMoveButton(true);
                b        = new BSkyVariableMoveButton();
                b.Width  = 35;
                b.Height = 35;
                break;

            case "RadioGroup":
                b        = new BSkyRadioGroup();
                b.Width  = 100;
                b.Height = 100;
                break;

            // Added by Aaron 03/31
            case "Browse":
                b        = new BSkyBrowse();
                b.Width  = 100;
                b.Height = 30;
                break;

            case "GroupingVariable":
                b       = new BSkyGroupingVariable();
                b.Width = 135;
                // BSkyGroupingVariable bc = b as BSkyGroupingVariable;
                // bc.oneItemList.Width = 100;
                // bc.Height = 50;
                b.Height = 30;
                break;

            case "gridForSymbols":
                // b = new BSkyScrollTextBox();
                b = new BSkygridForSymbols();
                //b.Width = 135;
                // BSkyGroupingVariable bc = b as BSkyGroupingVariable;
                // bc.oneItemList.Width = 100;
                // bc.Height = 50;
                //b.Height = 40;
                break;

            case "GridforCompute":
                // b = new BSkyScrollTextBox();
                b        = new BSkygridForCompute();
                b.Width  = 300;
                b.Height = 300;
                //b.Width = 135;
                // BSkyGroupingVariable bc = b as BSkyGroupingVariable;
                // bc.oneItemList.Width = 100;
                // bc.Height = 50;
                //b.Height = 40;
                break;


            case "ListBox":
                // b = new BSkyScrollTextBox();
                b        = new BSkyListBox();
                b.Width  = 135;
                b.Height = 120;
                // BSkyGroupingVariable bc = b as BSkyGroupingVariable;
                // bc.oneItemList.Width = 100;
                // bc.Height = 50;
                //b.Height = 40;
                break;

            case "SourceDatasetList":
                b        = new BSkyListBoxwBorderForDatasets(true, true);
                b.Width  = 135;
                b.Height = 120;
                // BSkyGroupingVariable bc = b as BSkyGroupingVariable;
                // bc.oneItemList.Width = 100;
                // bc.Height = 50;
                //b.Height = 40;
                break;

            case "DestinationDatasetList":
                b        = new BSkyListBoxwBorderForDatasets(false, true);
                b.Width  = 135;
                b.Height = 120;
                // BSkyGroupingVariable bc = b as BSkyGroupingVariable;
                // bc.oneItemList.Width = 100;
                // bc.Height = 50;
                //b.Height = 40;
                break;


            case "MasterListBox":
                // b = new BSkyScrollTextBox();
                b        = new BSkyMasterListBox();
                b.Width  = 135;
                b.Height = 120;
                // BSkyGroupingVariable bc = b as BSkyGroupingVariable;
                // bc.oneItemList.Width = 100;
                // bc.Height = 50;
                //b.Height = 40;
                break;

            case "AggregateCtrl":
                b        = new BSkyAggregateCtrl();
                b.Width  = 235;
                b.Height = 335;
                // BSkyGroupingVariable bc = b as BSkyGroupingVariable;
                // bc.oneItemList.Width = 100;
                // bc.Height = 50;
                //b.Height = 40;
                break;

            case "SortCtrl":
                b        = new BSkySortCtrl();
                b.Width  = 280;
                b.Height = 202;
                // BSkyGroupingVariable bc = b as BSkyGroupingVariable;
                // bc.oneItemList.Width = 100;
                // bc.Height = 50;
                //b.Height = 40;
                break;
            }

            //b.Name = GetName(objtype);
            return(b);
        }
Exemple #2
0
        protected override void OnSelectionChanged(SelectionChangedEventArgs e)
        {
            //A control is associated with a behavior collection
            //A behavior collection is a collection of behaviors
            //A behavior can contains one condition e.g. itemscount = 0 and one or more setters e.g. set the property canexecute =true on control destination. The setter also stores the
            //value of the property its bound to (the control and the propert name)
            //Behaviors are invoked on the control when a particular activity takes place for e.g. when a selection changes on a listbox control, when text is entered
            //on a text control.
            //Typical use case for behaviors is as follows. Every control has a CanExecute property. This can be enabled or disabled by default.
            //The OK button will only be enabled when the can execute property of all the controls on the canvas are set to true.
            //
            //For example, when the
            //one sample t.test dialog is rendered for the first time, the destination listbox will always be empty. We would then set the default value of canexecute to false.
            //We would define a condition for when items count is > than 0 and set canexecute for the destination property to true only when items count is > than 0.
            //We would also add another condition to set Canexecute to false when items count is 0 to account for the case when users move variables from the destination
            //back to the source.
            //Also note that you can have canexecute to true on the destination control of one sample t.test but have the canexecute property on the textbox set to false
            //as no valid entry has be entered tocompare the dialog against. In this situation the OK button on the dialog is disabled


            // Aaron 12/25 code below ensures that the events don't fire when I am in dialog editor mode.
            //This is to address the defect when in dialog mode, the itemscount =3 and the event on the destination list fires to set CanExecute to true
            //even though the intention is to save the dialog with CanExecute to False. This will disable the OK button when running the application unless
            //one item is in the destination list

            //if (!renderVars)
            //{

            //Since we support master slave listboxes, we need to handle the following scenarios
            //1. The case that a master listbox points to a slave that does not exist or was deleted
            //2. NOT AN ERROR CONDITION Master listbox points has an empty slave, this is fine and supported.
            //3. One or more master listboxes point to the same slave
            //4. NOT AN ERROR CONDITION Master listbox points to a valid slave but no master slave mappings created. In this situation as there are no mappings as soon as an entry in the master is selected, the slave blanks out as there are no entries in the slave that map to the master. The initial settings for the slave is to display all entries
            //5. NOT AN ERROR CONDITION In the case that the entry selected does not have any mapping to the slave, the slave blanks out
            base.OnSelectionChanged(e);
            //Added by Aaron 07/05/2014
            //Prevents the slave listbox being populated with items based on selection in master listbox in dialog editor mode
            if (BSkyCanvas.applyBehaviors == true)
            {
                string           newselection = this.SelectedItem as string;
                FrameworkElement feslave      = GetResource(this.SlaveListBoxName);
                //feslave is null if there is no valid slave listbox, in this case we don't try and display anyting in the slave listbox
                //The slave listbox does not exist and we just treat the master as a normal listbox
                if (feslave != null)
                {
                    BSkyListBox slavelistbox = feslave as BSkyListBox;
                    //4. NOT AN ERROR CONDITION Master listbox points to a valid slave but no master slave mappings created. In this situation as there are no mappings as soon as an entry in the master is selected, the slave blanks out as there are no entries in the slave that map to the master. The initial settings for the slave is to display all entries
                    if (MappingMasterSlaveEntries == null)
                    {
                        slavelistbox.Items.Clear(); return;
                    }
                    if (MappingMasterSlaveEntries.Count == 0)
                    {
                        slavelistbox.Items.Clear(); return;
                    }
                    slavelistbox.Items.Clear();
                    int i = 0;
                    foreach (MasterSlaveEntry mse in MappingMasterSlaveEntries)
                    {
                        if (mse.masterentry == newselection)
                        {
                            slavelistbox.Items.Add(mse.slaveentry as string);
                        }
                        if (i == 0)
                        {
                            slavelistbox.SelectedIndex = 0;
                            i = 1;
                        }
                    }
                }
            }
        }