Esempio n. 1
0
 public ShellViewModel(IWindowManager windowManager, IEventAggregator eventAggregator, RibbonViewModel ribbonViewModel, StatusBarViewModel statusBar, IConductor conductor, IDaxStudioHost host, IVersionCheck versionCheck)
 {
     Ribbon           = ribbonViewModel;
     Ribbon.Shell     = this;
     StatusBar        = statusBar;
     _windowManager   = windowManager;
     _eventAggregator = eventAggregator;
     _eventAggregator.Subscribe(this);
     Tabs = (DocumentTabViewModel)conductor;
     Tabs.ConductWith(this);
     //Tabs.CloseStrategy = new ApplicationCloseStrategy();
     Tabs.CloseStrategy = IoC.Get <ApplicationCloseAllStrategy>();
     _host = host;
     if (_host.CommandLineFileName != string.Empty)
     {
         Tabs.NewQueryDocument(_host.CommandLineFileName);
     }
     else
     {
         Tabs.NewQueryDocument();
     }
     VersionChecker = versionCheck;
     DisplayName    = string.Format("DaxStudio - {0}", Version.ToString(3));
     Application.Current.Activated += OnApplicationActivated;
     Log.Verbose("============ Shell Started - v{version} =============", Version.ToString());
     //Execute.OnUIThread(() => { notifyIcon = new NotifyIcon(); });
 }
Esempio n. 2
0
        public ShellViewModel(IWindowManager windowManager
                              , IEventAggregator eventAggregator
                              , RibbonViewModel ribbonViewModel
                              , StatusBarViewModel statusBar
                              , IConductor conductor
                              , IDaxStudioHost host
                              , IVersionCheck versionCheck
                              , IGlobalOptions options
                              , IAutoSaver autoSaver
                              )
        {
            Ribbon           = ribbonViewModel;
            Ribbon.Shell     = this;
            StatusBar        = statusBar;
            Options          = options;
            AutoSaver        = autoSaver;
            _windowManager   = windowManager;
            _eventAggregator = eventAggregator;
            _eventAggregator.Subscribe(this);
            Tabs = (DocumentTabViewModel)conductor;
            Tabs.ConductWith(this);
            //Tabs.CloseStrategy = new ApplicationCloseStrategy();
            Tabs.CloseStrategy = IoC.Get <ApplicationCloseAllStrategy>();
            _host = host;
            _app  = Application.Current;
            var recoveringFiles = false;

            // get master auto save indexes and only get crashed index files...
            var autoSaveInfo   = AutoSaver.LoadAutoSaveMasterIndex();
            var filesToRecover = autoSaveInfo.Values.Where(idx => idx.IsCurrentVersion && idx.ShouldRecover).SelectMany(entry => entry.Files);

            // check for auto-saved files and offer to recover them
            if (filesToRecover.Any())
            {
                recoveringFiles = true;
                RecoverAutoSavedFiles(autoSaveInfo);
            }
            else
            {
                // if there are no auto-save files to recover, start the auto save timer
                eventAggregator.PublishOnUIThreadAsync(new StartAutoSaveTimerEvent());
            }

            // if a filename was passed in on the command line open it
            if (!string.IsNullOrEmpty(_host.CommandLineFileName))
            {
                Tabs.NewQueryDocument(_host.CommandLineFileName);
            }

            // if no tabs are open at this point and we are not recovering autosave file then, open a blank document
            if (Tabs.Items.Count == 0 && !recoveringFiles)
            {
                NewDocument();
            }


            VersionChecker = versionCheck;

#if PREVIEW
            DisplayName = string.Format("DaxStudio - {0} (PREVIEW)", Version.ToString(4));
#else
            DisplayName = string.Format("DaxStudio - {0}", Version.ToString(3));
#endif
            Application.Current.Activated += OnApplicationActivated;
            Log.Verbose("============ Shell Started - v{version} =============", Version.ToString());

            AutoSaveTimer          = new Timer(Constants.AutoSaveIntervalMs);
            AutoSaveTimer.Elapsed += new ElapsedEventHandler(AutoSaveTimerElapsed);
        }
Esempio n. 3
0
        public ShellViewModel(IEventAggregator eventAggregator
                              , RibbonViewModel ribbonViewModel
                              , StatusBarViewModel statusBar
                              , IConductor conductor
                              , IDaxStudioHost host
                              , IVersionCheck versionCheck
                              , IGlobalOptions options
                              , IAutoSaver autoSaver
                              , IThemeManager themeManager)
        {
            Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", "Starting Constructor");
            _utcSessionStart = DateTime.UtcNow;
            Ribbon           = ribbonViewModel;
            Ribbon.Shell     = this;
            StatusBar        = statusBar;
            Options          = options;
            AutoSaver        = autoSaver;
            ThemeManager     = themeManager;
            _eventAggregator = eventAggregator;
            _eventAggregator.Subscribe(this);

            Tabs = (DocumentTabViewModel)conductor;
            Tabs.ConductWith(this);
            //Tabs.CloseStrategy = new ApplicationCloseStrategy();
            Tabs.CloseStrategy = IoC.Get <ApplicationCloseAllStrategy>();
            _host     = host;
            _username = UserHelper.GetUser();
            var recoveringFiles = false;

            // get master auto save indexes and only get crashed index files...
            var autoSaveInfo   = AutoSaver.LoadAutoSaveMasterIndex();
            var filesToRecover = autoSaveInfo.Values.Where(idx => idx.IsCurrentVersion && idx.ShouldRecover).SelectMany(entry => entry.Files);

            // check for auto-saved files and offer to recover them
            if (filesToRecover.Any())
            {
                Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", "Found auto-save files, beginning recovery");
                recoveringFiles = true;
                RecoverAutoSavedFiles(autoSaveInfo);
            }
            else
            {
                // if there are no auto-save files to recover, start the auto save timer
                Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", "Starting auto-save timer");
                eventAggregator.PublishOnUIThreadAsync(new StartAutoSaveTimerEvent());
            }

            // if a filename was passed in on the command line open it
            if (!string.IsNullOrEmpty(_host.CommandLineFileName))
            {
                Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", $"Opening file from command line: '{_host.CommandLineFileName}'");
                Tabs.NewQueryDocument(_host.CommandLineFileName);
            }

            // if no tabs are open at this point and we are not recovering auto-save file then, open a blank document
            if (Tabs.Items.Count == 0 && !recoveringFiles)
            {
                Log.Debug(Constants.LogMessageTemplate, nameof(ShellViewModel), "ctor", "Opening a new blank query window");
                NewDocument();
            }


            VersionChecker = versionCheck;

            DisplayName = AppTitle;

            Application.Current.Activated += OnApplicationActivated;


            AutoSaveTimer          = new Timer(Constants.AutoSaveIntervalMs);
            AutoSaveTimer.Elapsed += AutoSaveTimerElapsed;

            Log.Debug("============ Shell Started - v{version} =============", Version.ToString());
        }
Esempio n. 4
0
        public ShellViewModel(IWindowManager windowManager
                              , IEventAggregator eventAggregator
                              , RibbonViewModel ribbonViewModel
                              , StatusBarViewModel statusBar
                              , IConductor conductor
                              , IDaxStudioHost host
                              , IVersionCheck versionCheck
                              , ISettingProvider settingProvider)
        {
            Ribbon           = ribbonViewModel;
            Ribbon.Shell     = this;
            StatusBar        = statusBar;
            SettingProvider  = settingProvider;
            _windowManager   = windowManager;
            _eventAggregator = eventAggregator;
            _eventAggregator.Subscribe(this);
            Tabs = (DocumentTabViewModel)conductor;
            Tabs.ConductWith(this);
            //Tabs.CloseStrategy = new ApplicationCloseStrategy();
            Tabs.CloseStrategy = IoC.Get <ApplicationCloseAllStrategy>();
            _host = host;
            _app  = Application.Current;

            // TODO - get master auto save indexes and only get crashed index files...

            // check for auto-saved files and offer to recover them
            var autoSaveInfo = AutoSaver.LoadAutoSaveMasterIndex();

            if (autoSaveInfo.Values.Where(idx => idx.ShouldRecover).Count() > 0)
            {
                RecoverAutoSavedFiles(autoSaveInfo);
            }
            else
            {
                // if a filename was passed in on the command line open it
                if (_host.CommandLineFileName != string.Empty)
                {
                    Tabs.NewQueryDocument(_host.CommandLineFileName);
                }

                // if no tabs are open at this point open a blank one
                if (Tabs.Items.Count == 0)
                {
                    NewDocument();
                }

                // if there are no auto-save files to recover, start the auto save timer
                eventAggregator.PublishOnUIThreadAsync(new StartAutoSaveTimerEvent());
            }

            VersionChecker = versionCheck;

#if PREVIEW
            DisplayName = string.Format("DaxStudio - {0} (PREVIEW)", Version.ToString(4));
#else
            DisplayName = string.Format("DaxStudio - {0}", Version.ToString(3));
#endif
            Application.Current.Activated += OnApplicationActivated;
            Log.Verbose("============ Shell Started - v{version} =============", Version.ToString());

            _autoSaveTimer          = new Timer(Constants.AutoSaveIntervalMs);
            _autoSaveTimer.Elapsed += new ElapsedEventHandler(AutoSaveTimerElapsed);
        }