Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.21 KB | None | 0 0
  1. CXml1.cs
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml;
  8. using System.Xml.Linq;
  9. using System.IO;
  10.  
  11.  
  12. namespace _45._1
  13. {
  14. public static class CXml1
  15. {
  16.  
  17. public static int A1; // pocet vyskytu point
  18. public static int A2; // pocet vyskytu line
  19.  
  20.  
  21. public static void mvINit()
  22. {
  23. A1 = 0;
  24. A2 = 0;
  25. }
  26.  
  27. public static void mvReXml()
  28. {
  29. XmlReader xmlReader1;
  30. string lsAtrCurr1;
  31. int pt_index;
  32. int coord_x;
  33. int coord_y;
  34. int coord_z;
  35.  
  36. int ln_index;
  37. int point_1;
  38. int point_2;
  39.  
  40.  
  41.  
  42. xmlReader1 = XmlReader.Create("ingraf_cv451a.xml");
  43.  
  44. while (xmlReader1.Read())
  45. { //====== cyklus
  46. if (xmlReader1.NodeType == XmlNodeType.Element)
  47. {
  48. //Console.WriteLine("_Elem_name: " + xmlReader1.Name);
  49. }
  50.  
  51. if ((xmlReader1.NodeType == XmlNodeType.Element) && (xmlReader1.Name == "point"))
  52. {
  53. A1++;
  54. if (xmlReader1.HasAttributes)
  55. { //====== ma atributy
  56. lsAtrCurr1 = xmlReader1.GetAttribute("pt_index");
  57. pt_index = Convert.ToInt32(lsAtrCurr1);
  58. lsAtrCurr1 = xmlReader1.GetAttribute("coord_x");
  59. coord_x = Convert.ToInt32(lsAtrCurr1);
  60. lsAtrCurr1 = xmlReader1.GetAttribute("coord_y");
  61. coord_y = Convert.ToInt32(lsAtrCurr1);
  62. lsAtrCurr1 = xmlReader1.GetAttribute("coord_z");
  63. coord_z = Convert.ToInt32(lsAtrCurr1);
  64. }//====== ma atributy
  65.  
  66. }
  67.  
  68. if ((xmlReader1.NodeType == XmlNodeType.Element) && (xmlReader1.Name == "line"))
  69. {
  70. A2++;
  71. if (xmlReader1.HasAttributes)
  72. { //====== ma atributy
  73. lsAtrCurr1 = xmlReader1.GetAttribute("ln_index");
  74. ln_index = Convert.ToInt32(lsAtrCurr1);
  75. lsAtrCurr1 = xmlReader1.GetAttribute("point_1");
  76. point_1 = Convert.ToInt32(lsAtrCurr1);
  77. lsAtrCurr1 = xmlReader1.GetAttribute("point_2");
  78. point_2 = Convert.ToInt32(lsAtrCurr1);
  79.  
  80. }//====== ma atributy
  81.  
  82. }
  83.  
  84. } //====== cyklus
  85.  
  86. lsAtrCurr1 = "";
  87. }
  88.  
  89.  
  90. }
  91. }
  92.  
  93. CAct1.cs
  94. using System;
  95. using System.Collections.Generic;
  96. using System.Linq;
  97. using System.Text;
  98. using System.Threading.Tasks;
  99.  
  100. namespace _45._1
  101. {
  102. public static class CAct1
  103. {
  104.  
  105. public static void mvAct(int guiid)
  106. {
  107. switch (guiid)
  108. {
  109. case 1: //reXml
  110. CXml1.mvReXml(); //cte xml soubor
  111.  
  112. break;
  113. case 2: //Graf
  114.  
  115. break;
  116. case 3: //Exit
  117.  
  118. break;
  119. default : //nesmi nastat
  120. break;
  121.  
  122.  
  123. }
  124. }
  125.  
  126.  
  127.  
  128. }
  129. }
  130.  
  131. Form1.cs
  132. using System;
  133. using System.Collections.Generic;
  134. using System.ComponentModel;
  135. using System.Data;
  136. using System.Drawing;
  137. using System.Linq;
  138. using System.Text;
  139. using System.Threading.Tasks;
  140. using System.Windows.Forms;
  141.  
  142.  
  143. namespace _45._1
  144. {
  145. public partial class Form1 : Form
  146. {
  147. public Form1()
  148. {
  149. InitializeComponent();
  150. }
  151.  
  152. private void Form1_Load(object sender, EventArgs e)
  153. {
  154.  
  155. }
  156.  
  157. private void button3_Click(object sender, EventArgs e)
  158. {
  159. CAct1.mvAct(3);
  160. }
  161.  
  162. private void button1_Click(object sender, EventArgs e)
  163. {
  164. CAct1.mvAct(1);
  165.  
  166. }
  167.  
  168. private void button2_Click(object sender, EventArgs e)
  169. {
  170. CAct1.mvAct(2);
  171. }
  172. }
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement