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

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

namespace DataUp.Excel.Addin
{
    public class GetIdentifierViewModel : RepositoryDetailListViewModel
    {
        private ICommand getIdentifierCommand;
        private ICommand cancelCommand;

        private bool showError;
        private string errorMessage;

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

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

        public bool ShowError
        {
            get
            {
                return showError;
            }
            set
            {
                showError = value;
                OnNotifyPropertyChanged("ShowError");
            }
        }

        public string ErrorMessage
        {
            get
            {
                return errorMessage;
            }
            set
            {
                errorMessage = value;
                OnNotifyPropertyChanged("ErrorMessage");
            }
        }

        #region CustomEvent

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

        public event EventHandler GetIdentifierCancelled;

        #endregion

        public GetIdentifierViewModel()
            : base()
        {
            InitCommands();
        }

        private void InitCommands()
        {
            this.GetIdentifierCommand = new DelegateCommand<MetadataListViewModel>(OnGetIdentifier, OnGetIdentifierCanExecute);

            this.CancelCommand = new DelegateCommand(() =>
            {
                this.GetIdentifierCancelled.OnFire(this, new EventArgs());
            });
        }

        private void OnGetIdentifier(MetadataListViewModel metadataListViewModel)
        {
            this.GetIdentifierCompleted.OnFire(this, new EventArgs());
        }

        private bool OnGetIdentifierCanExecute(MetadataListViewModel metadataListViewModel)
        {
            bool canExecute = false;
            if (this.RepositoryDetailsViewModel != null)
            {
                canExecute = this.RepositoryDetailsViewModel.IsValid();
            }

            return canExecute;
        }
    }
}
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.