コード例 #1
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)
            {
                base.OnSelectionChanged(e);
                BSkyCanvas parent = UIHelper.FindVisualParent <BSkyCanvas>(this);
                if (parent != null && SelectionChangeBehaviour != null && BSkyCanvas.applyBehaviors == true)
                {
                    parent.ApplyBehaviour(this, SelectionChangeBehaviour);
                }
            }
        }
コード例 #2
0
        protected override void OnTextChanged(TextChangedEventArgs 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
            base.OnTextChanged(e);
            BSkyCanvas parent = UIHelper.FindVisualParent <BSkyCanvas>(this);

            //Added by Aaron 06/10/2014
            //Added the condition BSkyCanvas.applyBehaviors == true to make sure that apply behavior does not get called
            //in dialog editor mode
            //This is because we don't want events getting firect in dialog editor mode
            //This is because it may change properties of other controls whose initial values we want to preserve
            //We only want behaviors to fire after the dialog has been fully loaded.
            if (parent != null && TextChangedBehaviour != null && BSkyCanvas.applyBehaviors == true)
            {
                parent.ApplyBehaviour(this, TextChangedBehaviour);
            }
        }
コード例 #3
0
        //Used by the function private bool deployXmlXaml(string Commandname, bool overwrite) in file menueditor.xaml.cs, called when we install the dialog, we use this to get the original help file names and the name that will be used when installing these files to the config directory (The name of the command followed by the prefix
        //

        public List <helpfileset> gethelpfilenames(BSkyCanvas canvas)
        {
            List <helpfileset> ls = new List <helpfileset>();

            if (canvas.Helpfile != null && canvas.Helpfile != string.Empty)
            {
                //helpfile hf = new helpfile();
                //hf.add(count, canvas.Helpfile);
                //count ++;
                //lst.Add(hf);
                //count =count +1;
                helpfileset hs = new helpfileset();
                hs.originalhelpfilepath = canvas.Helpfile;
                hs.newhelpfilepath      = canvas.internalhelpfilename;
                ls.Add(hs);
            }
            foreach (Object obj in canvas.Children)
            {
                if (obj is BSkyButton)
                {
                    FrameworkElement fe = obj as FrameworkElement;
                    BSkyCanvas       cs = fe.Resources["dlg"] as BSkyCanvas;
                    if (cs != null)
                    {
                        ls.AddRange(gethelpfilenames(cs));
                    }
                }
            } //end of for
            return(ls);
        }
コード例 #4
0
 //Added by Aaron 11/14/2013
 //Looks for a valid property name on the canvas and all its chrildren
 public bool valPropName(string name, BSkyCanvas canvas)
 {
     foreach (FrameworkElement obj in canvas.Children)
     {
         if (valPropofCtrl(obj, name) == true)
         {
             return(true);
         }
         if (obj is BSkyRadioGroup)
         {
             BSkyRadioGroup ic       = obj as BSkyRadioGroup;
             StackPanel     stkpanel = ic.Content as StackPanel;
             foreach (FrameworkElement obj1 in stkpanel.Children)
             {
                 if (valPropofCtrl(obj, name) == true)
                 {
                     return(true);
                 }
             }
         }
         if (obj is BSkyButton)
         {
             FrameworkElement fe = obj as FrameworkElement;
             BSkyCanvas       cs = fe.Resources["dlg"] as BSkyCanvas;
             if (cs != null)
             {
                 valPropName(name, cs);
             }
         }
     }
     return(false);
 }
コード例 #5
0
        BSkyCanvas fe = null;//Anil 04Mar2013. To store sub-dialogs in session. Each option button should have only one sub-dialog
        protected override void OnClick()
        {
            base.OnClick();
            //Anil 04Mar2013 if (baseWindow == null)
            {
                BSkyCanvas parent = UIHelper.FindVisualParent <BSkyCanvas>(this);

                // Aaron fe is not the parent
                if (fe == null)//Anil 04Mar2013. Very first time sub-dialog will be null and so will be created. next time it will hold the object from first run.
                {
                    fe = this.Resources["dlg"] as BSkyCanvas;
                }
                // 01/20/2013
                //Added this code to address a defect when resources are empty
                if (fe == null)
                {
                    MessageBox.Show(BSky.GlobalResources.Properties.Resources.SubDialogNotCreated);
                    return;
                }
                //Aaron 05/05/2014
                //Commented the line below
                //We don't want users to be able to click syntax on a sub-dialog
                //I hence removed syntax on a sub-dialog
                //  baseWindow = new BaseOptionWindow();
                subDlgWindow = new SubDialogWindow();
                //Added the line below

                //Added by Aaron 10/22/2013
                //Added the code below to disable the syntax button on subdialogs

                // baseWindow.Paste.IsEnabled = false;
                subDlgWindow.Template = fe;
                var converter = new System.Windows.Media.BrushConverter();
                //Added 08/10/2014
                //This is so that the canvas dialog in sub dialog matches color of canvas
                fe.Background  = (Brush)converter.ConvertFrom("#FFEEefFf");
                fe.DataContext = this.DataContext;

                //Added aaron 05/05/2015
                //   subDlgWindow.Closing += new CancelEventHandler(Window_Closing);
                subDlgWindow.Owner = UIHelper.FindVisualParent <BaseOptionWindow>(this);
            }

            if (fe.GetType().Name == "BSkyCanvas")
            {
                subDlgWindow.ResizeMode = ResizeMode.NoResize;                                   //Aaron's
            }
            subDlgWindow.ShowDialog();
            //Added by Aaron 05/05/2015
            subDlgWindow.DetachCanvas();
            subDlgWindow.Template = null; //Anil 04Mar2013 Parent Child relation is un-set.
        }
コード例 #6
0
        public FrameworkElement GetResource(string name)
        {
            BSkyCanvas canvas = UIHelper.FindVisualParent <BSkyCanvas>(this);

            foreach (FrameworkElement fe in canvas.Children)
            {
                if (fe.Name == name)
                {
                    return(fe);
                }
            }
            return(null);
        }
コード例 #7
0
        //Added by Aaron 01/01/2014
        //This function was added to ensure that when a slave name was added, a valid slave name was added
        //This is called from  void OptionsPropertyGrid_PropertyValueChanged(object s, System.Windows.Forms.PropertyValueChangedEventArgs e)
        //in window1.xaml.cs
        public bool checkIfValidChild(string slavename)
        {
            BSkyCanvas canvas = UIHelper.FindVisualParent <BSkyCanvas>(this);

            foreach (FrameworkElement fe in canvas.Children)
            {
                if (fe.Name == slavename && fe is BSkyListBox)
                {
                    return(true);
                }
            }
            return(false);
        }
コード例 #8
0
        protected override void OnChecked(System.Windows.RoutedEventArgs e)
        {
            base.OnChecked(e);
            BSkyCanvas parent = UIHelper.FindVisualParent <BSkyCanvas>(this);

            //Added by Aaron 06/10/2014
            //Added the condition BSkyCanvas.applyBehaviors == true to make sure that apply behavior does not get called
            //in dialog editor mode
            //This is because we don't want events getting firect in dialog editor mode
            //This is because it may change properties of other controls whose initial values we want to preserve
            //We only want behaviors to fire after the dialog has been fully loaded.
            if (parent != null && CheckedChangeBehaviour != null && BSkyCanvas.applyBehaviors == true)
            {
                parent.ApplyBehaviour(this, CheckedChangeBehaviour);
            }
        }
コード例 #9
0
        //Added by Aaron 01/23/2013
        // Added by Aaron 03/31/2013
        // The internalhelpfilename holds the name of the help file that will be saved to the bin/config directory
        //In the function  private bool deployXmlXaml(string Commandname, bool overwrite) in file menueditor.xaml.cs, called when we install the dialog, we use this property to name the help files
        //IN the BSky file, the help files have their original name. This is so that if you unzip the dialog definition, so you see what you expect
        //We only change the help file names to the dialog name with a suffix of a number (as a single dialog can have multiple help files
        //If there is a valid help file associated with the canvas, then this function automaticaly associates it with an internalhelpfilename

        //The parameter 1 starts the suffix which is used to name the help files with 1

        public void processhelpfiles(BSkyCanvas canvas, string dialogName, int count)
        {
            if (canvas.Helpfile != null && canvas.Helpfile != string.Empty)
            {
                //helpfile hf = new helpfile();
                //hf.add(count, canvas.Helpfile);
                //count ++;
                //lst.Add(hf);
                //count =count +1;

                if (File.Exists(canvas.Helpfile))
                {
                    canvas.internalhelpfilename = dialogName + '_' + count.ToString() + System.IO.Path.GetExtension(canvas.Helpfile);
                    count = count + 1;
                }
                else
                {
                    Uri    myUri;
                    string url = canvas.Helpfile;
                    if (!url.StartsWith("http://"))
                    {
                        url = "http://" + url;
                    }
                    if (Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out myUri))
                    {
                        canvas.internalhelpfilename = "urlOrUri";
                        canvas.Helpfile             = url;
                    }
                    else
                    {
                        MessageBox.Show(BSky.GlobalResources.Properties.Resources.HelpMustBeValidFileURL);
                    }
                }
            }
            foreach (Object obj in canvas.Children)
            {
                if (obj is BSkyButton)
                {
                    FrameworkElement fe = obj as FrameworkElement;
                    BSkyCanvas       cs = fe.Resources["dlg"] as BSkyCanvas;
                    if (cs != null)
                    {
                        processhelpfiles(cs, dialogName, count);
                    }
                }
            } //end of for
        }
コード例 #10
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);
        }
コード例 #11
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);
        }