예제 #1
0
        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);
        }
예제 #2
0
 protected virtual void OnComponentRemoved(IDataFlowComponent component)
 {
     if (ComponentRemoved != null)
     {
         ComponentRemoved(this, new DataFlowComponentEventArgs(component));
     }
 }
예제 #3
0
        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);
        }
예제 #4
0
        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);
        }
예제 #5
0
        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);
        }
예제 #6
0
 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>());
 }
예제 #7
0
        private void _RemoveComponent(IDataFlowComponent component)
        {
            _RemoveAsSource(component);

            _componentLookup.Remove(component.DataFlowComponentId);

            OnComponentRemoved(component);
        }
예제 #8
0
 public IEnumerable <IDataFlowComponent> GetDestinationsOfComponent(IDataFlowComponent component)
 {
     if (_componentDestinations.ContainsKey(component))
     {
         return(_componentDestinations[component]);
     }
     return(Enumerable.Empty <IDataFlowComponent>());
 }
예제 #9
0
        public void AddOutput(CommandOutput output)
        {
            _outputMediator.AddOutput(output);
            IDataFlowComponent component = _adapterFactory.GetAdapter(output);

            VixenSystem.DataFlow.AddComponent(component);
            VixenSystem.OutputControllers.AddControllerOutputForDataFlowComponent(component, this, output.Index);
        }
예제 #10
0
        public void RemoveOutput(CommandOutput output)
        {
            _outputMediator.RemoveOutput(output);
            IDataFlowComponent component = _adapterFactory.GetAdapter(output);

            VixenSystem.DataFlow.RemoveComponent(component);
            VixenSystem.OutputControllers.RemoveControllerOutputForDataFlowComponent(component);
        }
예제 #11
0
        public void RemoveComponent(IDataFlowComponent component)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            _RemoveComponent(component);
        }
예제 #12
0
        private bool _CheckComponentSourceForCircularDependency(IDataFlowComponent component, IDataFlowComponentReference source)
        {
            if (source == null)
            {
                return(false);
            }

            return(_CheckComponentSourceForCircularDependency(component, source.Component));
        }
예제 #13
0
        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);
        }
예제 #14
0
        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);
            }
        }
예제 #15
0
        private void _RemoveComponentSource(IDataFlowComponent component)
        {
            if (component.Source == null)
            {
                return;
            }

            _SetComponentSource(component, null);
        }
예제 #16
0
        public bool RemoveControllerOutputForDataFlowComponent(IDataFlowComponent component)
        {
            if (component == null)
            {
                return(false);
            }

            return(_outputDataFlowComponentToController.Remove(component));
        }
예제 #17
0
        public void ApplyPatch(DataFlowPatch dataFlowPatch)
        {
            IDataFlowComponent component       = GetComponent(dataFlowPatch.ComponentId);
            IDataFlowComponent sourceComponent = GetComponent(dataFlowPatch.SourceComponentId);

            if (component != null)
            {
                SetComponentSource(component, sourceComponent, dataFlowPatch.SourceComponentOutputIndex);
            }
        }
예제 #18
0
		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;
			}
		}
예제 #19
0
        public DataFlowComponentReference(IDataFlowComponent component, int outputIndex)
        {
            if (component == null)
            {
                throw new ArgumentNullException("component");
            }

            Component   = component;
            OutputIndex = outputIndex;
        }
예제 #20
0
        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;
            }
        }
예제 #21
0
        private void _SetComponentSource(IDataFlowComponent component, IDataFlowComponentReference source)
        {
            if (Equals(source, component.Source))
            {
                return;
            }

            component.Source = source;

            OnComponentSourceChanged(component);
        }
예제 #22
0
        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);
            }
        }
예제 #23
0
 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);
         }
     }
 }
예제 #24
0
        private void _RemoveAsSource(IDataFlowComponent component)
        {
            List <IDataFlowComponent> childComponents;

            _componentDestinations.TryGetValue(component, out childComponents);
            if (childComponents != null)
            {
                foreach (IDataFlowComponent childComponent in childComponents.ToArray())
                {
                    _RemoveComponentSource(childComponent);
                }
            }
        }
예제 #25
0
        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));
        }
예제 #26
0
        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;
        }
예제 #27
0
        private bool _CheckComponentSourceForCircularDependency(IDataFlowComponent component, IDataFlowComponent source)
        {
            if (component == null || source == null)
            {
                return(false);
            }

            if (source == component)
            {
                return(true);
            }

            return(_CheckComponentSourceForCircularDependency(component, source.Source));
        }
예제 #28
0
        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);
        }
예제 #29
0
        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);
        }
예제 #30
0
        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);
        }
예제 #31
0
        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);
        }
예제 #32
0
        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;
                        }
                    }
                }
            }
        }
예제 #33
0
파일: Helper.cs 프로젝트: stewmc/vixen
 public static IDataFlowData GetOutputState(IDataFlowComponent dataFlowComponent, int outputIndex)
 {
     return (outputIndex < dataFlowComponent.Outputs.Length) ? dataFlowComponent.Outputs[outputIndex].Data : null;
 }
예제 #34
0
 public DataFlowComponentEventArgs(IDataFlowComponent component)
 {
     Component = component;
 }
예제 #35
0
파일: Export.cs 프로젝트: naztrain/vixen
        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;
        }
예제 #36
0
 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()))
         ;
 }
예제 #37
0
        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);
        }