Example #1
0
        static void AddPacketsToDocument(IDocumentObject doc, LogPacket[] packets)
        {
            PacketLogDocument packetLog = doc as PacketLogDocument;
            TestDocument testDoc = doc as TestDocument;

            if (packetLog != null)
            {
                foreach (LogPacket packet in packets)
                {
                    packetLog.AddPacket((LogPacket)packet.Clone());
                }
            }
            else if (testDoc != null)
            {
                IEnumerable<LogPacket> newPackets = packets.Select(p => (LogPacket)p.Clone());
                testDoc.AddRangeInputPacket(newPackets);
            }
        }
Example #2
0
        private void RunScript(LogPacket[] packets, ScriptContainer container, string classname)
        {
            if (packets.Length > 0)
            {
                try
                {
                    DataFrame[] frames = ParseWithUtils.ParseFrames(packets.Select(p => p.Frame), "/", container, classname).ToArray();

                    if (frames.Length > 0)
                    {
                        int index = 0;

                        lock (_packets)
                        {
                            index = _packets.IndexOf(packets[0]);
                            int currIndex = index;

                            foreach(LogPacket packet in packets)
                            {
                                _packets.Remove(packet);
                            }

                            LogPacket template = packets[0];

                            foreach (DataFrame frame in frames)
                            {
                                LogPacket newPacket = new LogPacket(template.Tag, template.NetId, Guid.NewGuid(), template.Network, frame, template.Color, template.Timestamp);

                                _packets.Insert(currIndex, newPacket);
                                currIndex++;
                            }
                        }

                        listLogPackets.SelectedIndices.Clear();
                        RefreshLog();
                        listLogPackets.SelectedIndices.Add(index);
                    }
                    else
                    {
                        MessageBox.Show(this, CANAPE.Properties.Resources.TreeDataKeyEditorControl_NoParseResults,
                            CANAPE.Properties.Resources.TreeDataKeyEditorControl_NoParseResultsCaption,
                            MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(this, ex.Message, CANAPE.Properties.Resources.TreeDataKeyEditorControl_ParseError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }