public void TestCountSimiliarVsEmpty() { Assert.AreEqual(Ex1.CountSimilar(Ex4), 0); Assert.AreEqual(Ex2.CountSimilar(Ex4), 0); Assert.AreEqual(Ex3.CountSimilar(Ex4), 0); Assert.AreEqual(Ex4.CountSimilar(Ex4), 0); }
public void TestMethod1() { Ex3 ex3 = new Ex3(); string html = paragraf + "<br/>" + taula + "<br/>" + llista + "<br/>" + direccio; ex3.Label2Pdf1(html, Directory.GetCurrentDirectory()); Assert.IsTrue(File.Exists("test1.pdf")); }
public void TestMethod2() { Ex3 ex3 = new Ex3(); string html = paragraf_css + "<br/>" + taula_css + "<br/>" + llista_css + "<br/>" + direccio_css; string css = ".green{color:green;font-family:times;font-size:20px;text-align:right;}.red{color:red;font-family: courier;font-size:24px}.setting{font-family: verdana;font-size: 24px;background-color: #F0F0F0;text-align:Center}.light_row{background - color: #F2F6FC;font - size: 13px;}.dark_row{background - color: #DADEEE;font - size: 13px;}.default_td{border: 1px solid #7F8FA9;font - size: 13px;}.default_th{background - color: #7F8FAD;border: 1px solid #000010;font - size: 13px;}"; ex3.Label2Pdf2(html, css, Directory.GetCurrentDirectory()); Assert.IsTrue(File.Exists("test2.pdf")); }
private static void Solution3() { Ex3 ex3 = new Ex3(45); Console.WriteLine(ex3); }
public void ReceiveImage() { int GetImageLength; int GetImageArea; int RealImageLength; MemoryStream ms = new MemoryStream(); IPBindPoint_ForImage = new IPEndPoint(ServerIP, sPort + 1); IPBindPoint_ForImage = new IPEndPoint(((IPEndPoint)Client[0].RemoteEndPoint).Address, sPort + 1); senderp = (IPEndPoint)IPBindPoint_ForImage; Bitmap GetImageBit; //Thread.Sleep(10000); try { ImageServer.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 500); while (Client[0].Connected) { //Get Image Size //ImageServer.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 0); Client[0].Receive(GetImageSize, 0, 4, SocketFlags.None); RealImageLength = BitConverter.ToInt32(GetImageSize, 0); Client[0].Receive(GetImageSize, 0, 4, SocketFlags.None); GetImageLength = BitConverter.ToInt32(GetImageSize, 0); if (GetImageLength == 0) { continue; } //Get Image Area /*ImageClient.Receive(GetImageAreaByte, 0, 4, SocketFlags.None); * GetImageArea = BitConverter.ToInt32(GetImageAreaByte, 0);*/ GetImageBytes = new byte[GetImageLength]; //ImageServer.Receive(GetImageBytes, 0, GetImageLength, SocketFlags.None); //ImageServer.ReceiveFrom(GetImageBytes, 0, GetImageLength, SocketFlags.None, ref senderp); int count = 0; int icount = 0; sw = false; do { try { GetByte = new byte[SizeForOne + 4]; for (int i = icount; i < GetImageLength / SizeForOne; i++) { //ChatBoxAdd(ImageServer.ReceiveFrom(GetByte, 0, SizeForOne + 4, SocketFlags.None, ref senderp).ToString()); ImageServer.BeginReceiveFrom(GetByte, 0, SizeForOne + 4, SocketFlags.None, ref senderp, new AsyncCallback(MessageCallBack), Tuple.Create(GetByte, 0, GetImageLength)); } Client[0].Send(new byte[4]); Client[0].Receive(new byte[4]); if (GetImageLength % SizeForOne != 0) { ImageServer.ReceiveFrom(GetImageBytes, GetImageLength - (GetImageLength % SizeForOne), GetImageLength % SizeForOne, SocketFlags.None, ref senderp); } sw = true; Client[0].Send(BitConverter.GetBytes(-1)); } catch (Exception Ex3) { ChatBoxAdd(Ex3.ToString()); ChatBoxAdd("UDP 데이터 소실 발생."); sw = false; icount = 0; Client[0].Send(BitConverter.GetBytes(-1)); break; Client[0].Send(BitConverter.GetBytes(icount)); } } while (!sw); try { if (sw == false) { throw new Exception(); } ms = new MemoryStream(); ms.Write(GetImageBytes, 0, (int)GetImageBytes.Length); ms.Position = 0; GetImageBytes = new byte[RealImageLength]; //var DecompressStream = new DeflateStream(ms, CompressionMode.Decompress,true); var DecompressStream = new GZipStream(ms, CompressionMode.Decompress, true); var DecompressedStream = new MemoryStream(); DecompressStream.CopyTo(DecompressedStream); DecompressStream.Close(); DecompressedStream.Position = 0; Bitmap Image = new Bitmap(DecompressedStream); //Bitmap Image = new Bitmap(ms); ChatBoxAdd("Success!"); MainPicture.MainPictureChange(Image); //pictureBox1Change(Image); Orginal_Image = Image; ms.Close(); DecompressedStream.Close(); ImageServer.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 0); Client[0].Send(new byte[4]); sw = true; } catch (Exception ex) { ChatBoxAdd(ex.ToString()); ImageServer.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, 0); Client[0].Send(new byte[4]); sw = true; } GetImageBytes = null; //Thread.Sleep(100); GetImageBit = null; GC.Collect(0); GC.Collect(1); } } catch (Exception Ex2) { ChatBoxAdd(Ex2.ToString()); } }
private void toolStripButton1_Click(object sender, EventArgs e) { if (goodInput && !loading) { loading = true; toolStripButton1.Enabled = false; if (iterations >= 100000) { DialogResult option = MessageBox.Show("Running " + iterations + " simulations will " + "take approximately: " + getTime() + "\nDo you wish to continue?", "Alert", MessageBoxButtons.OKCancel); if (option == DialogResult.Cancel) { goto Done; } } try { if (pictureBox1.Image != null) { pictureBox1.Image.Dispose(); } } catch (Exception Ex0) { var nullErrorMessageBox = MessageBox.Show ("ERROR disposing old image file! \nOutput: " + Ex0.ToString(), "Alert", MessageBoxButtons.OK); } RscriptWriter(); userInputScript = rPathDest; Console.WriteLine("userInputScript: " + userInputScript); outputLocation = RpathFinder(); Console.WriteLine("outputLocation: " + outputLocation); try { RunFromCmd(userInputScript, userInputCSV, outputLocation, iterations.ToString(), distributionType); } catch (Exception Ex1) { var nullErrorMessageBox = MessageBox.Show ("ERROR on CMD process! \nOutput: " + Ex1.ToString(), "Alert", MessageBoxButtons.OK); } try { Cursor.Current = Cursors.WaitCursor; toolStripButton1.BackColor = Color.GreenYellow; if (iterations >= 10000000) { Thread.Sleep(Convert.ToInt32(iterations * 0.10)); } else if (iterations >= 100000 && iterations < 10000000) { Thread.Sleep(Convert.ToInt32(iterations * 0.30)); } else if (iterations >= 10000 && iterations < 100000) { Thread.Sleep(Convert.ToInt32(iterations * 0.50)); } else { Thread.Sleep(2500); } } catch (Exception Ex2) { var nullErrorMessageBox = MessageBox.Show ("ERROR waiting for process to complete! \nOuput: " + Ex2.ToString(), "Alert", MessageBoxButtons.OK); } try { pictureBox1.Image = Image.FromFile(RpathFinder() + @"\output.png"); } catch (Exception Ex3) { var nullErrorMessageBox = MessageBox.Show ("ERROR loading the image file! \nOuput: " + Ex3.ToString(), "Alert", MessageBoxButtons.OK); } Done: try { if (!string.IsNullOrWhiteSpace(userInputScript)) { DeleteTempFile(userInputScript); } //if (!string.IsNullOrWhiteSpace(userInputScript)) //DeleteTempFile(RpathFinder() + @"\output.png"); loading = false; maxWarning = false; minWarning = false; } catch (Exception Ex4) { var nullErrorMessageBox = MessageBox.Show ("ERROR on cleanup process! \nOutput: " + Ex4.ToString(), "Alert", MessageBoxButtons.OK); } } }
public void TestCountSimilarVsSelf() { Assert.AreEqual(Ex1.CountSimilar(Ex1), Ex1.Count); Assert.AreEqual(Ex2.CountSimilar(Ex2), Ex2.Count); Assert.AreEqual(Ex3.CountSimilar(Ex3), Ex3.Count); }