public void AddPropertyFields(string headerText = null) { if (DataObject == null) return; ContentItems.Clear(); var ps = DataObject.GetPropertiesWithAttribute<InspectorProperty>().ToArray(); if (ps.Length < 1) return; if (!string.IsNullOrEmpty(headerText)) ContentItems.Add(new SectionHeaderViewModel() { Name = headerText, }); var data = DataObject; foreach (var property in ps) { PropertyInfo property1 = property.Key; var vm = new PropertyFieldViewModel() { Type = property.Key.PropertyType, Name = property.Key.Name, InspectorType = property.Value.InspectorType, CustomDrawerType = property.Value.CustomDrawerType, Getter = () => property1.GetValue(data, null), DataObject = data, Setter = (d,v) => { property1.SetValue(d, v, null); } }; ContentItems.Add(vm); } IsDirty = true; }
private void AddOutput(NodeInputConfig inputConfig, GenericNode node = null) { if (!IsVisible(inputConfig.Visibility)) { return; } var nodeToUse = node ?? GraphItem; var header = new InputOutputViewModel(); header.Name = inputConfig.Name.GetValue(node); header.DataObject = inputConfig.IsAlias ? DataObject : inputConfig.GetDataObject(nodeToUse); header.OutputConnectorType = inputConfig.SourceType; header.IsInput = false; header.IsOutput = true; if (inputConfig.AttributeInfo != null) { header.IsNewLine = inputConfig.AttributeInfo.IsNewRow; } else { header.IsNewLine = true; } ContentItems.Add(header); ApplyOutputConfiguration(inputConfig, header.DataObject as IGraphItem, header.OutputConnector, true); if (header.InputConnector != null) { header.OutputConnector.Configuration = inputConfig; } }
/// <summary> /// Add a content item to the collection /// </summary> /// <param name="key"></param> /// <param name="type"></param> /// <param name="path"></param> public void Add <T>(string key, string path) { if (Loaded) { throw new InvalidOperationException("Cannot add content while the ContentCollection is loaded"); } if (key is null) { throw new ArgumentNullException(nameof(key)); } if (key.Length == 0) { throw new ArgumentException("key.Length must be > 0", nameof(key)); } if (path is null) { throw new ArgumentNullException(nameof(path)); } if (path.Length == 0) { throw new ArgumentException("path.Length must be > 0", nameof(path)); } if (!(ContentItems.FirstOrDefault(e => e.Key == key).Key is null)) { throw new ArgumentException("Content with given key already exists", nameof(key)); } ContentItems.Add(new ContentItem { Key = key, Type = typeof(T), Path = path }); }
internal void AddContentItem(Item item, float assignedQuantity) { ContentItem contentItem = new ContentItem(); contentItem.OriginalItem = item; contentItem.Quantity = assignedQuantity; ContentItems.Add(contentItem); item.Quantity -= assignedQuantity; }
protected override void CreateContent() { base.CreateContent(); if (Action.Meta == null) { ContentItems.Add(new SectionHeaderViewModel() { Name = "Please Save And Compile", IsNewLine = true }); } }
private void CreateHeader(ShellNodeConfigSection item, object dataObject) { var sectionViewModel = new GenericItemHeaderViewModel() { Name = item.Name, AddCommand = item.AllowAdding ? new LambdaCommand("", () => {}) : null, DataObject = dataObject, NodeViewModel = this, AllowConnections = true, Column = item.Column, ColumnSpan = item.ColumnSpan, IsNewLine = item.IsNewRow }; ContentItems.Add(sectionViewModel); }
private void CreateOutput(ShellNodeConfigOutput output, object dataObject) { var vm = new InputOutputViewModel() { IsInput = false, IsOutput = true, DiagramViewModel = this.DiagramViewModel, Name = output.Name, DataObject = dataObject, Column = output.Column, ColumnSpan = output.ColumnSpan, IsNewLine = output.IsNewRow }; ContentItems.Add(vm); }
private IMongoCollection <MongoContentItem> GetMongoCollection(string type, bool published = false) { string name = $"ContentItems_{type}"; if (published) { name += "_Published"; } if (ContentItems.TryGetValue(name, out IMongoCollection <MongoContentItem>?items) == false) { items = OfmlDb.GetCollection <MongoContentItem>(name); ContentItems.Add(name, items); } return(items); }
protected override void CreateContent() { base.CreateContent(); if (IsVisible(SectionVisibility.WhenNodeIsNotFilter)) { var propertySelection = new InputOutputViewModel() { DataObject = PropertyChangedNode.CollectionIn, Name = "Collection", IsInput = true, IsOutput = false, IsNewLine = true, AllowSelection = true }; ContentItems.Add(propertySelection); AddPropertyFields(); } }
/// <inheritdoc /> public override void Set(IEnumerable <ContentItem> contentItems) { bool anyset = false; foreach (var item in contentItems) { ValidateKey(item.Key); ValidateLocation(item.Location); var contentItem = ContentItems.Find(item.Location, item.Key); if (contentItem == null) { contentItem = ContentItems.Add(new ContentItem { Content = item.Content, Key = item.Key, Location = item.Location, Id = GetId(item.Location, item.Key), OriginalContent = item.OriginalContent }); anyset = true; _cache.AddItem(contentItem); //Add item to current cache } else { if (contentItem.Content != item.Content) { contentItem.Content = item.Content; contentItem.OriginalContent = item.OriginalContent; anyset = true; _cache.UpdateItem(contentItem); //Update item in current cache } } } if (anyset) { _dataContext.SaveChanges(); } }
private async Task <IActionResult> getPageOfItems(string filter, int pageSize, int pageNumber = 1) { string contentQuery = $"documents/search?ref={targetRef}&q={filter}&pageSize={pageSize}&page={pageNumber}"; _log.LogInformation($"Attempting to fetch content at {contentQuery}"); var content = await apiClient.GetStringAsync($"{apiRoot}/{contentQuery}"); var resultsResponse = JsonConvert.DeserializeObject <Prismic.ResultsResponse>(content); _log.LogInformation($"Found {resultsResponse.TotalResultsSize} {contentType} documents: at page {pageNumber} of {resultsResponse.TotalPages} with page size {pageSize}"); if (resultsResponse.TotalResultsSize == 0) { return(new NoContentResult()); } foreach (Result result in resultsResponse.ResultsResults) { if (result.Data != null && !String.IsNullOrEmpty(result.Data.Key) && result.Data.Url != null && result.Data.Url.UrlUrl != null && !String.IsNullOrEmpty(result.Data.Url.UrlUrl.OriginalString)) { ContentItems.Add(new ShortUrlItem() { RowKey = result.Data.Key, Url = result.Data.Url.UrlUrl.OriginalString }); } else { _log.LogWarning($"Skipping result with id {result.Id} as it's missing a valid key or url"); } } if (resultsResponse.TotalPages > pageNumber) { return(await getPageOfItems(filter, pageSize, pageNumber + 1)); } return(new OkResult()); }
protected override void CreateContent() { base.CreateContent(); foreach (var item in GraphItem.DisplayedItems) { var vm = GetDataViewModel(item); if (vm == null) { InvertApplication.LogError(string.Format("Couldn't find view-model for {0}", item.GetType())); continue; } vm.DiagramViewModel = DiagramViewModel; ContentItems.Add(vm); } AddPropertyFields(); }
/// <summary> /// Add a new item to the available filterable items /// </summary> /// <param name="ContentTitle">Title of the content item</param> /// <param name="shortDescription">Short description of the content item</param> /// <param name="description">Details of content item</param> /// <param name="DataObject">The data object being represented</param> /// <param name="imageUrl">Image URL</param> /// <param name="imageDimensions">Dimensions of the image</param> /// <returns>Returns total content items count</returns> public int Add(string ContentTitle, string shortDescription = "", string description = "", object DataObject = null, Uri imageUrl = null, Point imageDimensions = new Point()) { FilterableContentListItem item = new FilterableContentListItem() { ContentTitle = ContentTitle, ContentShortDescription = shortDescription, Details = description, DataObject = DataObject, ImageURI = imageUrl, ImageDimensions = imageDimensions }; if (ContentItems == null) { ContentItems = new ObservableCollection <FilterableContentListItem>(); FilteredItems = new ObservableCollection <FilterableContentListItem>(ContentItems); } ContentItems.Add(item); return(ContentItems.Count); }
protected override void CreateContent() { //base.CreateContent(); foreach (var item in GraphItem.GraphItems.OfType <GenericSlot>()) { var vm = new InputOutputViewModel() { Name = item.Name, IsOutput = item is IActionOut, IsInput = !(item is IActionOut), DataObject = item, IsNewLine = true, DiagramViewModel = DiagramViewModel }; ContentItems.Add(vm); if (vm.InputConnector != null) { vm.InputConnector.Style = ConnectorStyle.Circle; vm.InputConnector.TintColor = UnityEngine.Color.green; } } }
public void AddPropertyFields(string headerText = null) { var ps = GraphItem.GetPropertiesWithAttribute <NodeProperty>().ToArray(); if (ps.Length < 1) { return; } if (!string.IsNullOrEmpty(headerText)) { ContentItems.Add(new SectionHeaderViewModel() { Name = headerText, }); } foreach (var property in ps) { PropertyInfo property1 = property.Key; var vm = new PropertyFieldViewModel(this) { Type = property.Key.PropertyType, Name = property.Key.Name, InspectorType = property.Value.InspectorType, CustomDrawerType = property.Value.CustomDrawerType, Getter = () => property1.GetValue(GraphItem, null), DataObject = GraphItem, DisableInputs = true, DisableOutputs = true, Setter = (d, v) => { property1.SetValue(d, v, null); } }; ContentItems.Add(vm); } }
/// <inheritdoc /> public override ContentItem GetOrCreate(string location, string key, string defaultContent) { ValidateKey(key); ValidateLocation(location); defaultContent = defaultContent ?? ""; //Search the cache in memory to reduce DB calls var cachedContentItem = ContentItemsCached.Find(x => x.Location.Equals(location) && x.Key.Equals(key)); if (cachedContentItem == null) { var newContentItem = ContentItems.Add(new ContentItem { Content = defaultContent, Key = key, Location = location, Id = GetId(location, key), OriginalContent = defaultContent }); _dataContext.SaveChanges(); _cache.AddItem(newContentItem); //Update the cache as well } if (cachedContentItem.OriginalContent != defaultContent) { var contentItem = ContentItems.Find(location, key); contentItem.OriginalContent = defaultContent; _dataContext.SaveChanges(); _cache.UpdateItemContent(contentItem); //Update the cache as well } return(cachedContentItem); }
protected virtual void CreateActionOuts() { foreach (var item in SequenceNode.GraphItems.OfType <IActionOut>()) { var vm = new InputOutputViewModel() { Name = item.Name, DataObject = item, IsOutput = true, IsNewLine = item.ActionFieldInfo == null || item.ActionFieldInfo.DisplayType == null ? true : item.ActionFieldInfo.DisplayType.IsNewLine, DiagramViewModel = DiagramViewModel }; ContentItems.Add(vm); if (!(item is ActionBranch)) { vm.OutputConnector.Style = ConnectorStyle.Circle; vm.OutputConnector.TintColor = UnityEngine.Color.green; } } }
private void AddSection(NodeConfigSectionBase section) { //if (DiagramViewModel != null && DiagramViewModel.CurrentRepository.CurrentFilter.IsAllowed(null, section.SourceType)) return; var section1 = section as NodeConfigSectionBase; if (!IsVisible(section.Visibility)) { return; } if (!string.IsNullOrEmpty(section.Name)) { var header = new GenericItemHeaderViewModel() { Name = section.Name, NodeViewModel = this, NodeConfig = NodeConfig, SectionConfig = section1, }; //if (section.AttributeInfo != null) //{ // header.IsNewLine = inputConfig.AttributeInfo.IsNewRow; //} //else //{ // header.IsNewLine = true; //} header.AddCommand = section1.AllowAdding ? new LambdaCommand("Add Item", () => { OnAdd(section, section1, this); }) : null; ContentItems.Add(header); } if (section1.GenericSelector != null && section1.ReferenceType == null) { foreach (var item in section1.GenericSelector(GraphItem).OfType <IDiagramNodeItem>().OrderBy(p => p.Order)) { if (section.SourceType.IsAssignableFrom(item.GetType())) { var vm = GetDataViewModel(item) as GraphItemViewModel; var itemViewModel = vm as ItemViewModel; if (itemViewModel != null) { itemViewModel.IsEditable = section1.IsEditable; ApplyInputConfiguration(section, item, vm.InputConnector, section.AllowMultipleInputs); ApplyOutputConfiguration(section, item, vm.OutputConnector, section.AllowMutlipleOutputs); } if (vm == null) { InvertApplication.LogError( string.Format( "Couldn't find view-model for {0} in section {1} with child type {2}", item.GetType(), section1.Name, section1.SourceType.Name)); continue; } vm.DiagramViewModel = DiagramViewModel; ContentItems.Add(vm); } else { InvertApplication.LogError(string.Format("Types do not match {0} and {1}", section.SourceType, item.GetType())); } } } else { foreach (var item in GraphItem.PersistedItems) { if (section.SourceType.IsAssignableFrom(item.GetType())) { var vm = GetDataViewModel(item) as ItemViewModel; if (vm == null) { InvertApplication.LogError(string.Format("Couldn't find view-model for {0}", item.GetType())); continue; } vm.IsEditable = section1.IsEditable; vm.DiagramViewModel = DiagramViewModel; if (section1.HasPredefinedOptions) { vm.IsEditable = false; } ApplyInputConfiguration(section, item, vm.InputConnector, section.AllowMultipleInputs); ApplyOutputConfiguration(section, item, vm.OutputConnector, section.AllowMutlipleOutputs); ContentItems.Add(vm); } } } }
internal IList <IPlaceholder> ApplyInDirective(string indirective) { CurrentItems = new List <IPlaceholder>(); ContentItems.Add(indirective, CurrentItems); return(CurrentItems); }
private void AddContentItem(object parameter) { ContentItems.Add(new ContentItem("New content item", DateTime.Now.ToLongDateString())); }
public MainWindowViewModel() { ContentItems.Add(new ContentItem("One", "One's content")); ContentItems.Add(new ContentItem("Two", "Two's content")); ContentItems.Add(new ContentItem("Three", "Three's content")); }
protected override void CreateContent() { var inputs = Handler.HandlerInputs; if (IsVisible(SectionVisibility.WhenNodeIsNotFilter)) { //if (inputs.Length > 0) // ContentItems.Add(new GenericItemHeaderViewModel() // { // Name = "Mappings", // DiagramViewModel = DiagramViewModel, // IsNewLine = true, // }); foreach (var item in inputs) { var vm = new InputOutputViewModel() { DataObject = item, Name = item.Title, IsInput = true, IsOutput = false, IsNewLine = true, AllowSelection = true }; ContentItems.Add(vm); } } else { foreach (var handlerIn in inputs) { var handlerItem = handlerIn.Item; if (handlerItem != null) { foreach (var component in handlerItem.SelectComponents) { var component1 = component; ContentItems.Add(new GenericItemHeaderViewModel() { Name = component.Name, IsBig = true, IsNewLine = true, NodeViewModel = this, }); //ContentItems.Add(new GenericItemHeaderViewModel() //{ // Name = component.Name, // DataObject = component, // IsNewLine = true //}); ContentItems.Add(new GenericItemHeaderViewModel() { Name = "Properties", IsNewLine = true, NodeViewModel = this, //DataObject = component, AddCommand = new LambdaCommand("", () => { var item = new PropertiesChildItem() { Node = component1 }; DiagramViewModel.CurrentRepository.Add(item); item.Name = item.Repository.GetUniqueName("Collection"); item.IsEditing = true; DataObjectChanged(); }) }); foreach (var property in component.Properties) { ContentItems.Add(new ScaffoldNodeTypedChildItem <PropertiesChildItem> .ViewModel(property, this)); } ContentItems.Add(new GenericItemHeaderViewModel() { Name = "Collections", IsNewLine = true, NodeViewModel = this, //DataObject = component, AddCommand = new LambdaCommand("", () => { var item = new CollectionsChildItem { Node = component1 }; DiagramViewModel.CurrentRepository.Add(item); item.Name = item.Repository.GetUniqueName("Collection"); item.IsEditing = true; DataObjectChanged(); }) }); foreach (var property in component.Collections) { ContentItems.Add(new ScaffoldNodeTypedChildItem <CollectionsChildItem> .ViewModel(property, this)); } } } } } base.CreateContent(); }