/// <summary>Display the trades grid context menu</summary> private void ShowContextMenu(DataGridView_.HitTestInfo hit, Trade trade, Order order) { var cmenu = new ContextMenuStrip(); if (trade != null) { var opt = cmenu.Items.Add2(new ToolStripMenuItem("Delete Trade")); opt.Enabled = !Bit.AnySet(trade.State, Trade.EState.PendingOrder | Trade.EState.ActivePosition); opt.ToolTipText = Bit.AnySet(trade.State, Trade.EState.PendingOrder | Trade.EState.ActivePosition) ? "Cannot delete trades with active or pending orders" : string.Empty; opt.Click += (s, a) => { Orders.RemoveAll(trade.Orders); Trades.Remove(trade); }; } if (order != null) { var opt = cmenu.Items.Add2(new ToolStripMenuItem("Delete Order")); opt.Enabled = !Bit.AnySet(order.State, Trade.EState.PendingOrder | Trade.EState.ActivePosition); opt.ToolTipText = Bit.AnySet(order.State, Trade.EState.PendingOrder | Trade.EState.ActivePosition) ? "Cannot delete trades with active or pending orders" : string.Empty; opt.Click += (s, a) => { Orders.Remove(order); }; } cmenu.Items.TidySeparators(); cmenu.Show(m_grid, hit.GridPoint); }
[Test] public void BitAnySet() { const string bitstr0 = "100100010100110010110"; const string bitstr1 = "011011101011001101001"; var bits0 = Bit.Parse(bitstr0); var bits1 = Bit.Parse(bitstr1); Assert.False(Bit.AnySet(bits0, bits1)); }