public SettingsWindow(SettingsViewModel model)
        {
            this.DataContext = this;
            this.Model = model;

            this.InitializeComponent();

            this.cboCache.SelectedItem = this.cboCache.Items[0];
        }
        public ExportWindow(string projectName, SettingsViewModel settings, IEnumerable<ChangesetViewModel> changesets)
        {
            this.DataContext = this;

            this.Settings = settings;
            this.Changesets = new ObservableCollection<SelectableChangesetViewModel>(changesets.Select(c => new SelectableChangesetViewModel(c)));

            this.GraphiteProjectKey = string.IsNullOrEmpty(projectName) 
                ? string.Empty 
                : projectName.ToLower().Replace(" ", "_").Replace(".", "_");

            this.InitializeComponent();
        }
        private void OnStartup(object sender, StartupEventArgs e)
        {
            this.SettingsModel = new SettingsViewModel(Settings.Default);

            if (string.IsNullOrEmpty(Settings.Default.TfsConnection))
                Settings.Default.Upgrade();

            if (string.IsNullOrEmpty(Settings.Default.TfsConnection) || !this.CanConnectToMongo(Settings.Default.MongoConnection))
            {
                bool? result = new SettingsWindow(this.SettingsModel).ShowDialog();

                if (!result.HasValue || !result.Value)
                    return;

                Settings.Default.Save();
            }

            this.MainWindow = new MainWindow(this.SettingsModel);

            this.MainWindow.ShowDialog();
        }
        public MainWindow(SettingsViewModel settings)
        {
            if (settings == null)
                throw new ArgumentNullException("settings");
            
            this.settings = settings;

            this.tfsConnector = new TfsConnector(this.settings.TfsConnection);

            var cache = new MongoDbCache<ChangeInfo>(
                this.settings.MongoConnection,
                MongoDbCache.DatabaseName,
                "changeStats");

            this.analystics = new TfsAnalytics(this.tfsConnector, cache);

            this.imageService = new DirectoryUserImageService(this.settings.DomainController, this.settings.DirectoryImageProperty);

            this.DataContext = this;

            this.Projects = new ObservableCollection<TeamProject>(this.tfsConnector.GeTeamProjects());

            this.Changesets = new ObservableCollection<ChangesetViewModel>();
            this.Changes = new ObservableCollection<ChangeViewModel>();
            
            this.InitializeComponent();

            Observable.FromEvent<EventHandler, EventArgs>(
                handler => (sender, e) => handler(e),
                h => this.RedrawCharts += h,
                h => this.RedrawCharts -= h)
                .Throttle(TimeSpan.FromSeconds(3)).ObserveOn(Scheduler.CurrentThread).Subscribe(l =>
                {
                    this.Dispatcher.Invoke(this.DrawCharts);
                });
        }