コード例 #1
0
        public void NewData(List <UDOneItem> items, double timeSpan)
        {
            if (items.Count == 0)
            {
                for (int i = 0; i < ContentGrid.RowDefinitions.Count; i++)
                {
                    if (names[i].Text == null || names[i].Text == "")
                    {
                        break;
                    }
                    else
                    {
                        ups[i].Text   = "0K/s";
                        downs[i].Text = "0K/s";
                    }
                }
            }
            else
            {
                if (TextSearsh.Text != "")
                {
                    if (items.Count > 0)
                    {
                        items = items.Where(x => GatName(x.ProcessID).ToLower().IndexOf(TextSearsh.Text.ToLower()) != -1).ToList();
                    }
                }

                localItems.Clear();
                localItems.AddRange(items);
                ClearViewContent();
                for (int i = 0; i < ContentGrid.RowDefinitions.Count && i < items.Count; i++)
                {
                    UDOneItem item = items[i];
                    downs[i].Text = Tool.GetNetSpeedString(item.Download, timeSpan);
                    ups[i].Text   = Tool.GetNetSpeedString(item.Upload, timeSpan);
                    if (item.ProcessID == -1)
                    {
                        names[i].Text = "bridge";
                    }
                    else
                    {
                        if (!idMap.TryGetValue(item.ProcessID, out ProcessView view))
                        {
                            view = new ProcessView(item.ProcessID);
                            idMap[item.ProcessID] = view;
                        }
                        names[i].Text = view.Name ?? "Process ID: " + view.ID;
                        if (view.Image != null)
                        {
                            icons[i].Source = view.Image;
                        }
                    }
                }
            }
            RefreshDetailButton(Mouse.GetPosition(ContentGrid));
        }
コード例 #2
0
        public void NewData(List <UDOneItem> items, double timeSpan)
        {
            UDOneItem item = items.Where(x => x.ProcessID == IDProcess).FirstOrDefault();

            if (item != null)
            {
                down.Text  = Tool.GetNetSpeedString(item.Download, timeSpan);
                up.Text    = Tool.GetNetSpeedString(item.Upload, timeSpan);
                Upload    += item.Upload;
                Download  += item.Download;
                up2.Text   = Tool.ToString(Upload);
                down2.Text = Tool.ToString(Download);
                Chart1.Uploaded(item.Upload);
                Chart1.Downloaded(item.Download);
                if (item.ProcessID == -1)
                {
                    Names.Text = "bridge";
                }
                else
                {
                    if (!idMap.TryGetValue(item.ProcessID, out ProcessView view))
                    {
                        view = new ProcessView(item.ProcessID);
                        idMap[item.ProcessID] = view;
                    }
                    Names.Text = view.Name ?? "Process ID: " + view.ID;
                    if (view.Image != null)
                    {
                        Icons.Source = view.Image;
                    }
                }
            }
            else
            {
                up.Text   = "0K/s";
                down.Text = "0K/s";
                Chart1.Uploaded(0);
                Chart1.Downloaded(0);
            }
        }