private void viewModel_NotifyInvalidCredentials(object sender, NotifyInvalidCredentialsEventArgs e) { Dispatcher.BeginInvoke(new Action(delegate { EditConfWindow wind = new EditConfWindow(); wind.ShowDialog(e.SyncConfiguration); })); }
private void TextBlockAdvancedConfig_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) { DialogResult = false; Close(); var d = new EditConfWindow(); d.ShowDialog(null); }
private async void buttonSave_Click(object sender, RoutedEventArgs e) { var password = textBoxPassword.Password; SyncConfiguration config = null; buttonSave.IsEnabled = false; buttonSave.Content = "Please wait..."; var stop = false; await Task.Run(() => { try { config = SharePointManager.TryFindConfiguration(_viewModel.SiteUrl, _viewModel.Username, password); } catch (Exception ex) { stop = true; Dispatcher.BeginInvoke(new Action(() => { buttonSave.IsEnabled = true; buttonSave.Content = "Next"; })); MessageBox.Show("An error occured:" + Environment.NewLine + ex.Message, "SPSync", MessageBoxButton.OK, MessageBoxImage.Error); } }); if (stop) { return; } if (config == null) { MessageBox.Show("We could not automatically find your configuration. Please use the advanced dialog to enter your configuration manually.", "SPSync", MessageBoxButton.OK, MessageBoxImage.Error); DialogResult = false; Close(); var d = new EditConfWindow(); d.ShowDialog(_viewModel); return; } if (config.DocumentLibrary.Contains("|")) { _viewModel.DocumentLibrary = config.DocumentLibrary; var selectWindow = new SelectDocumentLibraryWindow(); var selectResult = selectWindow.ShowDialog(_viewModel); if (!selectResult.HasValue || !selectResult.Value) { Dispatcher.Invoke(new Action(() => { buttonSave.IsEnabled = true; buttonSave.Content = "Next"; })); return; } config.DocumentLibrary = _viewModel.DocumentLibrary; } config.Name = _viewModel.Name; config.LocalFolder = _viewModel.LocalFolder; App.MainViewModel.AddOrUpdateConfiguration(config); DialogResult = true; Close(); new NewConfigFolderSelect(config).ShowDialog(); }
private void contextMenu_Click(object sender, RoutedEventArgs e) { var item = e.Source as MenuItem; if (item == null) { return; } var tag = item.Tag.ToString(); switch (tag) { case "SHOW": ShowWindow(); Focus(); break; case "SYNCALL": viewModel.SyncAll(); break; case "NEWSYNC": { NewConfig wind = new NewConfig(); wind.ShowNewConfigDialog(); break; } case "SETTINGS": { //SettingsWindow setWin = new SettingsWindow(); //setWin.ShowDialog(null); break; } case "INFO": SquirrelSetup.TryUpdateAsync(); var version = System.Reflection.Assembly.GetEntryAssembly().GetName().Version.ToString(4); MessageBox.Show(this, "SPSync - Version " + version + " BETA\n(C) 2016 Marco Wiedemeyer\nMore on http://spsync.net", "SPSync", MessageBoxButton.OK, MessageBoxImage.Information); break; case "EXIT": shutdownInitiatedFromApplication = true; Application.Current.Shutdown(); break; default: { var localFolder = tag.Split('|')[1]; var conf = viewModel.GetSyncConfiguration(localFolder); if (tag.StartsWith("SYNC|")) { var t = viewModel.SyncAsync(localFolder); } if (tag.StartsWith("EDIT|")) { EditConfWindow wind = new EditConfWindow(); wind.ShowDialog(conf); } if (tag.StartsWith("DELETE|")) { var result = MessageBox.Show(this, "Are you sure you want to delete the configuration '" + conf.Name + "'?", "SPSync", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (result == MessageBoxResult.Yes) { viewModel.DeleteConfiguration(localFolder); } } if (tag.StartsWith("ERROR|")) { ErrorReport wind = new ErrorReport(); wind.ShowDialog(conf); } break; } } }