public SubscriptionCache(ChannelGraph graph, IEnumerable <ITransport> transports) { if (!transports.Any()) { throw new Exception( "No transports are registered. FubuMVC's ServiceBus cannot function without at least one ITransport"); } _graph = graph; _transports = transports; _volatileNodes = new Cache <Uri, ChannelNode>(uri => { var transport = _transports.FirstOrDefault(x => x.Protocol == uri.Scheme); if (transport == null) { throw new UnknownChannelException(uri); } var node = new ChannelNode { Uri = uri, Key = uri.ToString() }; node.Channel = transport.BuildDestinationChannel(node.Uri); return(node); }); }
public object Deserialize(Envelope envelope, ChannelNode node) { var contentType = envelope.ContentType ?? node.AcceptedContentTypes.FirstOrDefault(); if (contentType.IsEmpty()) { throw new EnvelopeDeserializationException($"No content type can be determined for {envelope}"); } if (envelope.Data == null || envelope.Data.Length == 0) { throw new EnvelopeDeserializationException($"No data on the Envelope"); } // TODO -- fancier later with message mapping if (_serializers.ContainsKey(contentType)) { var serializer = _serializers[contentType]; using (var stream = new MemoryStream(envelope.Data)) { try { return(serializer.Deserialize(stream)); } catch (Exception ex) { throw new EnvelopeDeserializationException("Message serializer has failed", ex); } } } throw new EnvelopeDeserializationException($"Unknown content-type '{contentType}'"); }
public EnvelopeSent(EnvelopeToken envelope, ChannelNode node) { Envelope = envelope; Uri = node.Uri; Key = node.Key; }
// renders the given node to the internal ChannelData dictionary. If the given node is // not a channel, will recursively descend until we render its channels. private void RenderNode(ChannelNode node) { foreach(Channel channel in node) { // this is probably always going to be a single channel for the given node, as // we have iterated down to leaf nodes in RenderNode() above. May as well do // it this way, though, in case something changes in future. if(channel == null) continue; double[] allPointsTimeOrdered = _GetAllSignificantDataPoints().ToArray(); Debug.Assert(allPointsTimeOrdered.Length > 1); double lastPosition = allPointsTimeOrdered[0]; for(int i=1; i<allPointsTimeOrdered.Length; i++) { double position = allPointsTimeOrdered[i]; LightingValue startValue = new LightingValue(ColorGradient.GetColorAt(lastPosition), (float)LevelCurve.GetValue(lastPosition * 100) / 100); LightingValue endValue = new LightingValue(ColorGradient.GetColorAt(position), (float)LevelCurve.GetValue(position * 100) / 100); TimeSpan startTime = TimeSpan.FromMilliseconds(TimeSpan.TotalMilliseconds * lastPosition); TimeSpan timeSpan = TimeSpan.FromMilliseconds(TimeSpan.TotalMilliseconds * (position - lastPosition)); IIntent intent = new LightingIntent(startValue, endValue, timeSpan); _channelData.AddIntentForChannel(channel.Id, intent, startTime); lastPosition = position; } } }
public Receiver(IHandlerPipeline pipeline, ChannelGraph graph, ChannelNode node) { _pipeline = pipeline; _graph = graph; _node = node; _address = node.Uri; }
public ChannelNodeDefinition(string name = null, ChannelNode node = null) { if(name != null) { FilePath = name; } Node = node; }
public override Node VisitChannel(ChannelNode channel) { Markup("<code>"); Text($"#{((IChannel)_discord.GetChannel(channel.Id)).Name}"); Markup("</code>"); return(channel); }
public void SetUp() { theEnvelope = new Envelope() { Data = new byte[] { 1, 2, 3, 4 }, }; theSerializer = MockRepository.GenerateMock <IEnvelopeSerializer>(); theEnvelope.Headers["A"] = "1"; theEnvelope.Headers["B"] = "2"; theEnvelope.Headers["C"] = "3"; theEnvelope.CorrelationId = Guid.NewGuid().ToString(); theChannel = new RecordingChannel(); theNode = new ChannelNode { Channel = theChannel, Key = "Foo", Uri = "foo://bar".ToUri() }; theNode.Modifiers.Add(new HeaderSetter("D", "4")); theNode.Modifiers.Add(new HeaderSetter("E", "5")); theNode.Send(theEnvelope, theSerializer); }
private async Task invoke(Envelope envelope, ChannelNode receiver, DateTime now) { using (var context = new EnvelopeContext(this, envelope, _sender)) { if (envelope.IsDelayed(now)) { moveToDelayedMessageQueue(envelope, context); } else if (envelope.ResponseId.IsNotEmpty()) { completeRequestWithRequestedResponse(envelope, receiver); } else { try { deserialize(envelope, receiver); } catch (Exception e) { Logger.MessageFailed(envelope, e); envelope.Callback.MoveToErrors(new ErrorReport(envelope, e)); return; } finally { Logger.Received(envelope); } await ProcessMessage(envelope, context).ConfigureAwait(false); } } }
public IMessageSerializer SelectSerializer(Envelope envelope, ChannelNode node) { if (envelope.ContentType.IsNotEmpty()) { return(_serializers.ContainsKey(envelope.ContentType) ? _serializers[envelope.ContentType] : null); } string mimeType = null; if (envelope.AcceptedContentTypes.Any()) { mimeType = chooseContentType(envelope); } // It's perfectly possible to not have a matching, static ChannelNode here else if (node != null && node.AcceptedContentTypes.Any()) { mimeType = chooseContentType(node); } else { mimeType = chooseContentType(_graph); } return(mimeType.IsEmpty() ? null : _serializers[mimeType]); }
public ChannelNodeDefinition(string name = null, ChannelNode node = null) { if (name != null) { FilePath = name; } Node = node; }
protected override IChannel buildChannel(ChannelNode channelNode) { var uri = new LightningUri(channelNode.Uri); return(channelNode.Mode == ChannelMode.DeliveryGuaranteed ? LightningQueuesChannel.BuildPersistentChannel(uri, _queues, _settings.MapSize, _settings.MaxDatabases, channelNode.Incoming) : LightningQueuesChannel.BuildNoPersistenceChannel(uri, _queues, channelNode.Incoming)); }
public void setting_address_has_to_be_a_Uri() { var node = new ChannelNode(); Exception <ArgumentOutOfRangeException> .ShouldBeThrownBy(() => { node.SettingAddress = ReflectionHelper.GetAccessor <FakeThing>(x => x.Name); }); }
private void deserialize(Envelope envelope, ChannelNode receiver) { // TODO -- Not super duper wild about this one. if (envelope.Message == null) { envelope.Message = _serializer.Deserialize(envelope, receiver); } }
private ChannelNode FindChannel(string name) { if (ChannelRootNode == null) { ChannelRootNode = this.FindRootNode <ChannelNode>(); } return(FindNode(ChannelRootNode, node => node.Name.Trim().Equals(name.Trim(), StringComparison.CurrentCultureIgnoreCase))); }
private void Drop(ChannelNode channelNode, Point point) { var channel = channelNode.Parents.FirstOrDefault(x => x.IsRgbNode()) ?? channelNode; var channelLocation = new ChannelLocation { LeftOffset = point.X, TopOffset = point.Y, ChannelId = channel.Id }; ChannelLocations.Add(channelLocation); }
private List<string> _topDisplayedNodes; // TreeNode paths that are at the top of the view. Should only #endregion Fields #region Constructors public ConfigChannels() { InitializeComponent(); _displayedNode = null; _tooltip = new ToolTip(); multiSelectTreeviewChannelsGroups.DragFinishing += multiSelectTreeviewChannelsGroupsDragFinishingHandler; multiSelectTreeviewChannelsGroups.DragOverVerify += multiSelectTreeviewChannelsGroupsDragVerifyHandler; multiSelectTreeviewChannelsGroups.Deselected += multiSelectTreeviewChannelsGroups_DeselectedHandler; }
void projectTree_ItemDrag(object sender, ItemDragEventArgs e) { if ((e.Item as TreeNode).Tag != null && (e.Item as TreeNode).Tag is ChannelNode) { //By some reason I cannot pass channelNode object to this function. therefore I send just channel id string. //We need better solution here. ChannelNode node = (e.Item as TreeNode).Tag as ChannelNode; DoDragDrop(node.FullId, DragDropEffects.All); } }
public void use_channel_node_default_content_type_if_it_exists_and_not_set_on_the_envelope() { theGraph.DefaultContentType = serializers[4].ContentType; var node = new ChannelNode { DefaultContentType = serializers[1].ContentType }; ClassUnderTest.SelectSerializer(theEnvelope, node) .ShouldBeTheSameAs(serializers[1]); }
public void setting_default_content_type_will_clear_the_serializer() { var node = new ChannelNode(); node.DefaultSerializer = new BinarySerializer(); node.DefaultContentType = "application/xml"; node.DefaultContentType.ShouldBe("application/xml"); node.DefaultSerializer.ShouldBeNull(); }
public void FixtureSetup() { FubuTransport.AllQueuesInMemory = true; theRuntime = FubuTransport.For(x => { }).StructureMap(new Container()).Bootstrap(); graph = theRuntime.Factory.Get <ChannelGraph>(); var uri = graph.ReplyChannelFor(InMemoryChannel.Protocol); theReplyNode = graph.Single(x => x.Channel.Address == uri); }
public ReceiverContentTypeHandling() { theGraph = new ChannelGraph(); theNode = new ChannelNode(new Uri("memory://foo")); thePipeline = new RecordingHandlerPipeline(); theCallback = Substitute.For <IMessageCallback>(); theReceiver = new Receiver(thePipeline, theGraph, theNode); }
private static void addDescriptionCell(TableRowTag row, ChannelNode channel) { var cell = row.Cell(); cell.Add("h5").Text(channel.Key); cell.Add("div/i").Text(channel.Uri.ToString()); if (channel.DefaultContentType != null) { cell.Add("div").Text("Default Content Type: " + channel.DefaultContentType); } }
public void use_a_serializer_on_the_channel_node_as_the_default_if_content_type_is_not_explicitly_set() { theGraph.DefaultContentType = serializers[4].ContentType; var node = new ChannelNode { DefaultSerializer = MockRepository.GenerateMock <IMessageSerializer>() }; ClassUnderTest.SelectSerializer(theEnvelope, node) .ShouldBeTheSameAs(node.DefaultSerializer); }
private void addRow(TableRowTag row, ChannelNode channel) { addDescriptionCell(row, channel); addSchedulers(row, channel); addRoutingRules(row, channel); addSerialization(row, channel); addModifiers(row, channel); }
private ChannelNode _ReadChannelNode(XElement element) { string name = element.Attribute(ATTR_NAME).Value; Guid id = Guid.Parse(element.Attribute(ATTR_ID).Value); // check if we have already loaded the node with this GUID (ie. if it's a node that's referenced twice, // in different groups). If we have, return that node instead, and don't go any deeper into child nodes. // (we'll just assume that the XML data for this one is identical to the earlier XML node that was written // out. To be a bit more proper, we should probably change the WriteXML() to not fully write out repeat // ChannelNodes, and instead do some sort of soft reference to the first one (ie. GUID only). ) ChannelNode existingNode = VixenSystem.Nodes.GetChannelNode(id); if (existingNode != null) { return(existingNode); } // Children or channel reference ChannelNode node = null; if (element.Attribute(ATTR_CHANNEL_ID) == null) { // Branch node = new ChannelNode(id, name, null, element.Elements(ELEMENT_NODE).Select(_ReadChannelNode)); } else { // Leaf Guid channelId = Guid.Parse(element.Attribute(ATTR_CHANNEL_ID).Value); Channel channel = _channels.FirstOrDefault(x => x.Id == channelId); if (channel != null) { node = new ChannelNode(id, name, channel, null); } } if (node != null) { // Property data // It's not necessary to load the data before the properties, but it will // save it from creating data for each module and then dumping it. string moduleDataString = element.Element(ELEMENT_PROPERTY_DATA).InnerXml(); node.Properties.PropertyData.Deserialize(moduleDataString); // Properties foreach (XElement propertyElement in element.Element(ELEMENT_PROPERTIES).Elements(ELEMENT_PROPERTY)) { node.Properties.Add(new Guid(propertyElement.Value)); } } return(node); }
public void publishes_is_false_if_no_rules_pass() { var node = new ChannelNode(); for (int i = 0; i < 5; i++) { node.Rules.Add(MockRepository.GenerateMock <IRoutingRule>()); } node.Publishes(typeof(NewUser)).ShouldBeFalse(); }
/* * Changes * 1.) Do serialization within sendToChannel * 2.) do the cloning *outside* of sendToChannel * 3.) Make envelopeserializer smart enough not to replace the contents if it needs to */ private void sendToChannel(Envelope envelope, ChannelNode node) { var replyUri = _router.ReplyUriFor(node); var headers = node.Send(envelope, _serializer, replyUri: replyUri); _logger.InfoMessage(() => new EnvelopeSent(new EnvelopeToken { Headers = headers, Message = envelope.Message }, node)); }
private void completeRequestWithRequestedResponse(Envelope envelope, ChannelNode receiver) { try { deserialize(envelope, receiver); _replies.Handle(envelope); } catch (Exception e) { Logger.LogException(e, envelope.CorrelationId, "Failure during reply handling."); } }
public void SetUp() { theGraph = new ChannelGraph(); theNode = new ChannelNode(); theNode.Channel = new InMemoryChannel(new Uri("memory://foo")); theInvoker = new RecordingHandlerPipeline(); theCallback = MockRepository.GenerateMock <IMessageCallback>(); theLogger = new RecordingLogger(); theReceiver = new Receiver(theInvoker, theGraph, theNode); }
private void addModifiers(TableRowTag row, ChannelNode channel) { var cell = row.Cell().AddClass("modifiers"); if (channel.Modifiers.Any()) { cell.Add("ul", ul => { channel.Modifiers.Each(x => ul.Add("li").Text(x.ToString())); }); } else { cell.Text("None"); } }
private static void addRoutingRules(TableRowTag row, ChannelNode channel) { var cell = row.Cell().AddClass("routing-rules"); if (channel.Rules.Any()) { cell.Add("ul", ul => { channel.Rules.Each(x => ul.Add("li").Text(x.Describe())); }); } else { cell.Text("None"); } }
public void publishes_is_true_if_any_rule_passes() { var node = new ChannelNode(); for (int i = 0; i < 5; i++) { node.Rules.Add(MockRepository.GenerateMock <IRoutingRule>()); } node.Rules[2].Stub(x => x.Matches(typeof(NewUser))).Return(true); node.Publishes(typeof(NewUser)).ShouldBeTrue(); }
private void Drop(ChannelNode channelNode, Point point) { var channel = channelNode; var channelLocation = new NodeLayout { LeftOffset = point.X, TopOffset = point.Y, NodeId = channel.Id }; NodeLayouts.Add(channelLocation); }
private void DeleteNode(TreeNode tn) { ChannelNode cn = tn.Tag as ChannelNode; ChannelNode parent = (tn.Parent != null) ? tn.Parent.Tag as ChannelNode : null; VixenSystem.Nodes.RemoveNode(cn, parent, true); if (_displayedNode == cn) { _displayedNode = null; } }
private int GetNodeParentGroupCount(ChannelNode node) { int count = node.Parents.Count(); if(VixenSystem.Nodes.GetRootNodes().Contains(node)) count--; return count; }
private ChannelNodeShape _CreateShapeFromChannel(ChannelNode node) { ChannelNodeShape channelShape = _MakeChannelNodeShape(node, 1); if (channelShape != null) _channelShapes.Add(channelShape); return channelShape; }
private List<string> GetNodeParentGroupNames(ChannelNode node, int maxNames = Int32.MaxValue) { List<string> result = new List<string>(); foreach (ChannelNode parent in node.Parents) { if (maxNames <= 0) { break; } if (parent.Name != "Root") { result.Add(parent.Name); } maxNames--; } return result; }
private ChannelNode AddSingleNodeWithPrompt(ChannelNode parent = null) { // since we're only adding a single node, prompt with a single text dialog. using (TextDialog textDialog = new TextDialog("Channel Name?")) { if (textDialog.ShowDialog() == DialogResult.OK) { string newName; if (textDialog.Response == "") newName = "New Channel"; else newName = textDialog.Response; return AddNewNode(newName, true, parent); } } return null; }
private static PositionMap _ParseChildren(ChannelNode parentNode, PositionValue parentPosition) { // Traverse every node. Nodes with the position property will affect the childrens' // positions. PositionMap childValues = new PositionMap(); PositionModule positionProperty = parentNode.Properties.Get(PositionDescriptor._typeId) as PositionModule; foreach(ChannelNode childNode in parentNode.Children) { PositionValue childPosition = positionProperty.GetPositionValues(childNode.Id); if(childPosition != null) { // Parent has a modifying position for the child. childPosition = _Multiply(parentPosition, childPosition); } else { // Child inherits parent's position. childPosition = new PositionValue(parentPosition); } childValues[childNode.Id] = childPosition; childValues.AddRange(_ParseChildren(childNode, childPosition)); } return childValues; }
private void PopulatePropertiesArea(ChannelNode node) { listViewProperties.BeginUpdate(); listViewProperties.Items.Clear(); if (node != null) { foreach (IPropertyModuleInstance property in node.Properties) { ListViewItem item = new ListViewItem(); item.Text = property.Descriptor.TypeName; item.Tag = property; listViewProperties.Items.Add(item); } listViewProperties.SelectedItems.Clear(); } listViewProperties.EndUpdate(); PopulatePropertiesButtons(); }
private bool CheckIfNodeWillLosePatches(ChannelNode node) { if (node != null && node.Channel != null) { if (VixenSystem.DataFlow.GetChildren(VixenSystem.Channels.GetDataFlowComponentForChannel(node.Channel)).Any()) { string message = "Adding items to this Channel will convert it into a Group, which will remove any " + "patches it may have. Are you sure you want to continue?"; string title = "Convert Channel to Group?"; DialogResult result = MessageBox.Show(message, title, MessageBoxButtons.YesNoCancel); if (result != DialogResult.Yes) { return true; } } } return false; }
private void GeneratePulse(ChannelNode target, TimeSpan startTime, TimeSpan duration, double currentMovementPosition) { EffectIntents result; Pulse.Pulse pulse = new Pulse.Pulse(); pulse.TargetNodes = new ChannelNode[] { target }; pulse.TimeSpan = duration; pulse.LevelCurve = new Curve(PulseCurve); // figure out what color gradient to use for the pulse switch (ColorHandling) { case ChaseColorHandling.GradientForEachPulse: pulse.ColorGradient = ColorGradient; break; case ChaseColorHandling.GradientThroughWholeEffect: double startPos = ((double)startTime.Ticks / (double)TimeSpan.Ticks); double endPos = ((double)(startTime + duration).Ticks / (double)TimeSpan.Ticks); if (startPos < 0.0) startPos = 0.0; if (endPos > 1.0) endPos = 1.0; pulse.ColorGradient = ColorGradient.GetSubGradient(startPos, endPos); break; case ChaseColorHandling.StaticColor: pulse.ColorGradient = new ColorGradient(StaticColor); break; case ChaseColorHandling.ColorAcrossItems: pulse.ColorGradient = new ColorGradient(ColorGradient.GetColorAt(currentMovementPosition / 100.0)); break; } result = pulse.Render(); result.OffsetAllCommandsByTime(startTime); _channelData.Add(result); }
public NodeSource(ChannelNode node) { _node = node; Children = _node.Children.Select(x => new NodeSource(x)); NodeName = node.Name; }
private ChannelNodeShape _MakeChannelNodeShape(ChannelNode node, int zOrder) { ChannelNodeShape shape = (ChannelNodeShape) project.ShapeTypes["ChannelNodeShape"].CreateInstance(); shape.SetChannelNode(node); shape.Title = node.Name; diagramDisplay.InsertShape(shape); diagramDisplay.Diagram.Shapes.SetZOrder(shape, zOrder); diagramDisplay.Diagram.AddShapeToLayers(shape, _visibleLayer.Id); if (!_channelNodeToChannelShapes.ContainsKey(node)) _channelNodeToChannelShapes[node] = new List<ChannelNodeShape>(); _channelNodeToChannelShapes[node].Add(shape); if (shape.DataFlowComponent != null) { if (!_dataFlowComponentToShapes.ContainsKey(shape.DataFlowComponent)) _dataFlowComponentToShapes[shape.DataFlowComponent] = new List<FilterSetupShapeBase>(); _dataFlowComponentToShapes[shape.DataFlowComponent].Add(shape); } if (node.Children.Count() > 0) { foreach (var child in node.Children) { FilterSetupShapeBase childSetupShapeBase = _MakeChannelNodeShape(child, zOrder + 1); shape.ChildFilterShapes.Add(childSetupShapeBase); } shape.SecurityDomainName = SECURITY_DOMAIN_FIXED_SHAPE_NO_CONNECTIONS; shape.FillStyle = project.Design.FillStyles["ChannelGroup"]; } else { shape.SecurityDomainName = SECURITY_DOMAIN_FIXED_SHAPE_WITH_CONNECTIONS; shape.FillStyle = project.Design.FillStyles["ChannelLeaf"]; } return shape; }
private static DragDropEffects GetDropEffects(ChannelNode channelNode) { return channelNode.IsLeaf || channelNode.IsRgbNode() ? DragDropEffects.Move : DragDropEffects.None; }
private static bool _HaveMap(ChannelNode node) { return _nodePositionMap.ContainsKey(node.Id); }
private static void _ParseNode(ChannelNode node) { PositionValue positionValue = new PositionValue(0, 1); PositionMap positions = _ParseChildren(node, positionValue); _nodePositionMap.AddRange(positions); }
private void PopulateGeneralNodeInfo(ChannelNode node) { if (node == null) { labelParents.Text = ""; _tooltip.SetToolTip(labelParents, null); textBoxName.Text = ""; } else { // update the label with parent info about the node. Any good suggestions or improvements for this? int parentCount = GetNodeParentGroupCount(node); List<string> parents = GetNodeParentGroupNames(node); string labelString = "", tooltipString = ""; labelString = "This channel is in " + parentCount + " group" + ((parentCount != 1) ? "s" : "") + ((parentCount == 0) ? "." : ": "); tooltipString = labelString + "\r\n\r\n"; foreach (string p in parents) { labelString = labelString + p + ", "; tooltipString = tooltipString + p + "\r\n"; } labelParents.Text = labelString.TrimEnd(new char[] { ' ', ',' }); tooltipString = tooltipString.TrimEnd(new char[] { '\r', '\n' }); if (labelString.Length > 100) { _tooltip.SetToolTip(labelParents, tooltipString); } else { _tooltip.SetToolTip(labelParents, null); } textBoxName.Text = node.Name; } }
private void PopulateFormWithNode(ChannelNode node, bool forceUpdate) { if (node == _displayedNode && !forceUpdate) return; _displayedNode = node; PopulateGeneralNodeInfo(node); PopulatePropertiesArea(node); groupBoxSelectedNode.Enabled = (node != null); buttonDeleteChannel.Enabled = (multiSelectTreeviewChannelsGroups.SelectedNodes.Count > 0) && (node != null); buttonCreateGroup.Enabled = (multiSelectTreeviewChannelsGroups.SelectedNodes.Count > 0) && (node != null); buttonRename.Enabled = (multiSelectTreeviewChannelsGroups.SelectedNodes.Count > 0) && (node != null); }
/// <summary> /// Adds a single given channel node as a row in the timeline control. Recursively adds all /// child nodes of the given node as children, if needed. /// </summary> /// <param name="node">The node to generate a row for.</param> /// <param name="parentRow">The parent node the row should belong to, if any.</param> private void addNodeAsRow(ChannelNode node, Row parentRow) { // made the new row from the given node and add it to the control. TimedSequenceRowLabel label = new TimedSequenceRowLabel(); label.Name = node.Name; Row newRow = timelineControl.AddRow(label, parentRow, 32); newRow.ElementRemoved += ElementRemovedFromRowHandler; newRow.ElementAdded += ElementAddedToRowHandler; // Tag it with the node it refers to, and take note of which row the given channel node will refer to. newRow.Tag = node; if(_channelNodeToRows.ContainsKey(node)) _channelNodeToRows[node].Add(newRow); else _channelNodeToRows[node] = new List<Row> {newRow}; // iterate through all if its children, adding them as needed foreach(ChannelNode child in node.Children) { addNodeAsRow(child, newRow); } }
public ChannelSource(ChannelNode channelNode) { _channelNode = channelNode; Children = _channelNode.Children.Select(x => new ChannelSource(x)); ChannelNodeName = channelNode.Name; }
private IEnumerable<ChannelNode> AddMultipleNodesWithPrompt(ChannelNode parent = null) { List<ChannelNode> result = new List<ChannelNode>(); // since we're adding multiple nodes, prompt with the name generation form (which also includes a counter on there). using (NameGenerator nameGenerator = new NameGenerator()) { if (nameGenerator.ShowDialog() == DialogResult.OK) { result.AddRange(nameGenerator.Names.Where(name => !string.IsNullOrEmpty(name)).Select(name => AddNewNode(name, false, parent, true))); PopulateNodeTree(); } } return result; }
private ChannelNode AddNewNode(string nodeName, bool repopulateNodeTree = true, ChannelNode parent = null, bool skipPatchCheck = false) { // prompt the user if it's going to make a patched leaf a group; if they abandon it, return null if (!skipPatchCheck && CheckIfNodeWillLosePatches(parent)) return null; ChannelNode newNode = ChannelNodeService.Instance.CreateSingle(parent, nodeName, true); if (repopulateNodeTree) PopulateNodeTree(); return newNode; }
private void AddNodeToTree(TreeNodeCollection collection, ChannelNode channelNode) { TreeNode addedNode = new TreeNode(); addedNode.Name = channelNode.Id.ToString(); addedNode.Text = channelNode.Name; addedNode.Tag = channelNode; if (!channelNode.Children.Any()) { if (channelNode.Channel != null && VixenSystem.DataFlow.GetChildren(VixenSystem.Channels.GetDataFlowComponentForChannel(channelNode.Channel)).Any()) { if (channelNode.Channel.Masked) addedNode.ImageKey = addedNode.SelectedImageKey = "RedBall"; else addedNode.ImageKey = addedNode.SelectedImageKey = "GreenBall"; } else addedNode.ImageKey = addedNode.SelectedImageKey = "WhiteBall"; } else { addedNode.ImageKey = addedNode.SelectedImageKey = "Group"; } collection.Add(addedNode); foreach (ChannelNode childNode in channelNode.Children) { AddNodeToTree(addedNode.Nodes, childNode); } }
private static DragDropEffects GetDropEffects(ChannelNode channelNode) { return channelNode != null && (channelNode.IsLeaf) ? DragDropEffects.Move : DragDropEffects.None; }
private IntentNodeCollection RenderChannel(ChannelNode node, double positionWithinGroup, List<IndividualTwinkleDetails> twinkles = null) { if (node == null) return null; if (twinkles == null) twinkles = GenerateTwinkleData(); EffectIntents result = new EffectIntents(); // render the flat 'minimum value' across the entire effect Pulse.Pulse pulse = new Pulse.Pulse(); pulse.TargetNodes = new ChannelNode[] { node }; pulse.TimeSpan = TimeSpan; pulse.LevelCurve = new Curve(new PointPairList(new double[] { 0, 100 }, new double[] { MinimumLevel * 100.0, MinimumLevel * 100.0 })); // figure out what color gradient to use for the pulse switch (ColorHandling) { case TwinkleColorHandling.GradientForEachPulse: pulse.ColorGradient = new ColorGradient(ColorGradient.GetColorAt(0)); break; case TwinkleColorHandling.GradientThroughWholeEffect: pulse.ColorGradient = ColorGradient; break; case TwinkleColorHandling.StaticColor: pulse.ColorGradient = new ColorGradient(StaticColor); break; case TwinkleColorHandling.ColorAcrossItems: pulse.ColorGradient = new ColorGradient(ColorGradient.GetColorAt(positionWithinGroup)); break; } EffectIntents pulseData = pulse.Render(); result.Add(pulseData); // render all the individual twinkles foreach (IndividualTwinkleDetails twinkle in twinkles) { { // make a pulse for it pulse = new Pulse.Pulse(); pulse.TargetNodes = new ChannelNode[] { node }; pulse.TimeSpan = twinkle.Duration; pulse.LevelCurve = twinkle.TwinkleCurve; // figure out what color gradient to use for the pulse switch (ColorHandling) { case TwinkleColorHandling.GradientForEachPulse: pulse.ColorGradient = ColorGradient; break; case TwinkleColorHandling.GradientThroughWholeEffect: double startPos = ((double)twinkle.StartTime.Ticks / (double)TimeSpan.Ticks); double endPos = ((double)(twinkle.StartTime + twinkle.Duration).Ticks / (double)TimeSpan.Ticks); pulse.ColorGradient = ColorGradient.GetSubGradient(startPos, endPos); break; case TwinkleColorHandling.StaticColor: pulse.ColorGradient = new ColorGradient(StaticColor); break; case TwinkleColorHandling.ColorAcrossItems: pulse.ColorGradient = new ColorGradient(ColorGradient.GetColorAt(positionWithinGroup)); break; } pulseData = pulse.Render(); pulseData.OffsetAllCommandsByTime(twinkle.StartTime); result.Add(pulseData); } } return result.GetIntentNodesForChannel(node.Channel.Id); }