private void tsSetDeny_Click(object sender, EventArgs e) { SelectionBase selection = (SelectionBase)grid1.Selection; var region = selection.GetSelectionRegion(); foreach (var range in region) { for (int i = range.Start.Row; i <= range.End.Row; i++) { string channel = grid1[i, 2].Value.ToString(); string item = grid1[i, 3].Value.ToString(); if (!Deny.ContainsKey(channel)) { Deny.Add(channel, new List <string>()); } Deny[channel].Add(item); } } _Save(); _ApplyAllowDeny(); c_Summary.SetValue(m_Channels.Count); m_DenyForm.ResetItem(); var sum = Deny.Sum(entry => entry.Value.Count); tsDeny.Text = sum == 0 ? string.Empty : $"[{sum}]"; }
private void OnValueUpdated(string channel, string item, string value) { string key = $"{channel}.{item}"; if (Allow.Count > 0) { //if (!Allow.ContainsKey(channel) || !Allow[channel].Contains(item)) if (!Allow.ContainsKey(channel) || (Allow[channel].Count > 0 && !Allow[channel].Contains(item))) { return; } } if (Deny.ContainsKey(channel)) { if (Deny[channel].Contains(item)) { return; } } ThreadPool.QueueUserWorkItem((state) => { string k = state.ToString(); try { if (!m_Channels.ContainsKey(k)) { ChannelInfo info = new ChannelInfo(this, int.Parse(tsInterval.Text), channel, item, value); if (m_Channels.TryAdd(k, info)) { _ContentCell(k); c_Summary.SetValue(m_Channels.Count); } } else { m_Channels[key].Value.SetValue(value); } } catch (Exception) { } }, key); }
private void _ApplyAllowDeny() { _ClearCell(); lock (m_Channels) { for (int i = m_Channels.Count - 1; i >= 0; i--) { string[] items = m_Channels.ElementAt(i).Key.Split('.'); if (Allow.Count > 0) { if (!Allow.ContainsKey(items[0]) || (Allow[items[0]].Count > 0 && !Allow[items[0]].Contains(items[1]))) { ChannelInfo ci; m_Channels.TryRemove(m_Channels.ElementAt(i).Key, out ci); ci.Dispose(); continue; } } if (Deny.ContainsKey(items[0])) { if (Deny[items[0]].Contains(items[1])) { ChannelInfo ci; m_Channels.TryRemove(m_Channels.ElementAt(i).Key, out ci); ci.Dispose(); } } } } _HeaderCell(); foreach (var channel in m_Channels.Keys) { _ContentCell(channel); } grid1.AutoSizeCells(); _Sort(); }