예제 #1
0
        internal PipelineVariable(XmlNode node)
        {
            id = node.Attributes["id"].Value.Trim();
            name = Banshee.Base.Localization.SelectSingleNode(node, "name").InnerText.Trim();
            control_type = StringToControlType(node.SelectSingleNode("control-type").InnerText.Trim());

            XmlAttribute enables_attr = node.Attributes["enables"];
            if(enables_attr != null && enables_attr.Value != null) {
                string [] vars = enables_attr.Value.Split(',');
                if(vars != null && vars.Length > 0) {
                    enables = new string[vars.Length];
                    for(int i = 0; i < vars.Length; i++) {
                        enables[i] = vars[i].Trim();
                    }
                }
            }

            XmlAttribute disables_attr = node.Attributes["disables"];
            if(disables_attr != null && disables_attr.Value != null) {
                string [] vars = disables_attr.Value.Split(',');
                if(vars != null && vars.Length > 0) {
                    disables = new string[vars.Length];
                    for(int i = 0; i < vars.Length; i++) {
                        disables[i] = vars[i].Trim();
                    }
                }
            }

            try {
                XmlNode unit_node = node.SelectSingleNode("unit");
                if(unit_node != null) {
                    unit = node.SelectSingleNode("unit").InnerText.Trim();
                }
            } catch {
            }

            try {
                XmlNode advanced_node = node.SelectSingleNode("advanced");
                if(advanced_node != null) {
                    advanced = ParseAdvanced(advanced_node.InnerText);
                }
            } catch {
            }

            default_value = ReadValue(node, "default-value");
            min_value = ToDouble(ReadValue(node, "min-value"));
            max_value = ToDouble(ReadValue(node, "max-value"));
            min_label = ReadValue(node, "min-label", true);
            max_label = ReadValue(node, "max-label", true);

            string step_value_str = ReadValue(node, "step-value");
            if(step_value_str != null) {
                bool zeros = true;
                step_precision = step_value_str.IndexOf(".") + 1;

                for(int i = step_precision; i > 0 && i < step_value_str.Length; i++) {
                    if(step_value_str[i] != '0') {
                        zeros = false;
                        break;
                    }
                }

                step_precision = zeros ? 0 : step_value_str.Length - step_precision;
                step_value = ToDouble(step_value_str);
            }

            if(default_value != null && default_value != String.Empty && (current_value == null ||
                current_value == String.Empty)) {
                current_value = default_value;
            }

            foreach(XmlNode possible_value_node in Banshee.Base.Localization.SelectNodes(node, "possible-values/value")) {
                try {
                    string value = possible_value_node.Attributes["value"].Value.Trim();
                    string display = possible_value_node.InnerText.Trim();

                    PossibleValue possible_value = new PossibleValue(value, display);

                    XmlAttribute attr = possible_value_node.Attributes["enables"];
                    if(attr != null && attr.Value != null) {
                        string [] vars = attr.Value.Split(',');
                        if(vars != null && vars.Length > 0) {
                            possible_value.Enables = new string[vars.Length];
                            for(int i = 0; i < vars.Length; i++) {
                                possible_value.Enables[i] = vars[i].Trim();
                            }
                        }
                    }

                    attr = possible_value_node.Attributes["disables"];
                    if(attr != null && attr.Value != null) {
                        string [] vars = attr.Value.Split(',');
                        if(vars != null && vars.Length > 0) {
                            possible_value.Disables = new string[vars.Length];
                            for(int i = 0; i < vars.Length; i++) {
                                possible_value.Disables[i] = vars[i].Trim();
                            }
                        }
                    }

                    if(!possible_values.ContainsKey(value)) {
                        possible_values.Add(value, possible_value);
                        possible_values_keys.Add(value);
                    }
                } catch {
                }
            }
        }
예제 #2
0
        internal PipelineVariable(XmlNode node)
        {
            id           = node.Attributes["id"].Value.Trim();
            name         = Banshee.Base.Localization.SelectSingleNode(node, "name").InnerText.Trim();
            control_type = StringToControlType(node.SelectSingleNode("control-type").InnerText.Trim());

            XmlAttribute enables_attr = node.Attributes["enables"];

            if (enables_attr != null && enables_attr.Value != null)
            {
                string [] vars = enables_attr.Value.Split(',');
                if (vars != null && vars.Length > 0)
                {
                    enables = new string[vars.Length];
                    for (int i = 0; i < vars.Length; i++)
                    {
                        enables[i] = vars[i].Trim();
                    }
                }
            }

            XmlAttribute disables_attr = node.Attributes["disables"];

            if (disables_attr != null && disables_attr.Value != null)
            {
                string [] vars = disables_attr.Value.Split(',');
                if (vars != null && vars.Length > 0)
                {
                    disables = new string[vars.Length];
                    for (int i = 0; i < vars.Length; i++)
                    {
                        disables[i] = vars[i].Trim();
                    }
                }
            }

            try {
                XmlNode unit_node = node.SelectSingleNode("unit");
                if (unit_node != null)
                {
                    unit = node.SelectSingleNode("unit").InnerText.Trim();
                }
            } catch {
            }

            try {
                XmlNode advanced_node = node.SelectSingleNode("advanced");
                if (advanced_node != null)
                {
                    advanced = ParseAdvanced(advanced_node.InnerText);
                }
            } catch {
            }

            default_value = ReadValue(node, "default-value");
            min_value     = ToDouble(ReadValue(node, "min-value"));
            max_value     = ToDouble(ReadValue(node, "max-value"));
            min_label     = ReadValue(node, "min-label", true);
            max_label     = ReadValue(node, "max-label", true);

            string step_value_str = ReadValue(node, "step-value");

            if (step_value_str != null)
            {
                bool zeros = true;
                step_precision = step_value_str.IndexOf(".") + 1;

                for (int i = step_precision; i > 0 && i < step_value_str.Length; i++)
                {
                    if (step_value_str[i] != '0')
                    {
                        zeros = false;
                        break;
                    }
                }

                step_precision = zeros ? 0 : step_value_str.Length - step_precision;
                step_value     = ToDouble(step_value_str);
            }

            if (default_value != null && default_value != String.Empty && (current_value == null ||
                                                                           current_value == String.Empty))
            {
                current_value = default_value;
            }

            foreach (XmlNode possible_value_node in Banshee.Base.Localization.SelectNodes(node, "possible-values/value"))
            {
                try {
                    string value   = possible_value_node.Attributes["value"].Value.Trim();
                    string display = possible_value_node.InnerText.Trim();

                    PossibleValue possible_value = new PossibleValue(value, display);

                    XmlAttribute attr = possible_value_node.Attributes["enables"];
                    if (attr != null && attr.Value != null)
                    {
                        string [] vars = attr.Value.Split(',');
                        if (vars != null && vars.Length > 0)
                        {
                            possible_value.Enables = new string[vars.Length];
                            for (int i = 0; i < vars.Length; i++)
                            {
                                possible_value.Enables[i] = vars[i].Trim();
                            }
                        }
                    }

                    attr = possible_value_node.Attributes["disables"];
                    if (attr != null && attr.Value != null)
                    {
                        string [] vars = attr.Value.Split(',');
                        if (vars != null && vars.Length > 0)
                        {
                            possible_value.Disables = new string[vars.Length];
                            for (int i = 0; i < vars.Length; i++)
                            {
                                possible_value.Disables[i] = vars[i].Trim();
                            }
                        }
                    }

                    if (!possible_values.ContainsKey(value))
                    {
                        possible_values.Add(value, possible_value);
                        possible_values_keys.Add(value);
                    }
                } catch {
                }
            }
        }