コード例 #1
0
        public void SetDashBox(string meanstring, string namestring, string datastring)
        {
            AppleDataBox data_box = GetDashAtoms(meanstring, namestring);

            if (data_box != null && string.IsNullOrEmpty(datastring))
            {
                AppleAnnotationBox dash_box = GetParentDashBox(meanstring, namestring);
                dash_box.ClearChildren();
                ilst_box.RemoveChild(dash_box);
                return;
            }
            if (data_box != null)
            {
                data_box.Text = datastring;
            }
            else
            {
                AppleAdditionalInfoBox amean_box = new AppleAdditionalInfoBox(BoxType.Mean);
                AppleAdditionalInfoBox aname_box = new AppleAdditionalInfoBox(BoxType.Name);
                AppleDataBox           adata_box = new AppleDataBox(BoxType.Data, 1);
                amean_box.Text = meanstring;
                aname_box.Text = namestring;
                adata_box.Text = datastring;
                AppleAnnotationBox whole_box = new AppleAnnotationBox(BoxType.DASH);
                whole_box.AddChild(amean_box);
                whole_box.AddChild(aname_box);
                whole_box.AddChild(adata_box);
                ilst_box.AddChild(whole_box);
            }
        }
コード例 #2
0
        public void SetData(ByteVector type, AppleDataBox[] boxes)
        {
            type = FixId(type);
            bool added = false;

            foreach (Box box in ilst_box.Children)
            {
                if (type == box.BoxType)
                {
                    box.ClearChildren();
                    if (added)
                    {
                        continue;
                    }
                    added = true;
                    foreach (AppleDataBox b in boxes)
                    {
                        box.AddChild(b);
                    }
                }
            }
            if (added)
            {
                return;
            }
            Box box2 = new AppleAnnotationBox(type);

            ilst_box.AddChild(box2);
            foreach (AppleDataBox b in boxes)
            {
                box2.AddChild(b);
            }
        }
コード例 #3
0
ファイル: AppleTag.cs プロジェクト: redphx/beat-downloader
        /// <summary>
        /// Sets a specific strings in Dash (----) atom.  This method updates
        /// and existing atom, or creates a new one.
        /// </summary>
        /// <param name="meanstring">String specifying text for mean box</param>
        /// <param name="namestring">String specifying text for name box</param>
        /// <param name="datastring">String specifying text for data box</param>
        public void SetDashBox(string meanstring, string namestring, string datastring)
        {
            AppleDataBox data_box = GetDashAtoms(meanstring, namestring);

            if (data_box != null)
            {
                data_box.Text = datastring;
            }
            else
            {
                AppleAdditionalInfoBox amean_box = new AppleAdditionalInfoBox(BoxType.Mean, 0, 0);
                AppleAdditionalInfoBox aname_box = new AppleAdditionalInfoBox(BoxType.Name, 0, 0);
                AppleDataBox           adata_box = new AppleDataBox(BoxType.Data, 0);
                amean_box.Text = meanstring;
                aname_box.Text = namestring;
                adata_box.Text = datastring;
                AppleAnnotationBox whole_box = new AppleAnnotationBox(BoxType.DASH);
                whole_box.AddChild(amean_box);
                whole_box.AddChild(aname_box);
                whole_box.AddChild(adata_box);
                ilst_box.AddChild(whole_box);
            }
        }
コード例 #4
0
        /// <summary>
        ///    Sets the data for a specified box type to a collection of
        ///    boxes.
        /// </summary>
        /// <param name="type">
        ///    A <see cref="ByteVector" /> object containing the type to
        ///    add to the new instance.
        /// </param>
        /// <param name="boxes">
        ///    A <see cref="AppleDataBox[]" /> containing boxes to add
        ///    for the specified type.
        /// </param>
        public void SetData(ByteVector type, AppleDataBox [] boxes)
        {
            // Fix the type.
            type = FixId(type);

            bool added = false;

            foreach (Box box in ilst_box.Children)
            {
                if (type == box.BoxType)
                {
                    // Clear the box's children.
                    box.ClearChildren();

                    // If we've already added new childen,
                    // continue.
                    if (added)
                    {
                        continue;
                    }

                    added = true;

                    // Add the children.
                    foreach (AppleDataBox b in boxes)
                    {
                        box.AddChild(b);
                    }
                }
            }

            if (added)
            {
                return;
            }

            Box box2 = new AppleAnnotationBox(type);

            ilst_box.AddChild(box2);

            foreach (AppleDataBox b in boxes)
            {
                box2.AddChild(b);
            }
        }