Exemplo n.º 1
0
        public MainWindowViewModel()
        {
            // Set unity container

            UnityContainer unityContainer = (UnityContainer)System.Windows.Application.Current.Resources["UContainer"];

            unityContainer.RegisterType <OptionsModel>(new ContainerControlledLifetimeManager());
            unityContainer.RegisterType <RenameService>(new ContainerControlledLifetimeManager());

            // Instantiate objects now
            _option   = unityContainer.Resolve <OptionsModel>();
            _statServ = unityContainer.Resolve <StatusService>();
            _renServ  = unityContainer.Resolve <RenameService>();
            _renServ.SetOptions(_option); // only pass this as a copy not a reference;

            // Set actions for the view and just use lambda expression to return true regardless
            BrowseFolder = new DelegateCommand(BrowseExecute, () => true);
            RenameNow    = new DelegateCommand(RenExecute, () => true);

            // Call initialize(ON_INIT) for initialization just incase it was called from context menu
            // this call for everything status display, call to get folder etc.
            ProcessCode pc = ProcessCode.ON_INIT;

            InitializeAll(ref pc);



            _busy = false;
        }