Source

main / Source / Excel / Excel.AddIn / Excel.AddIn / ViewModels / MetadataViewPaneViewModel.cs

using System;
using System.Windows.Input;
using DataUp.Excel.Common;

namespace DataUp.Excel.Addin
{
    public class MetadataViewPaneViewModel : ViewModelBase
    {
        private MetadataListViewModel metadataListViewModel;

        private ICommand saveMetadataCommand;

        public MetadataListViewModel MetadataListViewModel
        {
            get
            {
                return metadataListViewModel;
            }
            set
            {
                metadataListViewModel = value;
                OnNotifyPropertyChanged("MetadataListViewModel");
            }
        }

        #region CustomEvent

        /// <summary>
        /// Capture View window close request
        /// </summary>
        public event EventHandler RequestClose;

        #endregion

        public ICommand SaveMetadataCommand
        {
            get
            {
                return saveMetadataCommand;
            }
            set
            {
                if (saveMetadataCommand != value)
                {
                    saveMetadataCommand = value;
                    OnNotifyPropertyChanged("SaveMetadataCommand");
                }
            }
        }

        public MetadataViewPaneViewModel()
        {
            InitCommands();

            this.MetadataListViewModel = new MetadataListViewModel();
        }

        private void InitCommands()
        {
            this.SaveMetadataCommand = new DelegateCommand(SaveButtonExecute, SaveButtonCanExecute);
        }

        /// <summary>
        /// Raise window close event
        /// </summary>
        public void OnRequestClose()
        {
            RequestClose.OnFire(this, EventArgs.Empty);
        }

        private void SaveButtonExecute()
        {
            // Save The metadata sheet on Next Button Click.

                UpdateMetadata();

                this.OnRequestClose();
        }

        private bool SaveButtonCanExecute()
        {
            return this.MetadataListViewModel.IsValid();
        }

        private void UpdateMetadata()
        {
            if (this.MetadataListViewModel.IsValid())
            {
                Controller.Instance.UpdateMetadata(this.MetadataListViewModel);
            }
        }

        private void Load()
        {
            this.MetadataListViewModel.LoadMetadata();
        }
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.