Пример #1
0
        public static bool SaveFileDialog(List <IRecorderItem> items)
        {
            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.Filter           = "ESR files (*.ESR)|*.ESR|All files (*.*)|*.*";
            saveFileDialog.FilterIndex      = 0;
            saveFileDialog.RestoreDirectory = true;

            if (saveFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return(false);
            }

            //Get the path of specified file
            string filePath = saveFileDialog.FileName;

            ESRFile file = new ESRFile();

            file.FileName       = filePath;
            file.FileBody.Items = items.Copy <List <IRecorderItem> >();

            using (new WaitCursor())
            {
                if (!file.SaveFile())
                {
                    System.Windows.MessageBox.Show("File Save Error!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
            }
            return(true);
        }
Пример #2
0
        public static ESRFile LoadFileDialog()
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter           = "ESR files (*.ESR)|*.ESR|All files (*.*)|*.*";
            openFileDialog.FilterIndex      = 0;
            openFileDialog.RestoreDirectory = true;

            if (openFileDialog.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return(null);
            }

            //Get the path of specified file
            string  filePath = openFileDialog.FileName;
            ESRFile file     = new ESRFile();

            file.FileName = filePath;

            using (new WaitCursor())
            {
                if (!file.LoadFile())
                {
                    System.Windows.MessageBox.Show("File Load Error!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(null);
                }
            }
            return(file);
        }