/// ------------------------------------------------------------------------------------ /// <summary> /// Create and load all the views. /// </summary> /// ------------------------------------------------------------------------------------ private void SetupViews() { CleanOutViews(); foreach (ToolStripButton btn in tsMain.Items) { btn.Checked = false; } SpongeProject project = CurrentProject; _backgroundStatisticsGather = new BackgroundStatisticsMananager(project.SessionsFolder); _backgroundStatisticsGather.Start(); var statisticsModel = new StatisticsViewModel(project, _backgroundStatisticsGather); _overviewView = new OverviewVw(project, statisticsModel); _sessionsView = new SessionsVw(CurrentProject, CurrentProject.GetPeopleNames); _peopleView = new PeopleVw(CurrentProject); _sendReceiveView = new SendReceiveVw(); _setupView = new SetupVw(); var views = new Control[] { _overviewView, _sessionsView, _peopleView, _sendReceiveView, _setupView }; Controls.AddRange(views); _viewManger = new ViewButtonManager(tsMain, views); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Browse for an existing project. /// </summary> /// ------------------------------------------------------------------------------------ private void tsbBrowse_Click(object sender, EventArgs e) { using (var dlg = new OpenFileDialog()) { var caption = LocalizationManager.LocalizeString( "WelcomeDlg.OpenFileDlgCaption", "Open Sponge Project", "Dialog Boxes"); var prjFilterText = LocalizationManager.LocalizeString( "WelcomeDlg.SpongePrjFileType", "Sponge Project (*.sprj)", "Dialog Boxes"); dlg.Title = caption; dlg.Filter = prjFilterText + "|*.sprj|" + Sponge.OFDlgAllFileTypeText + "|*.*"; dlg.InitialDirectory = SpongeProject.ProjectsFolder; dlg.CheckFileExists = true; dlg.CheckPathExists = true; if (dlg.ShowDialog(this) == DialogResult.Cancel) { return; } Project = SpongeProject.Load(dlg.FileName); if (Project != null) { MruProjects.AddNewPath(dlg.FileName); MruProjects.Save(); } } DialogResult = DialogResult.OK; Close(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a test project. /// </summary> /// ------------------------------------------------------------------------------------ protected void InitProject() { _prj = ReflectionHelper.GetResult(typeof(SpongeProject), "Create", kTestPrjName) as SpongeProject; ReflectionHelper.SetProperty(typeof(MainWnd), "CurrentProject", _prj); }
public void GetPairs_EmptyProject_GivesSomePairs() { using (new TestProjectWithSessions(0)) { SpongeProject project = SpongeProject.Create("test"); var pairs = CreateModel(project).GetPairs(); Assert.Less(0, pairs.Count()); } }
static void Main() { // Can't get this working yet. //Logger.Init(); //ErrorReport.EmailAddress = "*****@*****.**"; //ErrorReport.AddStandardProperties(); //ExceptionHandler.Init(); if (!Directory.Exists(MainApplicationFolder)) { Directory.CreateDirectory(MainApplicationFolder); } if (!Directory.Exists(SpongeProject.ProjectsFolder)) { Directory.CreateDirectory(SpongeProject.ProjectsFolder); } //Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("fr"); LocalizationManager.Enabled = true; LocalizationManager.Initialize(Path.Combine(MainApplicationFolder, "Localizations")); LocalizeItemDlg.SetDialogBounds += LocalizeItemDlg_SetDialogBounds; LocalizeItemDlg.SetDialogSplitterPosition += LocalizeItemDlg_SetDialogSplitterPosition; LocalizeItemDlg.SaveDialogBounds += LocalizeItemDlg_SaveDialogBounds; LocalizeItemDlg.SaveDialogSplitterPosition += LocalizeItemDlg_SaveDialogSplitterPosition; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); SpongeProject prj = null; MruProjects.Initialize(Settings.Default.MRUList); if (MruProjects.Latest != null && File.Exists(MruProjects.Latest)) { prj = SpongeProject.Load(MruProjects.Latest); } else { using (var dlg = new WelcomeDlg()) { if (dlg.ShowDialog() == DialogResult.OK) { prj = dlg.Project; } } } if (prj != null) { Application.Run(new MainWnd(prj)); } }
/// ------------------------------------------------------------------------------------ public SessionsVw(SpongeProject _prj, Func <IEnumerable <string> > peopleNameProvider) : this() { _peopleNameProvider = peopleNameProvider; _currProj = (_prj ?? MainWnd.CurrentProject); _currProj.ProjectChanged += HandleProjectFoldersChanged; //todo: this should go away when we have DI going, and the factory method for the panel injects the provider //_presetProvider = new PresetProvider(_currProj.SessionsFolder); //_infoPanel.PresetProvider = PresetProvider.CreateFromDirectory(_currProj.SessionsFolder); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Create a new project. /// </summary> /// ------------------------------------------------------------------------------------ private void tsbCreate_Click(object sender, EventArgs e) { Project = SpongeProject.Create(this); if (Project != null) { MruProjects.AddNewPath(Project.FullFilePath); MruProjects.Save(); DialogResult = DialogResult.OK; Close(); } }
public void GetOriginalRecordingTime_NoRecording_Zero() { SessionComponentDefinition originalRecording = SessionComponentDefinition.CreateHardCodedDefinitions().First(); using (var test = new TestProjectWithSessions(1)) { SpongeProject project = test.Project; Assert.AreEqual(new TimeSpan(0), CreateModel(project).GetRecordingDurations(originalRecording)); } }
public TestProjectWithSessions(int sessionCount) { _testAppFolder = new TemporaryFolder("~~SpongeStatViewModelTestFolder~~"); ReflectionHelper.SetField(typeof(Sponge), "s_mainAppFldr", _testAppFolder.FolderPath); Project = SpongeProject.Create("statVwModelTestPrj"); for (int i = 0; i < sessionCount; i++) { Session session = Project.AddSession(i.ToString()); session.Save(); } }
public void GetRecordingDurations_SomeRecording_MoreThanZero() { using (var test = new TestProjectWithSessions(1)) { SessionComponentDefinition firstRole = SessionComponentDefinition.CreateHardCodedDefinitions().First(); CreateCanonciallyNamedRecordingInSession(firstRole, test.Project.Sessions[0]); SpongeProject project = test.Project; Assert.Less(new TimeSpan(0), CreateModel(project).GetRecordingDurations(firstRole)); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Load one of the MRU projects. /// </summary> /// ------------------------------------------------------------------------------------ private void tsbMru_Click(object sender, EventArgs e) { var tsb = sender as ToolStripButton; if (tsb == null) { return; } // The full path to the project file is in the tooltip of the button. Project = SpongeProject.Load(tsb.ToolTipText); DialogResult = DialogResult.OK; Close(); }
public void GetRecordingDurations_DistinguishesBetweenRoles() { using (var test = new TestProjectWithSessions(1)) { SessionComponentDefinition firstRole = SessionComponentDefinition.CreateHardCodedDefinitions().First(); CreateCanonciallyNamedRecordingInSession(firstRole, test.Project.Sessions[0]); SessionComponentDefinition secondRole = SessionComponentDefinition.CreateHardCodedDefinitions().ToArray()[1]; SpongeProject project = test.Project; TimeSpan t = CreateModel(project).GetRecordingDurations(secondRole); Assert.AreEqual(new TimeSpan(0), t, "should not find any files with the second role"); } }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes the main window for the specified project. /// </summary> /// ------------------------------------------------------------------------------------ private void Initialize(SpongeProject prj) { if (CurrentProject != null) { CurrentProject.Dispose(); } CurrentProject = prj; CurrentProject.FileWatcherSynchronizingObject = this; SetupViews(); _viewManger.SetView(tsbOverview); SetWindowText(); LocalizeItemDlg.StringsLocalized -= SetWindowText; LocalizeItemDlg.StringsLocalized += SetWindowText; Show(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="OverviewVw"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public OverviewVw(SpongeProject project, StatisticsViewModel statisticsModel) { InitializeComponent(); gridGenre.Rows.Add(10); gridTasks.Rows.Add(10); gridGenre.AlternatingRowsDefaultCellStyle.BackColor = ColorHelper.CalculateColor(Color.Black, gridGenre.DefaultCellStyle.BackColor, 10); gridTasks.AlternatingRowsDefaultCellStyle.BackColor = ColorHelper.CalculateColor(Color.Black, gridTasks.DefaultCellStyle.BackColor, 10); var statisticsView = new StatisticsView(statisticsModel); this.Controls.Add(statisticsView); _viewBtnManger = new ViewButtonManager(tsOverview, new Control[] { statisticsView, gridGenre, pnlContributor, gridTasks }); _viewBtnManger.SetView(tsbStatistics); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="MainWnd"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public MainWnd(SpongeProject prj) : this() { Initialize(prj); }
/// ------------------------------------------------------------------------------------ /// <summary> /// /// </summary> /// ------------------------------------------------------------------------------------ public NewSessionDlgViewModel(SpongeProject project) { _project = project; _tooltip = new ToolTip(); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Initializes a new instance of the <see cref="SessionsVw"/> class. /// </summary> /// ------------------------------------------------------------------------------------ public PeopleVw(SpongeProject _prj) : this() { _currProj = (_prj ?? MainWnd.CurrentProject); lblNoPeopleMsg.Visible = (_currProj.People.Count == 0); lpPeople.Items = _currProj.People.ToArray(); }
private StatisticsViewModel CreateModel(SpongeProject project) { return(new StatisticsViewModel(project, new BackgroundStatisticsMananager(project.SessionsFolder))); }
public StatisticsViewModel(SpongeProject project, BackgroundStatisticsMananager backgroundStatisticsMananager) { _project = project; _backgroundStatisticsGather = backgroundStatisticsMananager; _backgroundStatisticsGather.NewStatistics += new EventHandler(OnNewStatistics); }