コード例 #1
0
        //04/13/2013
        //Aaron
        //This code is invoked when clicking the dialog designer lookup button to create a sub dialog
        protected override Control GetEditControl(string PropName, object CurrentValue,object CurrentObj)
        {
            int length = 0;
            //Aaron added 11/10/2013
            //Object wrapper is a wrapper object used to show categories in the grid
            //We need to extract the button object from the wrapper
            ObjectWrapper placeHolder=CurrentObj as ObjectWrapper;
            FrameworkElement selectedElement = placeHolder.SelectedObject as FrameworkElement;
            Window1 w = null;
            BSkyCanvas temp;
            if (selectedElement.Resources.Count > 0)
            {
                //Added 11/24/2013 by Aaron
                //I need to add this back to the chain of control so that this canvas is evaluated for duplicate detection
                //even though this canvas is represented in resources of the button, the canvas can be modified in resources
                //To ensure that its not searched 2 times (for duplicate detection or for setting of behaviours), I also remove it from the resources in line 3 below
               // BSkyCanvas.chainOpenCanvas.Add(selectedElement.Resources["dlg"] as BSkyCanvas);
              //selectedElement.Resources.Remove("dlg");
               // w = new Window1(selectedElement.Resources["dlg"] as BSkyCanvas, false);
                //Code below saves the original state of the canvas
                temp = selectedElement.Resources["dlg"] as BSkyCanvas;

                foreach (object obj in temp.Children)
                {
                    if (obj is IBSkyEnabledControl)
                    {
                        
                        IBSkyEnabledControl bskyCtrl = obj as IBSkyEnabledControl;
                        bskyCtrl.Enabled = bskyCtrl.IsEnabled;
                        bskyCtrl.IsEnabled = true;
                    }
                }

                //Adds it to the chainOpenCanvas for duplicate detection and property searches
                BSkyCanvas.chainOpenCanvas.Add(selectedElement.Resources["dlg"] as BSkyCanvas);
                //Removes it from button resources so canvas does not get searches 2 times
                selectedElement.Resources.Remove("dlg");
                w = new Window1(temp, false);
            }
            else
            {
                w = new Window1(false);
                //Added by Aaron 05/13/2014
                BSkyCanvas.chainOpenCanvas.Add(w.CanvasHost.Child as BSkyCanvas);
            }
            //I use this to prevent opening and saving on subdialogs
            w.CanOpen = false;
            w.CanSave = false;
            w.CanSaveSubDialog = true;
         
            return w;
        }
コード例 #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);
        }