Ejemplo n.º 1
0
        private void Button_ReadSettingFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName        = "default.rsf";                    // Default file name
                dlg.DefaultExt      = ".rsf";                           // Default file extension
                dlg.Filter          = "ReaderSettingFile (.rsf)|*.rsf"; // Filter files by extension
                dlg.CheckFileExists = false;
                dlg.CheckPathExists = false;

                // Show open file dialog box
                Nullable <bool> result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    this.TextBlock_SettingFileName.Text = dlg.FileName;
                }
                else
                {
                    throw new Exception("保存を中止しました.");
                }

                FileStream   fs;
                StreamWriter sw;
                try
                {
                    fs = new FileStream(this.TextBlock_SettingFileName.Text, FileMode.CreateNew);
                    sw = new StreamWriter(fs);
                }
                catch (System.IO.IOException ioex)
                {
                    myDialog mydialog = new myDialog("そのファイルはすでに存在します。上書きしますか?");
                    if (mydialog.ShowDialog() == true)
                    {
                        fs = new FileStream(this.TextBlock_SettingFileName.Text, FileMode.Create);
                        sw = new StreamWriter(fs);
                    }
                    else
                    {
                        throw new Exception("ファイル出力を中止します。");
                    }
                }

                sw.WriteLine(this.DataVector.Count);
                foreach (var item in this.DataVector)
                {
                    sw.WriteLine(item);
                }
                sw.Close();
                fs.Close();
                throw new Exception("設定を保存しました.");
            }
            catch (Exception ex)
            {
                myDialog mydialog = new myDialog(ex.Message);
                mydialog.ShowDialog();
            }
        }
Ejemplo n.º 2
0
        private void Button_SaveSettingFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName        = "default.rsf";                    // Default file name
                dlg.DefaultExt      = ".rsf";                           // Default file extension
                dlg.Filter          = "ReaderSettingFile (.rsf)|*.rsf"; // Filter files by extension
                dlg.CheckFileExists = false;
                dlg.CheckPathExists = false;

                // Show open file dialog box
                Nullable <bool> result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    this.TextBlock_SettingFileName.Text = dlg.FileName;
                }
                else
                {
                    throw new Exception("読込を中止しました.");
                }

                FileStream   fs;
                StreamReader sr;
                try
                {
                    fs = new FileStream(this.TextBlock_SettingFileName.Text, FileMode.Open);
                    sr = new StreamReader(fs);
                }
                catch (System.IO.IOException ioex)
                {
                    myDialog mydialog = new myDialog("そのファイルはすでに存在します。上書きしますか?");
                    if (mydialog.ShowDialog() == true)
                    {
                        fs = new FileStream(this.TextBlock_SettingFileName.Text, FileMode.Create);
                        sr = new StreamReader(fs);
                    }
                    else
                    {
                        throw new Exception("ファイル出力を中止します。");
                    }
                }

                this.DeleteAll();

                string str          = sr.ReadLine();
                int    vectorlength = int.Parse(str);
                for (int i = 0; i < vectorlength; i++)
                {
                    str = sr.ReadLine();
                    switch (str)
                    {
                    case "int":
                        this.AddInt();
                        break;

                    case "short":
                        this.AddShort();
                        break;

                    case "long":
                        this.AddLong();
                        break;

                    case "float":
                        this.AddFloat();
                        break;

                    case "double":
                        this.AddDouble();
                        break;

                    case "byte":
                        this.AddByte();
                        break;

                    default:
                        break;
                    }
                }
                sr.Close();
                fs.Close();
            }
            catch (Exception ex)
            {
                myDialog mydialog = new myDialog(ex.Message);
                mydialog.ShowDialog();
            }
        }
Ejemplo n.º 3
0
        private void Button_OutputExcelFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.CurrentDataVector_num != this.myfile.BPF)
                {
                    throw new Exception("データ配列の設定が完了していません.BPFが合うように設定してください.");
                }
                FileStream   fs;
                StreamWriter sw;
                try
                {
                    fs = new FileStream(this.TextBox_ExcelFileName.Text, FileMode.CreateNew);
                    sw = new StreamWriter(fs);
                }
                catch (System.IO.IOException ioex)
                {
                    myDialog mydialog = new myDialog("そのファイルはすでに存在します。上書きしますか?");
                    if (mydialog.ShowDialog() == true)
                    {
                        fs = new FileStream(this.TextBox_ExcelFileName.Text, FileMode.Create);
                        sw = new StreamWriter(fs);
                    }
                    else
                    {
                        throw new Exception("ファイル出力を中止します。");
                    }
                }
                this.reader = new BinaryReader(File.OpenRead(this.myfile.name));
                try
                {
                    while (true)
                    {
                        int    frame      = this.reader.ReadInt32();
                        long   time       = this.reader.ReadInt64();
                        int    datalength = this.reader.ReadInt32();
                        string str        = "";
                        str += frame.ToString() + ",";
                        str += time.ToString() + ",";
                        foreach (var data in this.DataVector)
                        {
                            switch (data)
                            {
                            case "int":
                            {
                                int i = this.reader.ReadInt32();
                                str += i.ToString() + ",";
                            }
                            break;

                            case "short":
                            {
                                short i = this.reader.ReadInt16();
                                str += i.ToString() + ",";
                            }
                            break;

                            case "long":
                            {
                                long i = this.reader.ReadInt64();
                                str += i.ToString() + ",";
                            }
                            break;

                            case "float":
                            {
                                float i = this.reader.ReadSingle();
                                str += i.ToString() + ",";
                            }
                            break;

                            case "double":
                            {
                                double i = this.reader.ReadDouble();
                                str += i.ToString() + ",";
                            }
                            break;

                            case "byte":
                            {
                                byte i = this.reader.ReadByte();
                                str += i.ToString() + ",";
                            }
                            break;

                            default:
                                break;
                            }
                        }

                        str = str.TrimEnd(',');
                        sw.WriteLine(str);
                    }
                }
                catch (Exception ex)
                {
                    sw.Close();
                    fs.Close();
                    this.reader.Close();
                    throw new Exception("出力が完了しました。");
                }
            }
            catch (Exception ex)
            {
                myDialog mydialog = new myDialog(ex.Message);
                mydialog.ShowDialog();
            }
        }
Ejemplo n.º 4
0
        private void Button_SaveSettingFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.FileName = "default.rsf"; // Default file name
                dlg.DefaultExt = ".rsf"; // Default file extension
                dlg.Filter = "ReaderSettingFile (.rsf)|*.rsf"; // Filter files by extension
                dlg.CheckFileExists = false;
                dlg.CheckPathExists = false;

                // Show open file dialog box
                Nullable<bool> result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    this.TextBlock_SettingFileName.Text = dlg.FileName;
                }
                else
                {
                    throw new Exception("読込を中止しました.");
                }

                FileStream fs;
                StreamReader sr;
                try
                {
                    fs = new FileStream(this.TextBlock_SettingFileName.Text, FileMode.Open);
                    sr = new StreamReader(fs);
                }
                catch (System.IO.IOException ioex)
                {
                    myDialog mydialog = new myDialog("そのファイルはすでに存在します。上書きしますか?");
                    if (mydialog.ShowDialog() == true)
                    {
                        fs = new FileStream(this.TextBlock_SettingFileName.Text, FileMode.Create);
                        sr = new StreamReader(fs);
                    }
                    else
                    {
                        throw new Exception("ファイル出力を中止します。");
                    }
                }

                this.DeleteAll();

                string str = sr.ReadLine();
                int vectorlength = int.Parse(str);
                for (int i = 0; i < vectorlength; i++ )
                {
                    str = sr.ReadLine();
                    switch (str)
                    {
                        case "int":
                            this.AddInt();
                            break;
                        case "short":
                            this.AddShort();
                            break;
                        case "long":
                            this.AddLong();
                            break;
                        case "float":
                            this.AddFloat();
                            break;
                        case "double":
                            this.AddDouble();
                            break;
                        case "byte":
                            this.AddByte();
                            break;
                        default:
                            break;
                    }
                }
                sr.Close();
                fs.Close();
            }
            catch (Exception ex)
            {
                myDialog mydialog = new myDialog(ex.Message);
                mydialog.ShowDialog();
            }
        }
Ejemplo n.º 5
0
        private void Button_ReadSettingFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
                dlg.FileName = "default.rsf"; // Default file name
                dlg.DefaultExt = ".rsf"; // Default file extension
                dlg.Filter = "ReaderSettingFile (.rsf)|*.rsf"; // Filter files by extension
                dlg.CheckFileExists = false;
                dlg.CheckPathExists = false;

                // Show open file dialog box
                Nullable<bool> result = dlg.ShowDialog();

                // Process open file dialog box results
                if (result == true)
                {
                    // Open document
                    this.TextBlock_SettingFileName.Text = dlg.FileName;
                }
                else
                {
                    throw new Exception("保存を中止しました.");
                }

                FileStream fs;
                StreamWriter sw;
                try
                {
                    fs = new FileStream(this.TextBlock_SettingFileName.Text, FileMode.CreateNew);
                    sw = new StreamWriter(fs);
                }
                catch (System.IO.IOException ioex)
                {
                    myDialog mydialog = new myDialog("そのファイルはすでに存在します。上書きしますか?");
                    if (mydialog.ShowDialog() == true)
                    {
                        fs = new FileStream(this.TextBlock_SettingFileName.Text, FileMode.Create);
                        sw = new StreamWriter(fs);
                    }
                    else
                    {
                        throw new Exception("ファイル出力を中止します。");
                    }
                }

                sw.WriteLine(this.DataVector.Count);
                foreach (var item in this.DataVector)
                {
                    sw.WriteLine(item);
                }
                sw.Close();
                fs.Close();
                throw new Exception("設定を保存しました.");
            }
            catch (Exception ex)
            {
                myDialog mydialog = new myDialog(ex.Message);
                mydialog.ShowDialog();
            }
        }
Ejemplo n.º 6
0
        private void Button_OutputExcelFile_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (this.CurrentDataVector_num != this.myfile.BPF)
                {
                    throw new Exception("データ配列の設定が完了していません.BPFが合うように設定してください.");
                }
                FileStream fs;
                StreamWriter sw;
                try
                {
                    fs = new FileStream(this.TextBox_ExcelFileName.Text, FileMode.CreateNew);
                    sw = new StreamWriter(fs);
                }
                catch (System.IO.IOException ioex)
                {
                    myDialog mydialog = new myDialog("そのファイルはすでに存在します。上書きしますか?");
                    if (mydialog.ShowDialog() == true)
                    {
                        fs = new FileStream(this.TextBox_ExcelFileName.Text, FileMode.Create);
                        sw = new StreamWriter(fs);
                    }
                    else
                    {
                        throw new Exception("ファイル出力を中止します。");
                    }
                }
                this.reader = new BinaryReader(File.OpenRead(this.myfile.name));
                try
                    {
                    while(true){

                        int frame = this.reader.ReadInt32();
                        long time = this.reader.ReadInt64();
                        int datalength = this.reader.ReadInt32();
                        string str = "";
                        str += frame.ToString() + ",";
                        str += time.ToString() + ",";
                        foreach (var data in this.DataVector)
                        {
                            switch (data)
                            {
                                case "int":
                                    {
                                        int i = this.reader.ReadInt32();
                                        str += i.ToString() + ",";
                                    }
                                    break;
                                case "short":
                                    {
                                        short i = this.reader.ReadInt16();
                                        str += i.ToString() + ",";
                                    }
                                    break;
                                case "long":
                                    {
                                        long i = this.reader.ReadInt64();
                                        str += i.ToString() + ",";
                                    }
                                    break;
                                case "float":
                                    {
                                        float i = this.reader.ReadSingle();
                                        str += i.ToString() + ",";
                                    }
                                    break;
                                case "double":
                                    {
                                        double i = this.reader.ReadDouble();
                                        str += i.ToString() + ",";
                                    }
                                    break;
                                case "byte":
                                    {
                                        byte i = this.reader.ReadByte();
                                        str += i.ToString() + ",";
                                    }
                                    break;
                                default:
                                    break;
                            }
                        }

                        str = str.TrimEnd(',');
                        sw.WriteLine(str);

                    }
                }
                catch (Exception ex)
                {
                    sw.Close();
                    fs.Close();
                    this.reader.Close();
                    throw new Exception("出力が完了しました。");
                }
            }
            catch(Exception ex)
            {
                myDialog mydialog = new myDialog(ex.Message);
                mydialog.ShowDialog();
            }
        }