Esempio n. 1
0
        private void SaveCurrentFile()
        {
            if (!Path.IsPathRooted(CurrentFileName))
            {
                SaveFileDialog saveFileDialog = new SaveFileDialog();
                saveFileDialog.ValidateNames   = true;
                saveFileDialog.Title           = "Save";
                saveFileDialog.OverwritePrompt = true;
                saveFileDialog.Filter          = "XML Files | *.xml";
                saveFileDialog.AddExtension    = true;
                saveFileDialog.DefaultExt      = "xml";

                bool?result = saveFileDialog.ShowDialog();
                if (result != null && result.HasValue && result.Value)
                {
                    CurrentFileName = saveFileDialog.FileName;
                }
                else
                {
                    return;
                }
            }

            if (currentPatternIndex != -1 && currentPatternIndex < UI.CurrentPatterns.Count)
            {
                UI.CurrentPatterns[currentPatternIndex].Stages = UI.Window.MultiStagesEditor.GetStages();
            }
            PatternsIO.SaveTo(CurrentFileName, UI.CurrentPatterns.Select(w => w.Pattern).ToArray());
            //HasMadeChangesSinceLastSave = false;
        }
Esempio n. 2
0
        private void OnOpenMenuItemClick(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.ValidateNames = true;
            openFileDialog.Title         = "Open";
            openFileDialog.Multiselect   = false;
            openFileDialog.Filter        = "XML Files | *.xml";
            openFileDialog.AddExtension  = true;
            openFileDialog.DefaultExt    = "xml";

            bool?result = openFileDialog.ShowDialog();

            if (result != null && result.HasValue && result.Value)
            {
                currentPatternIndex = -1;
                CurrentFileName     = openFileDialog.FileName;
                UI.CurrentPatterns  = new ObservableCollection <PatternWrapper>(PatternsIO.LoadFrom(CurrentFileName).Select(p => new PatternWrapper(p)).ToList());
                IsEditingFile       = true;
            }
        }