Beispiel #1
0
        void standardFileLoad(Node n)
        {
            try
            {
                list.Clear();


                StreamReader sr = new StreamReader(n.fpath.FullName + "//" + n.Name);
                sr.ReadLine();
                string   line = sr.ReadLine();
                string[] data = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                Energy.Clear();
                for (int i = 4; i < data.Length; i++)
                {
                    double tmp;
                    double.TryParse(data[i].Substring(1, data[i].Length - 2), out tmp);
                    Energy.Add(tmp);

                    //System.Windows.MessageBox.Show(tmp.ToString(),"ExpenseIt Standalone",MessageBoxButton.OK,MessageBoxImage.Information);
                }

                sr.ReadLine();

                line = sr.ReadLine();
                while (line[0] != 'E')
                {
                    data = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    ECPara ecp = new ECPara();
                    double tmp;
                    double.TryParse(data[0], out tmp);
                    ecp.Density = tmp;
                    double.TryParse(data[1], out tmp);
                    ecp.dY = tmp;
                    double.TryParse(data[2], out tmp);;
                    ecp.Height = tmp;
                    for (int i = 3; i < data.Length; i++)
                    {
                        double.TryParse(data[i], out tmp);
                        if (Math.Abs(tmp) < 1E-31)
                        {
                            continue;                       //skip 0 figure
                        }
                        evsr er = new evsr(Energy[i - 3], tmp);

                        ecp.list.Add(er);

                        //System.Windows.MessageBox.Show(tmp.ToString(),"ExpenseIt Standalone",MessageBoxButton.OK,MessageBoxImage.Information);
                    }
                    list.Add(ecp);

                    line = sr.ReadLine();
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("文件打开失败 " + ex.Message, "ExpenseIt Standalone", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
Beispiel #2
0
        private void ButtonOpen_Click(object sender, RoutedEventArgs e)
        {
            var n = treeview.SelectedItem as Node;

            if (n.Kind != "folder")
            {
                StreamReader sr = new StreamReader(n.fpath);
                sr.ReadLine();
                string   line = sr.ReadLine();
                string[] data = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                for (int i = 4; i < data.Length; i++)
                {
                    double tmp;
                    double.TryParse(data[i].Substring(1, data[i].Length - 2), out tmp);
                    Energy.Add(tmp);

                    //System.Windows.MessageBox.Show(tmp.ToString(),"ExpenseIt Standalone",MessageBoxButton.OK,MessageBoxImage.Information);
                }

                sr.ReadLine();

                line = sr.ReadLine();
                while (line[0] != 'E')
                {
                    data = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    ECPara ecp = new ECPara();

                    double.TryParse(data[0], out ecp.Density);
                    double.TryParse(data[1], out ecp.dY);
                    double.TryParse(data[2], out ecp.Height);
                    for (int i = 3; i < data.Length; i++)
                    {
                        double tmp;
                        double.TryParse(data[i], out tmp);
                        evsr er = new evsr(Energy[i - 3], tmp);

                        ecp.list.Add(er);

                        //System.Windows.MessageBox.Show(tmp.ToString(),"ExpenseIt Standalone",MessageBoxButton.OK,MessageBoxImage.Information);
                    }
                    list.Add(ecp);

                    line = sr.ReadLine();
                }
            }
        }
Beispiel #3
0
        void standardFileAdd(string path)
        {
            try
            {
                StreamReader sr = new StreamReader(path);
                sr.ReadLine();
                string   line = sr.ReadLine();
                string[] data = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                List <double> Energy = new List <double>();
                for (int i = 4; i < data.Length; i++)
                {
                    double tmp;
                    double.TryParse(data[i].Substring(1, data[i].Length - 2), out tmp);
                    Energy.Add(tmp);

                    //System.Windows.MessageBox.Show(tmp.ToString(),"ExpenseIt Standalone",MessageBoxButton.OK,MessageBoxImage.Information);
                }

                sr.ReadLine();

                line = sr.ReadLine();
                while (line[0] != 'E')
                {
                    data = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    ECPara ecp = new ECPara();
                    double tmp;
                    double.TryParse(data[0], out tmp);
                    ecp.Density = tmp;
                    double.TryParse(data[1], out tmp);
                    ecp.dY = tmp;
                    double.TryParse(data[2], out tmp);;
                    ecp.Height = tmp;

                    bool isFound = false;
                    foreach (ECPara e in list)
                    {
                        if (Math.Abs(e.Density - ecp.Density) < Settings.DIFF &&
                            Math.Abs(e.dY - ecp.dY) < Settings.DIFF &&
                            Math.Abs(e.Height - ecp.Height) < Settings.DIFF)
                        {
                            for (int i = 3; i < data.Length; i++)
                            {
                                double.TryParse(data[i], out tmp);
                                evsr er = new evsr(Energy[i - 3], tmp);

                                e.list.Add(er);

                                //System.Windows.MessageBox.Show(tmp.ToString(),"ExpenseIt Standalone",MessageBoxButton.OK,MessageBoxImage.Information);
                            }
                            isFound = true;
                            break;
                        }
                    }

                    if (!isFound)
                    {
                        for (int i = 3; i < data.Length; i++)
                        {
                            double.TryParse(data[i], out tmp);
                            evsr er = new evsr(Energy[i - 3], tmp);

                            ecp.list.Add(er);

                            //System.Windows.MessageBox.Show(tmp.ToString(),"ExpenseIt Standalone",MessageBoxButton.OK,MessageBoxImage.Information);
                        }
                        list.Add(ecp);
                    }



                    line = sr.ReadLine();
                }
            }
            catch (Exception ex)
            {
                System.Windows.MessageBox.Show("文件打开失败 " + ex.Message, "ExpenseIt Standalone", MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }