Esempio n. 1
0
        private void defaultpath_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog folderbrowse = new FolderBrowserDialog();

            if (folderbrowse.ShowDialog() != DialogResult.OK)
            {
                MessageBox.Show(Messages.SELECT_FOLDER_WARN
                                , "Warning", MessageBoxButtons.OK
                                , MessageBoxIcon.Warning);
                return;
            }
            else
            {
                Curr_dir = folderbrowse.SelectedPath;
                if (!hasWriteAccessToFolder(Curr_dir))
                {
                    MessageBox.Show(Messages.FILE_WRITE_ACCESS_ERR + Curr_dir
                                    , "Error", MessageBoxButtons.OK
                                    , MessageBoxIcon.Error);
                    return;
                }
            }
            AppDefaultSetting.setDefaultPath(Curr_dir);
            MessageBox.Show(Messages.DEF_SELECTED_MESSAGE + Curr_dir);
            setdefpath_txt.Text = Curr_dir;
        }
Esempio n. 2
0
        public mainform()
        {
            Curr_dir = AppDefaultSetting.getDefaultPath();
            InitializeComponent();
            ////testing
            //cui_data_inject x = new cui_data_inject();
            //  x.Show();

            this.Icon = new Icon(Directory.GetCurrentDirectory() + @"\Resources\bhge_icon.ico");
            this.pictureBox1.Image = Image.FromFile(Directory.GetCurrentDirectory() + @"\Resources\bhge.png");
            this.defaultpath.Image = Image.FromFile(Directory.GetCurrentDirectory() + @"\Resources\path_select.jpg");
            AppDefaultSetting.setDefaultPath("");
            Configure.Visible      = false;
            DAQ.Visible            = false;
            Home_page.Visible      = true;
            graphTrendData.Visible = false;
            txtBoxtxt = new TextBox();
            vnaconf   = new VNAConfiguration();
            //  dateTimePicker1 = new DateTimePicker();
            //  graphTrendData.Controls.Add(dateTimePicker1);
            picture = new PictureBox
            {
                Name = "pictureBox",
                Size = new Size(1177, 692),
                //Location = new Point(14, 17),
                // Image = Image.FromFile(@"C:\Users\212612447\Documents\CUI\CUI_Display_updated1\CUI_Display_updated\CUI_Display\ge_cover_img4.jpg"),
                Image    = Image.FromFile(Directory.GetCurrentDirectory() + @"\Resources\ge_cover_img4.jpg"),
                SizeMode = PictureBoxSizeMode.CenterImage
            };
            tableLayoutPanel1.Controls.Add(picture);
            picture.SizeMode = PictureBoxSizeMode.StretchImage;
            panel3.Visible   = false;
            picture.Visible  = true;
        }
Esempio n. 3
0
        /****************************************************************/
        public void save_config_data(string Curr_dir_path)
        {
            //first check if default path set or not...if not ask user to set defualt path....
            /*************************************************************************************************************/
            if (Curr_dir_path == String.Empty)
            {
                MessageBox.Show(Messages.DEFAULT_PATH_MISSING_ERR);
                FolderBrowserDialog update_default_path = new FolderBrowserDialog();
                if (update_default_path.ShowDialog() != DialogResult.OK)
                {
                    MessageBox.Show(Messages.SELECT_FOLDER_WARN
                                    , "Warnining", MessageBoxButtons.OK
                                    , MessageBoxIcon.Warning);
                    return;
                }
                else
                {
                    Curr_dir      = update_default_path.SelectedPath;
                    Curr_dir_path = Curr_dir;
                    if (!hasWriteAccessToFolder(Curr_dir))
                    {
                        MessageBox.Show(Messages.FILE_WRITE_ACCESS_ERR + Curr_dir
                                        , "Error", MessageBoxButtons.OK
                                        , MessageBoxIcon.Error
                                        );
                        Curr_dir = "";
                        return;
                    }
                    AppDefaultSetting.setDefaultPath(Curr_dir);
                }
                MessageBox.Show(Messages.DEF_SELECTED_MESSAGE + Curr_dir);
                //AppDefaultSetting.setDefaultPath();
            }
            /*************************************************************************************************************/
            string tagpath = Curr_dir_path + @"\Data\" + vnaconf.tagname + @"\";

            //populate buffer to data files and store at curr_dir(default path)
            try{
                if (!Directory.Exists(tagpath))
                {
                    Directory.CreateDirectory(Curr_dir_path + @"\Data\" + vnaconf.tagname + @"\");
                }
                /*************************************************************************************************************/

                /* //this is old logic
                 * using (var streamWriter = new StreamWriter(tagpath + vnaconf.tagname + "_" + vnaconf.timestamp + ".csv"))
                 * {
                 *
                 * for (int i = 0; i < 5; i++)
                 * {
                 *
                 *   var data1 = record_buff[i, 0];
                 *  var data2 = record_buff[i, 1];
                 *  var line = string.Format("{0},{1}", data1, data2);
                 *  streamWriter.WriteLine(line);
                 *
                 * }
                 *
                 * }
                 * }*/
                /*************************************************************************************************************/

                //new changes reflected
                /*************************************************************************************************************/
                using (var streamWriter = new StreamWriter(tagpath + vnaconf.tagname + "_" + vnaconf.timestamp + ".csv"))
                    using (var streamReader = new StreamReader(Directory.GetCurrentDirectory() + "\\Resources\\temp.csv")) {
                        string   line;
                        string[] row;
                        while ((line = streamReader.ReadLine()) != null)
                        {
                            row = line.Split(',');
                            var data1    = row[0];
                            var data2    = row[1];
                            var dataline = string.Format("{0},{1}", data1, data2);
                            streamWriter.WriteLine(dataline);
                        }
                    }
            }
            /*************************************************************************************************************/
            catch (Exception ex) {
                MessageBox.Show(Messages.FILE_READ_ERR + ex.Message,
                                "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }

            //code to write configuration parameter in file....like tagname ,,window n all
            /*************************************************************************************************************/
            try
            {
                using (var streamWriter = new StreamWriter(tagpath + vnaconf.tagname + "_" + vnaconf.timestamp + ".cfg"))
                {
                    var tagname = string.Format("{0},{1} \n", "tagname", vnaconf.tagname);
                    streamWriter.WriteLine(tagname);

                    var readytime = string.Format("{0},{1} \n", "Ready time", vnaconf.readytime);
                    streamWriter.WriteLine(readytime);

                    var deltat = string.Format("{0},{1} \n", "delta T", vnaconf.deltat);
                    streamWriter.WriteLine(deltat);

                    var wavevel = string.Format("{0},{1} \n", "Wave velocity", vnaconf.wavevelocity);
                    streamWriter.WriteLine(wavevel);

                    var win = string.Format("{0},{1} \n", "Window", vnaconf.window);
                    streamWriter.WriteLine(win);

                    var def_path = string.Format("{0},{1} \n", "Default Path", vnaconf.default_path);
                    streamWriter.WriteLine(def_path);
                }
                MessageBox.Show(Messages.FILE_SAVED_SUCC + tagpath, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
                savedata.Enabled = false;
                button5.Enabled  = true;
            }
            catch (Exception ex) {
                MessageBox.Show(Messages.FILE_READ_ERR + ex.Message,
                                "Error", MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            /*************************************************************************************************************/
        }