private void buttonUnpatchControllers_Click(object sender, EventArgs e) { foreach (KeyValuePair <IControllerDevice, HashSet <int> > controllerAndOutput in _cachedControllersAndOutputs) { OutputController controller = controllerAndOutput.Key as OutputController; if (controller == null) { continue; } foreach (int i in controllerAndOutput.Value) { IDataFlowComponent outputComponent = controller.GetDataFlowComponentForOutput(controller.Outputs[i]); if (outputComponent == null) { continue; } VixenSystem.DataFlow.ResetComponentSource(outputComponent); } } OnPatchingUpdated(); _UpdateEverything(_cachedElementNodes, _cachedControllersAndOutputs); }
protected virtual void OnComponentRemoved(IDataFlowComponent component) { if (ComponentRemoved != null) { ComponentRemoved(this, new DataFlowComponentEventArgs(component)); } }
private void _RemoveComponentSource(IDataFlowComponent component) { if (component.Source == null) { return; } IDataFlowComponent parent = component.Source.Component; List <IDataFlowComponent> children = null; _componentDestinations.TryGetValue(parent, out children); if (children == null) { Logging.Error("removing the source from a data flow component, but it's not already a child of the source!"); } else { children.Remove(component); if (children.Count == 0) { _componentDestinations.Remove(parent); } } _SetComponentSource(component, null); }
private void buttonSelectSourceElements_Click(object sender, EventArgs e) { List <ElementNode> elementNodesToSelect = new List <ElementNode>(); foreach (KeyValuePair <IControllerDevice, HashSet <int> > controllerAndOutputs in SelectedControllersAndOutputs) { OutputController oc = controllerAndOutputs.Key as OutputController; if (oc == null) { continue; } foreach (int i in controllerAndOutputs.Value) { IDataFlowComponent outputComponent = oc.GetDataFlowComponentForOutput(oc.Outputs[i]); IDataFlowComponent rootComponent = FindRootSourceOfDataComponent(outputComponent); if (rootComponent is ElementDataFlowAdapter) { Element element = (rootComponent as ElementDataFlowAdapter).Element; ElementNode elementNode = VixenSystem.Elements.GetElementNodeForElement(element); if (elementNode != null) { elementNodesToSelect.Add(elementNode); } } } } MasterForm.SelectElements(elementNodesToSelect, true); }
private void buttonUnpatchControllers_Click(object sender, EventArgs e) { int patchedCount = Convert.ToInt32(labelPatchedOutputCount.Text); if (patchedCount > 20) { string message = string.Format("Are you sure you want to unpatch {0} patch points?", patchedCount); //messageBox Arguments are (Text, Title, No Button Visible, Cancel Button Visible) MessageBoxForm.msgIcon = SystemIcons.Question; //this is used if you want to add a system icon to the message form. var messageBox = new MessageBoxForm(message, "Unpatch Controllers?", true, false); messageBox.ShowDialog(); if (messageBox.DialogResult == DialogResult.No) return; } foreach (KeyValuePair<IControllerDevice, HashSet<int>> controllerAndOutput in _cachedControllersAndOutputs) { OutputController controller = controllerAndOutput.Key as OutputController; if (controller == null) continue; foreach (int i in controllerAndOutput.Value) { IDataFlowComponent outputComponent = controller.GetDataFlowComponentForOutput(controller.Outputs[i]); if (outputComponent == null) continue; VixenSystem.DataFlow.ResetComponentSource(outputComponent); } } OnPatchingUpdated(); _UpdateEverything(_cachedElementNodes, _cachedControllersAndOutputs, false); }
public IEnumerable <IDataFlowComponent> GetDestinationsOfComponentOutput(IDataFlowComponent component, int outputIndex) { if (_componentDestinations.ContainsKey(component)) { return(_componentDestinations[component].Where(x => x.Source.OutputIndex == outputIndex)); } return(Enumerable.Empty <IDataFlowComponent>()); }
private void _RemoveComponent(IDataFlowComponent component) { _RemoveAsSource(component); _componentLookup.Remove(component.DataFlowComponentId); OnComponentRemoved(component); }
public IEnumerable <IDataFlowComponent> GetDestinationsOfComponent(IDataFlowComponent component) { if (_componentDestinations.ContainsKey(component)) { return(_componentDestinations[component]); } return(Enumerable.Empty <IDataFlowComponent>()); }
public void AddOutput(CommandOutput output) { _outputMediator.AddOutput(output); IDataFlowComponent component = _adapterFactory.GetAdapter(output); VixenSystem.DataFlow.AddComponent(component); VixenSystem.OutputControllers.AddControllerOutputForDataFlowComponent(component, this, output.Index); }
public void RemoveOutput(CommandOutput output) { _outputMediator.RemoveOutput(output); IDataFlowComponent component = _adapterFactory.GetAdapter(output); VixenSystem.DataFlow.RemoveComponent(component); VixenSystem.OutputControllers.RemoveControllerOutputForDataFlowComponent(component); }
public void RemoveComponent(IDataFlowComponent component) { if (component == null) { throw new ArgumentNullException("component"); } _RemoveComponent(component); }
private bool _CheckComponentSourceForCircularDependency(IDataFlowComponent component, IDataFlowComponentReference source) { if (source == null) { return(false); } return(_CheckComponentSourceForCircularDependency(component, source.Component)); }
public void AddControllerOutputForDataFlowComponent(IDataFlowComponent component, IControllerDevice controller, int outputIndex) { if (_outputDataFlowComponentToController.ContainsKey(component)) { Logging.Error("map already contains link for component: " + component.Name); } _outputDataFlowComponentToController[component] = new Tuple <IControllerDevice, int>(controller, outputIndex); }
private void _RemoveAsSource(IDataFlowComponent component) { IEnumerable <IDataFlowComponent> childComponents = _componentLookup.Values.Where(x => x.Source != null && Equals(x.Source.Component, component)); foreach (IDataFlowComponent childComponent in childComponents) { _RemoveComponentSource(childComponent); } }
private void _RemoveComponentSource(IDataFlowComponent component) { if (component.Source == null) { return; } _SetComponentSource(component, null); }
public bool RemoveControllerOutputForDataFlowComponent(IDataFlowComponent component) { if (component == null) { return(false); } return(_outputDataFlowComponentToController.Remove(component)); }
public void ApplyPatch(DataFlowPatch dataFlowPatch) { IDataFlowComponent component = GetComponent(dataFlowPatch.ComponentId); IDataFlowComponent sourceComponent = GetComponent(dataFlowPatch.SourceComponentId); if (component != null) { SetComponentSource(component, sourceComponent, dataFlowPatch.SourceComponentOutputIndex); } }
public DataFlowPatch(IDataFlowComponent component) { if (component == null) throw new ArgumentNullException("component"); ComponentId = component.DataFlowComponentId; if (component.Source != null) { SourceComponentId = component.Source.Component.DataFlowComponentId; SourceComponentOutputIndex = component.Source.OutputIndex; } }
public DataFlowComponentReference(IDataFlowComponent component, int outputIndex) { if (component == null) { throw new ArgumentNullException("component"); } Component = component; OutputIndex = outputIndex; }
private void _SetComponentSource(IDataFlowComponent component, IDataFlowComponentReference source) { if (Equals(source, component.Source)) { return; } component.Source = source; OnComponentSourceChanged(component); }
private void buttonSelectDestinationOutputs_Click(object sender, EventArgs e) { ControllersAndOutputsSet controllersAndOutputs = new ControllersAndOutputsSet(); foreach (ElementNode selectedElement in SelectedElements) { foreach (ElementNode leafElementNode in selectedElement.GetLeafEnumerator()) { if (leafElementNode == null || leafElementNode.Element == null) { continue; } IDataFlowComponent component = VixenSystem.DataFlow.GetComponent(leafElementNode.Element.Id); if (component == null) { continue; } IEnumerable <IDataFlowComponent> outputComponents = _findComponentsOfTypeInTreeFromComponent(component, typeof(CommandOutputDataFlowAdapter)); foreach (IDataFlowComponent outputComponent in outputComponents) { IControllerDevice controller; int outputIndex; VixenSystem.OutputControllers.getOutputDetailsForDataFlowComponent(outputComponent, out controller, out outputIndex); if (controller == null) { continue; } if (!controllersAndOutputs.ContainsKey(controller)) { controllersAndOutputs[controller] = new HashSet <int>(); } controllersAndOutputs[controller].Add(outputIndex); } } } if (controllersAndOutputs.Count == 0) { var msg = new MessageBoxForm("No controller patch points found.", "Not Found", MessageBoxButtons.OK, SystemIcons.Information); msg.ShowDialog(this); } else { MasterForm.SelectControllersAndOutputs(controllersAndOutputs, true); } }
public void Initialize(IEnumerable <DataFlowPatch> dataFlowPatches) { foreach (DataFlowPatch dataFlowPatch in dataFlowPatches) { IDataFlowComponent childComponent = GetComponent(dataFlowPatch.ComponentId); IDataFlowComponent sourceComponent = GetComponent(dataFlowPatch.SourceComponentId); if (childComponent != null && dataFlowPatch.SourceComponentOutputIndex >= 0 && dataFlowPatch.SourceComponentOutputIndex < sourceComponent.Outputs.Length) { VixenSystem.DataFlow.SetComponentSource(childComponent, sourceComponent, dataFlowPatch.SourceComponentOutputIndex); } } }
private void _RemoveAsSource(IDataFlowComponent component) { List <IDataFlowComponent> childComponents; _componentDestinations.TryGetValue(component, out childComponents); if (childComponents != null) { foreach (IDataFlowComponent childComponent in childComponents.ToArray()) { _RemoveComponentSource(childComponent); } } }
private IDataFlowComponent FindRootSourceOfDataComponent(IDataFlowComponent component) { if (component == null) { return(null); } if (component.Source == null || component.Source.Component == null) { return(component); } return(FindRootSourceOfDataComponent(component.Source.Component)); }
private void _countTypesDescendingFromElements(IEnumerable <ElementNode> elements, out int leafElementCount, out int groupCount, out int filterCount, out IEnumerable <PatchStatusItem <IDataFlowComponentReference> > outputs) { leafElementCount = groupCount = filterCount = 0; List <PatchStatusItem <IDataFlowComponentReference> > outputList = new List <PatchStatusItem <IDataFlowComponentReference> >(); // process each element foreach (var element in elements) { if (_countedNodes.Contains(element)) { continue; } _countedNodes.Add(element); int lec, gc, fc; IEnumerable <PatchStatusItem <IDataFlowComponentReference> > childOutputs; // process any child elements _countTypesDescendingFromElements(element.Children, out lec, out gc, out fc, out childOutputs); outputList.AddRange(childOutputs); if (element.Children.Any()) { gc++; } else { lec++; } IEnumerable <IOutputFilterModuleInstance> filters = _findFiltersThatDescendFromElement(element); fc += filters.Count(); if (element.Element != null) { IDataFlowComponent dfc = VixenSystem.DataFlow.GetComponent(element.Element.Id); childOutputs = _findPatchedAndUnpatchedOutputsFromComponent(dfc); outputList.AddRange(childOutputs); } // do some accounting leafElementCount += lec; groupCount += gc; filterCount += fc; } outputs = outputList; }
private bool _CheckComponentSourceForCircularDependency(IDataFlowComponent component, IDataFlowComponent source) { if (component == null || source == null) { return(false); } if (source == component) { return(true); } return(_CheckComponentSourceForCircularDependency(component, source.Source)); }
public bool SetComponentSource(IDataFlowComponent component, IDataFlowComponentReference source) { if (component == null) { throw new ArgumentNullException("component"); } if (_CheckComponentSourceForCircularDependency(component, source)) { return(false); } _RemoveComponentSource(component); _SetComponentSource(component, source); return(true); }
private void buttonSelectDestinationOutputs_Click(object sender, EventArgs e) { ControllersAndOutputsSet controllersAndOutputs = new ControllersAndOutputsSet(); foreach (ElementNode selectedElement in SelectedElements) { foreach (ElementNode leafElementNode in selectedElement.GetLeafEnumerator()) { if (leafElementNode == null || leafElementNode.Element == null) { continue; } IDataFlowComponent component = VixenSystem.DataFlow.GetComponent(leafElementNode.Element.Id); if (component == null) { continue; } IEnumerable <IDataFlowComponent> outputComponents = _findComponentsOfTypeInTreeFromComponent(component, typeof(CommandOutputDataFlowAdapter)); foreach (IDataFlowComponent outputComponent in outputComponents) { IControllerDevice controller; int outputIndex; VixenSystem.OutputControllers.getOutputDetailsForDataFlowComponent(outputComponent, out controller, out outputIndex); if (controller == null) { continue; } if (!controllersAndOutputs.ContainsKey(controller)) { controllersAndOutputs[controller] = new HashSet <int>(); } controllersAndOutputs[controller].Add(outputIndex); } } } MasterForm.SelectControllersAndOutputs(controllersAndOutputs); }
string ReverseBuildChannelName(IDataFlowComponent component, int outIndex) { string nameVal = component.Outputs[outIndex].Name ?? ""; if (component.Source != null) { if (component.Name.Equals("Color Breakdown")) { nameVal = ReverseBuildChannelName(component.Source.Component, component.Source.OutputIndex) + " " + component.Outputs[outIndex].Name; } else { nameVal = ReverseBuildChannelName(component.Source.Component, component.Source.OutputIndex); } } return(nameVal); }
private void _SetComponentSource(IDataFlowComponent component, IDataFlowComponentReference source) { if (Equals(source, component.Source)) { return; } component.Source = source; if (source != null) { // add the reverse reference (if we're not clearing it) -- track a data component's destinations, to make it easier to find later. if (!_componentDestinations.ContainsKey(source.Component)) { _componentDestinations[source.Component] = new List <IDataFlowComponent>(); } _componentDestinations[source.Component].Add(component); } OnComponentSourceChanged(component); }
private IEnumerable<IDataFlowComponentReference> _FindLeafOutputsOrBreakdownFilters(IDataFlowComponent component) { if (component == null) { yield break; } if (component is ColorBreakdownModule) { yield return new DataFlowComponentReference(component, -1); // this is a bit iffy -- -1 as a component output index -- but hey. } if (component.Outputs == null || component.OutputDataType == DataFlowType.None) { yield break; } for (int i = 0; i < component.Outputs.Length; i++) { IEnumerable<IDataFlowComponent> children = VixenSystem.DataFlow.GetDestinationsOfComponentOutput(component, i); if (!children.Any()) { yield return new DataFlowComponentReference(component, i); } else { foreach (IDataFlowComponent child in children) { foreach (IDataFlowComponentReference result in _FindLeafOutputsOrBreakdownFilters(child)) { yield return result; } } } } }
public static IDataFlowData GetOutputState(IDataFlowComponent dataFlowComponent, int outputIndex) { return (outputIndex < dataFlowComponent.Outputs.Length) ? dataFlowComponent.Outputs[outputIndex].Data : null; }
public DataFlowComponentEventArgs(IDataFlowComponent component) { Component = component; }
string ReverseBuildChannelName(IDataFlowComponent component, int outIndex) { string nameVal = component.Outputs[outIndex].Name ?? ""; if (component.Source != null) { if (component.Name.Equals("Color Breakdown")) { nameVal = ReverseBuildChannelName(component.Source.Component, component.Source.OutputIndex) + " " + component.Outputs[outIndex].Name; } else { nameVal = ReverseBuildChannelName(component.Source.Component, component.Source.OutputIndex); } } return nameVal; }
private IEnumerable<IDataFlowComponent> _findComponentsOfTypeInTreeFromComponent(IDataFlowComponent dataFlowComponent, Type dfctype) { return VixenSystem.DataFlow.GetDestinationsOfComponent(dataFlowComponent) .SelectMany(x => _findComponentsOfTypeInTreeFromComponent(x, dfctype)) .Concat(new[] {dataFlowComponent}) .Where(dfc => dfctype.IsAssignableFrom(dfc.GetType())) ; }
private IDataFlowComponent FindRootSourceOfDataComponent(IDataFlowComponent component) { if (component == null) return null; if (component.Source == null || component.Source.Component == null) return component; return FindRootSourceOfDataComponent(component.Source.Component); }