Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SaveAsCommandBinding&lt;TController, TModel&gt;"/> class.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="owner">The owner window.</param>
        public SaveAsCommandBinding(ViewModel <TController, TModel> viewModel, Window owner)
        {
            this.Command = ApplicationCommands.SaveAs;

            this.CanExecute += delegate(object sender, CanExecuteRoutedEventArgs e)
            {
                e.CanExecute = SaveAsCommand <TController, TModel> .CanExecute(viewModel, e.Parameter);
            };

            this.Executed += delegate(object sender, ExecutedRoutedEventArgs e)
            {
                SaveAsCommand <TController, TModel> .Execute(viewModel, owner, e.Parameter);
            };
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Saves the data model for the specified <see cref="ViewModel&lt;TController, TModel&gt;"/>.
        /// </summary>
        /// <param name="viewModel">The view model.</param>
        /// <param name="owner">The owner window.</param>
        /// <param name="savePath">The path to the file to which to save.</param>
        /// <returns>
        ///     <c>true</c> if the data model is saved; otherwise, <c>false</c>.
        /// </returns>
        public static bool Save(ViewModel <TController, TModel> viewModel, Window owner, string savePath)
        {
            // Get the save path from the controller
            if (string.IsNullOrEmpty(savePath))
            {
                savePath = viewModel.Controller.SavePath;
            }

            // Save using the save path
            if (!string.IsNullOrEmpty(savePath))
            {
                return(viewModel.Save(savePath));
            }

            // No save path specified - fall back to SaveAs
            return(SaveAsCommand <TController, TModel> .SaveAs(viewModel, owner));
        }
Ejemplo n.º 3
0
 internal static void Execute(ViewModel <TController, TModel> viewModel, Window owner, object parameter)
 {
     SaveAsCommand <TController, TModel> .SaveAs(viewModel, owner);
 }
Ejemplo n.º 4
0
 internal static bool CanExecute(ViewModel <TController, TModel> viewModel, object parameter)
 {
     return(SaveAsCommand <TController, TModel> .CanSaveAs(viewModel));
 }