Beispiel #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);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Gets the AppleDataBox that corresponds to the specified mean and name values.
        /// </summary>
        /// <param name="meanstring">String specifying text for mean box</param>
        /// <param name="namestring">String specifying text for name box</param>
        /// <returns>Existing AppleDataBox or null if one does not exist</returns>
        private AppleDataBox GetDashAtoms(string meanstring, string namestring)
        {
            foreach (Box box in ilst_box.Children)
            {
                if (box.BoxType != BoxType.DASH)
                {
                    continue;
                }

                // Get the mean and name boxes, make sure
                // they're legit, check the Text fields for
                // a match.  If we have a match return
                // the AppleDatabox containing the data

                AppleAdditionalInfoBox mean_box =
                    (AppleAdditionalInfoBox)
                    box.GetChild(BoxType.Mean);
                AppleAdditionalInfoBox name_box =
                    (AppleAdditionalInfoBox)
                    box.GetChild(BoxType.Name);

                if (mean_box == null || name_box == null ||
                    mean_box.Text != meanstring ||
                    name_box.Text != namestring)
                {
                    continue;
                }
                else
                {
                    return((AppleDataBox)box.GetChild(BoxType.Data));
                }
            }
            // If we haven't returned the found box yet, there isn't one, return null
            return(null);
        }
Beispiel #3
0
        /// <summary>
        ///    Gets all custom data boxes that match the specified mean
        ///    and name pair.
        /// </summary>
        /// <param name="mean">
        ///    A <see cref="string" /> object containing the "mean" to
        ///    match.
        /// </param>
        /// <param name="name">
        ///    A <see cref="string" /> object containing the name to
        ///    match.
        /// </param>
        /// <returns>
        ///    A <see cref="T:System.Collections.Generic.IEnumerable`1" /> object enumerating the
        ///    matching boxes.
        /// </returns>
        public IEnumerable <AppleDataBox> DataBoxes(string mean,
                                                    string name)
        {
            // These children will have a box type of "----"
            foreach (Box box in ilst_box.Children)
            {
                if (box.BoxType != BoxType.DASH)
                {
                    continue;
                }

                // Get the mean and name boxes, make sure
                // they're legit, and make sure that they match
                // what we want. Then loop through and add all
                // the data box children to our output.
                AppleAdditionalInfoBox mean_box =
                    (AppleAdditionalInfoBox)
                    box.GetChild(BoxType.Mean);
                AppleAdditionalInfoBox name_box =
                    (AppleAdditionalInfoBox)
                    box.GetChild(BoxType.Name);

                if (mean_box == null || name_box == null ||
                    mean_box.Text != mean ||
                    name_box.Text != name)
                {
                    continue;
                }

                foreach (Box data_box in box.Children)
                {
                    AppleDataBox adb =
                        data_box as AppleDataBox;

                    if (adb != null)
                    {
                        yield return(adb);
                    }
                }
            }
        }
Beispiel #4
0
 private AppleAnnotationBox GetParentDashBox(string meanstring, string namestring)
 {
     foreach (Box box in ilst_box.Children)
     {
         if (box.BoxType != BoxType.DASH)
         {
             continue;
         }
         AppleAdditionalInfoBox mean_box = (AppleAdditionalInfoBox)box.GetChild(BoxType.Mean);
         AppleAdditionalInfoBox name_box = (AppleAdditionalInfoBox)box.GetChild(BoxType.Name);
         if (mean_box == null || name_box == null || mean_box.Text != meanstring || name_box.Text != namestring)
         {
             continue;
         }
         else
         {
             return((AppleAnnotationBox)box);
         }
     }
     return(null);
 }
Beispiel #5
0
        /// <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);
            }
        }
Beispiel #6
0
 public IEnumerable <AppleDataBox> DataBoxes(string mean, string name)
 {
     foreach (Box box in ilst_box.Children)
     {
         if (box.BoxType != BoxType.DASH)
         {
             continue;
         }
         AppleAdditionalInfoBox mean_box = (AppleAdditionalInfoBox)box.GetChild(BoxType.Mean);
         AppleAdditionalInfoBox name_box = (AppleAdditionalInfoBox)box.GetChild(BoxType.Name);
         if (mean_box == null || name_box == null || mean_box.Text != mean || name_box.Text != name)
         {
             continue;
         }
         foreach (Box data_box in box.Children)
         {
             AppleDataBox adb = data_box as AppleDataBox;
             if (adb != null)
             {
                 yield return(adb);
             }
         }
     }
 }