public static ushort GetOpcode(MainWindow window, string name) { ushort opCode = (from val in PacketNames where val.Value.Equals(name) select val.Key).FirstOrDefault(); return opCode; }
public static string GetOpcodeName(MainWindow window, ushort opCode) { string name; if (PacketNames.ContainsKey(opCode)) { name = PacketNames[opCode]; } else { string opCodeLittleEndianHex = BitConverter.GetBytes(opCode).ToHex(); name = string.Format("0x{0}{1}", opCodeLittleEndianHex.Substring(2), opCodeLittleEndianHex.Substring(0, 2)); } return name; }
public static void Init(MainWindow mw) { string path = Directory.GetCurrentDirectory() + "\\opcodefile.txt"; if (File.Exists(path)) { TextReader reader = new StreamReader(path); string line = ""; while ((line = reader.ReadLine()) != null) { //I_TELEPORT = 0 string[] tmpString = line.Replace(" ", "").Split('='); PacketNames.Add(Convert.ToUInt16(tmpString[1]), tmpString[0]); } } else { MessageBox.Show("Opcodefile not found!"); } }
public Capture(MainWindow mainWindow) { MainWindow = mainWindow; }
public PacketProcessor(MainWindow mainWindow) { lockObject = new object(); MainWindow = mainWindow; }
public InputValueBox(MainWindow mainWindow, string title, string label, string def = "") { MainWindow = mainWindow; Grid grid = new Grid { Margin = new Thickness(15), }; grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.ColumnDefinitions.Add(new ColumnDefinition()); grid.RowDefinitions.Add(new RowDefinition()); grid.RowDefinitions.Add(new RowDefinition()); Label textLabel = new Label { Content = label, Margin = new Thickness(0, 0, 15, 0) }; textLabel.SetValue(Grid.ColumnProperty, 0); textLabel.SetValue(Grid.RowProperty, 0); grid.Children.Add(textLabel); TextBox = new TextBox { Text = def, Width = 160, Height = 26, HorizontalContentAlignment = HorizontalAlignment.Center, VerticalContentAlignment = VerticalAlignment.Center, }; TextBox.SetValue(Grid.ColumnProperty, 1); TextBox.SetValue(Grid.RowProperty, 0); grid.Children.Add(TextBox); Button cancelButton = new Button { Width = 80, Height = 26, Margin = new Thickness(0, 15, 0, 0), Content = "Cancel", HorizontalAlignment = HorizontalAlignment.Right }; cancelButton.SetValue(Grid.ColumnProperty, 1); cancelButton.SetValue(Grid.RowProperty, 1); cancelButton.Click += Cancel; grid.Children.Add(cancelButton); Button okButton = new Button { Width = 60, Height = 26, Margin = new Thickness(0, 15, 90, 0), Content = "Ok", HorizontalAlignment = HorizontalAlignment.Right }; okButton.SetValue(Grid.ColumnProperty, 1); okButton.SetValue(Grid.RowProperty, 1); okButton.Click += Ok; grid.Children.Add(okButton); Window = new Window { Title = title, Left = mainWindow.Left + Mouse.GetPosition(mainWindow).X, Top = mainWindow.Top + Mouse.GetPosition(mainWindow).Y, SizeToContent = SizeToContent.WidthAndHeight, Content = grid, ResizeMode = ResizeMode.NoResize, }; }