コード例 #1
0
        /// <summary>
        /// Copy names from a parent variable
        /// </summary>
        /// <param name="parent"></param>
        public void copyNamesFrom(Variable parent, int toLevel)
        {
            try
            {
                if (!toLevel.Between(1, 5))
                {
                    throw new Exception("toLevel should be an integer between 1 and 5");
                }
                if (toLevel >= 1)
                {
                    var1 = parent.var1.emptyIfNull();
                }
                if (toLevel >= 2)
                {
                    var2 = parent.var2.emptyIfNull();
                }
                if (toLevel >= 3)
                {
                    var3 = parent.var3.emptyIfNull();
                }
                if (toLevel >= 4)
                {
                    var4 = parent.var4.emptyIfNull();
                }
                if (toLevel == 5)
                {
                    var5 = parent.var5.emptyIfNull();
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 /// <summary>
 /// Default constructor
 /// </summary>
 public AddVariableRequest()
 {
     this.data = new Variable();
     this.data.var1 = "";
     this.data.var2 = "";
     this.data.var3 = "";
     this.data.var4 = "";
     this.data.var5 = "";
 }
コード例 #3
0
        /// <summary>
        /// Reset the form values
        /// </summary>
        public void ResetForm()
        {
            selectedParentVariable = null;
            selectedParentTreeNode = null;

            foreach (Control field in this.Controls)
            {
                if (field is TextBox)
                {
                    ((TextBox)field).Clear();
                }
                else if (field is ComboBox)
                {
                    ((ComboBox)field).SelectedIndex = 0;

                }
            }

        }
コード例 #4
0
        /// <summary>
        /// Populate form with values from an existing tree node
        /// </summary>
        /// <param name="node"></param>
        private void populateForm(StatTreeNode node)
        {
            if (node == null)
            {
                return;
            }

            // Disable editing if node selected parent level is greater than 3
            if (node.Level > 3)
            {
                formPanel.Enabled = false;
                return;
            }
            else
            {
                formPanel.Enabled = true;
            }

            // Get variable from selected node
            Variable sv = (Variable)node.Tag;

            // Set selected parent nodes
            selectedParentTreeNode = node;
            selectedParentVariable = sv;

            // Set level of NEW node
            tbVarLevel.Text = (node.Level + 2).ToString();

            // Get the name of the selected node
            tbParentVariable.Text = sv.getNameAtLevel(node.Level + 1);
            
            // Populate text and comboboxes
            cbKretstyper.SelectedValue = sv.fk_kretstyper;
            cbTimeUnit.SelectedValue = sv.time_unit;
            cbUnit.SelectedValue = sv.unit;
            chkbShowUnit.Checked = sv.showunit;

        }