Trimble Data Conversion programming related supplements

Trimble Data Conversion programming related supplements

This paper is a supplement to the data conversion applet of Tianbao digital level.

Interface design

Main functions of this program:

  1. Open;
  2. Generate observation manual;
  3. Output adjustment format;

According to the three main functions of the program, the following controls are roughly required:

  1. File opening: OpenFileDialog;
  2. File saving: SaveFileDialog;
  3. Menu bar: MenuStrip;
    The menu bar can perform the functions of generating and outputting adjustment format of observation manual. Users can choose level-1 menu, level-2 menu, level-3 menu, etc. according to their own needs.

Users can also add or modify corresponding controls according to their preferences. Controls can be found in the toolbox.

After finding the required control, place it in the appropriate position of the form and rename it.

Code writing

  1. Define the array;
string[,] ShuJu = new string[1000, 15];

First define an array in which the elements in the original data are stored.
2. Open the file;
First, filter the read format. Because the original data is dat format, you can limit the input format and ignore other formatted text.

OpenFileDialog dlg = new OpenFileDialog();
dlg.Filter = "(Data format of Tianbao electronic level)*.dat|*.dat|(text file)*.txt|*.txt";
if (dlg.ShowDialog() == DialogResult.OK)
   StreamReader srd;
   srd = File.OpenText(dlg.FileName); 
  1. Front and back ruler interpretation;
    According to different levels, the reading method of ruler is also different, which needs to be distinguished in the conversion process.
 if (flag % 4 == 1 || flag % 4 == 2)
    switch (line.Substring(49, 2))
        case "Rb":
            ShuJu[cz, 0] = (line.Substring(20, 9)).TrimStart();
            ShuJu[cz, 2] = (line.Substring(59, 7)).TrimStart();
            ShuJu[cz, 3] = (line.Substring(82, 7)).TrimStart();
        case "Rf":
            ShuJu[cz, 1] = (line.Substring(20, 9)).TrimStart();
            ShuJu[cz, 4] = (line.Substring(59, 7)).TrimStart();
            ShuJu[cz, 5] = (line.Substring(82, 7)).TrimStart();
  1. Output table
    The observation manual is displayed in the form of exclude form. To output the form, the following code must be added in the front row of the program:
    using ExcelApplication = Microsoft.Office.Interop.Excel.ApplicationClass;
    Enter relevant statements to fill in the contents of the table.
xlapp.get_Range("A1", "A1").ColumnWidth = 7; //Column width setting
xlapp.get_Range(xlapp.Cells[1, 1], xlapp.Cells[3 * cz + 7, 10]).HorizontalAlignment = XlHAlign.xlHAlignCenter;//format cell
xlapp.get_Range("C4", "D4").Merge(Missing.Value);//merge cell
xlapp.get_Range("A1", "J1").Merge(Missing.Value);//Header setting
xlapp.Cells[1, 1] = "Electronic leveling record book";
xlapp.get_Range("A1", "J1").Font.Bold = true;
xlapp.get_Range("A1", "J1").Font.Size = 16;
xlapp.get_Range("A1", "J1").Font.Name = "Blackbody";
xlapp.get_Range("A1", "J1").HorizontalAlignment = XlHAlign.xlHAlignCenter;
xlapp.Cells[3 * i + 8, 3] = ShuJu[i, 3];//Rear view distance 1
  1. File export;
StreamWriter myStream;
saveFileDialog1.Filter = "text file txt |*.txt";
saveFileDialog1.FilterIndex = 2;
saveFileDialog1.RestoreDirectory = true;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
   myStream = new StreamWriter(saveFileDialog1.FileName);
   myStream.Write(m_show);//write in
   myStream.Close();//Close flow
  1. Measurement correlation.
    In the process of programming, we should combine relevant level knowledge. Height difference Δ H is the difference between the two ruler readings; End elevation H2=H1+ ΣΔ H et al.

After the above process, the applet has taken shape, and it can be optimized and upgraded in the later stage to make it more competitive.

Tags: C# Windows OOP Data Analysis

Posted by stevepatd on Tue, 24 May 2022 17:37:38 +0300