Form1.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Drawing.Drawing2D;
  7. using System.Drawing.Imaging;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Windows.Forms;
  12. using System.Xml;
  13. using Dongke.IBOSS.Basics.FlowSetting;
  14. using Dongke.IBOSS.PRD.WCF.Proxys;
  15. namespace FlowSettingTest
  16. {
  17. public partial class Form1 : Form
  18. {
  19. public Form1()
  20. {
  21. InitializeComponent();
  22. this.flowBox1.NodeDoubleClick += flowBox1_NodeDoubleClick;
  23. textBox1.Text = this.flowBox1.CanvasSize.Width.ToString();
  24. textBox2.Text = this.flowBox1.CanvasSize.Height.ToString();
  25. }
  26. void flowBox1_NodeDoubleClick(object sender, NodeEventArgs e)
  27. {
  28. MessageBox.Show(e.Node.Name);
  29. }
  30. private void Form1_Paint(object sender, PaintEventArgs e)
  31. {
  32. }
  33. private void button1_Click_3(object sender, EventArgs e)
  34. {
  35. FlowNode n= this.flowBox1.NewNode();
  36. //n.BorderWidth = 1;
  37. if (n == null)
  38. {
  39. MessageBox.Show(this.flowBox1.BoxMode.ToString());
  40. return;
  41. }
  42. if(checkBox1.Checked && openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  43. {
  44. n.NodeImage = Image.FromFile(openFileDialog1.FileName);
  45. }
  46. else
  47. {
  48. n.BorderWidth = 1;
  49. }
  50. n.CanSkip = checkBox2.Checked;
  51. this.flowBox1.RefreshItems();
  52. }
  53. private void button2_Click_1(object sender, EventArgs e)
  54. {
  55. FlowLine n = this.flowBox1.NewLine();
  56. if (n == null)
  57. {
  58. MessageBox.Show(this.flowBox1.BoxMode.ToString());
  59. return;
  60. }
  61. n.ShowName = this.checkBox3.Checked;
  62. this.flowBox1.RefreshItems();
  63. }
  64. private void button3_Click_1(object sender, EventArgs e)
  65. {
  66. Form2 f2 = new Form2();
  67. f2.Show();
  68. Graphics g = this.CreateGraphics();
  69. ControlPaint.DrawFocusRectangle(g,new Rectangle(10,10,50,50),this.BackColor,Color.Transparent);
  70. }
  71. private void button4_Click(object sender, EventArgs e)
  72. {
  73. string ff = null;
  74. if (checkBox1.Checked && openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  75. {
  76. ff = openFileDialog1.FileName;
  77. }
  78. FlowNode n = this.flowBox1.DrawingNode();
  79. if (n == null)
  80. {
  81. MessageBox.Show(this.flowBox1.BoxMode.ToString());
  82. return;
  83. }
  84. if (!string.IsNullOrEmpty(ff))
  85. {
  86. n.NodeImage = Image.FromFile(ff);
  87. }
  88. else
  89. {
  90. n.BorderWidth = 1;
  91. }
  92. n.CanSkip = checkBox2.Checked;
  93. }
  94. private void button7_Click(object sender, EventArgs e)
  95. {
  96. int w = Convert.ToInt32(textBox1.Text);
  97. int h = Convert.ToInt32(textBox2.Text);
  98. this.flowBox1.CanvasSize = new Size(w, h);
  99. }
  100. private void button8_Click(object sender, EventArgs e)
  101. {
  102. if (openFileDialog2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  103. {
  104. flowBox1.CanvasBackgroundImage = Image.FromFile(openFileDialog2.FileName);
  105. }
  106. }
  107. private void button9_Click(object sender, EventArgs e)
  108. {
  109. flowBox1.CanvasBackgroundImage = null;
  110. }
  111. private void button10_Click(object sender, EventArgs e)
  112. {
  113. FlowLine n = this.flowBox1.DrawingLine();
  114. if (n == null)
  115. {
  116. MessageBox.Show(this.flowBox1.BoxMode.ToString());
  117. return;
  118. }
  119. n.ShowName = this.checkBox3.Checked;
  120. }
  121. private void button11_Click(object sender, EventArgs e)
  122. {
  123. bool check = this.flowBox1.CheckFlow();
  124. //if (!check)
  125. //{
  126. // MessageBox.Show(this.flowBox1.ErrorMessages[0]);
  127. //}
  128. Form3 f3 = new Form3(this.flowBox1);
  129. f3.Show();
  130. }
  131. private void button12_Click(object sender, EventArgs e)
  132. {
  133. this.flowBox1.RefreshItems();
  134. }
  135. private void button13_Click(object sender, EventArgs e)
  136. {
  137. this.flowBox1.ClearFlow();
  138. }
  139. private void button15_Click(object sender, EventArgs e)
  140. {
  141. if (openFileDialog3.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  142. {
  143. using (FileStream fs = new FileStream(openFileDialog3.FileName,FileMode.Open, FileAccess.Read))
  144. {
  145. flowBox1.LoadFlow(fs);
  146. textBox1.Text = this.flowBox1.CanvasSize.Width.ToString();
  147. textBox2.Text = this.flowBox1.CanvasSize.Height.ToString();
  148. }
  149. }
  150. }
  151. private void button14_Click(object sender, EventArgs e)
  152. {
  153. if (saveFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK)
  154. {
  155. XmlDocument xd = flowBox1.SaveFlowXmlDoc();
  156. if (xd.OuterXml == xd.InnerXml)
  157. {
  158. }
  159. xd.Save(saveFileDialog1.FileName);
  160. }
  161. }
  162. private void flowBox1_NodeDoubleClick_1(object sender, NodeEventArgs e)
  163. {
  164. MessageBox.Show(e.Node.Code);
  165. }
  166. private void flowBox1_FlowNodeLoading(object sender, NodeEventArgs e)
  167. {
  168. //Version v = new Version(1, 2, 3, 4);
  169. //Version v1 = new Version(0, 0);
  170. //Version v2 = new Version();
  171. //Version v3 = new Version(0, 0, 0, 0);
  172. if (e.Node.NodeImageType.HasValue)
  173. {
  174. string v = flowBox1.LoadVersion.ToString();
  175. if ("1.0" == v)
  176. {
  177. if (e.Node.NodeImageType == 1)
  178. {
  179. e.Node.NodeImage = new Bitmap(this.GetType(), "images.convergeNode.png");
  180. }
  181. else
  182. {
  183. e.Node.NodeImage = new Bitmap(this.GetType(), "images.gatherNode.png");
  184. }
  185. }
  186. else
  187. {
  188. if (e.Node.NodeImageType == 1)
  189. {
  190. e.Node.NodeImage = new Bitmap(this.GetType(), "images.newflow.png");
  191. }
  192. else
  193. {
  194. e.Node.NodeImage = new Bitmap(this.GetType(), "images.newflowcheck.png");
  195. }
  196. }
  197. }
  198. }
  199. private void button5_Click(object sender, EventArgs e)
  200. {
  201. if (this.flowBox1.DeletedNodes.Count > 0)
  202. {
  203. FlowNode[] nodes = this.flowBox1.DeletedNodes.ToArray();
  204. foreach (FlowNode node in nodes)
  205. {
  206. this.flowBox1.UndeleteNodeByNodeCode(node.ItemCode);
  207. }
  208. this.flowBox1.RefreshItems();
  209. }
  210. }
  211. private void button6_Click(object sender, EventArgs e)
  212. {
  213. WCFTestProxy.Service.Test();
  214. }
  215. }
  216. }