Ejemplo n.º 1
0
        public void ListenMessage(object o, ReceivedEventArgs e)
        {
            if (this.PacketView.InvokeRequired)
            {
                ReceivedHandler method = new ReceivedHandler(this.ListenMessage);
                base.Invoke(method, new object[]
                {
                    o,
                    e
                });
                return;
            }
            byte[] data     = e.Data;
            int    num      = data.Length;
            bool   @checked = this.cbAutoSend.Checked;
            string text     = string.Concat(o);

            if (@checked)
            {
                this.commServer.Send(text, data, data.Length);
            }
            if (this.PacketView.Items.Count > 200)
            {
                this.PacketView.Items.Clear();
            }
            ListViewItem listViewItem = this.PacketView.Items.Insert(0, string.Concat(this.PacketView.Items.Count));

            listViewItem.SubItems.Add(text ?? "");
            listViewItem.SubItems.Add(e.RemoteHost.ToString() ?? "");
            string text2 = ParseUtil.ParseString(data, num);

            if (this.rbUTF8.Checked)
            {
                text2 = ParseUtil.ParseStringByUTF8(data, num);
            }
            else if (this.rbHex.Checked)
            {
                text2 = ParseUtil.ToHexString(data, num);
            }
            string text3 = DateTime.Now.ToString("HH:mm:ss");

            listViewItem.SubItems.Add(text3);
            listViewItem.SubItems.Add(text2);
            listViewItem.SubItems.Add(string.Concat(num));
            if (this.cbLog.Checked)
            {
                ServerForm.logger.Info(e.RemoteHost.ToString() + " " + text2);
            }
        }
Ejemplo n.º 2
0
        public void ListenMessage(object o, ReceivedEventArgs e)
        {
            if (this.PacketView.InvokeRequired)
            {
                try
                {
                    ReceivedHandler method = new ReceivedHandler(this.ListenMessage);
                    base.Invoke(method, new object[]
                    {
                        o,
                        e
                    });
                    return;
                }
                catch (Exception ex)
                {
                    logger.Error(ex.Message);
                    logger.Error(ex.StackTrace);
                    return;
                }
            }
            if (this.PacketView.Items.Count > 200)
            {
                this.PacketView.Items.Clear();
            }
            ListViewItem listViewItem = this.PacketView.Items.Insert(0, string.Concat(this.PacketView.Items.Count));
            int          num          = e.Data.Length;
            string       text         = DateTime.Now.ToString("HH:mm:ss");

            listViewItem.SubItems.Add(text);
            string text2 = ParseUtil.ParseString(e.Data, num);

            if (this.rbHex.Checked)
            {
                text2 = ParseUtil.ToHexString(e.Data, num);
            }
            if (this.rbUTF8.Checked)
            {
                text2 = System.Text.Encoding.UTF8.GetString(e.Data);//ParseUtil.ToHexString(e.Data, num);
            }
            listViewItem.SubItems.Add(text2);
            listViewItem.SubItems.Add(string.Concat(num));
            if (this.cbLog.Checked)
            {
                logger.Info(e.RemoteHost.ToString() + " " + text2);
            }
        }
Ejemplo n.º 3
0
        public void ListenMessage(object o, ReceivedEventArgs e)
        {
            if (PacketView.InvokeRequired)
            {
                ReceivedHandler d = new ReceivedHandler(ListenMessage);
                this.Invoke(d, new object[] { o, e });
            }
            else
            {
                byte[]  data   = e.Data;
                int     length = data.Length;
                Boolean isEcho = this.cbAutoSend.Checked;
                string  connId = "" + o;
                if (isEcho)
                {
                    commServer.Send(connId, data, data.Length);
                }


                if (PacketView.Items.Count > 200)
                {
                    PacketView.Items.Clear();
                }

                ListViewItem item = PacketView.Items.Insert(0, "" + PacketView.Items.Count);
                item.SubItems.Add("" + connId);
                item.SubItems.Add("" + e.RemoteHost.ToString());

                string msg = ParseUtil.ParseString(data, length);
                if (rbHex.Checked)
                {
                    msg = ParseUtil.ToHexString(data, length);
                }

                string strDate = DateTime.Now.ToString("HH:mm:ss");
                item.SubItems.Add(strDate);

                item.SubItems.Add(msg);
                item.SubItems.Add("" + length);
                if (cbLog.Checked)
                {
                    logger.Info(e.RemoteHost.ToString() + " " + msg);
                }
                //item.SubItems.Add("" + msg.MsgContentDesc);
            }
        }
Ejemplo n.º 4
0
        public void ListenMessage(object o, ReceivedEventArgs e)
        {
            if (PacketView.InvokeRequired)
            {
                try
                {
                    ReceivedHandler d = new ReceivedHandler(ListenMessage);
                    this.Invoke(d, new object[] { o, e });
                }
                catch (System.Exception ex)
                {
                    logger.Error(ex.Message);
                    logger.Error(ex.StackTrace);
                }
            }
            else
            {
                if (PacketView.Items.Count > 200)
                {
                    PacketView.Items.Clear();
                }

                ListViewItem item = PacketView.Items.Insert(0, "" + PacketView.Items.Count);

                int    length  = e.Data.Length;
                string strDate = DateTime.Now.ToString("HH:mm:ss");
                item.SubItems.Add(strDate);
                string msg = ParseUtil.ParseString(e.Data, length);
                if (rbHex.Checked)
                {
                    msg = ParseUtil.ToHexString(e.Data, length);
                }
                item.SubItems.Add(msg);
                item.SubItems.Add("" + length);

                if (cbLog.Checked)
                {
                    logger.Info(e.RemoteHost.ToString() + " " + msg);
                }
                //item.SubItems.Add("" + msg.MsgContentDesc);
            }
        }
Ejemplo n.º 5
0
        public DecalFont(ConfigNode node, IEnumerable <TMP_FontAsset> fontAssets)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }
            if (fontAssets == null)
            {
                throw new ArgumentNullException(nameof(fontAssets));
            }

            var name = ParseUtil.ParseString(node, "name");

            _fontAsset = fontAssets.First(o => o.name == name);
            if (FontAsset == null)
            {
                throw new FormatException($"Could not find font asset named {name}");
            }

            _title         = ParseUtil.ParseString(node, "title", true, name);
            _fontStyle     = (FontStyles)ParseUtil.ParseInt(node, "style", true);
            _fontStyleMask = (FontStyles)ParseUtil.ParseInt(node, "styleMask", true);
        }