Пример #1
0
        /// <summary>
        /// Initializes a new instance of <see cref="Kamilla.Network.Viewing.ViewerItem"/> that i
        /// </summary>
        /// <param name="viewer">
        /// The <see cref="Kamilla.Network.Viewing.NetworkLogViewerBase"/> to which
        /// the current instance of <see cref="Kamilla.Network.Viewing.ViewerItem"/> belongs to.
        /// </param>
        /// <param name="log">
        /// Gets the <see cref="Kamilla.Network.Logging.NetworkLog"/> that
        /// stores the underlying <see cref="Kamilla.Network.Packet"/>.
        /// </param>
        /// <param name="index">
        /// Gets the counter of the current instance
        /// of <see cref="Kamilla.Network.Viewing.ViewerItem"/>.
        /// </param>
        /// <param name="packet">
        /// Gets the <see cref="Kamilla.Network.Packet"/> for which the current
        /// instance of <see cref="Kamilla.Network.Viewing.ViewerItem"/> was created.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// viewer is null.
        /// -or-
        /// log is null.
        /// -or-
        /// packet is null.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// index is negative.
        /// </exception>
        public ViewerItem(NetworkLogViewerBase viewer, NetworkLog log, Packet packet, int index)
        {
            if (viewer == null)
            {
                throw new ArgumentNullException("viewer");
            }

            if (log == null)
            {
                throw new ArgumentNullException("log");
            }

            if (packet == null)
            {
                throw new ArgumentNullException("packet");
            }

            if (index < 0)
            {
                throw new ArgumentOutOfRangeException("index");
            }

            m_viewer = viewer;
            m_log    = log;
            m_packet = packet;
            m_index  = index;
        }
Пример #2
0
        public OpcodeInfoWindow(NetworkLogViewerBase viewer)
        {
            InitializeComponent();

            m_viewer = viewer;
            var window = viewer.InterfaceObject as Window;
            if (window != null)
            {
                this.Owner = window;
                this.Style = window.Style;

                var styler = window as INotifyStyleChanged;
                if (styler != null)
                    styler.StyleChanged += (o, e) => this.Style = ((Window)m_viewer.InterfaceObject).Style;
            }

            var fields = typeof(WowOpcodes).GetFields(BindingFlags.Static | BindingFlags.Public);

            var list = new List<string>(fields.Length);
            foreach (var field in fields)
            {
                var value = (uint)field.GetRawConstantValue();
                if (value != SpecialOpcodes.UnknownOpcode)
                    list.Add(field.Name);
            }
            list.Sort();

            var items = ui_cbInput.Items;
            foreach (var item in list)
                items.Add(item);

            this.Prepare(WowOpcodes.UNKNOWN_OPCODE);
        }
Пример #3
0
        public override void Load(NetworkLogViewerBase viewer)
        {
            if (m_viewer != null)
                throw new InvalidOperationException();

            m_viewer = viewer;
            viewer.ItemVisualDataQueried += m_itemVisualDataQueriedHandler;

            var view = m_view = new GridView();

            var nColumns = s_columnWidths.Length;
            var headers = new string[]
            {
                NetworkStrings.CH_Number,
                NetworkStrings.CH_Time,
                NetworkStrings.CH_Ticks,
                NetworkStrings.CH_C2S,
                NetworkStrings.CH_S2C,
                NetworkStrings.CH_Length,
            };
            if (headers.Length != nColumns)
                throw new InvalidOperationException();

            double[] widths = Configuration.GetValue("Column Widths", (double[])null);
            if (widths == null || widths.Length != nColumns)
                widths = s_columnWidths;

            int[] columnOrder = Configuration.GetValue("Column Order", (int[])null);
            if (columnOrder == null || columnOrder.Length != nColumns
                || columnOrder.Any(val => val >= nColumns || val < 0))
                columnOrder = Enumerable.Range(0, nColumns).ToArray();

            for (int i = 0; i < nColumns; i++)
            {
                int col = columnOrder[i];

                var item = new GridViewColumnWithId();
                item.ColumnId = col;
                item.Header = headers[col];
                item.Width = widths[col];

                var dataTemplate = new DataTemplate();
                dataTemplate.DataType = typeof(ItemVisualData);

                var block = new FrameworkElementFactory(typeof(TextBlock));
                block.SetValue(TextBlock.TextProperty, new Binding(s_columnBindings[col]));

                dataTemplate.VisualTree = block;
                item.CellTemplate = dataTemplate;

                view.Columns.Add(item);
            }
        }
Пример #4
0
        public void Initialize(NetworkLogViewerBase viewer)
        {
            m_viewer = viewer;
            m_command = new PluginCommand(this, Strings.Gossip_OpenParser,
                new KeyGesture(Key.G, ModifierKeys.Control | ModifierKeys.Alt), Clicked);

            viewer.ProtocolChanged += new EventHandler(viewer_ProtocolChanged);
            viewer.NetworkLogChanged += new EventHandler(viewer_NetworkLogChanged);

            this.UpdateCommand();
            Console.WriteLine("Debug: Gossip Parser initialized.");
        }
Пример #5
0
        /// <summary>
        /// Initializes a new instance of <see cref="Kamilla.Network.Viewing.ViewerItem"/> that i
        /// </summary>
        /// <param name="viewer">
        /// The <see cref="Kamilla.Network.Viewing.NetworkLogViewerBase"/> to which
        /// the current instance of <see cref="Kamilla.Network.Viewing.ViewerItem"/> belongs to.
        /// </param>
        /// <param name="log">
        /// Gets the <see cref="Kamilla.Network.Logging.NetworkLog"/> that
        /// stores the underlying <see cref="Kamilla.Network.Packet"/>.
        /// </param>
        /// <param name="index">
        /// Gets the counter of the current instance
        /// of <see cref="Kamilla.Network.Viewing.ViewerItem"/>.
        /// </param>
        /// <param name="packet">
        /// Gets the <see cref="Kamilla.Network.Packet"/> for which the current
        /// instance of <see cref="Kamilla.Network.Viewing.ViewerItem"/> was created.
        /// </param>
        /// <exception cref="System.ArgumentNullException">
        /// viewer is null.
        /// -or-
        /// log is null.
        /// -or-
        /// packet is null.
        /// </exception>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// index is negative.
        /// </exception>
        public ViewerItem(NetworkLogViewerBase viewer, NetworkLog log, Packet packet, int index)
        {
            if (viewer == null)
                throw new ArgumentNullException("viewer");

            if (log == null)
                throw new ArgumentNullException("log");

            if (packet == null)
                throw new ArgumentNullException("packet");

            if (index < 0)
                throw new ArgumentOutOfRangeException("index");

            m_viewer = viewer;
            m_log = log;
            m_packet = packet;
            m_index = index;
        }
Пример #6
0
 /// <summary>
 /// When implemented in a derived class,
 /// loads the current instance of <see cref="Kamilla.Network.Protocols.Protocol"/>
 /// and attachs to the provided <see cref="Kamilla.Network.Viewing.NetworkLogViewerBase"/>.
 /// 
 /// This method MUST be called from the UI thread if one exists.
 /// </summary>
 /// <param name="viewer">
 /// The instance of <see cref="Kamilla.Network.Viewing.NetworkLogViewerBase"/> to attach to.
 /// </param>
 /// <returns>
 /// The <see cref="System.Windows.Controls.ViewBase"/> that defines the appearance of packet list.
 /// </returns>
 /// <exception cref="System.InvalidOperationException">
 /// The current instance of <see cref="Kamilla.Network.Protocols.Protocol"/> is already
 /// attached to a <see cref="Kamilla.Network.Viewing.NetworkLogViewerBase"/>.
 /// </exception>
 public abstract void Load(NetworkLogViewerBase viewer);
Пример #7
0
        public override void Unload()
        {
            if (m_viewer == null)
                throw new InvalidOperationException();

            var view = m_view;
            var columns = view.Columns;
            var nColumns = columns.Count;

            var widths = new double[nColumns];
            var order = new int[nColumns];

            for (int i = 0; i < nColumns; i++)
            {
                var column = (GridViewColumnWithId)columns[i];

                order[i] = column.ColumnId;
                widths[column.ColumnId] = column.Width;
            }

            Configuration.SetValue("Column Widths", widths);
            Configuration.SetValue("Column Order", order);
            m_view = null;

            m_viewer.ItemVisualDataQueried -= m_itemVisualDataQueriedHandler;
            m_viewer = null;
        }
Пример #8
0
        public override void Load(NetworkLogViewerBase viewer)
        {
            if (m_viewer != null)
                throw new InvalidOperationException();

            // Check opcode integrity
            {
                Console.WriteLine("Debug: Protocol '{0}' build {1} checking opcode integrity...",
                    this.CodeName, Disassembly.ClientBuild);
                var fields = typeof(WowOpcodes).GetFields(BindingFlags.Static | BindingFlags.Public);

                var list = new SortedSet<uint>();
                foreach (var field in fields)
                {
                    var value = (uint)field.GetRawConstantValue();
                    if (value != SpecialOpcodes.UnknownOpcode)
                    {
                        if (!list.Contains(value))
                            list.Add(value);
                        else
                            Console.WriteLine("Error: Protocol '{1}' duplicate opcode value {0}",
                                value, this.CodeName);
                    }
                }
                Console.WriteLine(
                    "Debug: Integrity check complete, {0}/{1} ({2:0.00}%) known unique opcode values.",
                    list.Count,
                    fields.Length,
                    list.Count * 100.0 / fields.Length
                    );
            }

            m_viewer = viewer;
            viewer.ItemVisualDataQueried += m_itemVisualDataQueriedHandler;
            viewer.ItemParsingDone += m_itemParsingDoneHandler;

            var view = m_view = new GridView();

            var nColumns = s_columnWidths.Length;
            var headers = new string[]
            {
                NetworkStrings.CH_Number,
                NetworkStrings.CH_Time,
                NetworkStrings.CH_Ticks,
                Strings.CH_ConnId,
                NetworkStrings.CH_C2S,
                NetworkStrings.CH_S2C,
                NetworkStrings.CH_Length,
                Strings.CH_Preview,
            };
            if (headers.Length != nColumns)
                throw new InvalidOperationException();

            double[] widths = Configuration.GetValue("Column Widths", (double[])null);
            if (widths == null || widths.Length != nColumns)
                widths = s_columnWidths;

            int[] columnOrder = Configuration.GetValue("Column Order", (int[])null);
            if (columnOrder == null || columnOrder.Length != nColumns
                || columnOrder.Any(val => val >= nColumns || val < 0))
                columnOrder = Enumerable.Range(0, nColumns).ToArray();

            if (s_customBrush == null)
                s_customBrush = new SolidColorBrush(Color.FromRgb(132, 22, 35));

            if (s_freezedBrush == null)
                s_freezedBrush = new SolidColorBrush(Color.FromRgb(36, 176, 185));

            for (int i = 0; i < nColumns; i++)
            {
                int col = columnOrder[i];

                var item = new GridViewColumnWithId();
                item.ColumnId = col;
                item.Header = headers[col];
                item.Width = widths[col];

                var dataTemplate = new DataTemplate();
                dataTemplate.DataType = typeof(ItemVisualData);

                var block = new FrameworkElementFactory(typeof(TextBlock));
                block.Name = "tb";
                block.SetValue(TextBlock.TextProperty, new Binding(s_columnBindings[col]));

                // Opcode
                if (col == 4 || col == 5)
                {
                    block.SetValue(TextBlock.FontFamilyProperty, new FontFamily("Lucida Console"));

                    DataTrigger trigger;

                    trigger = new DataTrigger();
                    trigger.Binding = new Binding(".VisualData.IsCustom");
                    trigger.Value = true;
                    trigger.Setters.Add(new Setter(TextBlock.ForegroundProperty, s_customBrush, "tb"));
                    dataTemplate.Triggers.Add(trigger);

                    trigger = new DataTrigger();
                    trigger.Binding = new Binding(".VisualData.IsFreezed");
                    trigger.Value = true;
                    trigger.Setters.Add(new Setter(TextBlock.ForegroundProperty, s_freezedBrush, "tb"));
                    dataTemplate.Triggers.Add(trigger);

                    trigger = new DataTrigger();
                    trigger.Binding = new Binding(".VisualData.IsUndefinedParser");
                    trigger.Value = true;
                    trigger.Setters.Add(new Setter(TextBlock.ForegroundProperty, Brushes.Gray, "tb"));
                    dataTemplate.Triggers.Add(trigger);
                }
                // Preview
                else if (col == 7)
                {
                    var trigger = new DataTrigger();
                    trigger.Binding = new Binding(".VisualData.ParsingError");
                    trigger.Value = true;
                    trigger.Setters.Add(new Setter(TextBlock.ForegroundProperty, Brushes.Red, "tb"));
                    dataTemplate.Triggers.Add(trigger);
                }

                dataTemplate.VisualTree = block;
                item.CellTemplate = dataTemplate;

                view.Columns.Add(item);
            }
        }