Пример #1
0
        public MainFooterViewModel(ProjectContext projectContext, StatusInfo statusInfo, UserInterface userInterface)
        {
            if (projectContext == null)
            {
                throw new ArgumentNullException(nameof(projectContext));
            }
            if (statusInfo == null)
            {
                throw new ArgumentNullException(nameof(statusInfo));
            }

            this.projectContext = projectContext;
            this.statusInfo     = statusInfo;

            SelectAllFlagsCommand          = new SelectAllFlagsCommand(userInterface, projectContext);
            SelectNoFlagsCommand           = new SelectNoFlagsCommand(userInterface, projectContext);
            StatusInfoCommand              = new StatusInfoCommand(statusInfo, userInterface);
            ToggleDisplaySelectedCommand   = new ToggleDisplaySelectedCommand(userInterface, projectContext);
            ToggleDisplayUnselectedCommand = new ToggleDisplayUnselectedCommand(userInterface, projectContext);

            DisplaySelected   = projectContext.DisplaySelected;
            DisplayUnselected = projectContext.DisplayUnselected;

            statusInfo.StatusTextChanged += HandleStatusTextChanged;

            this.projectContext.Loaded   += HandleProjectLoaded;
            this.projectContext.Unloaded += HandleProjectUnloaded;
            this.projectContext.DisplaySelectedChanged += HandleFlagsDisplaySelectedChanged;

            IsEnabled = projectContext.IsLoaded;
        }
Пример #2
0
        public MainWindowViewModel(UserInterface userInterface, StatusInfo statusInfo, OpenedProjects openedProjects)
        {
            if (userInterface == null)
            {
                throw new ArgumentNullException(nameof(userInterface));
            }
            if (statusInfo == null)
            {
                throw new ArgumentNullException(nameof(statusInfo));
            }
            if (openedProjects == null)
            {
                throw new ArgumentNullException(nameof(openedProjects));
            }

            this.userInterface  = userInterface;
            this.statusInfo     = statusInfo;
            this.openedProjects = openedProjects;

            // Create commands

            SelectAllFlagsCommand      = new SelectAllFlagsCommand(userInterface, openedProjects);
            SelectNoFlagsCommand       = new SelectNoFlagsCommand(userInterface, openedProjects);
            CopyCommand                = new CopyCommand(userInterface, openedProjects);
            PasteCommand               = new PasteCommand(userInterface, openedProjects);
            CreateProjectCommand       = new CreateProjectCommand(userInterface, openedProjects);
            CloseCurrentProjectCommand = new CloseCurrentProjectCommand(userInterface, openedProjects);
            DigitCommand               = new DigitCommand(userInterface, openedProjects);

            // Initialize everything

            IEnumerable <ProjectViewModel> projects = openedProjects
                                                      .Select(x => new ProjectViewModel(userInterface, statusInfo, openedProjects, x));

            Projects        = new ObservableCollection <ProjectViewModel>(projects);
            SelectedProject = Projects.FirstOrDefault();

            mainTitle          = new MainTitle(openedProjects);
            mainTitle.Changed += HandleMainTitleChanged;

            Title = mainTitle.ToString();

            this.openedProjects.CurrentProjectChanged += HandleCurrentProjectChanged;
            this.openedProjects.ProjectCreated        += HandleProjectCreated;
            this.openedProjects.ProjectClosed         += HandleProjectClosed;

            IsNoTabInfoVisible = Projects.Count == 0;
        }