/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(IGH_DataAccess DA) { List <IGH_Goo> data = new List <IGH_Goo>(); bool wrap = false; if (!DA.GetDataList(0, data)) { return; } DA.GetData(1, ref wrap); List <IGH_Goo> Fw, Bw; Fw = data.ConvertAll(d => d); Bw = data.ConvertAll(d => d); Fw.RemoveAt(Fw.Count - 1); Bw.RemoveAt(0); if (wrap) { IGH_Goo first, last; first = data[0]; last = data[data.Count - 1]; Fw.Insert(0, last); Bw.Add(first); } DA.SetDataList(0, Fw); DA.SetDataList(1, Bw); }
public override string Encode(string str) { var shifts = new List <string>(Bw.GetShiftsOf(str)); shifts.Sort(); var position = Bw.GetIndexOf(str, shifts); return(Rle.Transform(shifts, position).ToString()); }
//获取请求 public void Get_Friendreq() { try { Bw.Write("getfriendreq"); } catch { MessageBox.Show("获取好友列表失败"); } }
//获取列表 private void Get_Friend() { try { Bw.Write("getfriends"); } catch { MessageBox.Show("获取好友列表失败"); } }
private void Get_muGroups() { try { Bw.Write("getmugroups"); } catch { MessageBox.Show("获取群组分组失败"); } }
private void Get_Groups() { try { Bw.Write("getgroups"); } catch { MessageBox.Show("获取好友分组失败"); } }
private void Get_mutualchat() { try { Bw.Write("getmutualchat"); } catch { MessageBox.Show("获取群聊信息失败"); } }
public void Get_Putmureq() { try { Bw.Write("getputmureq"); } catch { MessageBox.Show("获取发送的群组申请列表失败"); } }
private void loadmunoread() { string sndmsg = "getmunoread#"; try { Bw.Write(sndmsg); } catch { MessageBox.Show("获取消息失败"); } }
private void btn_Send_Click(object sender, EventArgs e) { try { //通过TCP协议向服务器发送群发消息 string temp = this.tb_SendMsg.Text; //保存TextBox文本 Bw.Write("barchmsg#" + Username + "#" + temp); Bw.Flush(); AddMessage("barchmsg#" + Username + '#' + temp, false); this.tb_SendMsg.Clear(); } catch { } }
//修改属性 /*private void mustate(string GID,string groupname,string sign) * { * foreach (ListViewItem item in this.lv_group.Items) * { * if (item.Text == GID) * { * item.SubItems[1].Text = groupname; * item.SubItems[4].Text = sign; * } * } * } * private void state(string UID,string username,string sign) * { * * }*/ //关闭窗口 private void list_FormClosed(object sender, FormClosedEventArgs e) { try { string sendmsg = "logout#" + UID; Bw.Write(sendmsg); Bw.Flush(); iswork = false; Br.Close(); Bw.Close(); } catch { } Application.Exit(); }
private void bt_send_Click(object sender, EventArgs e) { if (cb_group.Text == "") { lb_state.Text = "分组不能为空"; return; } String sndmsg = "cgmugroup#"; sndmsg += GID; sndmsg += "#"; sndmsg += cb_group.Text; Bw.Write(sndmsg); this.Close(); }
private void delmuToolStripMenuItem_Click(object sender, EventArgs e) { if (this.lv_group.SelectedItems.Count == 0) { return; } ListViewItem lvitm = this.lv_group.SelectedItems[0]; DialogResult result = MessageBox.Show("确定解散该群吗?", "提示:", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.Yes) { Bw.Write("delmu#" + lvitm.SubItems[0].Text); } else { return; } }
// Making a Method to Display in Main public void CustomersAccount() { StreamWriter Ac; try { Ac = File.AppendText("C:\\Users\\RON TAYLOR\\Desktop\\Computer Programing\\Customer_Account.txt"); Console.WriteLine("please enter customers previous reading"); previous_meter = int.Parse(Console.ReadLine()); Console.WriteLine("please enter customers current reading"); current_meter = int.Parse(Console.ReadLine()); current_consumption = current_meter - previous_meter; Console.ReadLine(); Ac.WriteLine(previous_meter); Ac.WriteLine(current_meter); Ac.WriteLine(current_consumption); Ac.WriteLine("Previous meter :{0} Current meter: {1} Current consumption :{2}", previous_meter, current_meter, current_consumption); Ac.Close(); } catch { Console.WriteLine(" file not writtten "); } Console.ReadLine(); StreamReader Bw; Bw = File.OpenText("C:\\Users\\RON TAYLOR\\Desktop\\Computer Programing\\Customer_Account.txt"); Accdisplay = Bw.ReadLine(); while (Accdisplay != null) { Console.WriteLine(Accdisplay); Accdisplay = Bw.ReadLine(); } Bw.Close(); }
public String Split() { Int32 currentPage = 1; Int32 totalPages = 0; String currentPageField = String.Empty; String previousWP = String.Empty; String currentWP = String.Empty; FileStream outputStream = null;; PdfWriter writer; PdfImportedPage pageImport; byte[] byteArrayPdf; PdfContentByte cb; Document doc = null; try { if (!outputFolder.isDirectoryPathOK()) { return("Invalid output folder"); } BeforeProcessing(); //Document doc; PdfReader pdfReaderTemp = new PdfReader(PdfPath); Document docTemp = new Document(pdfReaderTemp.GetPageSize(currentPage)); outputStream = new FileStream(outputFolder + "\\tmp.pdf", FileMode.OpenOrCreate); outputStream.Flush(); writer = PdfWriter.GetInstance(docTemp, outputStream); outputStream.Close(); pdfReaderTemp.Close(); using (PdfReader pdfReader = new PdfReader(PdfPath)) { totalPages = pdfReader.NumberOfPages; ITextExtractionStrategy rectangleStrategy; /*Document*/ doc = new Document(pdfReader.GetPageSize(1)); for (currentPage = 1; currentPage <= pdfReader.NumberOfPages; currentPage++) { // Update progress bar try { Bw.ReportProgress(Utils.GetPercentage(currentPage, pdfReader.NumberOfPages)); } catch { } // check if bw is trying to be cancelled if (Bw == null || Bw.CancellationPending) { myLogger.Log("Processing cancelled on PDF #" + currentPage); break; } float height = pdfReader.GetPageSize(currentPage).Height; float width = pdfReader.GetPageSize(currentPage).Width; if (height > 785 && height < 802 && width > 1215 && width < 1230) { // Page is 11 x 17 rectangleStrategy = MakeRectangle(450, 1, 450, 70); } else if (height > 785 && height < 802 && width > 608 && width < 617) { // Page is 8.5 x 11 rectangleStrategy = MakeRectangle(190, 1, 255, 74); } else { myLogger.Log("Page # " + currentPage.ToString() + " not 8.5 x 11 or 11 x 17"); continue; } String currentText = PdfTextExtractor.GetTextFromPage(pdfReader, currentPage, rectangleStrategy); currentText = Encoding.UTF8.GetString(Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); if (pageFieldRegex.IsMatch(currentText)) { currentPageField = pageFieldRegex.Match(currentText).Value.Trim(); currentWP = ExtractWP(currentPageField, false); } else { if (pageFieldBlankRegex.IsMatch(currentText)) { currentPageField = pageFieldBlankRegex.Match(currentText).Value.Trim(); currentWP = ExtractWP(currentPageField, true); } else { continue; } } if (!String.Equals(previousWP, currentWP)) { //current wp is different than previous try { doc.Close(); } catch { } doc = new Document(pdfReader.GetPageSize(currentPage)); outputStream = new FileStream(outputFolder + "\\" + currentWP + ".pdf", FileMode.Create); writer = PdfWriter.GetInstance(doc, outputStream); byteArrayPdf = pdfReader.GetPageContent(currentPage); doc.Open(); cb = writer.DirectContent; pageImport = writer.GetImportedPage(pdfReader, currentPage); cb.AddTemplate(pageImport, 0, 0); writer.Flush(); previousWP = currentWP; } else { //current wp is the same as previous doc.NewPage(); byteArrayPdf = pdfReader.GetPageContent(currentPage); cb = writer.DirectContent; pageImport = writer.GetImportedPage(pdfReader, currentPage); cb.AddTemplate(pageImport, 0, 0); writer.Flush(); } } //try { doc.Close(); } //catch { } try { File.Delete(outputFolder + "\\tmp.pdf"); } catch { } }// using PdfReader pdfReader } catch (System.Exception se) { return(se.Message); } finally { try { doc.Close(); } catch { } try { outputStream.Dispose(); } catch { } try { File.Delete(outputFolder + "\\tmp.pdf"); } catch { } AfterProcessing(); } return(String.Concat(totalPages.ToString(), " pages processed in ", timer.Elapsed.TotalSeconds.PrintTimeFromSeconds(), " with ", myLogger.ErrorCount, " errors.")); }
public String ExportData() { //Document variables DocInfo docInfo = new DocInfo(); System.Boolean hasOfficialUse = false; string officialText; try { if (!ExportFilePath.isFilePathOK(".txt")) { return("Invalid export file path: " + ExportFilePath); } BeforeProcessing(); using (var pdfReader = new PdfReader(PdfPath)) { // For image checking var parser = new PdfReaderContentParser(pdfReader); ImageRenderListener listener = null; // Check to see if doc has "for official use only" at the bottom ITextExtractionStrategy officialTextRectangle = MakeRectangle(70, 1, 375, 120); officialText = PdfTextExtractor.GetTextFromPage(pdfReader, 1, officialTextRectangle); officialText = Encoding.UTF8.GetString(Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(officialText))); if (officialText.ToString().ToUpper().Contains("FOROFFICIALUSEONLY")) { hasOfficialUse = true; } else { hasOfficialUse = false; } // Loop through each page of the PDF for (Int32 currentPage = 1; currentPage <= pdfReader.NumberOfPages; currentPage++) { PageInfo currentPageInfo = new PageInfo() { PageNum = currentPage }; ITextExtractionStrategy rectangleStrategy; float height = pdfReader.GetPageSize(currentPage).Height; float width = pdfReader.GetPageSize(currentPage).Width; if (height > 785 && height < 802 && width > 1215 && width < 1230) { rectangleStrategy = MakeRectangle(450, 1, 450, 70); } else if (height > 785 && height < 802 && width > 608 && width < 617) { rectangleStrategy = MakeRectangle(190, 1, 255, 74); } else { myLogger.Log("Page # " + currentPage.ToString() + " not 8.5 x 11 or 11 x 17"); continue; } string currentText = PdfTextExtractor.GetTextFromPage(pdfReader, currentPage, rectangleStrategy); currentText = Encoding.UTF8.GetString(Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); if (hasOfficialUse) { currentText = OfficialUseRegex.Replace(currentText, "").Trim(); } ITextExtractionStrategy workPackageIndexStrategy = MakeRectangle(60, 600, 160, 50); string WPI = PdfTextExtractor.GetTextFromPage(pdfReader, currentPage, workPackageIndexStrategy); WPI = Encoding.UTF8.GetString(Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(WPI))); if (WPI.ToUpper().Contains("WORKPACKAGEINDEX")) { currentPageInfo.HasWpIndex = true; } // #-# if (NumDashNumRegex.IsMatch(currentText)) { currentPageInfo.PageNumText = NumDashNumRegex.Match(currentText).Value.Trim(); currentPageInfo.IsWP = true; } else { // #-#/blank if (NumDashNumBlankRegex.IsMatch(currentText)) { currentPageInfo.PageNumText = NumDashNumBlankRegex.Match(currentText).Value.Trim(); currentPageInfo.IsDashBlank = true; currentPageInfo.IsWP = true; } else { if (romanNumRegex.IsMatch(currentText.ToUpper().Trim())) { currentPageInfo.PageNumText = romanNumRegex.Match(currentText.ToUpper().Trim()).Value.Trim(); if (String.Equals(currentPageInfo.PageNumText.ToUpper(), "C") || String.Equals(currentPageInfo.PageNumText.ToUpper(), "D")) { currentPageInfo.PageNumText = currentPageInfo.PageNumText.ToLower(); currentPageInfo.IsLetter = true; } else { currentPageInfo.IsRoman = true; } } else { if (LetterRegex.IsMatch(currentText.Trim())) { currentPageInfo.PageNumText = LetterRegex.Match(currentText).Value.Trim(); currentPageInfo.IsLetter = true; } else { // Check if whole page is empty parser.ProcessContent(currentPage, (listener = new ImageRenderListener())); ITextExtractionStrategy currentTextRectangle = MakeRectangle(1, 1, 1000000, 1000000); String checkText = PdfTextExtractor.GetTextFromPage(pdfReader, currentPage, currentTextRectangle); checkText = Encoding.UTF8.GetString(Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(checkText))); if ((listener.Images.Count <= 0) && String.IsNullOrWhiteSpace(checkText)) { currentPageInfo.IsWholePageEmpty = true; currentPageInfo.IsPageNumAreaBlank = true; } else { if (String.IsNullOrWhiteSpace(currentText)) { currentPageInfo.IsPageNumAreaBlank = true; } else { if (indexRegex.IsMatch(currentText.Trim())) { currentPageInfo.PageNumText = indexRegex.Match(currentText).Value.Trim(); currentPageInfo.IsIndex = true; } else { currentPageInfo.PageNumText = currentText; currentPageInfo.IsMisc = true; } } } } } } } if (Bw.CancellationPending) { myLogger.Log("Processing cancelled at dwg #: " + currentPage.ToString()); break; } Bw.ReportProgress(Utils.GetPercentage(currentPage, pdfReader.NumberOfPages)); docInfo.Pages.Add(currentPageInfo); } } WriteDocInfoToTextFile(docInfo); } catch (System.Exception se) { return(se.Message); } finally { AfterProcessing(); } return(String.Concat(docInfo.ToString(), Environment.NewLine, "Processing completed in ", timer.Elapsed.TotalSeconds.PrintTimeFromSeconds(), Environment.NewLine, myLogger.ErrorCount.ToString(), " errors found.")); //return String.Concat( // docInfo.NumSheets, // "Processing completed in ", // timer.Elapsed.TotalSeconds.PrintTimeFromSeconds(), // " with ", // myLogger.ErrorCount, // " errors."); }
public String Extract() { String currentPageField = String.Empty; byte[] byteArrayPdf; PdfContentByte cb; PdfImportedPage pageImport; Int32 totalPages = 0; try { if (!WpFile.isFilePathOK()) { return("Invalid WP file"); } if (!outputFolder.isDirectoryPathOK()) { return("Invalid output folder"); } BeforeProcessing(); HashSet <String> WPs = GetWPsToExtract(); using (PdfReader pdfReader = new PdfReader(PdfPath)) { using (Document doc = new Document(pdfReader.GetPageSize(1))) { using (FileStream outputStream = new FileStream(outputFolder + "\\ExtractedWPs.pdf", FileMode.Create)) { PdfWriter writer = PdfWriter.GetInstance(doc, outputStream); totalPages = pdfReader.NumberOfPages; ITextExtractionStrategy rectangleStrategy; for (Int32 currentPage = 1; currentPage <= pdfReader.NumberOfPages; currentPage++) { String currentWP = String.Empty; try { Bw.ReportProgress(Utils.GetPercentage(currentPage, pdfReader.NumberOfPages)); } catch { } if (Bw.CancellationPending || Bw == null) { myLogger.Log("Processing cancelled on PDF #" + currentPage); break; } float height = pdfReader.GetPageSize(currentPage).Height; float width = pdfReader.GetPageSize(currentPage).Width; if (height > 785 && height < 802 && width > 1215 && width < 1230) { // Page is 11 x 17 rectangleStrategy = MakeRectangle(450, 1, 450, 70); } else if (height > 785 && height < 802 && width > 608 && width < 617) { // Page is 8.5 x 11 rectangleStrategy = MakeRectangle(190, 1, 255, 74); } else { myLogger.Log("Page # " + currentPage.ToString() + " not 8.5 x 11 or 11 x 17"); continue; } String currentText = PdfTextExtractor.GetTextFromPage(pdfReader, currentPage, rectangleStrategy); currentText = Encoding.UTF8.GetString(Encoding.Convert(Encoding.Default, Encoding.UTF8, Encoding.Default.GetBytes(currentText))); if (pageFieldRegex.IsMatch(currentText)) { currentPageField = pageFieldRegex.Match(currentText).Value.Trim(); currentWP = ExtractWP(currentPageField, false); } else { if (pageFieldBlankRegex.IsMatch(currentText)) { currentPageField = pageFieldBlankRegex.Match(currentText).Value.Trim(); currentWP = ExtractWP(currentPageField, true); } else { // This page has no Page # field/WP, so skip it continue; } } if (WPs.Contains(currentWP)) { // Write this page to document if (!doc.IsOpen()) { doc.Open(); } doc.NewPage(); byteArrayPdf = pdfReader.GetPageContent(currentPage); cb = writer.DirectContent; pageImport = writer.GetImportedPage(pdfReader, currentPage); cb.AddTemplate(pageImport, 0, 0); writer.Flush(); } } try { writer.Dispose(); } catch { } // PdfWriter } //FileStream } //Doc } //PdfReader } catch (System.Exception se) { return(se.Message); } finally { AfterProcessing(); } return(String.Concat(totalPages.ToString(), " pages processed in ", timer.Elapsed.TotalSeconds.PrintTimeFromSeconds(), " with ", myLogger.ErrorCount, " errors.")); }
public void Close() { Br.Close(); Bw.Close(); Client.Close(); }
private void bt_change_Click(object sender, EventArgs e) { Bw.Write("userstate#" + tb_username.Text + "#" + tb_sign.Text); }
private void bt_send_Click(object sender, EventArgs e) { Bw.Write("mustate#" + GID + "#" + tb_grpname.Text + "#" + tb_grpsign.Text); }
private void worker_DoWork(object sender, DoWorkEventArgs e) { startCalculatingLock = true; int iterationsLeft = mainWindow.UserDefinedLFSRIterations; if (calculatingStoppedAt > 0) { iterationsLeft = calculatingStoppedAt; } if (pauseCalculatingLock || stopCalculatingLock) { pauseCalculatingLock = false; stopCalculatingLock = false; } string startButtonContent = (string)e.Argument; int bitListCount = bitViewModel.Bits.Count; int sum; bool saveGeneratedValue = false; int counter = 0; StreamWriter tw = new StreamWriter(mainWindow.FileManagement.Files[0]); tw.Dispose(); BinaryWriter Bw = new BinaryWriter(File.Open(mainWindow.FileManagement.Files[0], FileMode.OpenOrCreate)); Bw.Dispose(); if (startButtonContent.Equals("Resume")) { if (mainWindow.FileManagement.Extension.Equals(".txt")) { tw = File.AppendText(mainWindow.FileManagement.Files[0]); } else { Bw = new BinaryWriter(File.Open(mainWindow.FileManagement.Files[0], FileMode.Append)); } } else { iterationsLeft = mainWindow.UserDefinedLFSRIterations; if (mainWindow.FileManagement.Extension.Equals(".txt")) { tw = new StreamWriter(mainWindow.FileManagement.Files[0]); } else { Bw = new BinaryWriter(File.Open(mainWindow.FileManagement.Files[0], FileMode.OpenOrCreate)); } this.Dispatcher.Invoke(() => { userDefinedProgressBar.Maximum = iterationsLeft; }); } int progress = iterationsLeft; StringBuilder byteToSave = new StringBuilder(); while (!pauseCalculatingLock && !stopCalculatingLock && iterationsLeft > 0) { if (saveGeneratedValue == true && cyclesUntilSavingCheck.Equals(0)) { if (mainWindow.FileManagement.Extension.Equals(".bin")) { if (byteToSave.Length == 0) { this.Dispatcher.Invoke(() => { Bw.Write(Convert.ToByte(byteToSave.ToString(), 2)); }); byteToSave.Clear(); } else { byteToSave.Append(bitViewModel.Bits[bitListCount - 1].BitValue); } } else { this.Dispatcher.Invoke(() => { tw.Write(bitViewModel.Bits[bitListCount - 1].BitValue); }); } (sender as BackgroundWorker).ReportProgress(0); iterationsLeft--; saveGeneratedValue = false; } sum = 0; for (int i = 0; i < bitListCount; i++) { if (bitViewModel.Bits[i].BitState.Equals("On") && bitViewModel.Bits[i].BitValue.Equals(1)) { sum++; } } sum = sum % 2; for (int i = bitListCount - 1; i > 0; i--) { bitViewModel.Bits[i].BitValue = bitViewModel.Bits[i - 1].BitValue; } bitViewModel.Bits[0].BitValue = sum; if (cyclesUntilSavingCheck.Equals(0) && bitViewModel.Bits[bitListCount - 1].BitValue.Equals(0)) { cyclesUntilSavingCheck = mainWindow.NewCyclesAtZero; } if (cyclesUntilSavingCheck.Equals(0) && bitViewModel.Bits[bitListCount - 1].BitValue.Equals(1)) { cyclesUntilSavingCheck = mainWindow.NewCyclesAtOne; counter++; saveGeneratedValue = true; } cyclesUntilSavingCheck--; } if (iterationsLeft == 0) { this.Dispatcher.Invoke(() => { startButton.Content = "Start"; startButton.IsEnabled = true; userDefinedProgressBar.Value = 0; }); } else { calculatingStoppedAt = iterationsLeft; } tw.Close(); Bw.Close(); startCalculatingLock = false; }
private bool PrvCalculateBackwards(bool impact) // prawda jesli przejmuje odpowiedzialnosc za obliczenia. { Bw.FillWith(0); Dw.FillWith(0); P.FillWith(0); G.FillWith(0); Qw = Q = Hw = H = 0; AJointActive NJ = (!IsEnding && NextJoint.IsActivable) ? (AJointActive)NextJoint : null; if (IsEnding || (!IsActive && !NJ.IsActive)) { return(false); } else if (IsLed && NextJoint.IsActive && !NextJoint.IsEnding) { #region złącze prowadzone i następne aktywne Variant = "3.1"; double e = GetCentripetalAcc(impact); AVector2D r = NextLink.r; AVector2D L = NextLink.L; AMatrix2x2 A_1 = NextJoint.A; AVector2D b_1 = NextJoint.b; double k0 = -r * (A_1 * r); double k1 = r * (A_1 * L) - r * NJ.Bw; double k3 = -r * (A_1 * L); double k4 = r * GetLeadingAcc() - r * b_1 - e; double k5 = NJ.P * r - L * (A_1 * r); double k6 = -NJ.P * L + NJ.Qw + L * (A_1 * L) - L * NJ.Bw; double k8 = NJ.P * L - L * (A_1 * L); double k9 = NJ.Q - L * b_1 + L * GetLeadingAcc() - NJ.GetProperArcAcceleration(impact); double k11 = k5 * k1 - k0 * k6; if (Math.Abs(k11) < NumericError * 2) { // it is impossible to determine both force and torch Variant = "3.1.1"; double eq1 = Math.Abs(k0) + Math.Abs(k1); double eq2 = Math.Abs(k5) + Math.Abs(k6); if (eq1 < NumericError || eq1 < eq2) { Variant = "3.1.1.1"; k0 = 1; k1 = k3 = k4 = 0; } if (eq2 < NumericError || eq2 <= eq1) { Variant = "3.1.1.2"; k6 = 1; k5 = k8 = k9 = 0; } k11 = k5 * k1 - k0 * k6; } double k14 = (k6 * k3 - k1 * k8) / k11; double k15 = (k0 * k8 - k5 * k3) / k11; double k16 = (k4 * k6 - k1 * k9) / k11; double k17 = (k0 * k9 - k5 * k4) / k11; G.FillWith(0); Hw = k15; H = k17; C.FillWith(0); Dw = r * k14 + L - L * k15; d = r * k16 - L * k17; A.FillWith(0); Bw.FillWith(0); b = GetLeadingAcc(); P.FillWith(0); Qw = L * A_1 * Dw + L * NJ.Bw * Hw; Q = L * A_1 * d + L * NJ.Bw * H + L * NJ.b - L * b; #endregion } else if (IsLed) { #region złącze prowadzone i następne nieaktywne Variant = "3.2"; double e = GetCentripetalAcc(impact); AVector2D r = NextLink.r; AVector2D L = NextLink.L; AMatrix2x2 A_1 = NextJoint.A; AVector2D b_1 = NextJoint.b; double scala = r * (A_1 * r); if (Math.Abs(scala) > NumericError) { // jeśli się da, to wywrzej wpływ na i+1-sze złącze Variant = "3.2.1"; C.FillWith(0); Dw = L - (r * (r * (A_1 * L) / scala)); d = r * (r * (GetLeadingAcc() - b_1) - e) / scala; } else { // ale jeśli się nie da to odpuść. Variant = "3.2.2"; C.FillWith(0); Dw.FillWith(0); d.FillWith(0); } A.FillWith(0); Bw.FillWith(0); b = GetLeadingAcc(); P.FillWith(0); Qw = L * A_1 * Dw - L * Bw; Q = L * A_1 * d + L * b_1 - L * b; #endregion } else if (!NextJoint.IsActive || NextJoint.IsEnding) { #region złącze nieprowadzone i następne nieaktywne Variant = "3.3"; double e = GetCentripetalAcc(impact); AVector2D r = NextLink.r; AVector2D L = NextLink.L; AMatrix2x2 A_1 = NextJoint.A; AVector2D b_1 = NextJoint.b; double scala = r * (A_1 * r) * m + 1; C = r | r / scala; Dw = L - r * (r * (A_1 * L) * m / scala); d = r * (r * Fe - (r * b_1 + e) * m) / scala; A = (AMatrix2x2.I() - C) / m; Bw = Dw / -m; b = (Fe - d) / m; P = L * A_1 * C - L * A; Qw = L * A_1 * Dw - L * Bw; Q = L * A_1 * d + L * b_1 - L * b; #endregion } else { #region aktywne zlacze w srodku ukladu Variant = "3.4"; double e = GetCentripetalAcc(impact); AVector2D r = NextLink.r; AVector2D L = NextLink.L; AMatrix2x2 A_1 = NextJoint.A; AVector2D b_1 = NextJoint.b; double k0 = 1.0 / -m - r * (A_1 * r); double k1 = r * (A_1 * L) - r * NJ.Bw; AVector2D k2 = r / m; double k3 = -r * (A_1 * L); double k4 = r * Fe / m - r * b_1 - e; double k5 = NJ.P * r - L * (A_1 * r); double k6 = -NJ.P * L + NJ.Qw + L * (A_1 * L) - L * NJ.Bw + L.LengthSq / m; AVector2D k7 = L / m; double k8 = NJ.P * L - L * (A_1 * L) - L.LengthSq / m; double k9 = NJ.Q - L * b_1 + L * Fe / m - NJ.GetProperArcAcceleration(impact); double k11 = k5 * k1 - k0 * k6; AVector2D k12 = (k6 * k2 - k1 * k7) / k11; AVector2D k13 = (k0 * k7 - k5 * k2) / k11; double k14 = (k6 * k3 - k1 * k8) / k11; double k15 = (k0 * k8 - k5 * k3) / k11; double k16 = (k4 * k6 - k1 * k9) / k11; double k17 = (k0 * k9 - k5 * k4) / k11; G = k13; Hw = k15; H = k17; C = (r | k12) - (L | k13); Dw = r * k14 + L - L * k15; d = r * k16 - L * k17; A = (AMatrix2x2.I() - C) / m; Bw = Dw / -m; b = (Fe - d) / m; P = L * A_1 * C + L * NJ.Bw * G - L * A; Qw = L * A_1 * Dw + L * NJ.Bw * Hw - L * Bw; Q = L * A_1 * d + L * NJ.Bw * H + L * NJ.b - L * b; #endregion } return(true); }
private void radButton1_Click(object sender, EventArgs e) { double Dscd2, Ge2, Dscd3, Ge3, Dscd4, Ge4; WEIRHIGHTradTextBox1.Text = valueofh().ToString(); if (PeakradTextBox1.Text == "" || widthreverradTextBox4.Text == "" || tailwaterradTextBox6.Text == "" || MeanradTextBox1.Text == "" || rivrbedradTextBox10.Text == "" || depthdownradTextBox11.Text == "" || depthupradTextBox2.Text == "" || WeirbodycomboBox1.Text == "" || PercentagecomboBox1.Text == "" || TypeofcomboBox1.Text == "") { MessageBox.Show("You have left a Required field empty", "message", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); } else { Qp = Convert.ToDouble(PeakradTextBox1.Text); LR = Convert.ToDouble(widthreverradTextBox4.Text); d3 = Convert.ToDouble(tailwaterradTextBox6.Text); mr = Convert.ToDouble(MeanradTextBox1.Text); RBL = Convert.ToDouble(rivrbedradTextBox10.Text); DGd = Convert.ToDouble(depthdownradTextBox11.Text); DGu = Convert.ToDouble(depthupradTextBox2.Text); if (WeirbodycomboBox1.Text == "Concrete") { wb = 2.3; } else if (WeirbodycomboBox1.Text == "Masonary") { wb = 2.4; } else if (WeirbodycomboBox1.Text == "Cement Mortar") { wb = 2.1; } else if (WeirbodycomboBox1.Text == "Reinforced Concrete") { wb = 2.45; } if (PercentagecomboBox1.Text == "10%") { X = 0.1; } else if (PercentagecomboBox1.Text == "15%") { X = 0.15; } else if (PercentagecomboBox1.Text == "20%") { X = 0.12; } if (TypeofcomboBox1.Text == "Fine Sand") { c = 15; Gex = 0.17; } if (TypeofcomboBox1.Text == "Coarse Sand") { c = 12; Gex = 0.2; } if (TypeofcomboBox1.Text == "Sand Mixed with boulder") { c = 9; Gex = 0.25; } if (TypeofcomboBox1.Text == "tight Sand") { c = 8; Gex = 0.25; } } // calculation began here Q = (1 - X) * Qp; L = (1 - X) * LR; He = Math.Pow(Q / (1.71 * L), (double)2 / 3); //hdrandresult = (2 * He) / 3; // d1randval = (2 * (valueofh() + He)) / 3; hdrandresult = hdrand(Hd, He, Q, L, Qp); d1randval = d1rand(d1, valueofh(), He, Q, L, hdrandresult); q = Q / L; v1 = q / d1randval; Fr = v1 / Math.Sqrt(d1randval * g); d2 = (double)d1randval / 2 * ((Math.Sqrt(1 + (8 * Math.Pow(Fr, 2)))) - 1); v2 = q / d2; d = d2 - d3; //value pass for norandfucction double d1d = (2 * (valueofh() + d + He)) / 3; if (d < 0.4) { d = 0; if (Fr < 2.5) { energyradTextBox1.Text = "DON'T USE ENERGY DISSIPATOR"; } else { if (Fr > 2.5 && Fr < 4.5) { energyradTextBox1.Text = "USE TYPE IV"; } else { if (Fr < 10) { if (v1 < 18) { energyradTextBox1.Text = "USE TYPE III"; } else { energyradTextBox1.Text = "USE TYPE II"; } } else { energyradTextBox1.Text = "USE BUCKET TYPE"; } } } DepthofCisterntextbox.Text = d.ToString(); } else { d1randval = nodrand(d1d, d, valueofh(), Q, He, L, d1randval); // d1randval= (2 * (valueofh() + d + He)) / 3; v1 = q / d1randval; Fr = v1 / (Math.Sqrt(g * d1randval)); d2 = ((double)d1randval / 2) * (Math.Sqrt((1 + 8 * (Math.Pow(Fr, 2))))); v2 = q / d2; if (Fr < 2.5) { energyradTextBox1.Text = "DON'T USE ENERGY DISSIPATOR"; } else { if (Fr > 2.5 && Fr < 4.5) { energyradTextBox1.Text = "USE TYPE IV"; } else { if (Fr < 10) { if (v1 < 18) { energyradTextBox1.Text = "USE TYPE III"; } else { energyradTextBox1.Text = "USE TYPE II"; } } else { energyradTextBox1.Text = "USE BUCKET TYPE"; } } } DepthofCisterntextbox.Text = d.ToString(); } // code for finding downstream bed leve double DsBL = downstreambedlevel(RBL, valueofh(), He, hdrandresult, d3, d2); // code for finding the top width of a weir body and bottom witdth of weir body Tw = He / (Math.Sqrt(wb - 1)); Bw = Tw + (valueofh() / (Math.Sqrt(wb - 1))); topwidthradTextBox2.Text = Tw.ToString(); BottomwidthradTextBox4.Text = Bw.ToString(); //code for finding uper stream cd and down stream cd double f = 1.76 * (Math.Sqrt(mr)); double R = 1.35 * (Math.Pow(q / f, (double)2 / 3)); double UsHFL = RBL + valueofh() + He; if (R > 2.5) { R = 2.5; DsHFL = RBL + d3; DsCL = DsHFL - (2 * R); DsCd = RBL - DsCL; UsCL = UsHFL - (1.5 * R); UsCd = RBL - UsCL; if (DsCd <= DGd) { downsstreamcutoofradTextBox6.Text = DGd.ToString(); } if (DsCd >= DGd) { DsCd = DGd; downsstreamcutoofradTextBox6.Text = DsCd.ToString(); } if (UsCd <= DGu) { upstramcuttoffradTextBox5.Text = DGu.ToString(); } if (UsCd >= DGu) { UsCd = DGu; upstramcuttoffradTextBox5.Text = UsCd.ToString(); } } else { DsHFL = RBL + d3; DsCL = DsHFL - (2 * R); DsCd = RBL - DsCL; UsCL = UsHFL - (1.5 * R); UsCd = RBL - UsCL; if (DsCd <= DGd) { downsstreamcutoofradTextBox6.Text = DGd.ToString(); } if (DsCd >= DGd) { DsCd = DGd; downsstreamcutoofradTextBox6.Text = DsCd.ToString(); } if (UsCd <= DGu) { upstramcuttoffradTextBox5.Text = DGu.ToString(); } if (UsCd >= DGu) { UsCd = DGu; upstramcuttoffradTextBox5.Text = UsCd.ToString(); } /* UsCd = DGu; * DsCd = DGd; * downsstreamcutoofradTextBox6.Text = DsCd.ToString(); * upstramcuttoffradTextBox5.Text = UsCd.ToString();*/ } DsCd = DGd; UsCd = DGu; //CODE FOR CALCULAING LENGTHOF UPSTREAM APRON ,LENGTHOF DOWNSREAM APRON(LDS) AND STILLING BASINE.................. H = ((RBL + valueofh() + He) - DsBL); Lb = c * H; ldsa = 3.87 * c * (Math.Sqrt(Math.Abs(H / 10))); Ls = 5 * d2; lds = ldsa - Ls; Lus = Lb - ((2 * UsCd) + Bw + ldsa + (2 * DsCd)); if (Lus > 0) { AL = (Lus + Bw + Ls + lds) / DsCd; lamda = (1 + (Math.Sqrt(1 + (Math.Pow(AL, 2))))) / 2; Ge = valueofh() / DsCd * (1 / (Math.PI * (Math.Sqrt(lamda)))); if (Ge < Gex) { lengthofdownradTextBox8.Text = ldsa.ToString(); lengthofupradTextBox7.Text = Lus.ToString(); lengthofstillingradTextBox9.Text = Ls.ToString(); } Dscd2 = DsCd + 0.2; AL = (Lus + Bw + Ls + lds) / Dscd2; lamda = (1 + (Math.Sqrt(1 + (Math.Pow(AL, 2))))) / 2; Ge2 = valueofh() / Dscd2 * (1 / (Math.PI * (Math.Sqrt(lamda)))); if (Ge2 < Gex) { lengthofdownradTextBox8.Text = ldsa.ToString(); lengthofupradTextBox7.Text = Lus.ToString(); lengthofstillingradTextBox9.Text = Ls.ToString(); } Dscd3 = DsCd + 0.3; AL = (Lus + Bw + Ls + lds) / Dscd3; lamda = (1 + (Math.Sqrt(1 + (Math.Pow(AL, 2))))) / 2; Ge3 = valueofh() / Dscd3 * (1 / (Math.PI * (Math.Sqrt(lamda)))); if (Ge3 < Gex) { lengthofdownradTextBox8.Text = ldsa.ToString(); lengthofupradTextBox7.Text = Lus.ToString(); lengthofstillingradTextBox9.Text = Ls.ToString(); } Dscd4 = DsCd + 0.4; AL = (Lus + Bw + Ls + lds) / Dscd4; lamda = (1 + (Math.Sqrt(1 + (Math.Pow(AL, 2))))) / 2; Ge4 = valueofh() / Dscd4 * (1 / (Math.PI * (Math.Sqrt(lamda)))); if (Ge4 > Gex) { lengthofdownradTextBox8.Text = ldsa.ToString(); lengthofupradTextBox7.Text = Lus.ToString(); lengthofstillingradTextBox9.Text = Ls.ToString(); } } else { Lus = 2.5; AL = (Lus + Bw + Ls + lds) / DsCd; lamda = (1 + (Math.Sqrt(1 + (Math.Pow(AL, 2))))) / 2; Ge = valueofh() / DsCd * (1 / (Math.PI * (Math.Sqrt(lamda)))); if (Ge < Gex) { lengthofdownradTextBox8.Text = ldsa.ToString(); lengthofupradTextBox7.Text = Lus.ToString(); lengthofstillingradTextBox9.Text = Ls.ToString(); } Dscd2 = DsCd + 0.2; AL = (Lus + Bw + Ls + lds) / Dscd2; lamda = (1 + (Math.Sqrt(1 + (Math.Pow(AL, 2))))) / 2; Ge2 = valueofh() / Dscd2 * (1 / (Math.PI * (Math.Sqrt(lamda)))); if (Ge2 < Gex) { lengthofdownradTextBox8.Text = ldsa.ToString(); lengthofupradTextBox7.Text = Lus.ToString(); lengthofstillingradTextBox9.Text = Ls.ToString(); } Dscd3 = DsCd + 0.3; AL = (Lus + Bw + Ls + lds) / Dscd3; lamda = (1 + (Math.Sqrt(1 + (Math.Pow(AL, 2))))) / 2; Ge3 = valueofh() / Dscd3 * (1 / (Math.PI * (Math.Sqrt(lamda)))); if (Ge3 < Gex) { lengthofdownradTextBox8.Text = ldsa.ToString(); lengthofupradTextBox7.Text = Lus.ToString(); lengthofstillingradTextBox9.Text = Ls.ToString(); } Dscd4 = DsCd + 0.4; AL = (Lus + Bw + Ls + lds) / Dscd4; lamda = (1 + (Math.Sqrt(1 + (Math.Pow(AL, 2))))) / 2; Ge4 = valueofh() / Dscd4 * (1 / (Math.PI * (Math.Sqrt(lamda)))); if (Ge4 < Gex) { lengthofdownradTextBox8.Text = ldsa.ToString(); lengthofupradTextBox7.Text = Lus.ToString(); lengthofstillingradTextBox9.Text = Ls.ToString(); } }//ENDING OF RADBUTON FOR WIR BODY //END FOR CALCULATING LDS, LUS AND LS APRONS...................................................................... //ALGORITHM FOR DOWNSTREAM FLOOR THICKNESS....................................................................... double Hdyn = He + valueofh(); double Lc = (2 * UsCd) + (Lus + Bw + Ls + lds + (2 * DsCd)); double Lpa = (2 * UsCd) + Lus; double Lpb = Lpa + Tw; double Lpc = Lpb + (Bw - Tw); double Lpd = Lpc + Ls; double Lpe = Lpd + (0.5 * lds); double Lpf = Lpd + lds; double valueofsfwb = SF / (wb - 1); double Tas = valueofh() * (1 - (Lpa / Lc)) * valueofsfwb; double Tbs = valueofh() * (1 - (Lpb / Lc)) * valueofsfwb; double Tcs = valueofh() * (1 - (Lpc / Lc)) * valueofsfwb; double Tds = valueofh() * (1 - (Lpd / Lc)) * valueofsfwb; double Tes = valueofh() * (1 - (Lpe / Lc)) * valueofsfwb; double Tfs = valueofh() * (1 - (Lpf / Lc)) * valueofsfwb; //Blieh approace Tad = Hdyn * (1 - (Lpa / Lc)) * valueofsfwb; Tbd = Hdyn * (1 - (Lpb / Lc)) * valueofsfwb; Tcd = Hdyn * (1 - (Lpc / Lc)) * valueofsfwb; Tdd = Hdyn * (1 - (Lpd / Lc)) * valueofsfwb; Ted = Hdyn * (1 - (Lpe / Lc)) * valueofsfwb; Tfd = Hdyn * (1 - (Lpf / Lc)) * valueofsfwb; //KOHSLAS APPROACH FOR FINDING HRC1 AND HRE2............................................ double bH = Lus + Bw + Ls + lds; double xbh = bH / DsCd; double lamda1 = 1 + (Math.Pow(xbh, 2)); double lamdadegre = (1 + (Math.Sqrt(lamda1))) / 2; double lamdavalue = (lamdadegre - 2) / lamdadegre; double tetaE = (1 / Math.PI) * (Math.Acos(lamdavalue)); double lamdavalue2 = (lamdadegre - 1) / lamdadegre; double tetaD = (1 / Math.PI) * (Math.Acos(lamdavalue2)); double tetaD1 = 1 - tetaD; double tetaC1 = 1 - tetaE; double Cdu = tetaC1 + ((tetaD1 - tetaC1) / DsCd) * 0.5; double Cmd = 19 * (Math.Sqrt(DsCd / bH)) * ((UsCd + DsCd) / bH); double Cfu = Cmd + Cdu; double Cdd = tetaE - ((tetaE - tetaD) / DsCd) * 0.5; double Cmu = 19 * (Math.Sqrt(UsCd / bH)) * ((UsCd + DsCd) / bH); double Cfd = Cdd - Cmu; double Hrc1 = valueofh() * Cfu; double Hre2 = valueofh() * Cfd; // KOHSLAS THICKNESS AT VARIOUS POINTS (a,b,c,d,e,f)................................................................... double Lak = Lpa - (2 * UsCd); double Lbk = Lpb - (2 * UsCd); double Lck = Lpc - (2 * UsCd); double Ldk = Lpd - (2 * UsCd); double Lek = Lpe - (2 * UsCd); double Lfk = Lpf - (2 * UsCd); double HR = (Hrc1 - Hre2) / bH; double Pa = Hrc1 - (HR * Lak); double Pb = Hrc1 - (HR * Lbk); double Pc = Hrc1 - (HR * Lck); double Pd = Hrc1 - (HR * Ldk); double Pe = Hrc1 - (HR * Lek); double Pf = Hrc1 - (HR * Lfk); //khoslat Tak = (Pa / (wb - 1)) * 1.3; if (Tak < 0.5) { Tak = 0.5; } Tbk = (Pb / (wb - 1)) * 1.3; Tck = (Pc / (wb - 1)) * 1.3; Tdk = (Pd / (wb - 1)) * 1.3; Tek = (Pe / (wb - 1)) * 1.3; Tfk = (Pf / (wb - 1)) * 1.3; // CODE FOR FINDING THE VALUE OF THICKNESS OF A FLOOR AT A POINT A,B,C,D,E,F //END FOR FINDING THE VALUE OF THICKNESS OF A,B,C,D,E,F //CODE PART FOR LENGTH OF D/S LOOSE TALLUS L3 AND L4.......................................................... double sqrhmaxnq = ((H / 10) * (q / 75)); double L3 = 18 * c * (Math.Sqrt(Math.Abs(sqrhmaxnq))) - ldsa; double L4 = L3 / 2; if (L3 < 0) { lengthofupstreamradTextBox12.Text = "YOU DO NOT ALLOW TO USE LOOSE TALLUS"; lengthofdownstreamradTextBox13.Text = "YOU DO NOT ALLOW TO USE LOOSE TALLUS"; } else { lengthofupstreamradTextBox12.Text = L3.ToString(); lengthofdownstreamradTextBox13.Text = L4.ToString(); } //END COD FOR lENGTH OF UPSTREAM AND DOWN STREAM LOSSE TALLUS (L3 AND L4)........................................ }//END FOR RAND BUTTON METHOD