public static IDrawer CreateDrawer <TDrawerBase>(this IQFrameworkContainer container, ViewModel viewModel) where TDrawerBase : IDrawer { if (_drawers != null) { } if (viewModel == null) { InvertApplication.LogError("Data is null."); return(null); } var drawer = container.ResolveRelation <TDrawerBase>(viewModel.GetType(), viewModel); if (drawer == null) { InvertApplication.Log(String.Format("Couldn't Create drawer for {0}.", viewModel.GetType())); } return(drawer); }
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(); }
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); } } } }
public Color GetColor(IGraphItem dataObject) { try { var item = dataObject as IDiagramNodeItem; if (item != null) { var node = item.Node as GenericNode; if (node != null) { var color = node.Config.GetColor(node); switch (color) { case NodeColor.Black: return(Color.black); case NodeColor.Blue: return(new Color(0.25f, 0.25f, 0.65f)); case NodeColor.DarkDarkGray: return(new Color(0.25f, 0.25f, 0.25f)); case NodeColor.DarkGray: return(new Color(0.45f, 0.45f, 0.45f)); case NodeColor.Gray: return(new Color(0.65f, 0.65f, 0.65f)); case NodeColor.Green: return(new Color(0.00f, 1f, 0f)); case NodeColor.LightGray: return(new Color(0.75f, 0.75f, 0.75f)); case NodeColor.Orange: return(new Color(0.059f, 0.98f, 0.314f)); case NodeColor.Pink: return(new Color(0.059f, 0.965f, 0.608f)); case NodeColor.Purple: return(new Color(0.02f, 0.318f, 0.659f)); case NodeColor.Red: return(new Color(1f, 0f, 0f)); case NodeColor.Yellow: return(new Color(1f, 0.8f, 0f)); case NodeColor.YellowGreen: return(new Color(0.604f, 0.804f, 0.196f)); } } } } catch (Exception ex) { InvertApplication.LogError(string.Format("Node is null on get color {0} : {1}", dataObject.Label, dataObject.Identifier)); } return(Color.white); }