public void neutralize(Beaker beaker)
        {
            float H  = beaker.getComponentVolume(ChemNotation.ion_H);
            float OH = beaker.getComponentVolume(ChemNotation.ion_OH);

            if (H > 0 && OH > 0)
            {
                int[] reactionRatio = densityToReactionRatio();

                // Because without reaction, amount of positive ion : negative ion = 1 : 1
                float OH_by_K  = beaker.getComponentVolume(ChemNotation.ion_K);
                float OH_by_Na = OH - OH_by_K;

                // Need to optimize those algorithms..
                if (H / reactionRatio[0] > OH_by_K / reactionRatio[1] + OH_by_Na / reactionRatio[2])
                {
                    beaker.removeBeakerComponent(ChemNotation.ion_H, H - (H / reactionRatio[0] - (OH_by_K / reactionRatio[1] + OH_by_Na / reactionRatio[2])));
                    beaker.removeBeakerComponent(ChemNotation.ion_OH, OH);
                    beaker.addBeakerComponent(ChemNotation.H2O, OH);
                }
                else
                {
                    beaker.removeBeakerComponent(ChemNotation.ion_H, H);
                    beaker.removeBeakerComponent(ChemNotation.ion_OH, OH - (OH_by_K / reactionRatio[1] + OH_by_Na / reactionRatio[2] - H / reactionRatio[0]));
                    beaker.addBeakerComponent(ChemNotation.H2O, H);
                }
            }
        }
        public ConfigWindow(Window instance, Beaker beaker)
        {
            InitializeComponent();
            this.instance = instance;

            Loaded       += ConfigWindowLoadedEvent;
            Closing      += ConfigWindowClosedEvent;
            currentBeaker = beaker;
        }
        public GraphWindow(Beaker beaker)
        {
            instance = this;
            Closed  += closeEvent;

            InitializeComponent();
            SeriesCollection = new SeriesCollection
            {
                new LineSeries
                {
                    Title          = "H+",
                    Values         = new ChartValues <ObservableValue> {
                    },
                    LineSmoothness = 0
                },

                new LineSeries
                {
                    Title          = "Cl-",
                    Values         = new ChartValues <ObservableValue> {
                    },
                    LineSmoothness = 0
                },

                new LineSeries
                {
                    Title          = "K+",
                    Values         = new ChartValues <ObservableValue> {
                    },
                    LineSmoothness = 0
                },

                new LineSeries
                {
                    Title          = "Na+",
                    Values         = new ChartValues <ObservableValue> {
                    },
                    LineSmoothness = 0
                },

                new LineSeries
                {
                    Title          = "OH-",
                    Values         = new ChartValues <ObservableValue> {
                    },
                    LineSmoothness = 0
                }
            };

            // Notice. this should observe order as describled in 'chemical notation'
            Labels      = new[] { "H+", "Cl-", "K+", "Na+", "OH-" };
            DataContext = this;
        }
 public TableWindow(Beaker beaker)
 {
     instance = this;
     Closed  += closeEvent;
     InitializeComponent();
 }