protected internal override void Adding <TViewModel>(TViewModel itemToBeAdded)
 {
     if (ViewModels.Any())
     {
         Remove(ViewModels.Single());
     }
 }
示例#2
0
        /*public TViewModel this[int index]
         * {
         *  get => ViewModels[index];
         *  set
         *  {
         *      EncapsulatedList[index] = value.Model;
         *      ViewModels[index] = value;
         *  }
         * }*/

        public EncapsulatingObservableCollection(IList <TModel> encapsulatedList, IList <TViewModel> viewModels)
        {
            EncapsulatedList  = encapsulatedList;
            ViewModels        = viewModels.ToList();
            AddItemCommand    = new DelegateCommand <TViewModel>(Add, o => true);
            RemoveItemCommand = new DelegateCommand <TViewModel>(item => Remove(item), o => ViewModels.Any());
            ClearItemCsommand = new DelegateCommand(o => Clear(), o => ViewModels.Any());
        }
示例#3
0
 double GetNextY(double startingOffset)
 {
     while (ViewModels.Any(p => p.PositionTop.Equals(startingOffset)))
     {
         startingOffset += YOffset;
     }
     return(startingOffset);
 }
        ObservableCollection <HeaderViewModel> GetWrapperItemsSource()
        {
            if (ViewModels == null || !ViewModels.Any())
            {
                return(null);
            }
            var collection = ViewModels.Select(x => ((ViewModel.NavigationViewModelBase)x).HeaderViewModel);

            return(new ObservableCollection <HeaderViewModel>(collection));
        }
示例#5
0
 protected override void DisposeManagedResources()
 {
     ViewModels.IgnoreEvents = true;
     Selection.IgnoreEvents  = true;
     base.DisposeManagedResources();
     if (ViewModels != null && ViewModels.Any())
     {
         foreach (var viewModel in ViewModels)
         {
             viewModel.Dispose();
         }
         ViewModels.Clear();
     }
     ViewModels = null;
     Selection.Clear();
 }
示例#6
0
        public void AddSchemas(IEnumerable <SchemaData> schemas)
        {
            currentViewModel = null;
            List <SchemaData> convertibleSchemas = new List <SchemaData>();

            convertibleSchemas.AddRange(schemas);

            int nrTries = 0;

            while (convertibleSchemas.Count > 0 && nrTries++ < MaxTries)
            {
                _log.DebugFormat("trying to convert {0} schemas to viewmodel definitions, starting parsing round #{1}", convertibleSchemas.Count, nrTries);
                List <SchemaData> extraSchemas = new List <SchemaData>();
                foreach (var schema in convertibleSchemas)
                {
                    _log.Debug("starting converting schema " + schema.Title);
                    ConvertSchema(schema);
                }
                convertibleSchemas = convertibleSchemas.Where(a => ViewModels.Any(b => b.TcmUri == a.Id && b.HasUnresolvedProperties)).ToList();
                if (extraSchemas.Count > 0)
                {
                    _log.DebugFormat("adding {0} extra schemas (found during property parsing)", extraSchemas.Count);
                    convertibleSchemas.AddRange(extraSchemas);
                }
                _log.DebugFormat("after parsing round #{0} there are still {1} schemas to be converted", nrTries, convertibleSchemas.Count);
            }
            // after adding all schemas, we need to tell the ViewRegistry to add all component templates linked to the current set of schemas
            // this will trigger the ModelRegistry to create merged models in case a CT is linked to multiple schemas
            UsingItemsFilterData filter = new UsingItemsFilterData()
            {
                ItemTypes = new[] { ItemType.ComponentTemplate }
            };

            foreach (var schema in convertibleSchemas.Where(s => s.Purpose == SchemaPurpose.Component))
            {
                var associatedCTs = Client.GetList(schema.Id, filter).Cast <ComponentTemplateData>();
                associatedCTs?.Select(s => ViewRegistry.GetViewModelDefinition(s.Id)); // we don't care about the return value but we want this
            }
        }
示例#7
0
 public bool Contains(TModel item) => ViewModels.Any(vm => vm.Model == item);
示例#8
0
 public bool ContainsModel(string tcmUri)
 {
     return(ViewModels.Any(m => m.TcmUri == tcmUri));
 }