private async void BtnKey_Click(object sender, RoutedEventArgs e)
        {
            HttpRequest req             = new HttpRequest();
            var         KeyRoomSelected = selectRoom.Name.Split('_');

            FeedsJson.FeedProprety feedProprety = await getDataJson(KeyRoomSelected[2]);

            if (MqttConnection.ChatRoomNameKey == feedProprety.key)
            {
                var    valuedata = feedProprety.license.Split('*');
                string NewKey    = downloadData.DownloadString("https://passwordsgenerator.net/calc.php?Length=50&Symbols=0&Lowercase=1&Uppercase=1&Numbers=1&Nosimilar=1&Last=1");
                NewKey = NewKey.Substring(0, 50);
                if (await req.UpdateFeed(feedProprety.name, feedProprety.key, feedProprety.description, NewKey, valuedata[1], valuedata[2]))
                {
                    MqttConnection.MqttPublish(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey, MqttConnection.NickName + "_KEY_" + NewKey);
                    DrawerHost.CloseDrawerCommand.Execute(DrawerHostContent, BtnKey);
                    ShowSnackBar("Key update successfully!");
                }
                else
                {
                    DrawerHost.CloseDrawerCommand.Execute(DrawerHostContent, BtnKey);
                    ShowSnackBar("Error updating Key!");
                }
            }
            else
            {
                DrawerHost.CloseDrawerCommand.Execute(DrawerHostContent, BtnKey);
                ShowSnackBar("At first, you must be joined to the room!");
            }
        }
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     if (MqttConnection.IsSolace)
     {
         MqttConnection.MqttUnsecurePublish("solace-cloud-client/clients", "{\"status\":\"disconnected\",\"at\":\"2020-10-14T00:23:28.481Z\",\"client\":{\"id\":\"dzbpiydeyvrngch_" + MqttConnection.NickName + "\",\"ip\":\"78.74.65.35\"}}");
     }
     MqttConnection.MqttDisconnect();
     Process.GetCurrentProcess().Kill();
 }
 public void MqttMessageAtStartConnection()
 {
     try
     {
         string messageDecrypt = StringCipher.Decrypt(messageEncrypt, MqttConnection.Key_EndToEnd);
         if (messageDecrypt.Contains("RESPONSE"))
         {
             var message = messageDecrypt.Split('_');
             if (message[1] == "NOONLY")
             {
                 OnlyMe           = false;
                 UserOnlineYet[i] = message[2];
                 //MessageBox.Show(MqttConnection.NickName + " --- " + message[2]);
                 if (MqttConnection.NickName == message[2])
                 {
                     //MessageBox.Show("ok");
                     Restore.Stop();
                     LogInContainer.IsEnabled       = true;
                     ProgressCircle.IsIndeterminate = false;
                     MqttConnection.MqttDisconnect();
                     UserOnlineYet = new string[49];
                     i             = 0;
                     if (!SolaceHostPort.Text.Contains("ssl://"))
                     {
                         SolaceHostPort.Text = "ssl://" + SolaceHostPort.Text;
                     }
                     ShowSnackBar("This nickname has already been used");
                     return;
                 }
                 i++;
             }
         }
     }
     catch (Exception)
     {
         Restore.Stop();
         LogInContainer.IsEnabled       = true;
         ProgressCircle.IsIndeterminate = false;
         if (MqttConnection.IsSolace)
         {
             MqttConnection.MqttUnsecurePublish("solace-cloud-client/clients", "{\"status\":\"disconnected\",\"at\":\"2020-10-14T00:23:28.481Z\",\"client\":{\"id\":\"dzbpiydeyvrngch_" + MqttConnection.NickName + "\",\"ip\":\"78.74.65.35\"}}");
         }
         MqttConnection.MqttDisconnect();
         UserOnlineYet = new string[49];
         i             = 0;
         if (!SolaceHostPort.Text.Contains("ssl://"))
         {
             SolaceHostPort.Text = "ssl://" + SolaceHostPort.Text;
         }
         MessageBox.Show("Error, BAD link room", "Bad end to end", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
 private void restore()
 {
     CreatorGroup           = "";
     NameGroup              = "";
     UrlStream              = "";
     MqttConnection.IsGroup = false;
     MqttConnection.MqttDisconnect();
     MqttConnection.setKeyEndToEnd("");
     MqttConnection.setUser("");
     MqttConnection.setAioKey("");
     MqttConnection.IamAdmin        = false;
     LogInContainer.IsEnabled       = true;
     ProgressCircle.IsIndeterminate = false;
     ShowSnackBar("The room does not exist or disabled!");
 }
        public MainWindow()
        {
            InitializeComponent();
            MqttConnection.setKeyEndToEnd("");

            VerifyConnectionDataFile(MqttConnection.Key_EndToEnd, Directory.GetCurrentDirectory() + "\\Data\\AdaDataConnection.dt", 1);
            VerifyConnectionDataFile(MqttConnection.Key_EndToEnd, Directory.GetCurrentDirectory() + "\\Data\\SolaceDataConnection.dt", 2);

            HideSnackBar.Tick    += HideSnackBar_Tick;
            HideSnackBar.Interval = new TimeSpan(0, 0, 0, 2, 0);

            Restore.Tick    += Restore_Tick;
            Restore.Interval = new TimeSpan(0, 0, 0, 3, 0);

            WebClient webClient = new WebClient();

            webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadVersionTxt);
            webClient.DownloadStringAsync(new Uri("http://epnbxbkyd4kxzppgghiyviro.altervista.org/StreamParty/version.txt"));
        }
        public bool createFeed(string name, string description, string Key_EndToEnd, string Url, string control)
        {
            try
            {
                var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://io.adafruit.com/api/v2/" + MqttConnection.UserName + "/feeds?X-AIO-Key=" + MqttConnection.AioKey + "&group_key=default");
                httpWebRequest.ContentType = "application/json";
                httpWebRequest.Method      = "POST";


                string key = getCorretName(name);
                if (key == "")
                {
                    return(false);
                }

                using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
                {
                    string json = "{\"description\":\"" + description + "\"," +
                                  "\"key\":\"" + key + "\"," +
                                  "\"license\":\"" + Key_EndToEnd + "*" + Url + "*" + control + "\"," +
                                  "\"name\":\"" + name + "\"}";
                    streamWriter.Write(json);
                }

                string datareceived = "";
                var    httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
                using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                {
                    datareceived = streamReader.ReadToEnd();
                }
                FeedsJson.FeedProprety feedProprety = JsonConvert.DeserializeObject <FeedsJson.FeedProprety>(datareceived);
                MqttConnection.setChatRoomNameKey(feedProprety.key);

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
        private async void BtnTrash_Click(object sender, RoutedEventArgs e)
        {
            HttpRequest req             = new HttpRequest();
            var         KeyRoomSelected = selectRoom.Name.Split('_');

            FeedsJson.FeedProprety feedProprety = await getDataJson(KeyRoomSelected[2]);

            MqttConnection.MqttPublish(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey, MqttConnection.NickName + "_CLOSEROOM_" + feedProprety.key);

            if (await req.DeleteFeed(feedProprety.key))
            {
                DrawerHost.CloseDrawerCommand.Execute(DrawerHostContent, BtnKey);
                ShowSnackBar("Room delete successfully!");
                RoomProgressCircle.IsIndeterminate = true;
                refreshRoom("");
            }
            else
            {
                DrawerHost.CloseDrawerCommand.Execute(DrawerHostContent, BtnKey);
                ShowSnackBar("Error deleting Key!");
            }
        }
        private async void BtnJoin_Click(object sender, RoutedEventArgs e)
        {
            var KeyRoomSelected = selectRoom.Name.Split('_');

            FeedsJson.FeedProprety feedProprety = await getDataJson(KeyRoomSelected[2]);

            if (MqttConnection.ChatRoomNameKey != feedProprety.key)
            {
                MqttConnection.MqttUnsubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                var valuedata = feedProprety.license.Split('*');
                MqttConnection.ChatRoomNameKey = feedProprety.key;
                MqttConnection.Key_EndToEnd    = valuedata[0];
                MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                MqttConnection.MqttPublish(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey, MqttConnection.NickName + "_JOINGROUP_" + feedProprety.name + "_" + valuedata[1]);
                DrawerHost.CloseDrawerCommand.Execute(DrawerHostContent, BtnJoin);
                ShowSnackBar("Joined successfully!");
            }
            else
            {
                DrawerHost.CloseDrawerCommand.Execute(DrawerHostContent, BtnJoin);
                ShowSnackBar("You are already joined!");
            }
        }
        private async void LogInBtn_Click(object sender, RoutedEventArgs e)
        {
            if (ServerAdafruit)
            {
                if (!string.IsNullOrWhiteSpace(NickName.Text) && !string.IsNullOrWhiteSpace(UsernameTxt.Text) && !string.IsNullOrWhiteSpace(AioKeyTxt.Password))
                {
                    if (NickName.Text.Length < 25 && !NickName.Text.Contains("_"))
                    {
                        ProgressCircle.IsIndeterminate = true;
                        LogInContainer.IsEnabled       = false;

                        NickName.Text      = NickName.Text.Trim();
                        UsernameTxt.Text   = UsernameTxt.Text.Trim();
                        AioKeyTxt.Password = AioKeyTxt.Password.Trim();
                        MqttConnection.setNickname(NickName.Text);
                        MqttConnection.setUser(UsernameTxt.Text);
                        MqttConnection.setAioKey(AioKeyTxt.Password);
                        HttpRequest req      = new HttpRequest();
                        string      response = await Task.Run(() => req.getJsonData("https://io.adafruit.com/api/v2/user?X-AIO-Key=" + MqttConnection.AioKey));

                        if (response != "")
                        {
                            UserDataJsonReceive.Rootobject UserData = JsonConvert.DeserializeObject <UserDataJsonReceive.Rootobject>(response);
                            if (UsernameTxt.Text == UserData.user.username)
                            {
                                if (await Task.Run(() => MqttConnection.MqttTryToConnect()))
                                {
                                    SaveConnectDataFile("", Directory.GetCurrentDirectory() + "\\Data", "\\AdaDataConnection.dt");
                                    MqttConnection.setChatRoomNameKey("chat");
                                    MqttConnection.client.MqttMsgPublishReceived += client_MqttMsgPublishReceived;
                                    MqttConnection.MqttSubscribe(UsernameTxt.Text + "/feeds/" + MqttConnection.ChatRoomNameKey);
                                    MqttConnection.IsSolace = false;
                                    MqttConnection.IsGroup  = false;
                                    MqttConnection.IamAdmin = true;
                                    Restore.Start();
                                }
                                else
                                {
                                    ShowSnackBar("Error to connect with server!");
                                    LogInContainer.IsEnabled       = true;
                                    ProgressCircle.IsIndeterminate = false;
                                }
                            }
                            else
                            {
                                ShowSnackBar("Bad Username or Aio Key");
                                ProgressCircle.IsIndeterminate = false;
                                LogInContainer.IsEnabled       = true;
                            }
                        }
                        else
                        {
                            ShowSnackBar("Bad internet connection!");
                            ProgressCircle.IsIndeterminate = false;
                            LogInContainer.IsEnabled       = true;
                        }
                    }
                    else
                    {
                        ShowSnackBar("Max 25 char for Nickname and not '_'");
                    }
                }
                else
                {
                    ShowSnackBar("Please, insert data!");
                }
            }
            else if (ServerSolace)
            {
                if (!string.IsNullOrWhiteSpace(SolaceNickName.Text) && !string.IsNullOrWhiteSpace(SolaceHostPort.Text) && !string.IsNullOrWhiteSpace(SolacePassword.Password))
                {
                    if (SolaceNickName.Text.Length < 25 && !SolaceNickName.Text.Contains("_"))
                    {
                        ProgressCircle.IsIndeterminate = true;
                        LogInContainer.IsEnabled       = false;

                        SolaceNickName.Text     = SolaceNickName.Text.Trim();
                        SolacePassword.Password = SolacePassword.Password.Trim();
                        SolaceHostPort.Text     = SolaceHostPort.Text.Trim();
                        SolaceHostPort.Text     = SolaceHostPort.Text.Remove(0, 6);
                        var SplitAddressPort = SolaceHostPort.Text.Split(':');
                        MqttConnection.setMqttServer(SplitAddressPort[0]);
                        MqttConnection.setMqttPort(SplitAddressPort[1]);
                        MqttConnection.setNickname(SolaceNickName.Text);
                        MqttConnection.setUser("solace-cloud-client");
                        MqttConnection.setAioKey(SolacePassword.Password);

                        if (await Task.Run(() => MqttConnection.MqttTryToConnect()))
                        {
                            SaveConnectDataFile("", Directory.GetCurrentDirectory() + "\\Data", "\\SolaceDataConnection.dt");
                            MqttConnection.setChatRoomNameKey("SolaceRoom");
                            MqttConnection.client.MqttMsgPublishReceived += client_MqttMsgPublishReceived;
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                            MqttConnection.MqttUnsecurePublish(MqttConnection.UserName + "/clients", "{\"status\":\"connected\",\"at\":\"2020-10-14T00:23:28.481Z\",\"client\":{\"id\":\"dzbpiydeyvrngch_" + MqttConnection.NickName + "\",\"ip\":\"78.74.65.35\"}}");
                            MqttConnection.IsSolace = true;
                            MqttConnection.IsGroup  = false;
                            MqttConnection.IamAdmin = true;
                            Restore.Start();
                        }
                        else
                        {
                            ShowSnackBar("Error to connect with server!");
                            LogInContainer.IsEnabled       = true;
                            ProgressCircle.IsIndeterminate = false;
                        }
                    }
                    else
                    {
                        ShowSnackBar("Max 25 char for Nickname and not '_'");
                    }
                }
                else
                {
                    ShowSnackBar("Please, insert data!");
                }
            }
        }
        private async void PasteKey_Click(object sender, RoutedEventArgs e)
        {
            string key_group_enc = Clipboard.GetText();
            string key_group_dec = StringCipher.Decrypt(key_group_enc, "");
            //MessageBox.Show(key_group_dec);
            var var_key_group_dec = key_group_dec.Split('|');

            HttpRequest req = new HttpRequest();

            try
            {
                MqttConnection.IsGroup = true;
                MqttConnection.setChatRoomNameKey(var_key_group_dec[0]);
                MqttConnection.setUser(var_key_group_dec[1]);
                MqttConnection.setAioKey(var_key_group_dec[2]);
                MqttConnection.setKeyEndToEnd(var_key_group_dec[3]);
                CreatorGroup            = var_key_group_dec[4];
                UrlStream               = var_key_group_dec[5];
                MqttConnection.IamAdmin = !bool.Parse(var_key_group_dec[6]);
                MqttConnection.setMqttServer(var_key_group_dec[7]);
                MqttConnection.setMqttPort(var_key_group_dec[8]);
            }
            catch (Exception)
            {
                ShowSnackBar("Invalid Key Room");
                return;
            }
            ProgressCircle.IsIndeterminate = true;
            LogInContainer.IsEnabled       = false;


            if (MqttConnection.MqttServer.Contains("adafruit"))
            {
                AdaServer_Click(sender, e);
                if (NickName.Text.Length < 25)
                {
                    if (string.IsNullOrWhiteSpace(NickName.Text))
                    {
                        ShowSnackBar("Please insert a NickName");
                        ProgressCircle.IsIndeterminate = false;
                        LogInContainer.IsEnabled       = true;
                        return;
                    }
                    MqttConnection.setNickname(NickName.Text);

                    if (await Task.Run(() => MqttConnection.MqttTryToConnect()))
                    {
                        string data = await req.getJsonData("https://io.adafruit.com/api/v2/" + MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey + "?X-AIO-Key=" + MqttConnection.AioKey);

                        if (data != "")
                        {
                            FeedsJson.FeedProprety feedProprety = JsonConvert.DeserializeObject <FeedsJson.FeedProprety>(data);
                            if (feedProprety.enabled)
                            {
                                NameGroup          = feedProprety.name;
                                UsernameTxt.Text   = "";
                                AioKeyTxt.Password = "";
                                MqttConnection.client.MqttMsgPublishReceived += client_MqttMsgPublishReceived;
                                MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                                MqttConnection.IsSolace = false;
                                MqttConnection.IsGroup  = true;
                                Restore.Start();
                            }
                            else
                            {
                                restore();
                            }
                        }
                        else
                        {
                            restore();
                        }
                    }
                    else
                    {
                        ShowSnackBar("Error to connect!");
                        LogInContainer.IsEnabled       = true;
                        ProgressCircle.IsIndeterminate = false;
                    }
                }
                else
                {
                    ShowSnackBar("Max 25 char for Nickname");
                    LogInContainer.IsEnabled       = true;
                    ProgressCircle.IsIndeterminate = false;
                }
            }
            else if (MqttConnection.MqttServer.Contains("messaging.solace.cloud"))
            {
                SolaceServer_Click(sender, e);
                if (SolaceNickName.Text.Length < 25)
                {
                    if (string.IsNullOrWhiteSpace(SolaceNickName.Text))
                    {
                        ShowSnackBar("Please insert a NickName");
                        ProgressCircle.IsIndeterminate = false;
                        LogInContainer.IsEnabled       = true;
                        return;
                    }
                    MqttConnection.setNickname(SolaceNickName.Text);

                    if (await Task.Run(() => MqttConnection.MqttTryToConnect()))
                    {
                        MqttConnection.setChatRoomNameKey("SolaceRoom");
                        MqttConnection.client.MqttMsgPublishReceived += client_MqttMsgPublishReceived;
                        MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                        MqttConnection.MqttUnsecurePublish(MqttConnection.UserName + "/clients", "{\"status\":\"connected\",\"at\":\"2020-10-14T00:23:28.481Z\",\"client\":{\"id\":\"dzbpiydeyvrngch_" + MqttConnection.NickName + "\",\"ip\":\"78.74.65.35\"}}");
                        MqttConnection.IsSolace = true;
                        MqttConnection.IsGroup  = true;
                        Restore.Start();
                    }
                    else
                    {
                        ShowSnackBar("Error to connect!");
                        LogInContainer.IsEnabled       = true;
                        ProgressCircle.IsIndeterminate = false;
                    }
                }
                else
                {
                    ShowSnackBar("Max 25 char for Nickname");
                    LogInContainer.IsEnabled       = true;
                    ProgressCircle.IsIndeterminate = false;
                }
            }
            else
            {
                ShowSnackBar("Invalid Server!");
                LogInContainer.IsEnabled       = true;
                ProgressCircle.IsIndeterminate = false;
            }
        }
 private void CloseBtn_Click(object sender, RoutedEventArgs e)
 {
     MqttConnection.MqttDisconnect();
     Process.GetCurrentProcess().Kill();
 }
        private async void GenerateBtn_Click(object sender, RoutedEventArgs e)
        {
            if (NameRoom.Text != "" && !string.IsNullOrWhiteSpace(UsernameTxt.Text) && !string.IsNullOrWhiteSpace(AioKeyTxt.Password) && !string.IsNullOrWhiteSpace(Key_EndToEnd.Text) && !Key_EndToEnd.Text.Contains("GENERATE"))
            {
                HttpRequest req = new HttpRequest();

                string KeyRoomDec = req.getCorretName(NameRoom.Text) + "|" + UsernameTxt.Text + "|" + AioKeyTxt.Password + "|" + Key_EndToEnd.Text + "|" + MqttConnection.NickName + "|" + UrlTxt.Text + "|" + CheckControll.IsChecked + "|" + MqttConnection.MqttServer + "|" + MqttConnection.MqttPort.ToString();
                string KeyRoomEnc = StringCipher.Encrypt(KeyRoomDec, "");

                if (CheckCurrentData.IsChecked == true)
                {
                    if (getNumFeed(req.getAllFeeds()) != 10)
                    {
                        MqttConnection.MqttUnsubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                        if (req.createFeed(NameRoom.Text, DescriptionTxt.Text, Key_EndToEnd.Text, UrlTxt.Text, CheckControll.IsChecked.ToString()))
                        {
                            MqttConnection.setKeyEndToEnd(Key_EndToEnd.Text);
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                            MqttConnection.MqttPublish(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey, MqttConnection.NickName + "_ROOMGROUP_" + NameRoom.Text + "_" + UrlTxt.Text);
                            Clipboard.SetText(KeyRoomEnc);
                            MessageBox.Show("Room created!!!" + '\n' + '\n' + "Don't worry, I copy the access key to the group, share it with your friends, you just have to paste and they just have to copy it and click on \"I have a key\"");
                            Close();
                        }
                        else
                        {
                            MqttConnection.setKeyEndToEnd("");
                            MqttConnection.setChatRoomNameKey("chat");
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                            ShowSnackBar("Error creating room!");
                        }
                    }
                    else
                    {
                        ShowSnackBar("Max number of group created, delete one!");
                    }
                }
                else
                {
                    string tempUser   = MqttConnection.UserName;
                    string tempAioKey = MqttConnection.AioKey;
                    MqttConnection.MqttDisconnect();
                    MqttConnection.setUser(UsernameTxt.Text);
                    MqttConnection.setAioKey(AioKeyTxt.Password);
                    if (!(await MqttConnection.MqttFastConnect()))
                    {
                        MqttConnection.setUser(tempUser);
                        MqttConnection.setAioKey(tempAioKey);
                        ShowSnackBar("Erron to connect with new data!");
                        UsernameTxt.Focus();
                        return;
                    }

                    if (getNumFeed(req.getAllFeeds()) != 10)
                    {
                        if (req.createFeed(NameRoom.Text, DescriptionTxt.Text, Key_EndToEnd.Text, UrlTxt.Text, CheckControll.IsChecked.ToString()))
                        {
                            MqttConnection.setKeyEndToEnd(Key_EndToEnd.Text);
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/clients");
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                            MqttConnection.MqttPublish(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey, MqttConnection.NickName + "_ROOMGROUP_" + NameRoom.Text + "_" + UrlTxt.Text);
                            Clipboard.SetText(KeyRoomEnc);
                            MessageBox.Show("Room created!!!" + '\n' + '\n' + "Don't worry, I copy the access key to the group, share it with your friends, you just have to paste and they just have to copy it and click on \"I have a key\"");
                            Close();
                        }
                        else
                        {
                            MqttConnection.setKeyEndToEnd("");
                            MqttConnection.setChatRoomNameKey("chat");
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/clients");
                            MqttConnection.MqttSubscribe(MqttConnection.UserName + "/feeds/" + MqttConnection.ChatRoomNameKey);
                            ShowSnackBar("Error creating room!");
                        }
                    }
                    else
                    {
                        ShowSnackBar("Max number of group created, delete one!");
                    }
                }
            }
            else
            {
                ShowSnackBar("Complete the box please");
            }
        }