Exemplo n.º 1
0
        public void Add(MotionDataObjectInfo info)
        {
            if (info.ObjectType == MotionDataObjectType.Undefined)
            {
                throw new ArgumentException("Cannot add Undefined type object info");
            }
            List <MotionDataObjectInfo> newInfos = new List <MotionDataObjectInfo>(Infos);

            newInfos.Add(info);
            Infos = newInfos.ToArray();
        }
Exemplo n.º 2
0
        public static MotionDataHeader Deserialize(XmlReader reader)
        {
            reader.MoveToContent();
            reader.ReadStartElement(typeof(MotionDataHeader).Name);
            MotionDataHeader            ret   = new MotionDataHeader();
            List <MotionDataObjectInfo> infos = new List <MotionDataObjectInfo>();

            for (reader.MoveToContent(); reader.NodeType != XmlNodeType.EndElement && reader.NodeType != XmlNodeType.None; reader.MoveToContent())
            {
                if (reader.IsEmptyElement)
                {
                    reader.Skip();
                    continue;
                }
                switch (reader.Name)
                {
                case "MotionFieldState":
                    XmlSerializer ser = new XmlSerializer(typeof(MotionFieldState));
                    ret.FieldState = (MotionFieldState)ser.Deserialize(reader);
                    break;

                case "Infos":
                    reader.ReadStartElement("Infos");
                    for (reader.MoveToContent(); reader.NodeType != XmlNodeType.EndElement && reader.NodeType != XmlNodeType.None; reader.MoveToContent())
                    {
                        if (reader.IsEmptyElement)
                        {
                            reader.Skip();
                            continue;
                        }
                        switch (reader.Name)
                        {
                        case "MotionDataObjectInfo":
                            infos.Add(MotionDataObjectInfo.Deserialize(reader, ret));
                            break;

                        default:
                            reader.Skip();
                            break;
                        }
                    }
                    reader.ReadEndElement();
                    break;

                default:
                    reader.Skip();
                    break;
                }
            }
            reader.ReadEndElement();
            ret._infos = infos.ToArray();
            return(ret);
        }
Exemplo n.º 3
0
        public static MotionDataObjectInfo Deserialize(XmlReader reader, MotionDataHeader parent)
        {
            if (parent == null)
            {
                throw new ArgumentNullException("parent", "'parent' cannot be null");
            }
            reader.MoveToContent();
            if (reader.IsEmptyElement)
            {
                return(null);
            }
            else
            {
                string name = "", groupName = "";
                Color  color = Color.White;
                MotionDataObjectType type = MotionDataObjectType.Undefined;
                int  index     = -1;
                bool visible   = true;
                bool isVirtual = false;
                reader.ReadStartElement(typeof(MotionDataObjectInfo).Name);
                for (reader.MoveToContent(); reader.NodeType != XmlNodeType.EndElement && reader.NodeType != XmlNodeType.None; reader.MoveToContent())
                {
                    if (reader.IsEmptyElement)
                    {
                        reader.Skip();
                        continue;
                    }
                    switch (reader.Name)
                    {
                    case "Name":
                        name = reader.ReadElementContentAsString();
                        break;

                    case "GroupName":
                        groupName = reader.ReadElementContentAsString();
                        break;

                    case "ObjectType":
                        type = (MotionDataObjectType)Enum.Parse(typeof(MotionDataObjectType), reader.ReadElementContentAsString());
                        break;

                    case "ObjectIndex":
                        index = reader.ReadElementContentAsInt();
                        break;

                    case "Show":
                    case "Visible":
                        visible = reader.ReadElementContentAsBoolean();
                        break;

                    case "Virtual":
                        isVirtual = reader.ReadElementContentAsBoolean();
                        break;

                    case "Color":
                        var cstr = reader.ReadElementContentAsString();
                        int cint;
                        if (int.TryParse(cstr, out cint))
                        {
                            color = Color.FromArgb(cint);
                        }
                        else
                        {
                            color = ColorTranslator.FromHtml(cstr);
                        }
                        break;

                    default:
                        reader.Skip();
                        break;
                    }
                }
                reader.ReadEndElement();
                if (type == MotionDataObjectType.Undefined || index == -1)
                {
                    return(null);
                }
                var ret = new MotionDataObjectInfo(parent, type, index);
                ret.Name      = name;
                ret.GroupName = groupName;
                ret.Color     = color;
                ret.Visible   = visible;
                ret.Virtual   = isVirtual;
                return(ret);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// 指定されたMotionDataObjectInfoに対応するモーションデータオブジェクトをフレームから削除します。
 /// </summary>
 /// <param title="targetInfo">削除するモーションデータオブジェクトのMotionDataObjectInfo</param>
 public void RemoveAt(MotionDataObjectInfo targetInfo)
 {
     RemoveAt(targetInfo.ObjectType, targetInfo.ObjectIndex);
 }