Esempio n. 1
0
 private static void WriteItem(XmlTextWriter w, TextPackage node, string nodeName, string[] elems)
 {
     w.WriteStartElement(nodeName);
     foreach (var elem in elems)
         WriteElement(w, node, elem);
     w.WriteEndElement();
 }
 public static List<TextPackage> Create()
 {
     List<TextPackage> packs = new List<TextPackage>();
     XmlDocument doc = new XmlDocument();
     doc.Load(@"license.xml");
     try
     {
         var childs = doc.DocumentElement.ChildNodes;
         foreach (XmlElement item in childs)
         {
             // type -> full, abstract
             var data = new TextPackage();
             data["Type"] = item.GetAttribute("type");
             foreach (XmlElement node in item.ChildNodes)
             {
                 data[node.Name] = node.InnerText;
             }
             packs.Add(data);
         }
     }
     catch (XmlException e)
     {
         MessageBox.Show(e.Message, "ライセンスファイルの読み込みエラー");
     }
     return packs;
 }
Esempio n. 3
0
 private static void WriteItems(XmlTextWriter w, TextPackage[] pack, string startNode, string[] elems)
 {
     w.WriteStartElement(startNode);
     {
         foreach (var node in pack)
             WriteItem(w, node, "Item", elems);
     }
     w.WriteEndElement();
 }
Esempio n. 4
0
 private static void ReadAttributes(XmlElement item, List<TextPackage> textPackage, string[] targets)
 {
     TextPackage pack = new TextPackage();
     foreach (XmlNode node in item)
     {
         foreach (string target in targets)
         {
             if (node.Name == target)
             {
                 pack[target] = node.InnerText;
                 break;
             }
         }
     }
     textPackage.Add(pack);
 }
 public static List<TextPackage> UnpackListBoxOnSection(TextPackage[] sourcePacks, ListBox listBox)
 {
     if (sourcePacks != null)
     {
         List<TextPackage> target_packs = new List<TextPackage>(sourcePacks);
         foreach (var item in target_packs)
         {
             string add_name = item["Section"].Length > 0 ?
                 item["Section"] + "#" + item["Title"] : item["Title"];
             listBox.Items.Add(add_name);
         }
         return target_packs;
     }
     else
     {
         return new List<TextPackage>();
     }
 }
 public static List<TextPackage> UnpackListBox(TextPackage[] sourcePacks, ListBox listBox)
 {
     if (sourcePacks != null)
     {
         List<TextPackage> result = new List<TextPackage>(sourcePacks);
         foreach (var item in result)
             listBox.Items.Add(item["Title"]);
         return result;
     }
     else
     {
         return new List<TextPackage>();
     }
 }
 public static void UnpackLicense(TextPackage[] sourcePacks, CheckedListBox licenseCheckedListBox)
 {
     if (sourcePacks != null)
     {
         foreach (var item in sourcePacks)
         {
             var checkedItems = licenseCheckedListBox.Items;	// チェックボックスの中身とライセンスが一致していたらチェックする
             for (int i = 0; i < checkedItems.Count; i++)
             {
                 if (item["Type"] == (string)checkedItems[i])
                     licenseCheckedListBox.SetItemChecked(i, true);
             }
         }
     }
 }
 /// <summary>
 /// 入力された項目名から自動的にTextPackageを作成する
 /// </summary>
 /// <param name="item_name">section title形式の文字列</param>
 /// <param name="caption"></param>
 /// <returns></returns>
 private static TextPackage MakeTextPackage(string item_name, string caption)
 {
     var section = "";
     var title = "";
     var splited_str = item_name.Split('#');
     if (splited_str.Length > 1)
     {
         section = splited_str[0];
         title = item_name.Remove(0, section.Length + 1);
     }
     else
     {
         title = item_name;
     }
     var pack = new TextPackage();
     pack["Section"] = section;
     pack["Caption"] = caption;
     pack["Title"] = title;
     return pack;
 }
Esempio n. 9
0
 private static void WriteElement(XmlTextWriter w, TextPackage pack, string element)
 {
     w.WriteStartElement(element);
     w.WriteString(pack[element]);
     w.WriteEndElement();
 }