Exemplo n.º 1
0
 private void JoinNetworkButtonOnClick(object sender, EventArgs e)
 {
     if (ValidateString(NetworkNameEditText.Text) && ValidateString(NetworkPasswordEditText.Text))
     {
         if (serverConnection.JoinToNetwork(NetworkNameEditText.Text, NetworkPasswordEditText.Text))
         {
             currentNetwork = localDb.GetCurrentNetwork();
             if (currentNetwork != null)
             {
                 CurrentNetworkInfoText1.Text = $"{currentNetwork.Name} - {currentNetwork.Password}; NetworkId: {currentNetwork.NetworkId}; Network creator: {currentNetwork.CreatorUserId}";
             }
             else
             {
                 CurrentNetworkInfoText1.Text = "Some error has been occured. Please delete your profile and try to resync your account";
             }
         }
         else
         {
             CurrentNetworkInfoText1.Text = "Could'n find a network witn such credentials. Please try with another ones";
         }
         NetworkNameEditText.Text     = "";
         NetworkPasswordEditText.Text = "";
         SetupCurrentNetworkElementGroup();
     }
     else
     {
         CurrentNetworkInfoText1.Text = "Network name and password can not be empty";
     }
 }
Exemplo n.º 2
0
        internal void AddCurrentNetwork(Network net)
        {
            CurrentNetwork curNet = new CurrentNetwork()
            {
                Name          = net.Name,
                NetworkId     = net.NetworkId,
                Password      = net.Password,
                CreatorUserId = net.CreatorUserId
            };

            sqliteRepository.SaveCurrentNetwork(curNet);
        }
Exemplo n.º 3
0
 public int SaveCurrentNetwork(CurrentNetwork curNet)
 {
     lock (collisionLock)
     {
         if (curNet.Id != 0)
         {
             database.Update(curNet);
             return(curNet.Id);
         }
         else
         {
             database.Insert(curNet);
             return(curNet.Id);
         }
     }
 }
Exemplo n.º 4
0
 private void SetupCurrentNetworkElementGroup()
 {
     currentNetwork = localDb.GetCurrentNetwork();
     if (currentNetwork != null)
     {
         CurrentNetworkInfoText1.Text              = $"{currentNetwork.Name} - {currentNetwork.Password}; NetworkId: {currentNetwork.NetworkId}";
         CreateNetworkButton.Visibility            = ViewStates.Invisible;
         JoinNetworkButton.Visibility              = ViewStates.Invisible;
         NetworkNameEditText.Visibility            = ViewStates.Invisible;
         NetworkPasswordEditText.Visibility        = ViewStates.Invisible;
         CurrentNetworkInfoTextName.Visibility     = ViewStates.Invisible;
         CurrentNetworkInfoTextPassword.Visibility = ViewStates.Invisible;
     }
     else
     {
         CreateNetworkButton.Visibility            = ViewStates.Visible;
         JoinNetworkButton.Visibility              = ViewStates.Visible;
         NetworkNameEditText.Visibility            = ViewStates.Visible;
         NetworkPasswordEditText.Visibility        = ViewStates.Visible;
         CurrentNetworkInfoTextName.Visibility     = ViewStates.Visible;
         CurrentNetworkInfoTextPassword.Visibility = ViewStates.Visible;
     }
 }
Exemplo n.º 5
0
 private void CreateNetworkButtonButtonOnClick(object sender, EventArgs e)
 {
     if (ValidateString(NetworkNameEditText.Text) && ValidateString(NetworkPasswordEditText.Text))
     {
         serverConnection.RegisterNewNetwork(NetworkNameEditText.Text, NetworkPasswordEditText.Text);
         currentNetwork = localDb.GetCurrentNetwork();
         if (currentNetwork != null)
         {
             CurrentNetworkInfoText1.Text = $"{currentNetwork.Name} - {currentNetwork.Password}; NetworkId: {currentNetwork.NetworkId}";
         }
         else
         {
             CurrentNetworkInfoText1.Text = "Some error has been occured. Please try again with different credentials";
         }
         NetworkNameEditText.Text     = "";
         NetworkPasswordEditText.Text = "";
         SetupCurrentNetworkElementGroup();
     }
     else
     {
         CurrentNetworkInfoText1.Text = "Network name and password can not be empty";
     }
 }
Exemplo n.º 6
0
        private void Testbutton_Click(object sender, RoutedEventArgs e)
        {
            string         testFileName   = "";
            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*";
            openFileDialog.Title  = "Test input file";
            if (openFileDialog.ShowDialog() == true)
            {
                testFileName = openFileDialog.FileName;
            }
            if (File.Exists(testFileName))
            {
                try
                {
                    int           numberOfOutputs = Creator.BestNetwork.Layers[Creator.BestNetwork.Layers.Length - 1].Weights.ColumnCount;
                    IDataProvider dataProvider;

                    if (ChosenTask == TaskType.Classification)
                    {
                        dataProvider = new ClassificationDataProvider(testFileName, Creator.InputsNumber, numberOfOutputs, Creator.IsBiasOn);
                    }
                    else if (ChosenTask == TaskType.Approximation || ChosenTask == TaskType.Transformation)
                    {
                        dataProvider = new ApproximationDataProvider(testFileName, Creator.InputsNumber, numberOfOutputs, Creator.IsBiasOn);
                    }
                    else
                    {
                        MessageBox.Show("Choose task type!");
                        return;
                    }

                    string pathToLogFile = Directory.GetCurrentDirectory() + @"\OutputFile.txt";

                    if (!File.Exists(pathToLogFile))
                    {
                        using (var outputFile = File.Create(pathToLogFile))
                        {
                            //Do nothing
                        }
                    }

                    using (StreamWriter writer = new StreamWriter(pathToLogFile))
                    {
                        var dataSet = dataProvider.DataSet;
                        var output  = Vector <double> .Build.Dense(dataSet.Length);

                        for (int dataIndex = 0; dataIndex < dataSet.Length; dataIndex++)
                        {
                            output = CurrentNetwork.CalculateOutput(dataSet[dataIndex].X);
                            writer.WriteLine(output.ToString());
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                MessageBox.Show("Incorrect file path!");
                return;
            }
        }