public SaveDialog(Window owner) { _viewModel = new SaveDialogViewModel(this, owner); this.DataContext = _viewModel; this.Owner = owner; InitializeComponent(); }
public void Execute(IEnumerable <IScreen> toClose, Action <bool, IEnumerable <IScreen> > callback) { //enumerator = toClose.GetEnumerator(); this.toclose = toClose; this.callback = callback; var docs = toClose.Cast <ISaveable>();// .ConvertAll(o => (DocumentViewModel)o); var dirtyDocs = new ObservableCollection <ISaveable>(docs.Where <ISaveable>(x => x.IsDirty)); if (dirtyDocs.Count > 0) { var closeDialog = new SaveDialogViewModel(); closeDialog.Documents = dirtyDocs; _windowManager.ShowDialogBox(closeDialog, settings: new Dictionary <string, object> { { "WindowStyle", WindowStyle.None }, { "ShowInTaskbar", false }, { "ResizeMode", ResizeMode.NoResize }, { "Background", System.Windows.Media.Brushes.Transparent }, { "AllowsTransparency", true } }); if (closeDialog.Result == Enums.SaveDialogResult.Cancel) { // loop through and cancel closing for any dirty documents finalResult = false; // cancel closing Evaluate(finalResult); } else { _eventAggregator.PublishOnUIThread(new StopAutoSaveTimerEvent()); Evaluate(finalResult); } } else { // callback(true, new List<IScreen>()); _eventAggregator.PublishOnUIThread(new StopAutoSaveTimerEvent()); Evaluate(finalResult); } }
private async void RunSaveDialog() { var customDialog = new CustomDialog(); var dialogViewModel = new SaveDialogViewModel(instanceCancel => _dialogCoordinator.HideMetroDialogAsync(this, customDialog), async instanceCompleted => { PackagedSolution.Name = instanceCompleted.Input; OnPropertyChanged("PackagedSolution.Name"); SaveCurrentPackagedSolution(); await _dialogCoordinator.HideMetroDialogAsync(this, customDialog); DisplayTimedMessage("Succes", $"Pakkeløsningen \"{PackagedSolution.Name}\" blev gemt.", 2); }); customDialog.Content = new SaveDialogView { DataContext = dialogViewModel }; await _dialogCoordinator.ShowMetroDialogAsync(this, customDialog); }