コード例 #1
0
        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);
        }
コード例 #2
0
        //recursively looks at every canvas for the control. Recursion is used when there is a button on the canvas
        private FrameworkElement returnCtrl(string ControlName, BSkyCanvas cs)
        {
            IBSkyEnabledControl objcast = null;
            FrameworkElement    retval  = null;;

            foreach (Object obj in cs.Children)
            {
                if (obj is IBSkyControl)
                {
                    //All controls that can be dropped on the canvas inherit from IBSkyControl
                    IBSkyControl ib = obj as IBSkyControl;
                    if (ib.Name == ControlName)
                    {
                        //Checking if the control is valid
                        //The following controls inherit from IBSKyInputControl
                        //BSKyCheckBox, BSKyComboBox, BSkyGroupingVariable, BSkyRadioButton, BSkyRadioGroup, BSkyTextBox, BSkySourceList, BSkyTargetList
                        objcast = obj as IBSkyEnabledControl;
                        if (objcast != null)
                        {
                            return(ib as FrameworkElement);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    //05/18/2013
                    //Added by Aaron
                    //Code below checks the radio buttons within each radiogroup looking for duplicate names
                    if (obj is BSkyRadioGroup)
                    {
                        BSkyRadioGroup ic       = obj as BSkyRadioGroup;
                        StackPanel     stkpanel = ic.Content as StackPanel;

                        foreach (object obj1 in stkpanel.Children)
                        {
                            BSkyRadioButton btn = obj1 as BSkyRadioButton;
                            if (btn.Name == ControlName)
                            {
                                return(btn as FrameworkElement);
                            }
                        }
                    }
                }
                if (obj is BSkyButton)
                {
                    FrameworkElement fe     = obj as FrameworkElement;
                    BSkyCanvas       canvas = fe.Resources["dlg"] as BSkyCanvas;
                    if (canvas != null)
                    {
                        retval = returnCtrl(ControlName, canvas);
                        if (retval != null)
                        {
                            return(retval);
                        }
                    }
                }
            }

            return(null);
        }
コード例 #3
0
        //public void propCtrlMethods()
        //{

        //}

        //Is the property a valid property of the control
        public bool valPropofCtrl(FrameworkElement obj, string propertyName)
        {
            string[] validProperties = null;
            if (obj != null)
            {
                if (obj is BSkySourceList || obj is BSkyTargetList)
                {
                    validProperties = new string[] { "maxNoOfVariables", "ItemsCount", "MoveVariables", "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            // Type t = obj.GetType();
                            //Get information of the property on which the condition is specified. The property belongs to the object
                            //PropertyInfo pInfo = t.GetProperty(propertyName);
                            //Type propType = pInfo.PropertyType;

                            return(true);
                        }
                    }
                    return(false);
                }
                if (obj is BSkyListBoxwBorderForDatasets)
                {
                    validProperties = new string[] { "maxNoOfVariables", "ItemsCount", "MoveVariables", "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            // Type t = obj.GetType();
                            //Get information of the property on which the condition is specified. The property belongs to the object
                            //PropertyInfo pInfo = t.GetProperty(propertyName);
                            //Type propType = pInfo.PropertyType;

                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkyListBox)
                {
                    validProperties = new string[] { "SelectedItemsCount", "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkyTextBox)
                {
                    validProperties = new string[] { "Text", "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkyEditableComboBox)
                {
                    validProperties = new string[] { "DefaultSelection", "NoItemsSelected", "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkyNonEditableComboBox)
                {
                    validProperties = new string[] { "NoItemsSelected", "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }


                else if (obj is BSkyCheckBox)
                {
                    validProperties = new string[] { "Text", "IsSelected", "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkyRadioButton)
                {
                    validProperties = new string[] { "Text", "IsSelected", "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkyRadioGroup)
                {
                    validProperties = new string[] { "Text", "IsSelected", "CanExecute", "Enabled" };
                    BSkyRadioGroup ic       = obj as BSkyRadioGroup;
                    StackPanel     stkpanel = ic.Content as StackPanel;
                    foreach (object obj1 in stkpanel.Children)
                    {
                        BSkyRadioButton btn = obj1 as BSkyRadioButton;
                        foreach (string x in validProperties)
                        {
                            if (x == propertyName)
                            {
                                return(true);
                            }
                        }
                    }
                    return(false);
                }


                else if (obj is BSkyButton)
                {
                    validProperties = new string[] { "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkyBrowse)
                {
                    validProperties = new string[] { "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkyGroupingVariable)
                {
                    validProperties = new string[] { "CanExecute", "Enabled", "ItemsCount" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkyAggregateCtrl)
                {
                    validProperties = new string[] { "CanExecute", "Enabled", "ItemsCount" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }

                else if (obj is BSkySortCtrl)
                {
                    validProperties = new string[] { "CanExecute", "Enabled", "ItemsCount" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else if (obj is BSkygridForSymbols)
                {
                    validProperties = new string[] { "CanExecute", "Enabled" };
                    foreach (string x in validProperties)
                    {
                        if (x == propertyName)
                        {
                            return(true);
                        }
                    }
                    return(false);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
            //  PropertyInfo [] propertyholder =   BSky.Controls.Window1.selectedElementRef.GetType().GetProperties();
            // PropertyInfo[] prop_info_array = obj.GetType().GetProperties();
            //PropertyInfo proptemp = obj.GetType().GetProperty("propertylist");
            //  foreach (PropertyInfo pInfo in prop_info_array)
            // {
            //m = (CategoryAttribute[])pInfo.GetCustomAttributes(typeof(CategoryAttribute), false);
            // AttributeCollection att_coll = TypeDescriptor.GetAttributes(pInfo);

            //   if (pInfo.Name == propertyName) return true;
            // }
            //    if (success == false)
            //      //  System.Windows.Forms.MessageBox.Show("You have entered an invalid property name, please review the property names in                        the grid and enter a valid value");
            //    return false;
            //}
            //return false;
        }