Exemplo n.º 1
0
        public static ObservableCollection<Parameter> parseParameterXmlList(XmlNodeList parameterData, IParameterContainer component, XmlNode skip)
        {
            ObservableCollection<Parameter> parameterList = new ObservableCollection<Parameter>();
            foreach (XmlNode node in parameterData)
            {
                if (node == skip)
                    continue;

                Parameter p = new Parameter();
                if (component is Element)
                    p.Semantic = DataItemsTools.getParameterSemantic(node, component as Element, p);
                else
                    p.Semantic = ParameterSemantic.NONE;

                foreach (XmlAttribute attr in node.Attributes)
                {
                    if (attr.Name == "Name")
                    {
                        p.Name = attr.Value;
                    }
                    else if (attr.Name == "Default")
                    {
                        p.Values = attr.Value;
                    }
                    else if (attr.Name == "Count")
                    {
                        p.Count = int.Parse(attr.Value);
                    }
                }
                p.Type = ParameterTypeName.TypeFromString(node.Name);
                if (p.Type == ParameterType.SEQUENCEPARAMETER)
                {
                    p.Type = ParameterType.SEQUENCEPARAMETER;
                    p.Params = parseParameterXmlList(node.ChildNodes, component);
                }
                else if (p.Type == ParameterType.COMPOUNDPARAMETER)
                {
                    p.Type = ParameterType.COMPOUNDPARAMETER;
                    p.Params = parseParameterXmlList(node.ChildNodes, component);
                }
                else
                {

                }
                p.ParentComponent = component;
                parameterList.Add(p);
            }
            return parameterList;
        }
Exemplo n.º 2
0
 private Exception paraseCompoundParameterData(Parameter compound, string[] values, ref int value, List<string> errors, Element compInstance)
 {
     Exception e = null;
     foreach (Parameter parameter in compound.Params)
     {
         if (parameter.Type == ParameterType.COMPOUNDPARAMETER || parameter.Type == ParameterType.SEQUENCEPARAMETER) // TODO this needs special treatment
         {
             e = paraseCompoundParameterData(parameter, values, ref value, errors, compInstance);
             if (e != null)
                 return e;
         }
         StringBuilder sb = new StringBuilder();
         // still enough left?
         if (value + parameter.Count > values.Length)
         {
             errors.Add("Error not enough ParameterData\nParameter " + parameter.Name + " in Element " + compInstance.Name);
             e = new Exception();
             break;
         }
         for (int i = 0; i < parameter.Count; ++i)
         {
             if (values[value] != null)
                 sb.Append(values[value++]);
             if (i < parameter.Count -1)
                 sb.Append(",");
         }
         parameter.Values = sb.ToString();
     }
     return e;
 }
Exemplo n.º 3
0
 public GameMessage(GameMessage msg)
 {
     m_name = msg.Name;
     m_parameter = msg.m_parameter.copy();
     m_parameter.Changed += new DataItems.Parameter.ParameterChangedEventHandler(m_parameter_Changed);
 }
Exemplo n.º 4
0
 private void toXmlRec(StringBuilder sb, Parameter p)
 {
     foreach (Parameter parameter in p.Params)
     {
         sb.Append("<");
         sb.Append(ParameterTypeName.TypeToString(parameter.Type));
         sb.Append(" Name=\"");
         sb.Append(parameter.Name);
         sb.Append("\" Value=\"");
         sb.Append(parameter.Values);
         sb.Append("\">");
         toXmlRec(sb, parameter);
         sb.Append("</");
         sb.Append(ParameterTypeName.TypeToString(parameter.Type));
         sb.Append(">");
     }
 }
Exemplo n.º 5
0
 private void toXml(StringBuilder sb, Parameter p)
 {
     sb.Append("<Root>");
     // write MsgId
     sb.Append("<idParameter Id=\"");
     sb.Append(Name);
     sb.Append("\" />");
     toXmlRec(sb, p);
     sb.Append("</Root>");
 }
Exemplo n.º 6
0
 void m_parameter_Changed(object sender, Parameter.ParameterChangedEventArgs e)
 {
     if (this.ManualUpdate)
         OnChanged(e);
 }
Exemplo n.º 7
0
 private void copyParameterList()
 {
     foreach (Parameter p in m_macro.Parameters)
     {
         Parameter newParameter = new Parameter(p);
         m_macro.AddParameter(p);
     }
 }
Exemplo n.º 8
0
 public Parameter(Parameter copy)
 {
     this.m_name = copy.m_name;
     this.m_parent = copy.m_parent;
     this.m_type = copy.m_type;
     this.m_values = copy.m_values;
     this.m_semantic = copy.m_semantic;
     this.m_count = copy.m_count;
     this.m_editable = copy.m_editable;
     this.m_semanticValues = copy.m_semanticValues;
     foreach (Parameter p in copy.m_subParams)
     {
         Parameter newP = new Parameter(p);
         newP.Parent = this;
         this.m_subParams.Add(newP);
     }
 }
Exemplo n.º 9
0
 public ParameterChangedEventArgs(Parameter parameter)
 {
     m_parameter = parameter;
 }
Exemplo n.º 10
0
 // duplicates a Sequence parameter
 public void duplicate()
 {
     if (Parent != null)
     {
         if (Parent.Type == ParameterType.SEQUENCEPARAMETER)
         {
             Parameter newParam = new Parameter(this);
             int index = this.Parent.Params.IndexOf(this);
             this.Parent.Params.Insert(index + 1, newParam);
         }
     }
 }
Exemplo n.º 11
0
        public void deserializeFromXml(XmlElement parent)
        {
            foreach (XmlAttribute attrib in parent.Attributes)
            {
                if (attrib.Name == "name")
                    this.m_name = attrib.Value;
                else if (attrib.Name == "type")
                {
                    Enum.TryParse(attrib.Value, out m_type);
                }
                else if (attrib.Name == "semantic")
                {
                    Enum.TryParse(attrib.Value, out m_semantic);
                }
            }

            XmlNode valuesNode = Helper.XmlHelper.getNodeByName(parent.ChildNodes, "Values");
            if (valuesNode != null && valuesNode.FirstChild != null)
                m_values = valuesNode.FirstChild.Value;

            XmlNode subParametersNode = Helper.XmlHelper.getNodeByName(parent.ChildNodes, "Subparameters");
            if (subParametersNode != null)
            {
                foreach (XmlNode subp in subParametersNode.ChildNodes)
                {
                    if (subp is XmlElement && subp.Name == "Parameter")
                    {
                        Parameter p = new Parameter();
                        p.deserializeFromXml(subp as XmlElement);
                        m_subParams.Add(p);
                    }
                }
            }
        }
Exemplo n.º 12
0
 public void deserialize(System.IO.BinaryReader br)
 {
     m_name = br.ReadString();
     m_type = ParameterTypeName.TypeFromString(br.ReadString());
     m_semantic = ParameterTypeName.SemanticFromString(br.ReadString());
     //if (ParentComponent is Element)
     //    m_semantic = Parameter.getParameterSemantic(ParentComponent as Element, this);
     m_values = br.ReadString();
     m_count = br.ReadInt32();
     int paramCount = br.ReadInt32();
     for (int i = 0; i < paramCount; ++i)
     {
         Parameter p = new Parameter();
         p.deserialize(br);
         p.Parent = this;
         m_subParams.Add(p);
     }
 }
Exemplo n.º 13
0
        public static ParameterSemantic getParameterSemantic(Element element, Parameter param)
        {
            App app = App.Current as App;
            OptionGroup optionGroup = null;
            Config config = app.Config;
            if (element.Semantic > Element.ElementSemantic.NONE && element.Semantic <= Element.ElementSemantic.CAMERA)
            {
                optionGroup = (config.GetOptionGroup("3D Editor Options") as OptionGroup);
            }
            else if (element.Semantic >= Element.ElementSemantic.STATE && element.Semantic <= Element.ElementSemantic.STATEMACHINE)
            {
                optionGroup = (config.GetOptionGroup("StateMachines") as OptionGroup);
            }

            if (optionGroup != null)
            {
                foreach (IOption option in optionGroup.Options)
                {
                    if (option.Type == StringSemanticOption.m_type)
                    {
                        StringSemanticOption Param = option as StringSemanticOption;
                        if (Param != null)
                        {
                            String[] values = Param.Value.Split(',');
                            foreach (String value in values)
                            {
                                if (value == param.Name)
                                {
                                    if (Param.Semantic == ParameterSemantic.MESH)
                                    {
                                        ResourceFolder folder = app.Data.Resources.getFolder("Meshes");
                                        if (folder != null)
                                        {
                                            param.SemanticValues = folder.Resources;
                                        }
                                    }
                                    else if (Param.Semantic == ParameterSemantic.MATERIAL)
                                    {
                                        ResourceFolder folder = app.Data.Resources.getFolder("Materials");
                                        if (folder != null)
                                        {
                                            param.SemanticValues = folder.Resources;
                                        }
                                    }
                                    else if (Param.Semantic == ParameterSemantic.TEXTURE)
                                    {
                                        ResourceFolder folder = app.Data.Resources.getFolder("Textures");
                                        if (folder != null)
                                        {
                                            param.SemanticValues = folder.Resources;
                                        }
                                    }
                                    return Param.Semantic;
                                }
                                //Parameter parameter = findParameter(component, dimension, value.Trim());
                            }
                        }
                    }
                }
            }
            return ParameterSemantic.NONE;
        }
Exemplo n.º 14
0
        public static ParameterSemantic getParameterSemantic(XmlNode parameter, Element element, Parameter param)
        {
            //App app = App.Current as App;
            //String parameterName = "";
            //int size = 1;
            //foreach (XmlAttribute attr in parameter.Attributes)
            //{
            //    if (attr.Name == "Name")
            //    {
            //        parameterName = attr.Value;
            //    }
            //    if (attr.Name == "Default")
            //    {
            //        size = attr.Value.Split(',').Length;
            //    }
            //}
            //OptionGroup optionGroup = null;
            //if (element.Semantic > Element.ElementSemantic.NONE && element.Semantic <= Element.ElementSemantic.CAMERA)
            //{
            //    optionGroup = (app.Config.GetOptionGroup("3D Editor Options") as OptionGroup);
            //}
            //else if (element.Semantic >= Element.ElementSemantic.STATE && element.Semantic <= Element.ElementSemantic.STATEMACHINE)
            //{
            //    optionGroup = (app.Config.GetOptionGroup("StateMachines") as OptionGroup);
            //}

            //if (optionGroup != null)
            //{
            //    foreach (IOption option in optionGroup.Options)
            //    {
            //        if (option.Type == StringSemanticOption.m_type)
            //        {
            //            StringSemanticOption Param = option as StringSemanticOption;
            //            if (Param != null)
            //            {
            //                String[] values = Param.Value.Split(',');
            //                foreach (String value in values)
            //                {
            //                    if (value == parameterName)
            //                    {
            //                        if (Param.Semantic == ParameterSemantic.MESH)
            //                        {
            //                            ResourceFolder folder = app.Data.Resources.getFolder("Meshes");
            //                            if (folder != null)
            //                            {
            //                                param.SemanticValues = folder.Resources;
            //                            }
            //                        }
            //                        else if (Param.Semantic == ParameterSemantic.MATERIAL)
            //                        {
            //                            ResourceFolder folder = app.Data.Resources.getFolder("Materials");
            //                            if (folder != null)
            //                            {
            //                                param.SemanticValues = folder.Resources;
            //                            }
            //                        }
            //                        else if (Param.Semantic == ParameterSemantic.TEXTURE)
            //                        {
            //                            ResourceFolder folder = app.Data.Resources.getFolder("Textures");
            //                            if (folder != null)
            //                            {
            //                                param.SemanticValues = folder.Resources;
            //                            }
            //                        }
            //                        return Param.Semantic;
            //                    }
            //                    //Parameter parameter = findParameter(component, dimension, value.Trim());
            //                }
            //            }
            //        }
            //    }
            //}
            return ParameterSemantic.NONE;
        }