예제 #1
0
        protected override void ConfigureContainerBuilder(ContainerBuilder builder)
        {
            base.ConfigureContainerBuilder(builder);

            var eventAggregator = new EventAggregator();

            builder.RegisterInstance <IEventAggregator>(eventAggregator).As <IEventAggregator>().SingleInstance();

            var uiSprints         = new UISprints();
            var databaseViewModel = new DatabaseSchemaViewModel(eventAggregator);
            var mainViewModel     = new MainViewModel(eventAggregator, uiSprints, databaseViewModel);
            var pathViewModel     = new PathViewModel(eventAggregator, mainViewModel);

            // just one instance in all application - combos etc..
            builder.RegisterInstance <UISprints>(uiSprints).As <UISprints>().SingleInstance();
            builder.RegisterInstance <DatabaseSchemaViewModel>(databaseViewModel).As <DatabaseSchemaViewModel>().SingleInstance();
            builder.RegisterInstance <MainViewModel>(mainViewModel).As <MainViewModel>().SingleInstance();
            builder.RegisterInstance <PathViewModel>(pathViewModel).As <PathViewModel>().SingleInstance();
        }
예제 #2
0
        public MainViewModel(IEventAggregator evAgg, UISprints sprints, DatabaseSchemaViewModel dataViewModel)
        {
            DataViewModel = dataViewModel;
            Sprints       = sprints.Sprints;
            eventAgg      = evAgg;

            rootTables = new NodeDbTableRoot(evAgg)
            {
                Name        = "ROOT for DB Tables",
                Description = "just helper instance...",
                Nodes       = new ObservableCollection <NodeDbTableToExcel>()
            };

            eventAgg.GetEvent <PathViewAddedEvent>().Subscribe(() => {
                Task.Run(() =>
                {
                    DoLoad();
                });
            });

            evAgg.GetEvent <SelectionChangedEvent>().Subscribe(SelectionChanged());

            Import = new DelegateCommand(() => DoImport());
            Save   = new DelegateCommand(() => DoSave());
            Load   = new DelegateCommand(() => DoLoad());

            ShowLog = new DelegateCommand(() =>
            {
                Process process = new Process();
                // Configure the process using the StartInfo properties.
                var rootAppender = ((Hierarchy)LogManager.GetRepository())
                                   .Root.Appenders.OfType <log4net.Appender.FileAppender>()
                                   .FirstOrDefault();

                string filename            = rootAppender != null ? rootAppender.File : string.Empty;
                process.StartInfo.FileName = rootAppender.File;
                //process.StartInfo.Arguments = @"c:\!! LOGs\EscapeDBUsage.log";
                process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                process.Start();
                //process.WaitForExit();// Waits here for the process to exit.
            });

            ShowDataFolder = new DelegateCommand(() =>
            {
                Process process = new Process();
                // Configure the process using the StartInfo properties.
                process.StartInfo.FileName    = "explorer";
                process.StartInfo.Arguments   = FoldersHelper.DataFolder;
                process.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
                process.Start();
                //process.WaitForExit();// Waits here for the process to exit.
            });

            Refresh        = new DelegateCommand(() => DoRefresh());
            RefreshColumns = new DelegateCommand(() => DoRefreshColumns());

            ExpandAll   = new DelegateCommand(() => DoExpandAll());
            CollapseAll = new DelegateCommand(() => DoCollapseAll());

            SaveSprints = new DelegateCommand(() => DoSaveSprints());

            AddExcel = new DelegateCommand(() => DoAddExcel());

            AddTables = new DelegateCommand(() => DoAddTables());
        }