Esempio n. 1
0
        private bool checkDuplicateNameInRdGrp(BSkyCanvas canvas, string name)
        {
            string message;

            foreach (Object obj in canvas.Children)
            {
                // if (obj is IBSkyControl && obj != selectedElement)
                if (obj is IBSkyControl)
                {
                    IBSkyControl ib = obj as IBSkyControl;
                    //if (ib.Name == e.ChangedItem.Value.ToString())
                    if (ib.Name == name)
                    {
                        message = string.Format(BSky.GlobalResources.Properties.Resources.PlzEnterUniqueName, name);
                        MessageBox.Show(message);
                        //  this.OptionsPropertyGrid.ResetSelectedProperty();
                        return(true);
                    }
                }

                //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 == name)
                        {
                            message = string.Format(BSky.GlobalResources.Properties.Resources.PlzEnterUniqueName, name);
                            MessageBox.Show(message);
                            return(true);
                        }
                    }
                }
                if (obj is BSkyButton)
                {
                    FrameworkElement fe = obj as FrameworkElement;
                    BSkyCanvas       cs = fe.Resources["dlg"] as BSkyCanvas;
                    if (cs != null)
                    {
                        if (checkDuplicateNameInRdGrp(cs, name))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Esempio n. 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);
        }