private void ButtonLoginLogout_Click(object sender, RoutedEventArgs e) { if(MainWindow.IsLogin() == false) { var loginWindow = new LoginWindow(); loginWindow.Owner = this; loginWindow.ShowDialog(); if (MainWindow.IsLogin()) { TextBlockUserName.Text = Properties.Settings.Default.UserName; ButtonLoginLogout.Content = Properties.Resources.Logout; } } else { Properties.Settings.Default.UserID = String.Empty; Properties.Settings.Default.PasswordHash = String.Empty; Properties.Settings.Default.AvatarPath = "Resources/ImageDefaultAvatar.png"; Properties.Settings.Default.Save(); TextBlockUserName.Text = Properties.Resources.Guest; ButtonLoginLogout.Content = Properties.Resources.Login; } }
internal void AddImages(string[] filePaths) { bool imageSizeLimit = false;// Display a message on the size limit only once foreach (string filePath in filePaths) { try { var image = new Image(); var bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.DecodePixelWidth = 100; bitmapImage.UriSource = new Uri(filePath); bitmapImage.EndInit(); image.Source = bitmapImage; image.Tag = filePath;// Save file path int maximumImageSize = 3000000;// Maximum file size in bytes if (IsLogin() == false && new FileInfo(filePath).Length > maximumImageSize) { if (!imageSizeLimit) { imageSizeLimit = true; var result = MessageBox.Show(Properties.Resources.MessageImageSizeLimit, Properties.Resources.Error, MessageBoxButton.YesNo, MessageBoxImage.Warning); if (result == MessageBoxResult.Yes) { var loginWindow = new LoginWindow(); if (Visibility == System.Windows.Visibility.Visible) loginWindow.Owner = this; else loginWindow.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterScreen; loginWindow.ShowDialog(); if (IsLogin()) ListBoxImages.Items.Add(image); } } continue; } ListBoxImages.Items.Add(image); } catch (Exception ex) { Log.Add(ex); } } UpdateFilesInformation(); if (Properties.Settings.Default.UploadImagesAutomatically == true) { if (isUploading == false) UploadAllImages(); } }
private void ButtonLogin_Click(object sender, RoutedEventArgs e) { if (IsLogin() == false) { var loginWindow = new LoginWindow(); loginWindow.Owner = this; loginWindow.ShowDialog(); } else { var settingsWindow = new SettingsWindow(); settingsWindow.Owner = this; settingsWindow.TabControl.SelectedIndex = 2; settingsWindow.ShowDialog(); } }