Esempio n. 1
0
 private void OnUserDataIncoming(object sender, UserDataIncomingEventArgs e)
 {
     try
     {
         _productCache.AddTail(e);
     }
     catch (System.Exception)
     {
     }
 }
Esempio n. 2
0
        private void ShowIncomingUserDataEvent(UserDataIncomingEventArgs args)
        {
            try
            {
                if (this.IncomingStreamVisable)
                {
                    this.Invoke(new Action(() =>
                    {
                        // 当前选择的设备与args中的设备是否一致
                        string fixedName = this.DecorateDeviceID(args.Package.RemoteID);
                        bool selected    = (_selectedDeviceName.CompareTo(fixedName) == 0);

                        if (selected && _filterControl.Filter(args.Package.UserData))
                        {
                            // clear
                            if (treeViewDataSummary.Nodes.Count > 100)
                            {
                                treeViewDataSummary.Nodes.RemoveAt(0);
                            }

                            // add
                            TreeNode node = new TreeNode();
                            node.Tag      = args;

                            // 获取自定义标签
                            string customLable;
                            if (UserDataResolver != null)
                            {
                                customLable = string.Format("{0},{1}",
                                                            UserDataResolver.GetLabel(args.Package.UserData, true),
                                                            DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
                            }
                            else
                            {
                                customLable = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
                            }

                            // set node text
                            node.Text = String.Format("{0}, Delay = {1}", customLable, args.Package.TransmissionDelay);

                            // set node image.
                            node.ImageKey         = "InputStream";
                            node.SelectedImageKey = node.ImageKey;

                            // Add Node
                            treeViewDataSummary.Nodes.Add(node);
                        }
                    }));
                }
            }
            catch (System.Exception ex)
            {
                this.ShowLog(ex.Message);
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 处理收到的用户数据
 /// </summary>
 private void OnUserDataIncoming(object sender, UserDataIncomingEventArgs args)
 {
     try
     {
         // 保存
         if (_settingPage.UserDataStorageEnabled)
         {
             _fileManager.SaveUserData(args.Package.RemoteID, args.Package.UserData);
         }
     }
     catch (System.Exception ex)
     {
         LogUtility.Error(ex);
     }
 }
Esempio n. 4
0
        private void NotifyIncomingUserDataEvent(IncomingPackage pkg)
        {
            if (this.UserDataIncoming != null)
            {
                this.UserDataIncoming.GetInvocationList().ToList().ForEach(handler =>
                {
                    try
                    {
                        var args = new UserDataIncomingEventArgs(pkg);
                        args.Package.QueuingDelay = (UInt32)((DateTime.Now - args.Package.CreationTime).TotalMilliseconds / 10);

                        handler.DynamicInvoke(null, args);
                    }
                    catch (System.Exception)
                    {
                    }
                });
            }
        }