示例#1
0
        private void btRegister_Click(object sender, EventArgs e)
        {
            var scanned    = HCommAir.GetScannedTools();
            var registered = HCommAir.GetRegisteredTools();

            // check sender
            if (sender == btRegister)
            {
                // check index
                if (lbScannedTools.SelectedIndex < 0 || lbScannedTools.SelectedIndex > scanned.Count)
                {
                    return;
                }
                // get item
                var info = scanned.Find(x => x.Mac == scanned[lbScannedTools.SelectedIndex].Mac);
                // add item
                HCommAir.RegisterTool(info);
                // save tool list
                HCommAir.SaveRegisterTools(tbPath.Text);
            }
            else
            {
                // check index
                if (lbRegisteredTools.SelectedIndex < 0 || lbRegisteredTools.SelectedIndex > registered.Count)
                {
                    return;
                }
                // get item
                var info = registered.Find(x => x.Mac == registered[lbRegisteredTools.SelectedIndex].Mac);
                // remove item
                HCommAir.UnRegisterTool(info);
                // save tool list
                HCommAir.SaveRegisterTools(tbPath.Text);
            }
        }
示例#2
0
        private void timer_Tick(object sender, EventArgs e)
        {
            var scanned    = HCommAir.GetScannedTools();
            var registered = HCommAir.GetRegisteredTools();

            // check scanned tools count
            if (scanned.Count != ScanTools.Count)
            {
                // clear scanned tools item
                ScanTools.Clear();
                // add item list
                foreach (var info in scanned)
                {
                    // add
                    ScanTools.Add(info);
                }
                // refresh
                lbScannedTools.Refresh();
            }
            // check registered tools count
            if (registered.Count != RegisterTools.Count)
            {
                // clear register tools item
                RegisterTools.Clear();
                // add item list
                foreach (var info in registered)
                {
                    // add
                    RegisterTools.Add(info);
                }
                // refresh
                lbRegisteredTools.Refresh();
            }
            // check graph state
            if (!GraphState || SelectedSession == null || SelectedSession.State != ConnectionState.Connected ||
                !((DateTime.Now - GraphTime).TotalSeconds > 5))
            {
                return;
            }
            // set
            SelectedSession.SetGraph();
            // reset time
            GraphTime = DateTime.Now;
        }