Example #1
0
        public static void SaveFile <T>(this SaveFileDialog dialog, Environment.SpecialFolder folder, string fileName, T data)
        {
            dialog.InitialDirectory = Environment.GetFolderPath(folder);
            dialog.Filter           = "XML file (*.xml)|*.xml";
            dialog.Title            = $"Save {fileName}";
            dialog.FileName         = $"{fileName}_{DateTime.Now.ToString("MM-dd-yyyy-HHmmss", CultureInfo.InvariantCulture)}";

            if (dialog.ShowDialog() == true)
            {
                var xmlText = CloneSerializer.XMLSerialize(data);
                File.WriteAllText(dialog.FileName, xmlText);
            }
        }
        private void SaveRuleButton_Click(object sender, RoutedEventArgs e)
        {
            var rules = this.getScrubRules();

            if (rules == null || rules.Count == 0)
            {
                MessageBox.Show("No Rules found. Please add/load anonymization rules before Save", "No rules Found", MessageBoxButton.OK, MessageBoxImage.Warning);
                return;
            }

            SaveFileDialog saveFileDialog = new SaveFileDialog();

            saveFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            saveFileDialog.Filter           = "XML file (*.xml)|*.xml";
            saveFileDialog.Title            = "CosmicClone save AnonymizationRules";
            saveFileDialog.FileName         = "AnonymizationRules_" + DateTime.Now.ToString("MM-dd-yyyy-HHmmss", CultureInfo.InvariantCulture);

            if (saveFileDialog.ShowDialog() == true)
            {
                var xmlText = CloneSerializer.XMLSerialize(rules);
                File.WriteAllText(saveFileDialog.FileName, xmlText);
            }
        }