public ConfigPage() { InitializeComponent(); ThirdPartyLicensesLabel.Text = "dotnet:\n" + "The MIT License(MIT)\nCopyright(c) 2019 Microsoft\n\n" + "sqlite-net:\n" + "The MIT License(MIT)\nCopyright (c) Krueger Systems, Inc.\n\n" + "SkiaScene:\n" + "The MIT License(MIT)\nCopyright (c) 2017 OndrejKunc\n\n" + "Xamarin:\n" + "The MIT License(MIT)\nCopyright (c) .NET Foundation Contributors\n\n" + "Zeroconf:\n" + "The MIT License(MIT)\nCopyright (c) [year] [fullname]\n\n"; if (ConnectionClass.connected) { ConnectButton.Text = AppResources.Disconnect; } else { ConnectButton.Text = AppResources.Connect; } IP_address_entry.Text = DatabaseClass.GetLastIPAddress(); Port_entry.Text = DatabaseClass.GetLastPort(); Password_entry.Text = DatabaseClass.GetLastPassword(); }
private void AcceptButton_Clicked(object sender, EventArgs e) { if (TextEntry.Text == AppResources.AddShortcutsPage) { DisplayAlert(AppResources.Error, AppResources.WrongShortcutNameError, AppResources.OK); return; } ShortcutCell.Text = TextEntry.Text; ShortcutCell.WWWAddress = WWWAddressEntry.Text; ShortcutCell.Image = "https://www.google.com/s2/favicons?domain=" + ShortcutCell.WWWAddress; //Pobranie adresu favicon'a z wykorzystaniem Google'a if (Id != -1) { DatabaseClass.EditShortcut(ShortcutCell); } else { DatabaseClass.AddNewShortcut(ShortcutCell); } if (DatabaseClass.DatabaseState == DatabaseState.DATABASE_OK) { Navigation.PopModalAsync(); } else { DisplayAlert(AppResources.Error, DatabaseClass.exceptionText, AppResources.OK); } }
public ShortcutFormPage(int id = -1) { InitializeComponent(); Id = id; if (Id != -1) //Gdy formularz ma być wykorzystany do edycji skrótu { ShortcutCell = DatabaseClass.GetShortcutFromDatabase(Id); TextEntry.Text = ShortcutCell.Text; WWWAddressEntry.Text = ShortcutCell.WWWAddress; Button DeleteButton = new Button() { Text = AppResources.DeleteShortcutFormPage, BackgroundColor = Color.Red, TextColor = Color.White, Margin = new Thickness(50, 100), }; DeleteButton.Clicked += DeleteButton_Clicked; FormStackLayout.Children.Add(DeleteButton); AcceptButton.Text = AppResources.ChangeShortcutFormPage; } }
private void DeleteButton_Clicked(object sender, EventArgs e) { DatabaseClass.DeleteShortcut(ShortcutCell); if (DatabaseClass.DatabaseState == DatabaseState.DATABASE_OK) { Navigation.PopModalAsync(); } else { DisplayAlert(AppResources.Error, DatabaseClass.exceptionText, AppResources.OK); } }
private void RefreshShortcutsList() //Metoda odświeżająca listę skrótów { Shortcuts.Clear(); DatabaseClass.CreateShortcutsList(Shortcuts); Shortcuts.Add(new ShortcutCell() { Image = "plus.png", Text = AppResources.AddShortcutsPage, WWWAddress = "", ButtonVisible = false, }); ShortcutsListView.ItemsSource = null; ShortcutsListView.ItemsSource = Shortcuts; //Podpięcie nowej listy skrótów do kontrolki ListView }
public static ConnectionState Connect(string ipAddress, string port, string password) //łączenie z serwerem, którego adres IP/nazwa hosta podana jest jako argument { if (ipAddress == "" || port == "0") { return(ConnectionState.CONNECTION_NOT_ESTABLISHED); } try { tcpClient = new TcpClient(); tcpClient.ReceiveTimeout = 5000; tcpClient.SendTimeout = 5000; tcpClient.Connect(ipAddress, int.Parse(port)); connected = true; stream = ConnectionClass.tcpClient.GetStream(); stream.WriteTimeout = 500; stream.ReadTimeout = 500; ConnectionClass.ipAddress = ipAddress; ConnectionClass.port = short.Parse(port); ConnectionClass.password = password; DatabaseClass.UpdateConfig(ConnectionClass.ipAddress, ConnectionClass.port.ToString(), ConnectionClass.password); while (!readDataStopped) { } readData = true; readDataTask = new Task(new Action(ReceiveData)); readDataTask.Start(); startApplicationConnectAttempt = false; _aes = new AesCryptoServiceProvider(); _aes.KeySize = 256; _aes.BlockSize = 128; _aes.Padding = PaddingMode.Zeros; pass = new PasswordDeriveBytes(password, GenerateSalt(_aes.BlockSize / 8, password)); _aes.Key = pass.GetBytes(_aes.KeySize / 8); _aes.IV = pass.GetBytes(_aes.BlockSize / 8); if (!pingServer && pingServerStopped) { pingServer = true; pingServerTask = new Task(new Action(PingServer)); pingServerTask.Start(); } else if (!sendingPing) { pingServer = false; while (!pingServerStopped) { } ; pingServer = true; pingServerTask = new Task(new Action(PingServer)); pingServerTask.Start(); } if (widgetService == null) { widgetService = DependencyService.Get <IWidgetService>(); } widgetService.CreateWidget(); return(ConnectionState.CONNECTION_ESTABLISHED); } catch (Exception error) { exceptionText = error.ToString(); connected = false; readData = false; return(ConnectionState.CONNECTION_NOT_ESTABLISHED); } }