private void GenerateTable(int variables, bool reverse, IEnumerable <LogicItem> values = null)
        {
            _items.Clear();
            if (reverse)
            {
                char[] arr = ABC.Substring(0, variables).ToCharArray();
                Array.Reverse(arr);
                Variables.Header = new string(arr);
            }
            else
            {
                Variables.Header = ABC.Substring(0, variables);
            }
            int limit = 1 << variables;

            if (values != null)
            {
                foreach (var item in values)
                {
                    _items.Add(item);
                }
            }
            else
            {
                for (int i = 0; i < limit; i++)
                {
                    _items.Add(new LogicItem()
                    {
                        Index = i, BinaryValue = LogicItem.GetBinaryValue(i, variables), Checked = false
                    });
                }
            }
        }
 private void InputByNumbers()
 {
     _variables = (int)MintermNumbers.Value;
     try
     {
         if (string.IsNullOrEmpty(MintermInput.Text))
         {
             throw new Exception("No minterm numbers entered");
         }
         string[] items    = MintermInput.Text.Split(',');
         string[] dontcare = null;
         if (!string.IsNullOrEmpty(DontcarInput.Text))
         {
             dontcare = DontcarInput.Text.Split(',');
             if (dontcare.Length < 1)
             {
                 items = DontcarInput.Text.Split(' ');
             }
         }
         if (items.Length < 1)
         {
             items = MintermInput.Text.Split(' ');
         }
         if (items.Length < 1)
         {
             throw new Exception("Incorrect input");
         }
         List <LogicItem> litems = new List <LogicItem>();
         foreach (var item in items)
         {
             litems.Add(new LogicItem()
             {
                 Index       = Convert.ToInt32(item),
                 BinaryValue = LogicItem.GetBinaryValue(Convert.ToInt32(item), _variables),
                 Checked     = true
             });
         }
         if (dontcare != null)
         {
             foreach (var item in dontcare)
             {
                 litems.Add(new LogicItem()
                 {
                     Index       = Convert.ToInt32(item),
                     BinaryValue = LogicItem.GetBinaryValue(Convert.ToInt32(item), _variables),
                     Checked     = null
                 });
             }
         }
         SimpleMinterm.Text = QuineMcclusky.GetSimplified(litems, _variables, (bool)HazardSafe.IsChecked, (bool)LsbBit.IsChecked, false);
         SimpleMaxterm.Text = QuineMcclusky.GetSimplified(litems, _variables, (bool)HazardSafe.IsChecked, (bool)LsbBit.IsChecked, true);
     }
     catch (Exception ex)
     {
         WpfHelpers.ExceptionDialog(ex);
     }
 }
 private LogicItem[] GenerateMinterms()
 {
     LogicItem[] ret = new LogicItem[1 << _variables];
     for (int i = 0; i < ret.Length; i++)
     {
         ret[i]             = new LogicItem();
         ret[i].Checked     = null;
         ret[i].Index       = i;
         ret[i].BinaryValue = LogicItem.GetBinaryValue(i, _variables);
     }
     return(ret);
 }
        private void Generate()
        {
            _counter.Clear();
            _items.Clear();
            int limit = 1 << _variables;

            for (int i = 0; i < limit; i++)
            {
                _items.Add(LogicItem.GetBinaryValue(i, _variables));
            }
            StageCurrent.ItemsSource = _items;
            StageNext.ItemsSource    = _items;
        }