Inheritance: System.Windows.Controls.UserControl
Exemplo n.º 1
0
        public void SetVariables(IList <FRandomVariable> variables, IDictionary <string, string> abbreviations)
        {
            var uichildren = xVariableList.Children;
            int i          = 0;

            foreach (var rv in variables)
            {
                if (i >= uichildren.Count)
                {
                    VariablesInspectorVariable niv = new VariablesInspectorVariable();
                    niv.SetVariable(rv, abbreviations);
                    xVariableList.Children.Add(niv);
                }
                else
                {
                    FRandomVariable rv_i = (uichildren[i] as VariablesInspectorVariable).GetVariable();
                    if (rv_i != rv)
                    {
                        VariablesInspectorVariable niv_rv
                            = uichildren
                              .OfType <VariablesInspectorVariable>()
                              .Where(niv => niv.GetVariable() == rv)
                              .FirstOrDefault();
                        if (niv_rv != null)
                        {
                            uichildren.Remove(niv_rv);
                        }
                        else
                        {
                            niv_rv = new VariablesInspectorVariable();
                            niv_rv.SetVariable(rv, abbreviations);
                        }

                        uichildren.Insert(i, niv_rv);
                    }
                }
                ++i;
            }

            if (uichildren.Count >= variables.Count)
            {
                uichildren.RemoveRange(variables.Count, uichildren.Count - variables.Count);
            }
        }
Exemplo n.º 2
0
        public void SetVariables(IList<FRandomVariable> variables, IDictionary<string,string> abbreviations)
        {
            var uichildren = xVariableList.Children;
            int i = 0;
            foreach (var rv in variables)
            {
                if (i >= uichildren.Count)
                {
                    VariablesInspectorVariable niv = new VariablesInspectorVariable();
                    niv.SetVariable(rv, abbreviations);
                    xVariableList.Children.Add(niv);
                }
                else
                {
                    FRandomVariable rv_i = (uichildren[i] as VariablesInspectorVariable).GetVariable();
                    if (rv_i != rv)
                    {
                        VariablesInspectorVariable niv_rv
                            = uichildren
                            .OfType<VariablesInspectorVariable>()
                            .Where(niv => niv.GetVariable() == rv)
                            .FirstOrDefault();
                        if (niv_rv != null)
                        {
                            uichildren.Remove(niv_rv);
                        }
                        else
                        {
                            niv_rv = new VariablesInspectorVariable();
                            niv_rv.SetVariable(rv, abbreviations);
                        }

                        uichildren.Insert(i, niv_rv);
                    }
                }
                ++i;
            }

            if (uichildren.Count >= variables.Count)
            {
                uichildren.RemoveRange(variables.Count, uichildren.Count - variables.Count);
            }
        }