Beispiel #1
0
        /// <summary>
        /// Adds a <see cref="PublicationRowViewModel"/>
        /// </summary>
        /// <param name="publication">The associated <see cref="Publication"/></param>
        private void AddPublicationRowViewModel(Publication publication)
        {
            if (this.Publications.Any(x => x.Thing == publication))
            {
                return;
            }

            var row = new PublicationRowViewModel(publication, this.Session, this);

            row.Index = this.Thing.Publication.IndexOf(publication);

            var listOfParams = new List <PublicationParameterOrOverrideRowViewModel>();

            foreach (var parameterOrOverrideBase in publication.PublishedParameter)
            {
                var parameterRow = new PublicationParameterOrOverrideRowViewModel(parameterOrOverrideBase, this.Session, row);

                // turn off the checkbox for this row
                parameterRow.IsCheckable = false;
                listOfParams.Add(parameterRow);
            }

            this.Publications.Add(row);
            row.ContainedRows.AddRange(listOfParams.OrderBy(r => r.Thing.ParameterType.Name));
        }
Beispiel #2
0
        /// <summary>
        /// Adds the publishable <see cref="PublicationParameterOrOverrideRowViewModel"/> row view model to the tree.
        /// </summary>
        /// <param name="parameter">The <see cref="ParameterOrOverrideBase"/> that this row will belong to.</param>
        private void AddPublishableParameterRowViewModel(ParameterOrOverrideBase parameter)
        {
            var domainRow = this.Domains.SingleOrDefault(vm => vm.Thing == parameter.Owner);

            if (domainRow == null)
            {
                return;
            }

            // if the row already exists then simply update it
            var parameterRow = domainRow.ContainedRows.FirstOrDefault(pr => pr.Thing == parameter);

            if (parameterRow != null)
            {
                ((PublicationParameterOrOverrideRowViewModel)parameterRow).SetProperties();
                return;
            }

            // create the row only if it is publishable
            parameterRow = new PublicationParameterOrOverrideRowViewModel(parameter, this.Session, domainRow);

            // if the domain row has a checkbox, select this one as well.
            ((PublicationParameterOrOverrideRowViewModel)parameterRow).ToBePublished = domainRow.ToBePublished;

            domainRow.ContainedRows.SortedInsert(parameterRow, rowComparer);
        }
Beispiel #3
0
        /// <summary>
        /// Add a domain to the <see cref="Domains"/> List
        /// </summary>
        /// <param name="domain">Domain to be added</param>
        private void AddDomainOfExpretiseRowViewModel(DomainOfExpertise domain)
        {
            var row = new PublicationDomainOfExpertiseRowViewModel(domain, this.Session, this);

            var listOfParams = new List <PublicationParameterOrOverrideRowViewModel>();

            foreach (var parameter in domain.OwnedParametersThatCanBePublished(this.Thing))
            {
                var parameterRow = new PublicationParameterOrOverrideRowViewModel(parameter, this.Session, row);
                listOfParams.Add(parameterRow);
            }

            this.Domains.Add(row);
            row.ContainedRows.AddRange(listOfParams.OrderBy(r => r.Name));
        }
Beispiel #4
0
        /// <summary>
        /// Updates the <see cref="Domains"/> of the parameter in case the <see cref="ParameterOrOverrideBase.Owner"/> that contains Parameter changes.
        /// </summary>
        /// <param name="parameterOrOverrideBase">The <see cref="ParameterOrOverrideBase"/> to relocate or remove</param>
        private void RelocateParameterRowViewModel(ParameterOrOverrideBase parameterOrOverrideBase)
        {
            // In case the owner has changed check if there are other domains that contain that parameter.
            var oldOwners = this.Domains.Where(d => d.ContainedRows.Any(p => p.Thing == parameterOrOverrideBase) && d.Thing != parameterOrOverrideBase.Owner);

            foreach (var owner in oldOwners)
            {
                var row = owner.ContainedRows.FirstOrDefault(pr => pr.Thing == parameterOrOverrideBase);
                if (row != null)
                {
                    owner.ContainedRows.Remove(row);
                    row.Dispose();
                }
            }

            if (!parameterOrOverrideBase.CanBePublished)
            {
                return;
            }

            var domainRow = this.Domains.SingleOrDefault(vm => vm.Thing == parameterOrOverrideBase.Owner);

            if (domainRow == null)
            {
                return;
            }

            var parameterRow = domainRow.ContainedRows.FirstOrDefault(pr => pr.Thing == parameterOrOverrideBase);

            if (parameterRow == null)
            {
                parameterRow = new PublicationParameterOrOverrideRowViewModel(parameterOrOverrideBase, this.Session, domainRow);

                // if the domain row has a checkbox, select this one as well.
                ((PublicationParameterOrOverrideRowViewModel)parameterRow).ToBePublished = domainRow.ToBePublished;

                domainRow.ContainedRows.SortedInsert(parameterRow, rowComparer);
            }
        }