Ejemplo n.º 1
0
        public MainWindowViewModel(IFooterNavigationViewModel footer, IContentViewModel content, ITaskService taskService)
        {
            _taskService = taskService;
            LogOutCommand = new DelegateCommand(() =>
            {
                LogOut(content);
            });

            var task = _taskService.GetOrCreateTask(Thread.CurrentPrincipal.Identity.Name);
            _taskService.PrepareWorkspaceForTask(task.Id);

            if(task == null)
                throw new ArgumentException("Task cannot be null");

            Footer = footer;
            Content = content;
            footer.NavigationHappened += OnFooterNavigation;

            if (task.CurrentDocument == null){
                footer.GoToFirstFile.Execute().Wait();
            }
            else
            {
                var path = Footer.LoadDocumentAndReturnItsPath(task.CurrentDocument.Name);
                Content.ImageVisualization.FilePath = path;
                Content.Fields.TotalFieldsNumber = task.Documents.Count;
                Content.Fields.TaskId = task.Id;
                content.Fields.OnNavigationHappened(task, true);
            }
        }