private void LoadFromXMLButton_Click(object sender, RoutedEventArgs e)
        {
            if (mainWindow.neuralNetwork != null)
            {
                SaveWarning warning = new SaveWarning();
                warning.ShowDialog();

                if (warning.OverrideNetwork)
                {
                    OpenFileDialog file = new OpenFileDialog();
                    file.CheckFileExists = true;
                    file.Multiselect     = false;
                    file.Filter          = "XML (.xml)|*.xml";
                    file.ShowDialog();

                    mainWindow.neuralNetwork = NeuralNetwork.LoadNetworkFromXML(file.FileName);
                }
            }
            else
            {
                OpenFileDialog file = new OpenFileDialog();
                file.CheckFileExists = true;
                file.Multiselect     = false;
                file.Filter          = "XML (.xml)|*.xml";
                file.ShowDialog();

                mainWindow.neuralNetwork = NeuralNetwork.LoadNetworkFromXML(file.FileName);
            }
        }
        private void CreateNetworkButton_Click(object sender, RoutedEventArgs e)
        {
            //check if learning rate is set
            double learningRate;

            if (!Double.TryParse(LearningRateTextBox.Text, out learningRate))
            {
                consoleTextBox.AppendText("Learning rate must be set and must be in a correct format (x,xxx) ! \n");
                return;
            }

            for (int lay = 1; lay < layerDisplay.Items.Count; lay++)
            {
                if ((layerDisplay.Items[lay] as NetworkLayerDescriptor).neurons == 0)
                {
                    consoleTextBox.AppendText("Network´s layer cant have 0 neurons ! \n");
                    return;
                }
            }

            neuralNetwork = window.neuralNetwork;
            SaveWarning saveWarning;

            //if there allready is a network, ask user to save it
            if (neuralNetwork != null)
            {
                saveWarning = new SaveWarning();
                saveWarning.ShowDialog();

                if (saveWarning.OverrideNetwork)
                {
                    List <int> layers = new List <int>();
                    List <ActivationFunctions> activationFunctions = new List <ActivationFunctions>();

                    for (int lay = 1; lay < layerDisplay.Items.Count; lay++)
                    {
                        layers.Add((layerDisplay.Items[lay] as NetworkLayerDescriptor).neurons);
                        activationFunctions.Add((ActivationFunctions)Enum.Parse(typeof(ActivationFunctions), (layerDisplay.Items[lay] as NetworkLayerDescriptor).selectedIndex.ToString()));
                    }

                    window.neuralNetwork = new NeuralNetwork(layers.ToArray(), learningRate, activationFunctions);
                    this.neuralNetwork   = window.neuralNetwork;

                    consoleTextBox.AppendText("Network succesfully created ! \n");
                }
                else
                {
                    consoleTextBox.AppendText("Creation canceled \n");
                }
            }
            //if there is no network, create a new one
            else
            {
                List <int> layers = new List <int>();
                List <ActivationFunctions> activationFunctions = new List <ActivationFunctions>();

                for (int lay = 1; lay < layerDisplay.Items.Count; lay++)
                {
                    layers.Add((layerDisplay.Items[lay] as NetworkLayerDescriptor).neurons);
                    activationFunctions.Add((ActivationFunctions)Enum.Parse(typeof(ActivationFunctions), (layerDisplay.Items[lay] as NetworkLayerDescriptor).selectedIndex.ToString()));
                }

                window.neuralNetwork = new NeuralNetwork(layers.ToArray(), learningRate, activationFunctions);
                this.neuralNetwork   = window.neuralNetwork;

                consoleTextBox.AppendText("Network succesfully created ! \n");
            }
        }