public MainWindow() { // При инициализации компонента, вызываем окно авторизации и аутентификации InitializeComponent(); AuthWindow auth = new AuthWindow(); auth.ShowDialog(); // Если невозможно отправлять запросы, приложение закрывается if (Config.token == "" || Config.userID == "") { this.Close(); } // Добавление иллюстрации с котом JsonDocument postImage = JsonDocument.Parse(RequesterRandom.getImage()); uriImage = postImage.RootElement[0].GetProperty("url").ToString(); BitmapImage bitmap = new BitmapImage(); bitmap.BeginInit(); bitmap.UriSource = new Uri(uriImage, UriKind.Absolute); bitmap.EndInit(); cat.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; cat.Source = bitmap; }
// Генерация случайного поста private void generateRandom_Click(object sender, RoutedEventArgs e) { try { JsonDocument postText = JsonDocument.Parse(RequesterRandom.getText()); messageText.Text = postText.RootElement[0].ToString(); } catch { } }