Esempio n. 1
0
 private void FileBrowseButton_Click(object sender, EventArgs e)
 {
     if (MyOpenFileDialog.ShowDialog() == DialogResult.OK)
     {
         FileTextBox.Text = MyOpenFileDialog.FileName;
     }
 }
Esempio n. 2
0
        private void ChooseFile_Click(object sender, EventArgs e)
        {
            MyOpenFileDialog.ShowDialog();
            string fileName = MyOpenFileDialog.FileName;

            ParamsText.Text = fileName;
        }
Esempio n. 3
0
        /// <summary>
        /// 打开并读取数据文件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OpenDataFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            MyOpenFileDialog.InitialDirectory = Application.StartupPath;
            MyOpenFileDialog.Filter           = "txt file(*.txt)|*.txt"; // 文件类型过滤器设置为txt文件
            bool estiThroErrData = false;

            if (MyOpenFileDialog.ShowDialog() == DialogResult.OK)
            {
                string[] allText = File.ReadAllLines(MyOpenFileDialog.FileName, Encoding.UTF8); // 读取txt文件中全部的数据
                for (int i = 0; i < allText.Length - 1; i++)
                {
                    string[] rowText = allText[i].Replace(" ", "").Replace(",,", ",").Split(',');   // 每一行的数据
                    if (rowText[0] == "")
                    {
                        estiThroErrData = true;
                        i       = i + 1;
                        rowText = allText[i].Replace(" ", "").Replace(",,", ",").Split(',');        // 每一行的数据
                        ml      = Convert.ToDouble(rowText[0]);
                        mb      = AngleTransUtil.DegreeToRand(Convert.ToDouble(rowText[1]) / 3600); //将mb转成弧度
                        //ma = DegreeToRand(DMSToDegree(Convert.ToDouble(rowText[2])));
                        continue;
                    }
                    if (estiThroErrData)
                    {   // 贯通数据
                        bool          isDirEdge  = Convert.ToInt16(rowText[3]) == 1;
                        int           surveyNum  = Convert.ToInt16(rowText[4]);
                        TraversePoint startPoint = new TraversePoint(rowText);
                        startPoint.Pointindex = PointNum;
                        rowText = allText[i + 1].Replace(" ", "").Replace(",,", ",").Split(',');   // 每一行的数据
                        TraversePoint endPoint = new TraversePoint(rowText);
                        endPoint.Pointindex = PointNum + 1;
                        TraverseEdge traverEdge = new TraverseEdge(startPoint, endPoint, isDirEdge, surveyNum);
                        traverseEdge.Add(traverEdge);
                        PointNum++;
                    }
                    else
                    {
                        // 陀螺经纬仪观测数据
                        ObserveData obData = new ObserveData(rowText); // 观测数据
                        if (rowText[0] == "DM")
                        {                                              //地面
                            groundData.Add(obData);
                        }
                        if (rowText[0] == "JX")
                        {
                            //井下
                            downholeData.Add(obData);
                        }
                    }
                }
            }
            isReadData = true;
            InitState();
            // 更新表格数据
            InsertObDataIntoTable();
        }
Esempio n. 4
0
        private string ChooseFolder()
        {
            IMyOpenFileDialog myOpenFileDialog = new MyOpenFileDialog();
            var another = myOpenFileDialog.Show("*.*", FILTERS, "");

            if (string.IsNullOrEmpty(another))
            {
                return(null);
            }
            return(Path.GetDirectoryName(another));
        }
        private void CheckFromFileMenuItem_Click(object sender, System.EventArgs e)
        {
            FileServer fs;
            string     filename;

            string[] loadedItems;
            bool     isUnknownItem;

            try
            {
                //Get file name.
                MyOpenFileDialog.ShowDialog();
                filename = MyOpenFileDialog.FileName;
                if (filename == "")
                {
                    return;
                }

                base.FindForm().Cursor = Cursors.WaitCursor;
                //Load file.
                fs          = new FileServer();
                loadedItems = fs.ReadSingleColumn(filename);
                if (loadedItems.GetLength(0) < 1)
                {
                    base.FindForm().Cursor = Cursors.Default;
                    return;
                }

                //See if there are loaded items which are not
                //in the checked list box.
                for (int i = 0; i < loadedItems.GetLength(0); i++)
                {
                    isUnknownItem = true;
                    for (int j = 0; j < MyCheckedListBox.Items.Count; j++)
                    {
                        if (MyCheckedListBox.Items[j].ToString().ToUpper() == loadedItems[i].ToUpper())
                        {
                            isUnknownItem = false;
                            break; //Exit for.
                        }
                    }
                    if (isUnknownItem)
                    {
                        base.FindForm().Cursor = Cursors.Default;
                        MessageManager.ShowWarning("The item " + loadedItems[i] +
                                                   " in the file is not present in the list.", base.FindForm());
                        return;
                    }
                }

                //Check the loaded items.
                for (int i = 0; i < loadedItems.GetLength(0); i++)
                {
                    for (int j = 0; j < MyCheckedListBox.Items.Count; j++)
                    {
                        if (MyCheckedListBox.Items[j].ToString().ToUpper() == loadedItems[i].ToUpper())
                        {
                            MyCheckedListBox.SetItemChecked(j, true);
                            break; //Exit for.
                        }
                    }
                }
                base.FindForm().Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                MessageManager.ShowError(ex, "Unable to check items from file.", base.FindForm());
            }
        }
        private void SelectFromFileMenuItem_Click(object sender, System.EventArgs e)
        {
            FileServer fs;
            string     filename;

            string[] loadedItems;
            bool     isUnknownItem;

            try
            {
                //Get file name.
                MyOpenFileDialog.ShowDialog();
                filename = MyOpenFileDialog.FileName;
                if (filename == "")
                {
                    return;
                }

                if (MyParentForm != null)
                {
                    MyParentForm.Cursor = Cursors.WaitCursor;
                }
                //Load file.
                fs          = new FileServer();
                loadedItems = fs.ReadSingleColumn(filename);
                if (loadedItems.GetLength(0) < 1)
                {
                    if (MyParentForm != null)
                    {
                        MyParentForm.Cursor = Cursors.Default;
                    }
                    return;
                }

                //See if there are loaded items which are not
                //in the list view.
                for (int i = 0; i < loadedItems.GetLength(0); i++)
                {
                    isUnknownItem = true;
                    for (int j = 0; j < MyExtListView.Items.Count; j++)
                    {
                        if (MyExtListView.Items[j].Text.ToUpper() == loadedItems[i].ToUpper())
                        {
                            isUnknownItem = false;
                            break; //Exit for.
                        }
                    }
                    if (isUnknownItem)
                    {
                        if (MyParentForm != null)
                        {
                            MyParentForm.Cursor = Cursors.Default;
                        }
                        MessageManager.ShowWarning("The item " + loadedItems[i] +
                                                   " in the file is not present in the list.", MyParentForm);
                        return;
                    }
                }

                //Clear selection.
                for (int j = 0; j < MyExtListView.Items.Count; j++)
                {
                    ((ListViewItem)MyExtListView.Items[j]).Selected = false;
                }

                //Select the loaded items.
                for (int i = 0; i < loadedItems.GetLength(0); i++)
                {
                    for (int j = 0; j < MyExtListView.Items.Count; j++)
                    {
                        if (MyExtListView.Items[j].Text.ToUpper() == loadedItems[i].ToUpper())
                        {
                            ((ListViewItem)MyExtListView.Items[j]).Selected = true;
                            break; //Exit for.
                        }
                    }
                }
                if (MyParentForm != null)
                {
                    MyParentForm.Cursor = Cursors.Default;
                }
            }
            catch (Exception ex)
            {
                MessageManager.ShowError(ex, "Unable to select items from file.", MyParentForm);
            }
        }