Exemple #1
0
        /// <summary>
        /// If conditions satisfies then remove equation from list and calls DeleteChart event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="ChoosedClass"></param>
        private void Equation_DeleteEvent(object sender, EquationUI ChoosedClass)
        {
            if (!(sender is Button))
            {
                throw new ArgumentException();
            }
            Grid myGrid = new Grid();
            UIElementCollection allElements = EquationListStack.Children;

            foreach (var grid in allElements)
            {
                if (grid is Grid)
                {
                    if ((grid as Grid).Children.Contains(sender as Button))
                    {
                        myGrid = grid as Grid;
                    }
                }
            }
            if (EquationListStack.Children.Count < 2 || allElements.IndexOf(myGrid) == allElements.Count - 1)
            {
                MessageBox.Show("Cannot Delete This Field!", "Error");
            }
            else
            {
                EquationListStack.Children.Remove(myGrid);
                Equations.Remove(ChoosedClass);
                DeleteChart(this, ChoosedClass);
            }
        }
Exemple #2
0
        /// <summary>
        /// Creats an equation and add it to equation list.
        /// Adds grid of Equation to stack panel.
        /// </summary>
        public void AddEquation()
        {
            EquationUI newEquation = new EquationUI();

            //TextBox Properties
            newEquation.DataTextBox.TextChanged += OnTextChanged_AddEquation;
            newEquation.DataTextBox.Background   = AvailableColors[CurrentColorIndex];
            //Event Properties
            newEquation.Delete += Equation_DeleteEvent;
            newEquation.Draw   += NewEquation_Draw;
            EquationListStack.Children.Add(newEquation.GetGrid());
            Equations.Add(newEquation);
            CurrentColorIndex = ++CurrentColorIndex >= AvailableColors.Count ? 0 : CurrentColorIndex;
        }